public class View extends MobileLayoutPane
Glisten user interfaces are built using views, which are essentially named
MobileLayoutPanes
. To construct a View instance,
a developer simply calls the constructor and then begins to use the API
inherited from MobileLayoutPane, most notably
BorderPane.setTop(Node)
, BorderPane.setCenter(Node)
,
and BorderPane.setBottom(Node)
.
Layers
can be placed on top of a View by adding them to the
layers
list. By doing this, it is possible to present
popup cards and other context-specific information to users.
Developers create and add Views to an application using the MobileApplication
class. For this the method MobileApplication.addViewFactory(String, Supplier)
is called passing in the name of the View, which must be unique, and a View factory
which when called by Glisten, should return a new instance of this particular
View.
The most important view factory is the one that specifies the 'home view', which is
shown when the application first starts. For example, the following sample is an application
with a single View that has the Label
with the text 'Hello World' as
its contents:
public class HelloWorld extends MobileApplication { @Override public void init() { addViewFactory(HOME_VIEW, () -> { Label helloWorld = new Label("Hello world!"); return new View(helloWorld) { @Override protected void updateAppBar(AppBar appBar) { appBar.setTitleText("Some title"); } }; }); } }
From the user interacting with a View a change to another View might be
desirable. To do this, developers should call MobileApplication.switchView(String)
or a similar method.
For more information about Views and how they fit into the overall Glisten
framework checkout the API documentation of the MobileApplication
class.
Layer
,
MobileApplication
Type | Property and Description |
---|---|
javafx.beans.property.StringProperty |
name
The name of this View - this is very important as it is the means through
which this View is differentiated from all other Views in API on
MobileApplication . |
javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> |
onCloseRequest
Called when there is an external request to close this
View . |
javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> |
onHidden
Called just after the View has been hidden.
|
javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> |
onHiding
Called just prior to the View being hidden.
|
javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> |
onShowing
Called just prior to the View being shown.
|
javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> |
onShown
Called just after the View is shown.
|
javafx.beans.property.ReadOnlyBooleanProperty |
showing
A boolean property used to represent whether this View is currently starting being
shown on screen.
|
javafx.beans.property.ObjectProperty<java.util.function.Function<View,javafx.animation.Transition>> |
showTransitionFactory
Specifies a
Function which should be used as factory to create a transition
used by the View during its appearance. |
bottomProperty, centerProperty, leftProperty, rightProperty, topProperty
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, heightProperty, insetsProperty, maxHeightProperty, maxWidthProperty, minHeightProperty, minWidthProperty, opaqueInsetsProperty, paddingProperty, prefHeightProperty, prefWidthProperty, scaleShapeProperty, shapeProperty, snapToPixelProperty, widthProperty
impl_traversalEngineProperty, needsLayoutProperty
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, cacheHintProperty, cacheProperty, clipProperty, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, focusedProperty, focusTraversableProperty, hoverProperty, idProperty, impl_showMnemonicsProperty, impl_treeVisibleProperty, inputMethodRequestsProperty, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParentTransformProperty, localToSceneTransformProperty, managedProperty, mouseTransparentProperty, nodeOrientationProperty, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, pickOnBoundsProperty, pressedProperty, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, styleProperty, translateXProperty, translateYProperty, translateZProperty, visibleProperty
DEFAULT_ANIMATION_DURATION, DEFAULT_BACKGROUND_FADE_LEVEL
Constructor and Description |
---|
View(javafx.scene.Node content)
Creates a new View instance with the given content and a null name.
|
View(java.lang.String name)
Creates a new View instance with the given name.
|
View(java.lang.String name,
javafx.scene.Node content)
Creates a new View instance with the given name and content.
|
Modifier and Type | Method and Description |
---|---|
MobileApplication |
getApplication()
Convenience method that returns the
MobileApplication instance that this
View finds itself contained within. |
java.lang.String |
getName()
Gets the value of the property name.
|
javafx.event.EventHandler<LifecycleEvent> |
getOnCloseRequest()
Gets the value of the property onCloseRequest.
|
javafx.event.EventHandler<LifecycleEvent> |
getOnHidden()
Gets the value of the property onHidden.
|
javafx.event.EventHandler<LifecycleEvent> |
getOnHiding()
Gets the value of the property onHiding.
|
javafx.event.EventHandler<LifecycleEvent> |
getOnShowing()
Gets the value of the property onShowing.
|
javafx.event.EventHandler<LifecycleEvent> |
getOnShown()
Gets the value of the property onShown.
|
javafx.animation.Transition |
getShowTransition()
Returns current show transition for the
View
This method never returns null, so transition can be played safely |
java.util.function.Function<View,javafx.animation.Transition> |
getShowTransitionFactory()
Gets the value of the property showTransitionFactory.
|
boolean |
isShowing()
Gets the value of the property showing.
|
javafx.beans.property.StringProperty |
nameProperty()
The name of this View - this is very important as it is the means through
which this View is differentiated from all other Views in API on
MobileApplication . |
javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> |
onCloseRequestProperty()
Called when there is an external request to close this
View . |
javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> |
onHiddenProperty()
Called just after the View has been hidden.
|
javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> |
onHidingProperty()
Called just prior to the View being hidden.
|
javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> |
onShowingProperty()
Called just prior to the View being shown.
|
javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> |
onShownProperty()
Called just after the View is shown.
|
void |
setName(java.lang.String value)
Sets the value of the property name.
|
void |
setOnCloseRequest(javafx.event.EventHandler<LifecycleEvent> value)
Sets the value of the property onCloseRequest.
|
void |
setOnHidden(javafx.event.EventHandler<LifecycleEvent> value)
Sets the value of the property onHidden.
|
void |
setOnHiding(javafx.event.EventHandler<LifecycleEvent> value)
Sets the value of the property onHiding.
|
void |
setOnShowing(javafx.event.EventHandler<LifecycleEvent> value)
Sets the value of the property onShowing.
|
void |
setOnShown(javafx.event.EventHandler<LifecycleEvent> value)
Sets the value of the property onShown.
|
void |
setShowTransitionFactory(java.util.function.Function<View,javafx.animation.Transition> value)
Sets the value of the property showTransitionFactory.
|
javafx.beans.property.ReadOnlyBooleanProperty |
showingProperty()
A boolean property used to represent whether this View is currently starting being
shown on screen.
|
javafx.beans.property.ObjectProperty<java.util.function.Function<View,javafx.animation.Transition>> |
showTransitionFactoryProperty()
Specifies a
Function which should be used as factory to create a transition
used by the View during its appearance. |
protected void |
updateAppBar(AppBar appBar)
If the view uses an
AppBar it is the responsibility of the developer
to appropriately set it up in this method. |
getLayers, layoutChildren
bottomProperty, centerProperty, clearConstraints, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, getAlignment, getBottom, getCenter, getContentBias, getLeft, getMargin, getRight, getTop, leftProperty, rightProperty, setAlignment, setBottom, setCenter, setLeft, setMargin, setRight, setTop, topProperty
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, getBackground, getBorder, getClassCssMetaData, getCssMetaData, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, impl_computeContains, impl_computeGeomBounds, impl_computeLayoutBounds, impl_createPeer, impl_notifyLayoutBoundsChanged, impl_pickNodeLocal, impl_updatePeer, insetsProperty, isCacheShape, isCenterShape, isResizable, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapSize, snapSpace, snapToPixelProperty, widthProperty
getBaselineOffset, getChildrenUnmodifiable, getImpl_traversalEngine, getManagedChildren, getStylesheets, impl_getAllParentStylesheets, impl_processCSS, impl_processMXNode, impl_traversalEngineProperty, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, requestParentLayout, setImpl_traversalEngine, setNeedsLayout, updateBounds
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, containsBounds, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, hasProperties, hoverProperty, idProperty, impl_clearDirty, impl_computeIntersects, impl_cssGetCursorInitialValue, impl_cssGetFocusTraversableInitialValue, impl_findStyles, impl_geomChanged, impl_getLeafTransform, impl_getMatchingStyles, impl_getPeer, impl_getPivotX, impl_getPivotY, impl_getPivotZ, impl_getStyleMap, impl_hasTransforms, impl_intersects, impl_intersectsBounds, impl_isDirty, impl_isDirtyEmpty, impl_isShowMnemonics, impl_isTreeVisible, impl_layoutBoundsChanged, impl_markDirty, impl_pickNode, impl_processCSS, impl_reapplyCSS, impl_setShowMnemonics, impl_setStyleMap, impl_showMnemonicsProperty, impl_syncPeer, impl_transformsChanged, impl_traverse, impl_treeVisibleProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, visibleProperty
public final javafx.beans.property.ReadOnlyBooleanProperty showingProperty
isShowing()
public final javafx.beans.property.StringProperty nameProperty
MobileApplication
. Ideally, the name would be set in the
View constructor, and never changed, although at present this is not
enforced.getName()
,
setName(String)
public final javafx.beans.property.ObjectProperty<java.util.function.Function<View,javafx.animation.Transition>> showTransitionFactoryProperty
Function
which should be used as factory to create a transition
used by the View during its appearance.
Given a View the factory should return a Transition
.public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> onShowingProperty
getOnShowing()
,
setOnShowing(EventHandler)
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> onShownProperty
getOnShown()
,
setOnShown(EventHandler)
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> onHidingProperty
getOnHiding()
,
setOnHiding(EventHandler)
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> onHiddenProperty
getOnHidden()
,
setOnHidden(EventHandler)
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> onCloseRequestProperty
View
.
If in the event handler the received event is consumed the View will
no longer hide.public View(java.lang.String name)
name
- The given name for the Viewpublic View(javafx.scene.Node content)
content
- The given content for the Viewpublic View(java.lang.String name, javafx.scene.Node content)
name
- The given name for the Viewcontent
- The given content for the Viewpublic final javafx.beans.property.ReadOnlyBooleanProperty showingProperty()
isShowing()
public final boolean isShowing()
public final javafx.beans.property.StringProperty nameProperty()
MobileApplication
. Ideally, the name would be set in the
View constructor, and never changed, although at present this is not
enforced.getName()
,
setName(String)
public final java.lang.String getName()
public final void setName(java.lang.String value)
public final javafx.beans.property.ObjectProperty<java.util.function.Function<View,javafx.animation.Transition>> showTransitionFactoryProperty()
Function
which should be used as factory to create a transition
used by the View during its appearance.
Given a View the factory should return a Transition
.public final java.util.function.Function<View,javafx.animation.Transition> getShowTransitionFactory()
public final void setShowTransitionFactory(java.util.function.Function<View,javafx.animation.Transition> value)
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> onShowingProperty()
getOnShowing()
,
setOnShowing(EventHandler)
public final void setOnShowing(javafx.event.EventHandler<LifecycleEvent> value)
public final javafx.event.EventHandler<LifecycleEvent> getOnShowing()
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> onShownProperty()
getOnShown()
,
setOnShown(EventHandler)
public final void setOnShown(javafx.event.EventHandler<LifecycleEvent> value)
public final javafx.event.EventHandler<LifecycleEvent> getOnShown()
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> onHidingProperty()
getOnHiding()
,
setOnHiding(EventHandler)
public final void setOnHiding(javafx.event.EventHandler<LifecycleEvent> value)
public final javafx.event.EventHandler<LifecycleEvent> getOnHiding()
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> onHiddenProperty()
getOnHidden()
,
setOnHidden(EventHandler)
public final void setOnHidden(javafx.event.EventHandler<LifecycleEvent> value)
public final javafx.event.EventHandler<LifecycleEvent> getOnHidden()
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<LifecycleEvent>> onCloseRequestProperty()
View
.
If in the event handler the received event is consumed the View will
no longer hide.public final void setOnCloseRequest(javafx.event.EventHandler<LifecycleEvent> value)
public final javafx.event.EventHandler<LifecycleEvent> getOnCloseRequest()
public javafx.animation.Transition getShowTransition()
View
This method never returns null, so transition can be played safelyNoTransition
if factory returned nullprotected void updateAppBar(AppBar appBar)
AppBar
it is the responsibility of the developer
to appropriately set it up in this method. Every time the view is shown,
this method will be called with a "clean" AppBar
i.e. without any elements in it.appBar
- the AppBar
AppBar.clear()
public final MobileApplication getApplication()
MobileApplication
instance that this
View finds itself contained within.MobileApplication
instance