Class MultiSplitLayout
java.lang.Object
org.openstreetmap.josm.gui.widgets.MultiSplitLayout
- All Implemented Interfaces:
LayoutManager
The MultiSplitLayout layout manager recursively arranges its
components in row and column groups called "Splits". Elements of
the layout are separated by gaps called "Dividers". The overall
layout is defined with a simple tree model whose nodes are
instances of MultiSplitLayout.Split, MultiSplitLayout.Divider,
and MultiSplitLayout.Leaf. Named Leaf nodes represent the space
allocated to a component that was added with a constraint that
matches the Leaf's name. Extra space is distributed
among row/column siblings according to their 0.0 to 1.0 weight.
If no weights are specified then the last sibling always gets
all of the extra space, or space reduction.
Although MultiSplitLayout can be used with any Container, it's the default layout manager for MultiSplitPane. MultiSplitPane supports interactively dragging the Dividers, accessibility, and other features associated with split panes.
All properties in this class are bound: when a properties value is changed, all PropertyChangeListeners are fired.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classModels a single vertical/horiztonal divider.static classThe specified Node is either the wrong type or was configured incorrectly.static classModels a java.awt Component child.static classBase class for the nodes that model a MultiSplitLayout.static classDefines a vertical or horizontal subdivision into two or more tiles. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate booleanprivate MultiSplitLayout.Nodeprivate final PropertyChangeSupport -
Constructor Summary
ConstructorsConstructorDescriptionCreate a MultiSplitLayout with a default model with a single Leaf node named "default".Create a MultiSplitLayout with the specified model. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLayoutComponent(String name, Component child) Add a component to this MultiSplitLayout.voidAdd property change listener.private static RectangleboundsWithXandWidth(Rectangle bounds, double x, double width) private static RectangleboundsWithYandHeight(Rectangle bounds, double y, double height) private static voidprivate ComponentdividerAt(int x, int y) Return the Divider whose bounds contain the specified point, or null if there isn't one.private static MultiSplitLayout.DividerdividerAt(MultiSplitLayout.Node root, int x, int y) Return the Dividers whose bounds overlap the specified Rectangle.private static List<MultiSplitLayout.Divider>private voidintReturns the width of Dividers in Split rows, and the height of Dividers in Split columns.booleanReturns the value of the floatingDividers property.getModel()Return the root of the tree of Split, Leaf, and Divider nodes that define this layout.Replies array of property change listeners.private voidlayout1(MultiSplitLayout.Node root, Rectangle bounds) private voidlayout2(MultiSplitLayout.Node root, Rectangle bounds) voidlayoutContainer(Container parent) Compute the bounds of all of the Split/Divider/Leaf Nodes in the layout model, and then set the bounds of each child component with a matching Leaf Node.private voidlayoutGrow(MultiSplitLayout.Split split, Rectangle bounds) private voidlayoutShrink(MultiSplitLayout.Split split, Rectangle bounds) private static voidminimizeSplitBounds(MultiSplitLayout.Split split, Rectangle bounds) minimumLayoutSize(Container parent) private Dimensionprivate static booleanprivate DimensionpreferredLayoutSize(Container parent) private DimensionvoidremoveLayoutComponent(Component child) Removes the specified component from the layout.voidRemove property change listener.voidsetDividerSize(int dividerSize) Sets the width of Dividers in Split rows, and the height of Dividers in Split columns.voidsetFloatingDividers(boolean floatingDividers) If true, Leaf node bounds match the corresponding component's preferred size and Splits/Dividers are resized accordingly.voidsetModel(MultiSplitLayout.Node newModel) Set the root of the tree of Split, Leaf, and Divider nodes that define this layout.private static DimensionsizeWithInsets(Container parent, Dimension size) private static voidthrowInvalidLayout(String msg, MultiSplitLayout.Node node)
-
Field Details
-
childMap
-
pcs
-
model
-
dividerSize
-
floatingDividers
-
-
Constructor Details
-
MultiSplitLayout
public MultiSplitLayout()Create a MultiSplitLayout with a default model with a single Leaf node named "default".#see setModel
-
MultiSplitLayout
Create a MultiSplitLayout with the specified model.#see setModel
- Parameters:
model- model
-
-
Method Details
-
addPropertyChangeListener
Add property change listener.- Parameters:
listener- listener to add
-
removePropertyChangeListener
Remove property change listener.- Parameters:
listener- listener to remove
-
getPropertyChangeListeners
Replies array of property change listeners.- Returns:
- array of property change listeners
-
firePCS
-
getModel
Return the root of the tree of Split, Leaf, and Divider nodes that define this layout.- Returns:
- the value of the model property
- See Also:
-
setModel
Set the root of the tree of Split, Leaf, and Divider nodes that define this layout. The model can be a Split node (the typical case) or a Leaf. The default value of this property is a Leaf named "default".- Parameters:
newModel- the root of the tree of Split, Leaf, and Divider node- Throws:
IllegalArgumentException- if model is a Divider or null- See Also:
-
getDividerSize
Returns the width of Dividers in Split rows, and the height of Dividers in Split columns.- Returns:
- the value of the dividerSize property
- See Also:
-
setDividerSize
Sets the width of Dividers in Split rows, and the height of Dividers in Split columns. The default value of this property is the same as for JSplitPane Dividers.- Parameters:
dividerSize- the size of dividers (pixels)- Throws:
IllegalArgumentException- if dividerSize < 0- See Also:
-
getFloatingDividers
Returns the value of the floatingDividers property.- Returns:
- the value of the floatingDividers property
- See Also:
-
setFloatingDividers
If true, Leaf node bounds match the corresponding component's preferred size and Splits/Dividers are resized accordingly. If false then the Dividers define the bounds of the adjacent Split and Leaf nodes. Typically this property is set to false after the (MultiSplitPane) user has dragged a Divider.- Parameters:
floatingDividers- boolean value- See Also:
-
addLayoutComponent
Add a component to this MultiSplitLayout. Thenameshould match the name property of the Leaf node that represents the bounds ofchild. After layoutContainer() recomputes the bounds of all of the nodes in the model, it will set this child's bounds to the bounds of the Leaf node withname. Note: if a component was already added with the same name, this method does not remove it from its parent.- Specified by:
addLayoutComponentin interfaceLayoutManager- Parameters:
name- identifies the Leaf node that defines the child's boundschild- the component to be added- See Also:
-
removeLayoutComponent
Removes the specified component from the layout.- Specified by:
removeLayoutComponentin interfaceLayoutManager- Parameters:
child- the component to be removed- See Also:
-
childForNode
-
preferredComponentSize
-
preferredNodeSize
-
minimumNodeSize
-
sizeWithInsets
-
preferredLayoutSize
- Specified by:
preferredLayoutSizein interfaceLayoutManager
-
minimumLayoutSize
- Specified by:
minimumLayoutSizein interfaceLayoutManager
-
boundsWithYandHeight
-
boundsWithXandWidth
-
minimizeSplitBounds
-
layoutShrink
-
layoutGrow
-
layout2
-
layout1
-
throwInvalidLayout
-
checkLayout
-
layoutContainer
Compute the bounds of all of the Split/Divider/Leaf Nodes in the layout model, and then set the bounds of each child component with a matching Leaf Node.- Specified by:
layoutContainerin interfaceLayoutManager
-
dividerAt
-
dividerAt
Return the Divider whose bounds contain the specified point, or null if there isn't one.- Parameters:
x- x coordinatey- y coordinate- Returns:
- the Divider at x,y
-
nodeOverlapsRectangle
-
dividersThatOverlap
private static List<MultiSplitLayout.Divider> dividersThatOverlap(MultiSplitLayout.Node root, Rectangle r) -
dividersThatOverlap
Return the Dividers whose bounds overlap the specified Rectangle.- Parameters:
r- target Rectangle- Returns:
- the Dividers that overlap r
- Throws:
IllegalArgumentException- if the Rectangle is null
-