Class CGridPerspective
java.lang.Object
bibliothek.gui.dock.common.perspective.AbstractCDockablePerspective
bibliothek.gui.dock.common.perspective.SingleCDockablePerspective
bibliothek.gui.dock.common.perspective.CGridPerspective
- All Implemented Interfaces:
CDockablePerspective,CElementPerspective,CStationPerspective
- Direct Known Subclasses:
CWorkingPerspective
A representation of a
CGridArea. If this perspective is loaded with content, then all the coordinates
are in a range between 0 and 100.- Author:
- Benjamin Sigg
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassThe type of object that is used by aCGridPerspectiveas intern representation.Nested classes/interfaces inherited from class bibliothek.gui.dock.common.perspective.SingleCDockablePerspective
SingleCDockablePerspective.Intern -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new, empty perspective.CGridPerspective(String id, Path typeId) Creates a new, empty perspective.CGridPerspective(String id, Path typeId, boolean workingArea) Creates a new, empty perspective. -
Method Summary
Modifier and TypeMethodDescriptionGetsthisas station, if this is a station.create()Called the first timeSingleCDockablePerspective.intern()is called, this method creates the intern representation of thisSingleCDockablePerspective.Gets all the nodes of the grid.Gets the element that is maximized.Gets the perspective which presents this station.getRoot()Gets access to the intern tree that represents the layout of this area.Gets the unique id denoting the type of thisCStation, this should be the exact same result asCStation.getTypeId()will return.grid()Allows access to the internal representation of this area as grid.voidgridAdd(double x, double y, double width, double height, CDockablePerspective... dockables) Addsdockablesat locationx/ywith sizewidth/heightto an internal list of pending commands to execute.voidDeletes all pending commands that were collected by thegrid*methods.voidRemoves all children of this area, then executes pending commands that add dockables at specified locations.
In particular this method analyzes all the commands that were generated by calls to thegrid*methods and merges them into a layout that fits the locations and sizes the client specified as good as possible.
IfisAutoDeploy()returnstrue, then this method is called automatically before storing the layout of this area.
This method will silently return if the list of pending commands was never accessed directly or indirectly by the client.voidgridHorizontal(double x1, double x2, double y) Adds a constraint to the algorithm that is executed bygridDeploy(), the constraint tells that there should be a horizontal divider fromx1/ytox2/y.voidgridPlaceholder(double x, double y, double width, double height, CDockablePerspective... dockables) Addsdockablesas placeholder at locationx/ywith sizewidth/heightto an internal list of pending commands to execute.voidgridPlaceholder(double x, double y, double width, double height, Path... placeholders) Adds placeholders at locationx/ywith sizewidth/heightto an internal list of pending commands to execute.voidvoidgridSelect(double x, double y, double width, double height, CDockablePerspective selection) Using locationx/yand sizewidth/heightas key, this method set the selection in a group of dockables.voidgridVertical(double x, double y1, double y2) Adds a constraint to the algorithm that is executed bygridDeploy(), the constraint tells that there should be a vertical divider fromx/y1tox/y2.intern()Gets the internal representation for this element.
IfCElementPerspective.asDockable()returns a non-nullvalue, thenintern().asDockable()must not returnnulleither.
IfCElementPerspective.asStation()returns a non-nullvalue, thenintern().asStation()must not returnnulleither.booleanTells whethergridDeploy()will be called automatically before accessing the tree ofDockables.booleanisRoot()Tells whether this is a root station or not.booleanTells whether this station will act as aworking area.voidmaximize(CDockablePerspective dockable) Maximizeddockableon this station.voidmaximize(PerspectiveDockable dockable) Maximizeddockableon this station.protected voidvoidsetAutoDeploy(boolean autoDeploy) Sets whethergridDeploy()is called automatically by this area before accessing the tree ofDockables.voidsetPerspective(CPerspective perspective) Informs this station by which perspective it is used.voidsetPlaceholders(PlaceholderMap placeholders) voidsetRoot(boolean root) Sets the root station flag.voidsetWorkingArea(boolean workingArea) Sets whether this station should be regarded as aworking areaor not.voidunpack(double x, double y, double width, double height) Unpacks the stations (e.g.Methods inherited from class bibliothek.gui.dock.common.perspective.SingleCDockablePerspective
asDockable, getUniqueIdMethods inherited from class bibliothek.gui.dock.common.perspective.AbstractCDockablePerspective
getLocationHistory, getParent, getWorkingArea, remove, setWorkingAreaMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface bibliothek.gui.dock.common.perspective.CElementPerspective
asDockableMethods inherited from interface bibliothek.gui.dock.common.perspective.CStationPerspective
getUniqueId
-
Constructor Details
-
CGridPerspective
Creates a new, empty perspective.- Parameters:
id- the unique identifier of this perspective
-
CGridPerspective
Creates a new, empty perspective.- Parameters:
id- the unique identifier of this perspectivetypeId- the type of this station, can benull
-
CGridPerspective
Creates a new, empty perspective.- Parameters:
id- the unique identifier of this perspectivetypeId- the type of this station, can benullworkingArea- whether this station should be treated asworking areaor not.
-
-
Method Details
-
isWorkingArea
public boolean isWorkingArea()Description copied from interface:CStationPerspectiveTells whether this station will act as aworking area.- Specified by:
isWorkingAreain interfaceCStationPerspective- Returns:
- whether this station acts as working area
-
getTypeId
Description copied from interface:CStationPerspectiveGets the unique id denoting the type of thisCStation, this should be the exact same result asCStation.getTypeId()will return.- Specified by:
getTypeIdin interfaceCStationPerspective- Returns:
- the type id, can be
null
-
isRoot
public boolean isRoot()Description copied from interface:CStationPerspectiveTells whether this is a root station or not.- Specified by:
isRootin interfaceCStationPerspective- Returns:
- the root flag
- See Also:
-
setRoot
public void setRoot(boolean root) Description copied from interface:CStationPerspectiveSets the root station flag. Setting flag is equivalent of setting therootparameter when callingCControl.addStation(bibliothek.gui.dock.common.CStation, boolean). The location of aDockableis always relative to its nearest root-station parent.
Please note that the root-flag set by callingCControl.addStation(bibliothek.gui.dock.common.CStation, boolean)will never be overridden by the flag set in the perspective.- Specified by:
setRootin interfaceCStationPerspective- Parameters:
root-
-
setWorkingArea
public void setWorkingArea(boolean workingArea) Sets whether this station should be regarded as aworking areaor not. This setting is not stored, it is the clients responsibility to make sure that the matchingCStationis or is not a working area.- Parameters:
workingArea- whether this station is to be treated like a working area or not
-
create
Description copied from class:SingleCDockablePerspectiveCalled the first timeSingleCDockablePerspective.intern()is called, this method creates the intern representation of thisSingleCDockablePerspective.- Overrides:
createin classSingleCDockablePerspective- Returns:
- the internal representation of
this
-
intern
Description copied from interface:CElementPerspectiveGets the internal representation for this element.
IfCElementPerspective.asDockable()returns a non-nullvalue, thenintern().asDockable()must not returnnulleither.
IfCElementPerspective.asStation()returns a non-nullvalue, thenintern().asStation()must not returnnulleither.- Specified by:
internin interfaceCElementPerspective- Overrides:
internin classSingleCDockablePerspective- Returns:
- the internal representation
-
setPerspective
Description copied from interface:CStationPerspectiveInforms this station by which perspective it is used.- Specified by:
setPerspectivein interfaceCStationPerspective- Parameters:
perspective- the perspective that uses this station ornull
-
getPerspective
Description copied from interface:CStationPerspectiveGets the perspective which presents this station.- Specified by:
getPerspectivein interfaceCStationPerspective- Returns:
- the owner of this station, can be
null
-
maybeDeploy
protected void maybeDeploy() -
unpack
public void unpack(double x, double y, double width, double height) Unpacks the stations (e.g. a stack) that is stored atx,y,width,height. The result is like removing all children and add them again withgridAdd(double, double, double, double, CDockablePerspective...).- Parameters:
x- the x-coordinate of a set ofCDockablePerspective, can be any numbery- the y-coordinate of a set ofCDockablePerspective, can be any numberwidth- the width of a set ofCDockablePerspective, can be any number greater than 0height- the height of a set ofCDockablePerspective, can be any number greater than 0
-
gridAdd
public void gridAdd(double x, double y, double width, double height, CDockablePerspective... dockables) Addsdockablesat locationx/ywith sizewidth/heightto an internal list of pending commands to execute. This method does not change the layout of this area, but a call togridDeploy()will.
Calling this method several times with the same location and size has the same effect as calling it once, but with a bigger array that contains all the dockables that would otherwise be added through many calls.- Parameters:
x- the x-coordinate ofdockables, can be any numbery- the y-coordinate ofdockables, can be any numberwidth- the width ofdockables, can be any number greater than 0height- the height ofdockables, can be any number greater than 0dockables- the elements to add, should contain at least one item- See Also:
-
gridPlaceholder
public void gridPlaceholder(double x, double y, double width, double height, CDockablePerspective... dockables) Addsdockablesas placeholder at locationx/ywith sizewidth/heightto an internal list of pending commands to execute. This method does not change the layout of this area, but a call togridDeploy()will.
Calling this method several times with the same location and size has the same effect as calling it once, but with a bigger array that contains all the dockables that would otherwise be added through many calls.- Parameters:
x- the x-coordinate ofdockables, can be any numbery- the y-coordinate ofdockables, can be any numberwidth- the width ofdockables, can be any number greater than 0height- the height ofdockables, can be any number greater than 0dockables- the elements whose placeholders to add, should contain at least one item- Throws:
IllegalArgumentException- if not all dockables have a placeholder- See Also:
-
gridPlaceholder
Adds placeholders at locationx/ywith sizewidth/heightto an internal list of pending commands to execute. This method does not change the layout of this area, but a call togridDeploy()will.
Calling this method several times with the same location and size has the same effect as calling it once, but with a bigger array that contains all the dockables that would otherwise be added through many calls.- Parameters:
x- the x-coordinate ofdockables, can be any numbery- the y-coordinate ofdockables, can be any numberwidth- the width ofdockables, can be any number greater than 0height- the height ofdockables, can be any number greater than 0placeholders- the placeholders to add, should contain at least one element and nonullelements- Throws:
IllegalArgumentException- if not all dockables have a placeholder- See Also:
-
gridSelect
public void gridSelect(double x, double y, double width, double height, CDockablePerspective selection) Using locationx/yand sizewidth/heightas key, this method set the selection in a group of dockables. This method does not change the layout directly, but a call togridDeploy()will.- Parameters:
x- the x-coordinate ofdockables, can be any numbery- the y-coordinate ofdockables, can be any numberwidth- the width ofdockables, can be any number greater than 0height- the height ofdockables, can be any number greater than 0selection- the element that should be selected, must already be in the group- See Also:
-
gridHorizontal
public void gridHorizontal(double x1, double x2, double y) Adds a constraint to the algorithm that is executed bygridDeploy(), the constraint tells that there should be a horizontal divider fromx1/ytox2/y.- Parameters:
x1- the beginning of the dividerx2- the end of the dividery- the vertical position of the divider
-
gridVertical
public void gridVertical(double x, double y1, double y2) Adds a constraint to the algorithm that is executed bygridDeploy(), the constraint tells that there should be a vertical divider fromx/y1tox/y2.- Parameters:
x- the horizontal position of the dividery1- the beginning of the dividery2- the end of the divider
-
gridClear
public void gridClear()Deletes all pending commands that were collected by thegrid*methods. A call to this method does not change the current layout of this area, but a call togridDeploy()will.- See Also:
-
gridDeploy
public void gridDeploy()Removes all children of this area, then executes pending commands that add dockables at specified locations.
In particular this method analyzes all the commands that were generated by calls to thegrid*methods and merges them into a layout that fits the locations and sizes the client specified as good as possible.
IfisAutoDeploy()returnstrue, then this method is called automatically before storing the layout of this area.
This method will silently return if the list of pending commands was never accessed directly or indirectly by the client.- See Also:
-
gridPrepare
public void gridPrepare() -
grid
Allows access to the internal representation of this area as grid. Changes to the returned object will stored but not change the layout of this area directly, a call togridDeploy()will change the layout however.- Returns:
- the internal grid
- See Also:
-
getGridNodes
Gets all the nodes of the grid. Each node is a set ofPerspectiveDockables and their location and size.- Returns:
- the nodes, may be empty, is unmodifiable
-
setAutoDeploy
public void setAutoDeploy(boolean autoDeploy) Sets whethergridDeploy()is called automatically by this area before accessing the tree ofDockables. The default value for this property istrue.
Clients have to callgridDeploy()if this property isfalsein order to execute commands that were collected with thegrid*methods.- Parameters:
autoDeploy- whethergridDeploy()is called automatically
-
isAutoDeploy
public boolean isAutoDeploy()Tells whethergridDeploy()will be called automatically before accessing the tree ofDockables.- Returns:
- whether automatic deployment is active
- See Also:
-
getRoot
Gets access to the intern tree that represents the layout of this area. Clients may alter this tree in any way they like. Please note that ifautomatic deploymentis active,gridDeploy()can be triggered by invoking this method.- Returns:
- the root of the intern tree of dockables,
nullif this area does not have any children
-
maximize
Maximizeddockableon this station. Please read about the side effects inmaximize(PerspectiveDockable).- Parameters:
dockable- the element to maximize, notnull
-
maximize
Maximizeddockableon this station. Note that maximized elements will be de-maximized by aCControlunlessCControl.setRevertToBasicModes(boolean)was switched tofalse. A call to this method has several side effects that must be cared for:- If necessary and if auto-deploy is set,
gridDeploy()is called. - If the parent of
dockableis not this station, thendockableis removed from the parent and added to this. The locationdockablehas on its parent is stored and can be used during un-maximization. - If
dockablehas no parent, then it is added to this station. No location information is stored. This is no problem forCDockablePerspectiveas they usually have a history of legal locations associated, but for any other dockable the missing location can lead to strange behavior when un-maximizing.
- Parameters:
dockable- the element to maximize
- If necessary and if auto-deploy is set,
-
getMaximized
Gets the element that is maximized.- Returns:
- the maximized child or
null
-
asStation
Description copied from interface:CElementPerspectiveGetsthisas station, if this is a station.- Specified by:
asStationin interfaceCElementPerspective- Overrides:
asStationin classSingleCDockablePerspective- Returns:
thisornull
-
getFactoryID
-
getPlaceholders
-
setPlaceholders
-