001/**
002 * Get more info at : www.jrebirth.org .
003 * Copyright JRebirth.org © 2011-2016
004 * Contact : sebastien.bordes@jrebirth.org
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.jrebirth.af.api.ui;
019
020import javafx.scene.Node;
021import javafx.scene.layout.Pane;
022
023import org.jrebirth.af.api.exception.CoreException;
024
025/**
026 * The interface <strong>View</strong>.
027 *
028 * The contract for the view layer.
029 *
030 * @author Sébastien Bordes
031 *
032 * @param <M> A class that implement the Model interface, this is the model of the view
033 * @param <N> A class that extend the JavaFX node, this is the base component of the view
034 * @param <C> The class type which will control this view, it must implements the controller interface
035 */
036public interface View<M extends Model, N extends Node, C extends Controller<?, ?>> {
037
038    /**
039     * Return the view root node.
040     *
041     * @return the view base javafx node
042     */
043    N node();
044
045    /**
046     * Return the view's pane that hold the root node.
047     *
048     * @return the view base pane
049     */
050    Pane pane();
051
052    /**
053     * Return the error javafx node.
054     *
055     * @return the error javafx node
056     */
057    Pane errorNode();
058
059    /**
060     * Return the view model.
061     *
062     * @return the view model
063     */
064    M model();
065
066    /**
067     * Return the view controller.
068     *
069     * @return the view controller
070     */
071    C controller();
072
073    /**
074     * Prepare the view by creating all visual nodes.
075     *
076     * This method is called after Model initialization
077     *
078     * @throws CoreException if the preparation fails
079     */
080    void prepare() throws CoreException;
081
082    /**
083     * Handle custom tasks to do the first time after creation of the view.
084     *
085     * For example : you could start the show animation of the view.
086     */
087    void start();
088
089    /**
090     * Handle custom tasks to do at each rendering of the view (re-display).
091     *
092     * For example : play from start the start animation.
093     */
094    void reload();
095
096    /**
097     * Handle custom tasks to do when the view is closed or hidden.
098     *
099     * For example : you could start the hide animation of the view.
100     */
101    void hide();
102
103}