Class ResponsivePane
java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.layout.Region
javafx.scene.layout.Pane
javafx.scene.layout.StackPane
jfxtras.scene.layout.responsivepane.ResponsivePane
- All Implemented Interfaces:
javafx.css.Styleable, javafx.event.EventTarget
public class ResponsivePane
extends javafx.scene.layout.StackPane
= ResponsivePane
This layout chooses the best fitting layout and stylesheet for a given stage size.
ResponsivePane is loosely based on responsive design as advocated by website designs, and implemented in for example the Twitter Bootstrap project.
But there is a twist in the logic; responsive design assumes a given width and unlimited vertical space with the use of a scrollbar.
For websites this is ok, but applications do not have unlimited vertical space.
Take for example a webbrowser; it contains a webview with a scrollbar, but it does not run inside a scrollpane itself.
So for applications there is no such thing as unlimited vertical space!
It has to use scalable controls, like lists, tables ort webview, to dynamically fill its horizontal and vertical space, just like we are used to in Swing and JavaFX for ages.
But given large screen size differences, from 4 inch phones to 32 inch desktops, it is ridiculous to think that a single layout can adapt to all sizes: on a phone you may choose to use a TabbedPane with less controls visible, and on desktop you go all out with a MigPane and a number of gimmicks.
ResponsiveLayout allows you to define reusable nodes and have specific screen size related layouts, using the reusable nodes.
It will then use what layout fits best.
A typical use of ResponsivePane would look like this:
[source,java]
--
-
Property Summary
PropertiesTypePropertyDescriptionjavafx.beans.property.ObjectProperty<Layout> ActiveLayoutjavafx.beans.property.ObjectProperty<Stylesheet> ActiveMyStylesheetjavafx.beans.property.ObjectProperty<Stylesheet> ActiveSceneStylesheetjavafx.beans.property.ObjectProperty<Boolean> Debug: show rendering hints (for Ref) and prints out changes to the layout on the consolejavafx.beans.property.ObjectProperty<Boolean> Trace: like debug, plus show calculations determining if changes are needed on the consoleProperties inherited from class javafx.scene.layout.StackPane
alignmentProperties inherited from class javafx.scene.layout.Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, widthProperties inherited from class javafx.scene.Parent
needsLayoutProperties inherited from class javafx.scene.Node
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, 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, viewOrder, visible -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final javafx.beans.property.SimpleObjectProperty<Layout> private final javafx.beans.property.SimpleObjectProperty<Stylesheet> private final javafx.beans.property.SimpleObjectProperty<Stylesheet> private final javafx.beans.property.SimpleObjectProperty<Boolean> private final javafx.collections.ObservableList<Layout> private final javafx.collections.ObservableList<Stylesheet> (package private) Doublestatic final Stringprivate final javafx.collections.ObservableList<javafx.scene.Node> private final javafx.collections.ObservableList<Stylesheet> private final Stylesheetprivate final Layoutprivate final javafx.beans.property.SimpleObjectProperty<Boolean> Fields inherited from class javafx.scene.layout.Region
USE_COMPUTED_SIZE, USE_PREF_SIZEFields inherited from class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjavafx.beans.property.ObjectProperty<Layout> ActiveLayoutjavafx.beans.property.ObjectProperty<Stylesheet> ActiveMyStylesheetjavafx.beans.property.ObjectProperty<Stylesheet> ActiveSceneStylesheetvoidConvenience method for addLayout(Size, Node)voidaddLayout(String device, Orientation orientation, javafx.scene.Node root) Convenience method for addLayout(Size, Orientation, Node)voidConvenience method for addLayout(Size, Node)voidaddLayout(Device device, Orientation orientation, javafx.scene.Node root) Convenience method for addLayout(Size, Orientation, Node)voidConvenience method for getLayouts().add(new Layout(sizeAtLeast, root))voidaddLayout(Size sizeAtLeast, Orientation orientation, javafx.scene.Node root) Convenience method for getLayouts().add(new Layout(sizeAtLeast, orientation, root))voidaddMyStylesheet(String device, String file) Convenience method for addMyStylesheet(Size sizeAtLeast, String file)voidaddMyStylesheet(Device device, String file) Convenience method for addMyStylesheet(Size sizeAtLeast, String file)voidaddMyStylesheet(Size sizeAtLeast, String file) Convenience method for getMyStylesheets().add(new Stylesheet(sizeAtLeast, file));javafx.scene.NodeaddReusableNode(String id, javafx.scene.Node node) javafx.scene.NodeaddReusableNode(javafx.scene.Node node) voidaddSceneStylesheet(String device, String file) Convenience method for addSceneStylesheet(Size sizeAtLeast, String file)voidaddSceneStylesheet(Device device, String file) Convenience method for addSceneStylesheet(Size sizeAtLeast, String file)voidaddSceneStylesheet(Size sizeAtLeast, String file) Convenience method for getSceneStylesheets().add(new Stylesheet(sizeAtLeast, file));javafx.beans.property.ObjectProperty<Boolean> Debug: show rendering hints (for Ref) and prints out changes to the layout on the console(package private) double(package private) Layout(package private) StylesheetdetermineBestFittingStylesheet(List<Stylesheet> availableStylesheets) (package private) doubleDetermine the pixels-per-inch of the screen we are on(package private) javafx.scene.NodefindResuableNode(String refId) Gets the value of theactiveLayoutproperty.Gets the value of theactiveMyStylesheetproperty.Gets the value of theactiveSceneStylesheetproperty.getDebug()Gets the value of thedebugproperty.getDeviceSize(String device) Convienience method for getDeviceSize(device)getDeviceSize(Device device) Convienience method for getDeviceSize(device.toString())javafx.collections.ObservableList<Layout> layoutsjavafx.collections.ObservableList<Stylesheet> myStylesheetsjavafx.collections.ObservableList<javafx.scene.Node> refsjavafx.collections.ObservableList<Stylesheet> sceneStylesheetsgetTrace()Gets the value of thetraceproperty.protected void(package private) voidload(Stylesheet stylesheet, List<Stylesheet> availableStylesheets, List<String> activeStylesheetUrls) private voidvoidsetActiveLayout(Layout value) Sets the value of theactiveLayoutproperty.voidsetActiveMyStylesheet(Stylesheet value) Sets the value of theactiveMyStylesheetproperty.voidSets the value of theactiveSceneStylesheetproperty.voidSets the value of thedebugproperty.voidsetDeviceSize(String device, Size size) Convenience method for deviceSizes.put(device, size)voidsetDeviceSize(Device device, Size size) Convenience method for deviceSizes.put(device.toString(), size)voidSets the value of thetraceproperty.(package private) voidjavafx.beans.property.ObjectProperty<Boolean> Trace: like debug, plus show calculations determining if changes are needed on the consolewithActiveLayout(Layout value) withActiveMyStylesheet(Stylesheet value) IdMethods inherited from class javafx.scene.layout.StackPane
alignmentProperty, clearConstraints, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, getAlignment, getAlignment, getClassCssMetaData, getContentBias, getCssMetaData, getMargin, requestLayout, setAlignment, setAlignment, setMarginMethods inherited from class javafx.scene.layout.Pane
getChildrenMethods inherited from class javafx.scene.layout.Region
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, 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, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthPropertyMethods inherited from class javafx.scene.Parent
getBaselineOffset, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestParentLayout, setNeedsLayout, updateBoundsMethods inherited from class javafx.scene.Node
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, 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, getInitialCursor, getInitialFocusTraversable, 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, getViewOrder, hasProperties, hoverProperty, idProperty, 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, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visiblePropertyMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface javafx.css.Styleable
getStyleableNode
-
Property Details
-
debug
Debug: show rendering hints (for Ref) and prints out changes to the layout on the console- See Also:
-
trace
Trace: like debug, plus show calculations determining if changes are needed on the console- See Also:
-
activeLayout
-
activeSceneStylesheet
ActiveSceneStylesheet- See Also:
-
activeMyStylesheet
ActiveMyStylesheet- See Also:
-
-
Field Details
-
debugProperty
-
traceProperty
-
reusableNodes
private final javafx.collections.ObservableList<javafx.scene.Node> reusableNodes -
layouts
-
activeLayoutProperty
-
sceneStylesheets
-
activeSceneStylesheetProperty
-
myStylesheets
-
activeMyStylesheetProperty
-
deviceSizes
-
ppi
Double ppi -
PPI_SYSTEM_PROPERTY
-
SINGULARITY_LAYOUT
-
SINGULAR_STYLESHEET
-
-
Constructor Details
-
ResponsivePane
public ResponsivePane()
-
-
Method Details
-
withId
Id -
debugProperty
Debug: show rendering hints (for Ref) and prints out changes to the layout on the console- Returns:
- the
debugproperty - See Also:
-
getDebug
Gets the value of thedebugproperty.- Property description:
- Debug: show rendering hints (for Ref) and prints out changes to the layout on the console
- Returns:
- the value of the
debugproperty - See Also:
-
setDebug
Sets the value of thedebugproperty.- Property description:
- Debug: show rendering hints (for Ref) and prints out changes to the layout on the console
- Parameters:
value- the value for thedebugproperty- See Also:
-
withDebug
-
traceProperty
Trace: like debug, plus show calculations determining if changes are needed on the console- Returns:
- the
traceproperty - See Also:
-
getTrace
Gets the value of thetraceproperty.- Property description:
- Trace: like debug, plus show calculations determining if changes are needed on the console
- Returns:
- the value of the
traceproperty - See Also:
-
setTrace
Sets the value of thetraceproperty.- Property description:
- Trace: like debug, plus show calculations determining if changes are needed on the console
- Parameters:
value- the value for thetraceproperty- See Also:
-
withTrace
-
log
-
getReusableNodes
public javafx.collections.ObservableList<javafx.scene.Node> getReusableNodes()refs -
addReusableNode
- Parameters:
id-node-- Returns:
-
addReusableNode
public javafx.scene.Node addReusableNode(javafx.scene.Node node) - Parameters:
node-- Returns:
-
findResuableNode
- Parameters:
refId-- Returns:
-
getLayouts
layouts -
addLayout
Convenience method for addLayout(Size, Node) -
addLayout
Convenience method for addLayout(Size, Node) -
addLayout
Convenience method for getLayouts().add(new Layout(sizeAtLeast, root)) -
addLayout
Convenience method for addLayout(Size, Orientation, Node) -
addLayout
Convenience method for addLayout(Size, Orientation, Node) -
addLayout
Convenience method for getLayouts().add(new Layout(sizeAtLeast, orientation, root)) -
activeLayoutProperty
ActiveLayout- Returns:
- the
activeLayoutproperty - See Also:
-
getActiveLayout
Gets the value of theactiveLayoutproperty.- Property description:
- ActiveLayout
- Returns:
- the value of the
activeLayoutproperty - See Also:
-
setActiveLayout
Sets the value of theactiveLayoutproperty.- Property description:
- ActiveLayout
- Parameters:
value- the value for theactiveLayoutproperty- See Also:
-
withActiveLayout
-
getSceneStylesheets
sceneStylesheets -
addSceneStylesheet
-
addSceneStylesheet
-
addSceneStylesheet
-
activeSceneStylesheetProperty
ActiveSceneStylesheet- Returns:
- the
activeSceneStylesheetproperty - See Also:
-
getActiveSceneStylesheet
Gets the value of theactiveSceneStylesheetproperty.- Property description:
- ActiveSceneStylesheet
- Returns:
- the value of the
activeSceneStylesheetproperty - See Also:
-
setActiveSceneStylesheet
Sets the value of theactiveSceneStylesheetproperty.- Property description:
- ActiveSceneStylesheet
- Parameters:
value- the value for theactiveSceneStylesheetproperty- See Also:
-
withActiveSceneStylesheet
-
getMyStylesheets
myStylesheets -
addMyStylesheet
-
addMyStylesheet
-
addMyStylesheet
-
activeMyStylesheetProperty
ActiveMyStylesheet- Returns:
- the
activeMyStylesheetproperty - See Also:
-
getActiveMyStylesheet
Gets the value of theactiveMyStylesheetproperty.- Property description:
- ActiveMyStylesheet
- Returns:
- the value of the
activeMyStylesheetproperty - See Also:
-
setActiveMyStylesheet
Sets the value of theactiveMyStylesheetproperty.- Property description:
- ActiveMyStylesheet
- Parameters:
value- the value for theactiveMyStylesheetproperty- See Also:
-
withActiveMyStylesheet
-
getDeviceSizes
-
setDeviceSize
-
setDeviceSize
-
getDeviceSize
-
getDeviceSize
-
layoutChildren
protected void layoutChildren()- Overrides:
layoutChildrenin classjavafx.scene.layout.StackPane
-
setupLayout
void setupLayout() -
determinePPI
double determinePPI()Determine the pixels-per-inch of the screen we are on- Returns:
-
determineActualDiagonalInInches
double determineActualDiagonalInInches()- Returns:
-
determineBestFittingLayout
Layout determineBestFittingLayout()- Returns:
-
determineBestFittingStylesheet
- Returns:
-
load
void load(Stylesheet stylesheet, List<Stylesheet> availableStylesheets, List<String> activeStylesheetUrls) - Parameters:
stylesheet-
-