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
alignment
Properties inherited from class javafx.scene.layout.Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width
Properties inherited from class javafx.scene.Parent
needsLayout
Properties 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) Double
static final String
private final javafx.collections.ObservableList
<javafx.scene.Node> private final javafx.collections.ObservableList
<Stylesheet> private final Stylesheet
private final Layout
private final javafx.beans.property.SimpleObjectProperty
<Boolean> Fields inherited from class javafx.scene.layout.Region
USE_COMPUTED_SIZE, USE_PREF_SIZE
Fields 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> ActiveSceneStylesheetvoid
Convenience method for addLayout(Size, Node)void
addLayout
(String device, Orientation orientation, javafx.scene.Node root) Convenience method for addLayout(Size, Orientation, Node)void
Convenience method for addLayout(Size, Node)void
addLayout
(Device device, Orientation orientation, javafx.scene.Node root) Convenience method for addLayout(Size, Orientation, Node)void
Convenience method for getLayouts().add(new Layout(sizeAtLeast, root))void
addLayout
(Size sizeAtLeast, Orientation orientation, javafx.scene.Node root) Convenience method for getLayouts().add(new Layout(sizeAtLeast, orientation, root))void
addMyStylesheet
(String device, String file) Convenience method for addMyStylesheet(Size sizeAtLeast, String file)void
addMyStylesheet
(Device device, String file) Convenience method for addMyStylesheet(Size sizeAtLeast, String file)void
addMyStylesheet
(Size sizeAtLeast, String file) Convenience method for getMyStylesheets().add(new Stylesheet(sizeAtLeast, file));javafx.scene.Node
addReusableNode
(String id, javafx.scene.Node node) javafx.scene.Node
addReusableNode
(javafx.scene.Node node) void
addSceneStylesheet
(String device, String file) Convenience method for addSceneStylesheet(Size sizeAtLeast, String file)void
addSceneStylesheet
(Device device, String file) Convenience method for addSceneStylesheet(Size sizeAtLeast, String file)void
addSceneStylesheet
(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) Stylesheet
determineBestFittingStylesheet
(List<Stylesheet> availableStylesheets) (package private) double
Determine the pixels-per-inch of the screen we are on(package private) javafx.scene.Node
findResuableNode
(String refId) Gets the value of theactiveLayout
property.Gets the value of theactiveMyStylesheet
property.Gets the value of theactiveSceneStylesheet
property.getDebug()
Gets the value of thedebug
property.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 thetrace
property.protected void
(package private) void
load
(Stylesheet stylesheet, List<Stylesheet> availableStylesheets, List<String> activeStylesheetUrls) private void
void
setActiveLayout
(Layout value) Sets the value of theactiveLayout
property.void
setActiveMyStylesheet
(Stylesheet value) Sets the value of theactiveMyStylesheet
property.void
Sets the value of theactiveSceneStylesheet
property.void
Sets the value of thedebug
property.void
setDeviceSize
(String device, Size size) Convenience method for deviceSizes.put(device, size)void
setDeviceSize
(Device device, Size size) Convenience method for deviceSizes.put(device.toString(), size)void
Sets the value of thetrace
property.(package private) void
javafx.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, setMargin
Methods inherited from class javafx.scene.layout.Pane
getChildren
Methods 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, widthProperty
Methods inherited from class javafx.scene.Parent
getBaselineOffset, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestParentLayout, setNeedsLayout, updateBounds
Methods 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, visibleProperty
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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
ActiveLayout- See Also:
-
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
debug
property - See Also:
-
getDebug
Gets the value of thedebug
property.- Property description:
- Debug: show rendering hints (for Ref) and prints out changes to the layout on the console
- Returns:
- the value of the
debug
property - See Also:
-
setDebug
Sets the value of thedebug
property.- Property description:
- Debug: show rendering hints (for Ref) and prints out changes to the layout on the console
- Parameters:
value
- the value for thedebug
property- See Also:
-
withDebug
-
traceProperty
Trace: like debug, plus show calculations determining if changes are needed on the console- Returns:
- the
trace
property - See Also:
-
getTrace
Gets the value of thetrace
property.- Property description:
- Trace: like debug, plus show calculations determining if changes are needed on the console
- Returns:
- the value of the
trace
property - See Also:
-
setTrace
Sets the value of thetrace
property.- Property description:
- Trace: like debug, plus show calculations determining if changes are needed on the console
- Parameters:
value
- the value for thetrace
property- 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
activeLayout
property - See Also:
-
getActiveLayout
Gets the value of theactiveLayout
property.- Property description:
- ActiveLayout
- Returns:
- the value of the
activeLayout
property - See Also:
-
setActiveLayout
Sets the value of theactiveLayout
property.- Property description:
- ActiveLayout
- Parameters:
value
- the value for theactiveLayout
property- See Also:
-
withActiveLayout
-
getSceneStylesheets
sceneStylesheets -
addSceneStylesheet
Convenience method for addSceneStylesheet(Size sizeAtLeast, String file) -
addSceneStylesheet
Convenience method for addSceneStylesheet(Size sizeAtLeast, String file) -
addSceneStylesheet
Convenience method for getSceneStylesheets().add(new Stylesheet(sizeAtLeast, file)); -
activeSceneStylesheetProperty
ActiveSceneStylesheet- Returns:
- the
activeSceneStylesheet
property - See Also:
-
getActiveSceneStylesheet
Gets the value of theactiveSceneStylesheet
property.- Property description:
- ActiveSceneStylesheet
- Returns:
- the value of the
activeSceneStylesheet
property - See Also:
-
setActiveSceneStylesheet
Sets the value of theactiveSceneStylesheet
property.- Property description:
- ActiveSceneStylesheet
- Parameters:
value
- the value for theactiveSceneStylesheet
property- See Also:
-
withActiveSceneStylesheet
-
getMyStylesheets
myStylesheets -
addMyStylesheet
Convenience method for addMyStylesheet(Size sizeAtLeast, String file) -
addMyStylesheet
Convenience method for addMyStylesheet(Size sizeAtLeast, String file) -
addMyStylesheet
Convenience method for getMyStylesheets().add(new Stylesheet(sizeAtLeast, file)); -
activeMyStylesheetProperty
ActiveMyStylesheet- Returns:
- the
activeMyStylesheet
property - See Also:
-
getActiveMyStylesheet
Gets the value of theactiveMyStylesheet
property.- Property description:
- ActiveMyStylesheet
- Returns:
- the value of the
activeMyStylesheet
property - See Also:
-
setActiveMyStylesheet
Sets the value of theactiveMyStylesheet
property.- Property description:
- ActiveMyStylesheet
- Parameters:
value
- the value for theactiveMyStylesheet
property- See Also:
-
withActiveMyStylesheet
-
getDeviceSizes
-
setDeviceSize
Convenience method for deviceSizes.put(device.toString(), size) -
setDeviceSize
Convenience method for deviceSizes.put(device, size) -
getDeviceSize
Convienience method for getDeviceSize(device.toString()) -
getDeviceSize
Convienience method for getDeviceSize(device) -
layoutChildren
protected void layoutChildren()- Overrides:
layoutChildren
in 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
-
-