@DefaultProperty(value="center")
public class View
extends javafx.scene.layout.BorderPane
View is a layout container that closely matches the typical layout of many mobile application. All user interfaces are built using views. Each view has a unique name and it needs to be passed to construct a View instance.
Layers
can be placed on top of a View by calling Layer.show()
.
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.
Views can update the contents of the AppBar by overriding updateAppBar(AppBar)
.
In order to hide an AppBar from a View, Node.visibleProperty()
should be set to false.
For more information about Views and how they fit into the overall Glisten
framework checkout the API documentation of the MobileApplication
class.
MobileApplication
,
Layer
Type | Property and Description |
---|---|
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,MobileTransition>> |
showTransitionFactory
Specifies a
MobileTransition which should be used as factory to create a transition
used by the View during its appearance. |
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, impl_showMnemonics, impl_treeVisible, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, visible
Constructor and Description |
---|
View()
Creates a new View instance with no content
|
View(javafx.scene.Node content)
Creates a new View instance with the given content.
|
Modifier and Type | Method and Description |
---|---|
MobileApplication |
getApplication()
Convenience method that returns the
MobileApplication instance that this
View finds itself contained within. |
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.
|
MobileTransition |
getShowTransition()
Returns current show transition for the
View
This method never returns null, so transition can be played safely |
java.util.function.Function<View,MobileTransition> |
getShowTransitionFactory()
Gets the value of the property showTransitionFactory.
|
boolean |
isShowing()
Gets the value of the property showing.
|
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 |
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,MobileTransition> 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,MobileTransition>> |
showTransitionFactoryProperty()
Specifies a
MobileTransition 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. |
bottomProperty, centerProperty, clearConstraints, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, getAlignment, getBottom, getCenter, getContentBias, getLeft, getMargin, getRight, getTop, layoutChildren, 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.ObjectProperty<java.util.function.Function<View,MobileTransition>> showTransitionFactoryProperty
MobileTransition
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 MobileTransition
.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()
public View(javafx.scene.Node content)
content
- The given content for the Viewpublic final javafx.beans.property.ReadOnlyBooleanProperty showingProperty()
isShowing()
public final boolean isShowing()
public final javafx.beans.property.ObjectProperty<java.util.function.Function<View,MobileTransition>> showTransitionFactoryProperty()
MobileTransition
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 MobileTransition
.public final java.util.function.Function<View,MobileTransition> getShowTransitionFactory()
MobileTransition
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 MobileTransition
.public final void setShowTransitionFactory(java.util.function.Function<View,MobileTransition> value)
MobileTransition
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 MobileTransition
.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)
View
.
If in the event handler the received event is consumed the View will
no longer hide.public final javafx.event.EventHandler<LifecycleEvent> getOnCloseRequest()
View
.
If in the event handler the received event is consumed the View will
no longer hide.public MobileTransition 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