private void recalculateLayoutConstraints() { double prefWidth = 0; double prefHeight = 0; for (DockingSplitPaneChildBase child : dockingSplitPaneChildren) { LayoutConstraintsDescriptor childLayoutConstraints = child.getLayoutConstraints(); if (LayoutConstraintsDescriptor.isPreferred(prefWidth) && (LayoutConstraintsDescriptor.isFlexible(childLayoutConstraints.getPrefWidth()) || childLayoutConstraints.getPrefWidth() > prefWidth)) { prefWidth = childLayoutConstraints.getPrefWidth(); } if (LayoutConstraintsDescriptor.isPreferred(prefHeight) && (LayoutConstraintsDescriptor.isFlexible(childLayoutConstraints.getPrefHeight()) || childLayoutConstraints.getPrefHeight() > prefHeight)) { prefHeight = childLayoutConstraints.getPrefHeight(); } if (LayoutConstraintsDescriptor.isFlexible(prefWidth) && LayoutConstraintsDescriptor.isFlexible(prefHeight)) { break; } } final LayoutConstraintsDescriptor layoutConstraintsDescriptor = LayoutConstraintsDescriptor.getLayoutConstraints(prefWidth, prefHeight); setLayoutConstraints(layoutConstraintsDescriptor); }
/** * Gets a LayoutConstraintsDescriptor with the specified preferred width and preferred height * * @param prefWidth the preferred width of the Docking Area. Can be negative to indicate a flexible width. * @param prefHeight the preferred height of the Docking Area. Can be negative to indicate a flexible height. * @return a LayoutConstraintsDescriptor */ public static LayoutConstraintsDescriptor getLayoutConstraints(double prefWidth, double prefHeight) { return new LayoutConstraintsDescriptor(prefWidth, prefHeight); }
/** * Creates a new instance of this class. * * @param prefWidth the preferred width of the Docking Area. Can be negative to indicate a flexible width. * @param prefHeight the preferred height of the Docking Area. Can be negative to indicate a flexible height. */ private LayoutConstraintsDescriptor(double prefWidth, double prefHeight) { this.prefWidth = getPrefSize(prefWidth); this.prefHeight = getPrefSize(prefHeight); }
private double getPrefSize(RegionDimension dimension, LayoutConstraintsDescriptor layoutConstraints) { if (dimension.equals(RegionDimension.WIDTH)) { return layoutConstraints.getPrefWidth(); } else { return layoutConstraints.getPrefHeight(); } }
@Override public void updateLayoutConstraints() { if (LayoutConstraintsDescriptor.isPreferred(getLayoutConstraints().getPrefWidth())) { getLayoutConstraints().setPrefWidth(getWidth()); } if (LayoutConstraintsDescriptor.isPreferred(getLayoutConstraints().getPrefHeight())) { getLayoutConstraints().setPrefHeight(getHeight()); } }
private double getPrefSize(double prefSize) { if (isPreferred(prefSize)) { return prefSize; } else { return FLEXIBLE_PREF; } }
if (parentSize > 0) { for (int i = 0; i < prefs.length; i++) { if (LayoutConstraintsDescriptor.isPreferred(prefs[i])) { relativeSizes[i] = prefs[i] / parentSize; requiredRelativeSize += relativeSizes[i]; double flexibleRelativeSize = (1 - requiredRelativeSize) / flexiblePositions; for (int i = 0; i < prefs.length; i++) { if (LayoutConstraintsDescriptor.isFlexible(prefs[i])) { relativeSizes[i] = flexibleRelativeSize;
public static LayoutConstraintsDescriptor createLayoutConstraintsDescriptor(LayoutConstraintsType layoutConstraints) { return LayoutConstraintsDescriptor.getLayoutConstraints(layoutConstraints.getPrefWidth(), layoutConstraints.getPrefHeight()); }
private void addChildListeners(DockingSplitPaneChildBase child) { child.layoutConstraintsProperty().addListener(layoutConstraintsChangeListener); child.getLayoutConstraints().addPropertyChangeListener(PREF_WIDTH, layoutConstraintsDimensionChangeListener); child.getLayoutConstraints().addPropertyChangeListener(PREF_HEIGHT, layoutConstraintsDimensionChangeListener); }
private void removeChildListeners(DockingSplitPaneChildBase child) { child.layoutConstraintsProperty().removeListener(layoutConstraintsChangeListener); child.getLayoutConstraints().removePropertyChangeListener(PREF_WIDTH, layoutConstraintsDimensionChangeListener); child.getLayoutConstraints().removePropertyChangeListener(PREF_HEIGHT, layoutConstraintsDimensionChangeListener); }
public static boolean isFlexible(double size) { return !isPreferred(size); }
private void configureChild(DockingSplitPaneChildBase child, boolean addListeners) { LayoutConstraintsDescriptor layoutConstraints = child.getLayoutConstraints(); if (dockingSplitPane.isHorizontal()) { configureChild(child, RegionDimension.WIDTH, layoutConstraints.getPrefWidth(), addListeners); } else { configureChild(child, RegionDimension.HEIGHT, layoutConstraints.getPrefHeight(), addListeners); } }
private void configureChild(DockingSplitPaneChildBase child, RegionDimension dimension, double prefSize, boolean addListeners) { if (LayoutConstraintsDescriptor.isPreferred(prefSize)) { dimension.setPrefSize(child, prefSize); // dimension.setMinSize(child, prefSize); SplitPane.setResizableWithParent(child, Boolean.FALSE); } else { dimension.setPrefSize(child, Region.USE_COMPUTED_SIZE); SplitPane.setResizableWithParent(child, Boolean.TRUE); } dimension.setMaxSize(child, Double.MAX_VALUE); if (addListeners) { addChildListeners(child); } }
public static LayoutConstraintsDescriptor prefWidth(double prefWidth) { return new LayoutConstraintsDescriptor(prefWidth, FLEXIBLE_PREF); }
public void setPrefWidth(double prefWidth) { double oldValue = this.prefWidth; this.prefWidth = getPrefSize(prefWidth); firePropertyChange(propertyChangeSupport, "prefWidth", oldValue, this.prefWidth); }
public static LayoutConstraintsDescriptor flexible() { return new LayoutConstraintsDescriptor(FLEXIBLE_PREF, FLEXIBLE_PREF); }
public void setPrefHeight(double prefHeight) { double oldValue = this.prefHeight; this.prefHeight = getPrefSize(prefHeight); firePropertyChange(propertyChangeSupport, "prefHeight", oldValue, this.prefHeight); }
public static LayoutConstraintsDescriptor prefHeight(double prefHeight) { return new LayoutConstraintsDescriptor(FLEXIBLE_PREF, prefHeight); }