public abstract class ToolbarGridLayoutManager<P extends PlaceholderListItem<Dockable>> extends Object implements LayoutManager2
LayoutManager2 orders a set of Components in columns. To
decide which component belongs to which column, the contents of a
DockablePlaceholderToolbarGrid are used.| Modifier and Type | Class and Description |
|---|---|
protected class |
ToolbarGridLayoutManager.Wrapper
A wrapper around one
Component, caches minimal, maximal or
preferred size. |
| Constructor and Description |
|---|
ToolbarGridLayoutManager(Container parent,
Orientation orientation,
DockablePlaceholderToolbarGrid<P> grid,
ToolbarGroupDockStation station)
Creates a new layout manager.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLayoutComponent(Component comp,
Object constraints) |
void |
addLayoutComponent(String name,
Component comp) |
void |
addListener(ToolbarGridLayoutManagerListener listener)
Adds the observer
listener to this object. |
Rectangle |
getBounds(int column)
Gets the boundaries of the column at index
column. |
Rectangle |
getBounds(int column,
int line)
Calculates the current boundaries of the cell at
column/line
. |
int |
getColumnAt(int location)
Tells which column covers the coordinate
location. |
Rectangle |
getGapBounds(int column,
boolean includeScrollBars)
Gets the boundaries of the gab between the column
column-1
and column. |
Rectangle |
getGapBounds(int column,
int line)
Gets the size of a gap between two rows.
|
int |
getInsertionLineAt(int column,
int location)
Tells where to insert an item during a drag and drop operation, if the mouse is hovering over
the column
column. |
float |
getLayoutAlignmentX(Container target) |
float |
getLayoutAlignmentY(Container target) |
Rectangle |
getScreenBounds(int column) |
Rectangle |
getScreenBounds(int column,
int line) |
protected abstract Component |
getScrollbar(int column)
Gets the scrollbars that are currently shown for
column. |
protected abstract int |
getScrollbarValue(int column,
int required,
int available)
Gets the current position of the scrollbar for
column, this method is at the same time
used to inform the scrollbar about the required and available size. |
void |
invalidateLayout(Container target) |
boolean |
isColumnAt(int location)
Tells whether there is a column covering
location. |
protected ToolbarGridLayoutManager.Wrapper[][] |
layout()
Gets an array of columns, where each column is an array of
Components. |
protected void |
layout(Container parent,
ToolbarGridLayoutManager.Wrapper[][] components,
Dimension required,
Dimension available,
bibliothek.gui.dock.station.toolbar.layout.ToolbarGridLayoutManager.Size size)
Layouts
components such that they fit into
available. |
void |
layoutContainer(Container parent) |
Dimension |
maximumLayoutSize(Container parent) |
Dimension |
minimumLayoutSize(Container parent) |
void |
mutate()
Closes all gaps for inserting items.
|
void |
mutate(int column)
Opens a gap for inserting an item into
column. |
void |
mutate(int column,
int line)
Opens a gap for inserting an item into
column at line. |
Dimension |
preferredLayoutSize(Container parent) |
void |
removeLayoutComponent(Component comp) |
void |
removeListener(ToolbarGridLayoutManagerListener listener)
Removes the observer
listener from this object. |
void |
setController(DockController controller)
Sets the
DockController in whose realm this manager works. |
void |
setDividerStrategy(ToolbarGroupDividerStrategy dividers)
Sets the strategy responsible for painting a border between the
Dockables. |
protected abstract void |
setShowScrollbar(int column,
boolean show)
Enables or disables a scrollbar for a column.
|
protected abstract Component |
toComponent(P item)
Converts
item into a Component, this
LayoutManager will then set the location and size of the
resulting component. |
public ToolbarGridLayoutManager(Container parent, Orientation orientation, DockablePlaceholderToolbarGrid<P> grid, ToolbarGroupDockStation station)
parent - the Container which is going to use this LayoutManagerorientation - the orientation, must not be nullgrid - the list of items to lay out, must not be nullstation - the station using this layout managerpublic void setController(DockController controller)
DockController in whose realm this manager works. Allows this manager access to properties
like the SpanFactory.controller - the controller or nullpublic void setDividerStrategy(ToolbarGroupDividerStrategy dividers)
Dockables. The strategy is
required to find the minimum size of the gaps between the items.dividers - the new strategy, can be nullpublic void mutate()
public void mutate(int column)
column.column - the column where an item is insertedpublic void mutate(int column,
int line)
column at line.column - the column into which an item is insertedline - the location of the new itemprotected abstract Component toComponent(P item)
item into a Component, this
LayoutManager will then set the location and size of the
resulting component.item - the item to convertComponent whose position and size will be setprotected abstract void setShowScrollbar(int column,
boolean show)
column - the column whose settings are updatedshow - whether to show scrollbars or notprotected abstract int getScrollbarValue(int column,
int required,
int available)
column, this method is at the same time
used to inform the scrollbar about the required and available size.required - the amount of pixels required to show the columnavailable - the amount of pixels actually available for showing the column0 and required - availableprotected abstract Component getScrollbar(int column)
column.column - the column whose scrollbars are requestednull if not presentprotected ToolbarGridLayoutManager.Wrapper[][] layout()
Components.public void addLayoutComponent(String name, Component comp)
addLayoutComponent in interface LayoutManagerpublic void removeLayoutComponent(Component comp)
removeLayoutComponent in interface LayoutManagerpublic void addLayoutComponent(Component comp, Object constraints)
addLayoutComponent in interface LayoutManager2public int getColumnAt(int location)
location. If the location is between columns, then the
result can be either of these columns.location - a point on the axis that is orthogonal to the orientation of the columnslocation or -1 if out of boundsisColumnAt(int)public boolean isColumnAt(int location)
location.location - a point on the axis that is orthogonal to the orientation of the columnslocationgetColumnAt(int)public int getInsertionLineAt(int column,
int location)
column.column - the column over which the mouse is hovering, must be an existing columnlocation - a point on the axis that is parallel to the orientation of the columnspublic Dimension maximumLayoutSize(Container parent)
maximumLayoutSize in interface LayoutManager2public Dimension preferredLayoutSize(Container parent)
preferredLayoutSize in interface LayoutManagerpublic Dimension minimumLayoutSize(Container parent)
minimumLayoutSize in interface LayoutManagerpublic void addListener(ToolbarGridLayoutManagerListener listener)
listener to this object. The observer will be called whenever
the layout of a Container is updated.listener - the new observer, not nullpublic void removeListener(ToolbarGridLayoutManagerListener listener)
listener from this object.listener - the listener to removepublic void layoutContainer(Container parent)
layoutContainer in interface LayoutManagerprotected void layout(Container parent, ToolbarGridLayoutManager.Wrapper[][] components, Dimension required, Dimension available, bibliothek.gui.dock.station.toolbar.layout.ToolbarGridLayoutManager.Size size)
components such that they fit into
available.public float getLayoutAlignmentX(Container target)
getLayoutAlignmentX in interface LayoutManager2public float getLayoutAlignmentY(Container target)
getLayoutAlignmentY in interface LayoutManager2public void invalidateLayout(Container target)
invalidateLayout in interface LayoutManager2public Rectangle getBounds(int column, int line)
column/line
.column - the column in which to search the cellline - the row in columnIllegalArgumentException - if there is no cell at column/linepublic Rectangle getScreenBounds(int column, int line)
public Rectangle getBounds(int column)
column. This
method returns the union of the boundaries of all cells, meaning if there
are gaps between the cells they are included in the boundaries. But
excess space around the cells (e.g. because other columns are bigger) is
ignored by this method.column - the column whose boundaries are searchednull if the column
column does not have any cells. This however is a
special case that should not appear in a live application and
indicates a bigger issue.IllegalArgumentException - if column is out of boundspublic Rectangle getScreenBounds(int column)
public Rectangle getGapBounds(int column, boolean includeScrollBars)
column-1
and column. This is the gap of column to its
left or top neighbor. The gap may have a width or height of
0, meaning the gap is not visible to the user. If
column is 0, then the gap to the left or top
end of the Container using this LayoutManager is
returned. If column is equal to the total number of columns,
the gap to the right or bottom end of the Container is returned.Container.column - the column whose left gap is searchedincludeScrollBars - if true, then the scrollbars are part of the gap as wellnull if one columns has no cells. This
however is a case that should not appear in a live client and
that indicates a bigger issue.IllegalArgumentException - if column is out of boundspublic Rectangle getGapBounds(int column, int line)
column - the column in which the rows areline - the row into which an item is insertedline-1 and lineCopyright © 2018. All rights reserved.