public abstract class ToolbarGridLayoutManager<P extends bibliothek.gui.dock.station.support.PlaceholderListItem<bibliothek.gui.Dockable>>
extends java.lang.Object
implements java.awt.LayoutManager2
LayoutManager2
orders a set of Component
s 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(java.awt.Container parent,
Orientation orientation,
DockablePlaceholderToolbarGrid<P> grid,
ToolbarGroupDockStation station)
Creates a new layout manager.
|
Modifier and Type | Method and Description |
---|---|
void |
addLayoutComponent(java.awt.Component comp,
java.lang.Object constraints) |
void |
addLayoutComponent(java.lang.String name,
java.awt.Component comp) |
void |
addListener(ToolbarGridLayoutManagerListener listener)
Adds the observer
listener to this object. |
java.awt.Rectangle |
getBounds(int column)
Gets the boundaries of the column at index
column . |
java.awt.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 . |
java.awt.Rectangle |
getGapBounds(int column,
boolean includeScrollBars)
Gets the boundaries of the gab between the column
column-1
and column . |
java.awt.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(java.awt.Container target) |
float |
getLayoutAlignmentY(java.awt.Container target) |
java.awt.Rectangle |
getScreenBounds(int column) |
java.awt.Rectangle |
getScreenBounds(int column,
int line) |
protected abstract java.awt.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(java.awt.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
Component s. |
protected void |
layout(java.awt.Container parent,
ToolbarGridLayoutManager.Wrapper[][] components,
java.awt.Dimension required,
java.awt.Dimension available,
bibliothek.gui.dock.station.toolbar.layout.ToolbarGridLayoutManager.Size size)
Layouts
components such that they fit into
available . |
void |
layoutContainer(java.awt.Container parent) |
java.awt.Dimension |
maximumLayoutSize(java.awt.Container parent) |
java.awt.Dimension |
minimumLayoutSize(java.awt.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 . |
java.awt.Dimension |
preferredLayoutSize(java.awt.Container parent) |
void |
removeLayoutComponent(java.awt.Component comp) |
void |
removeListener(ToolbarGridLayoutManagerListener listener)
Removes the observer
listener from this object. |
void |
setController(bibliothek.gui.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
Dockable s. |
protected abstract void |
setShowScrollbar(int column,
boolean show)
Enables or disables a scrollbar for a column.
|
protected abstract java.awt.Component |
toComponent(P item)
Converts
item into a Component , this
LayoutManager will then set the location and size of the
resulting component. |
public ToolbarGridLayoutManager(java.awt.Container parent, Orientation orientation, DockablePlaceholderToolbarGrid<P> grid, ToolbarGroupDockStation station)
parent
- the Container
which is going to use this LayoutManager
orientation
- the orientation, must not be null
grid
- the list of items to lay out, must not be null
station
- the station using this layout managerpublic void setController(bibliothek.gui.DockController controller)
DockController
in whose realm this manager works. Allows this manager access to properties
like the SpanFactory
.controller
- the controller or null
public void setDividerStrategy(ToolbarGroupDividerStrategy dividers)
Dockable
s. The strategy is
required to find the minimum size of the gaps between the items.dividers
- the new strategy, can be null
public 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 java.awt.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 - available
protected abstract java.awt.Component getScrollbar(int column)
column
.column
- the column whose scrollbars are requestednull
if not presentprotected ToolbarGridLayoutManager.Wrapper[][] layout()
Component
s.public void addLayoutComponent(java.lang.String name, java.awt.Component comp)
addLayoutComponent
in interface java.awt.LayoutManager
public void removeLayoutComponent(java.awt.Component comp)
removeLayoutComponent
in interface java.awt.LayoutManager
public void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
addLayoutComponent
in interface java.awt.LayoutManager2
public 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 columnslocation
getColumnAt(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 java.awt.Dimension maximumLayoutSize(java.awt.Container parent)
maximumLayoutSize
in interface java.awt.LayoutManager2
public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
preferredLayoutSize
in interface java.awt.LayoutManager
public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
minimumLayoutSize
in interface java.awt.LayoutManager
public 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 null
public void removeListener(ToolbarGridLayoutManagerListener listener)
listener
from this object.listener
- the listener to removepublic void layoutContainer(java.awt.Container parent)
layoutContainer
in interface java.awt.LayoutManager
protected void layout(java.awt.Container parent, ToolbarGridLayoutManager.Wrapper[][] components, java.awt.Dimension required, java.awt.Dimension available, bibliothek.gui.dock.station.toolbar.layout.ToolbarGridLayoutManager.Size size)
components
such that they fit into
available
.parent
- the Container
whose layout is updatedcomponents
- the components to layoutrequired
- the size required for the optimal layoutavailable
- the size that is actually availablesize
- which Dimension
to get for laying out the componentspublic float getLayoutAlignmentX(java.awt.Container target)
getLayoutAlignmentX
in interface java.awt.LayoutManager2
public float getLayoutAlignmentY(java.awt.Container target)
getLayoutAlignmentY
in interface java.awt.LayoutManager2
public void invalidateLayout(java.awt.Container target)
invalidateLayout
in interface java.awt.LayoutManager2
public java.awt.Rectangle getBounds(int column, int line)
column/line
.column
- the column in which to search the cellline
- the row in column
java.lang.IllegalArgumentException
- if there is no cell at column/line
public java.awt.Rectangle getScreenBounds(int column, int line)
public java.awt.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.java.lang.IllegalArgumentException
- if column
is out of boundspublic java.awt.Rectangle getScreenBounds(int column)
public java.awt.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.java.lang.IllegalArgumentException
- if column
is out of boundspublic java.awt.Rectangle getGapBounds(int column, int line)
column
- the column in which the rows areline
- the row into which an item is insertedline-1
and line