public class IlvGridLayout extends IlvGraphLayout
The Grid Layout algorithm has two major modes: grid and
row/column. (For details, see the method setLayoutMode(int)
.) In grid mode, the layout arranges the
nodes of a graph in the cells of a grid (matrix). If a node is too
large to fit into one grid cell (with a margin), it occupies multiple
cells. The size of the grid cells can be specified using the methods
setHorizontalGridOffset(double)
and setVerticalGridOffset(double)
. The margins can be specified using
the methods setTopMargin(double)
, setBottomMargin(double)
, setLeftMargin(double)
, and setRightMargin(double)
.
The following sample drawing shows a layout in the grid mode where the grid size has been specified so that each node fits into one grid cell. (Usually such layouts are more esthetic and appear to be more regular, but a larger area is left empty around the smallest nodes. This is generally the best option when all the nodes have the same size.)
The following sample drawing shows a layout in the grid mode where the grid size has been specified so that some nodes fit into one grid cell and other nodes occupy multiple cells. (Usually such layouts take less space if the nodes have a heterogeneous size.)
The following diagram shows the dimensional parameters of the layout in grid mode.
In row/column mode, the layout arranges the nodes of a graph
either by rows or by columns (according to the specified option). The
width of the rows is controlled by the width of the layout region
parameter. The height of the columns is controlled by the height of
the layout region parameter. The margins can be specified using the
methods setTopMargin(double)
, setBottomMargin(double)
, setLeftMargin(double)
, and setRightMargin(double)
. The minimum horizontal distance between
nodes is equal to the sum of the left and right margins. The minimum
vertical distance between nodes is equal to the sum of the top and
bottom margins.
For graphs with nodes of heterogeneous size, the row/column mode often allows a more compact layout than the grid mode.
The following sample drawing shows a layout in the row mode. >
The following sample drawing shows a layout in the column mode.
The following diagram shows the dimensional parameters of the layout in row mode (the parameters for the column mode are analogous).
The algorithm is primarily designed for graphs without (visible) links between the nodes. If links exist, they are ignored by the Grid layout.
Several alignment options are provided (see setGlobalHorizontalAlignment(int)
and setGlobalVerticalAlignment(int)
). The alignment can be specified
individually for each node (see setHorizontalAlignment(Object,
int)
and setVerticalAlignment(Object, int)
).
An incremental mode is provided (see setIncrementalMode(boolean)
). If the incremental mode is enabled,
the stability of the layout is preserved as much as possible when new
nodes are added, existing ones removed, or node sizes modified. This
means that the nodes are placed at the same location, or in the same
order, as in the previous layout whenever possible. In this mode, the
layout algorithm processes the changes incrementally rather than
redoing the entire layout for every change.
Nodes that the layout algorithm is not allowed to move can be
specified using the method IlvGraphLayout.setFixed(Object, boolean)
. (See
also IlvGraphLayout.setPreserveFixedNodes(boolean)
.) In grid mode, nonfixed
nodes are placed in such a way that they do not overlap the grid cells
occupied by other fixed or nonfixed nodes. In row/column mode,
nonfixed nodes are placed in such a way that they do not overlap fixed
or nonfixed nodes. Of course, fixed nodes can overlap other fixed
nodes.
The layout algorithm can take into account a different node size than
the size corresponding to the bounding box of the node. Using setNodeBoxInterface(IlvNodeBoxInterface)
, you can specify an object
that provides the box that has to be taken into account for each node.
The following diagram shows the dimensional parameters of the layout
in grid mode (the row/column case mode is analogous) when a node box
that is different from the bounding box of the node is used:
Modifier and Type | Field and Description |
---|---|
static Comparator |
ASCENDING_AREA
Ordering by ascending area option.
|
static Comparator |
ASCENDING_HEIGHT
Ordering by ascending height option.
|
static Comparator |
ASCENDING_INDEX
Ordering by ascending index option.
|
static Comparator |
ASCENDING_WIDTH
Ordering by ascending width option.
|
static Comparator |
AUTOMATIC_ORDERING
Automatic ordering option.
|
static int |
BOTTOM
Bottom alignment option.
|
static int |
CENTER
Center alignment option.
|
static Comparator |
DESCENDING_AREA
Ordering by descending area option.
|
static Comparator |
DESCENDING_HEIGHT
Ordering by height option.
|
static Comparator |
DESCENDING_INDEX
Ordering by descending index option.
|
static Comparator |
DESCENDING_WIDTH
Ordering by descending width option.
|
static int |
LEFT
Left alignment option.
|
static int |
MIXED
Mixed alignment option.
|
static int |
NO_INDEX
No index code.
|
static Comparator |
NO_ORDERING
No ordering option.
|
static int |
RIGHT
Right alignment option.
|
static int |
TILE_TO_COLUMNS
Tile-to-columns layout mode.
|
static int |
TILE_TO_GRID_FIXED_HEIGHT
Tile-to-grid layout mode with fixed height of the grid.
|
static int |
TILE_TO_GRID_FIXED_WIDTH
Tile-to-grid layout mode with fixed width of the grid.
|
static int |
TILE_TO_ROWS
Tile-to-rows layout mode.
|
static int |
TOP
Top alignment option.
|
INVERSE_VIEW_COORDINATES, MANAGER_COORDINATES, VIEW_COORDINATES
Constructor and Description |
---|
IlvGridLayout()
Creates a new instance of the Grid Layout algorithm.
|
IlvGridLayout(IlvGridLayout source)
Creates a new layout instance by copying an existing one.
|
Modifier and Type | Method and Description |
---|---|
void |
checkAppropriateLinks()
Throws an exception if the links are not appropriate for the layout.
|
IlvGraphLayout |
copy()
Copies the layout instance.
|
void |
copyParameters(IlvGraphLayout source)
Copies the parameters from a given layout instance.
|
protected IlvGraphLayoutGrapherProperty |
createLayoutGrapherProperty(String name,
boolean withDefaults)
Returns a new instance of
IlvGridLayoutGrapherProperty that
stores the parameter settings of this layout class. |
protected IlvGraphLayoutNodeProperty |
createLayoutNodeProperty(String name,
IlvGraphic node,
boolean withDefaults)
Returns a new instance of
IlvGridLayoutNodeProperty that
stores the parameter settings of this layout class for nodes. |
void |
detach()
Detaches the graph model from the layout instance.
|
double |
getBottomMargin()
Returns the bottom margin.
|
int |
getGlobalHorizontalAlignment()
Returns the global horizontal alignment style.
|
int |
getGlobalVerticalAlignment()
Returns the global vertical alignment style.
|
int |
getHorizontalAlignment(Object node)
Returns the local horizontal alignment style of the node.
|
double |
getHorizontalGridOffset()
Returns the horizontal grid offset.
|
int |
getIndex(Object node)
Returns the index value associated with a node.
|
int |
getLayoutMode()
Returns the current layout mode.
|
double |
getLeftMargin()
Returns the left margin.
|
int |
getMaxNumberOfNodesPerRowOrColumn()
Returns the maximum number of nodes per row in
TILE_TO_ROWS
mode or the maximum number of nodes per column in TILE_TO_COLUMNS mode. |
IlvGraphicVector |
getMovingNodes()
Returns the vector of nodes being moved by the graph layout algorithm.
|
IlvNodeBoxInterface |
getNodeBoxInterface()
Returns the object that provides the rectangle defining the location
and size of each node, if one is specified.
|
Comparator |
getNodeComparator()
Returns the comparator used for sorting the nodes.
|
double |
getRightMargin()
Returns the right margin.
|
double |
getTopMargin()
Returns the top margin.
|
int |
getVerticalAlignment(Object node)
Returns the local vertical alignment style of the node.
|
double |
getVerticalGridOffset()
Returns the vertical grid offset.
|
protected void |
init()
Initializes instance variables.
|
boolean |
isIncrementalMode()
Returns
true if the incremental mode is enabled, and
false otherwise. |
protected void |
layout(boolean redraw)
Computes the layout using the Grid Layout algorithm.
|
void |
setBottomMargin(double margin)
Sets the bottom margin parameter.
|
void |
setGlobalHorizontalAlignment(int alignment)
Sets the global horizontal alignment style.
|
void |
setGlobalVerticalAlignment(int alignment)
Sets the global vertical alignment style.
|
void |
setHorizontalAlignment(Object node,
int alignment)
Sets the horizontal alignment style of an individual node.
|
void |
setHorizontalGridOffset(double offset)
Sets the spacing of the grid lines on the horizontal axis.
|
void |
setIncrementalMode(boolean enable)
Sets the incremental mode.
|
void |
setIndex(Object node,
int index)
Sets the index of a node.
|
void |
setLayoutMode(int mode)
Sets the layout mode.
|
void |
setLeftMargin(double margin)
Sets the left margin parameter.
|
void |
setMaxNumberOfNodesPerRowOrColumn(int nNodes)
Sets the maximum number of nodes per row or per column.
|
void |
setNodeBoxInterface(IlvNodeBoxInterface nodeBoxInterface)
Sets an object that provides the rectangle defining the location and
size of each node.
|
void |
setNodeComparator(Comparator comparator)
Sets the comparator used for sorting the nodes.
|
void |
setRightMargin(double margin)
Sets the right margin parameter.
|
void |
setTopMargin(double margin)
Sets the top margin parameter.
|
void |
setVerticalAlignment(Object node,
int alignment)
Sets the vertical alignment style of an individual node.
|
void |
setVerticalGridOffset(double offset)
Sets the spacing of the grid lines on the vertical axis.
|
boolean |
supportsAllowedTime()
Indicates that this layout class can stop the layout computation in a
proper manner when the user-defined allowed time is exceeded.
|
boolean |
supportsLayoutRegion()
Indicates that this layout class can control the size of the graph
drawing to fit a user-defined region (a rectangle) or a user-defined
manager view.
|
boolean |
supportsPreserveFixedNodes()
Indicates that this layout class allows the user to specify fixed
nodes.
|
boolean |
supportsSaveParametersToNamedProperties()
Indicates that this layout class can transfer the layout parameters to
named properties.
|
boolean |
supportsStopImmediately()
Indicates that this layout class can control the current run by
interrupting the run of the layout immediately.
|
addGraphLayoutEventListener, addGraphLayoutParameterEventListener, afterLayoutOfSubgraph, attach, attach, beforeLayout, beforeLayoutOfSubgraph, callLayoutStepPerformedIfNeeded, checkAppropriateLink, cleanGraphModel, cleanLink, cleanNode, clipAllLinks, clipLink, connectAllLinksToCenter, connectLinkToCenter, contentsChanged, createLayoutLinkProperty, createLayoutReport, getAllowedTime, getAutoLayoutHandler, getBalanceSplineCurveThreshold, getCalcLayoutRegion, getCoordinatesMode, getGrapher, getGraphModel, getInstanceId, getLayout, getLayoutOfConnectedComponents, getLayoutOfConnectedComponentsReport, getLayoutRegion, getLayoutReport, getLayouts, getLinkClipInterface, getLinkConnectionBoxInterface, getMaxSplineCurveSize, getMinBusyTime, getMinSplineCurveSize, getParentLayout, getProperty, getProperty, getRecursiveLayout, getRemainingAllowedTime, getSeedValueForRandomGenerator, getSpecLayoutRegion, getSplineLinkFilter, increasePercentageComplete, isAnimate, isAutoLayout, isFitToView, isFixed, isGeometryUpToDate, isInputCheckEnabled, isLayoutNeeded, isLayoutOfConnectedComponentsEnabled, isLayoutOfConnectedComponentsEnabledByDefault, isLayoutRunning, isLayoutRunning, isLayoutTimeElapsed, isLocalRecursiveLayoutNeeded, isMemorySavings, isParametersUpToDate, isPreserveFixedLinks, isPreserveFixedNodes, isSplineRoutingEnabled, isStoppedImmediately, isStructureUpToDate, isUseDefaultParameters, isUseSeedValueForRandomGenerator, layoutStepPerformed, onParameterChanged, onParameterChanged, performAutoLayout, performLayout, performLayout, performLayout, PerformLayout, performSublayout, removeGraphLayoutEventListener, removeGraphLayoutParameterEventListener, setAllowedTime, setAnimate, setAutoCheckAppropriateLinksEnabled, setAutoLayout, setAutoLayoutHandler, setBalanceSplineCurveThreshold, setCoordinatesMode, setFixed, setGeometryUpToDate, setGrapher, setGraphModel, setInputCheckEnabled, setLayoutOfConnectedComponents, setLayoutOfConnectedComponentsEnabled, setLayoutRegion, setLayoutRegion, setLayoutRegion, setLayoutReport, setLayoutRunning, setLinkClipInterface, setLinkConnectionBoxInterface, setMaxSplineCurveSize, setMemorySavings, setMinBusyTime, setMinSplineCurveSize, setParametersUpToDate, setParentLayout, setPreserveFixedLinks, setPreserveFixedNodes, setProperty, setProperty, setSeedValueForRandomGenerator, setSplineLinkFilter, setSplineRoutingEnabled, setStructureUpToDate, setUseDefaultParameters, setUseSeedValueForRandomGenerator, stopImmediately, supportsAnimation, supportsLayoutOfConnectedComponents, supportsLinkClipping, supportsLinkConnectionBox, supportsMemorySavings, supportsPercentageComplete, supportsPreserveFixedLinks, supportsRandomGenerator, supportsSplineRouting, unfixAllLinks, unfixAllNodes, useAnimateRedraw
public static final int CENTER
setGlobalHorizontalAlignment(int)
, all the nodes are
horizontally centered in their grid cell or column. The alignment of
an individual node can be set by setHorizontalAlignment(Object, int)
.
When used as the argument of the method setGlobalVerticalAlignment(int)
, all the nodes are vertically
centered in their grid cell or row. The alignment of an individual
node can be set by setVerticalAlignment(Object, int)
.
public static final int LEFT
setGlobalHorizontalAlignment(int)
, all the nodes are aligned to the
left border of their grid cell or column. The alignment of an
individual node can be set by setHorizontalAlignment(Object,
int)
.public static final int RIGHT
setGlobalHorizontalAlignment(int)
, all the nodes are aligned
to the right border of their grid cell or column. The alignment of an
individual node can be set by setHorizontalAlignment(Object,
int)
.public static final int TOP
setGlobalVerticalAlignment(int)
, all the nodes are aligned to the
top border of their grid cell or row. The alignment of an individual
node can be set by setVerticalAlignment(Object, int)
.public static final int BOTTOM
setGlobalVerticalAlignment(int)
, all the nodes are aligned
to the bottom border of their grid cell or row. The alignment of an
individual node can be set by setVerticalAlignment(Object,
int)
.public static final int MIXED
setGlobalHorizontalAlignment(int)
or setGlobalVerticalAlignment(int)
, each node can have a different
alignment. The alignment of an individual node can be set by setHorizontalAlignment(Object, int)
and setVerticalAlignment(Object, int)
.public static final int TILE_TO_ROWS
setLayoutMode(int)
, all the nodes are organized in rows and
are vertically aligned with respect to the row border according to
the vertical alignment option. In this mode, the grid offset
parameters are not used and the height of the layout region IlvGraphLayout.setLayoutRegion(ilog.views.IlvManagerView)
controls the maximum total height of the layout.setLayoutMode(int)
,
Constant Field Valuespublic static final int TILE_TO_COLUMNS
setLayoutMode(int)
, all the nodes are organized in columns
and are horizontally aligned with respect to the row border according
to the horizontal alignment option. In this mode, the grid offset
parameters are not used and the width of the layout region IlvGraphLayout.setLayoutRegion(ilog.views.IlvManagerView)
controls the maximum total width of the layout.setLayoutMode(int)
,
Constant Field Valuespublic static final int TILE_TO_GRID_FIXED_WIDTH
setLayoutMode(int)
, the nodes
are placed in the cells of a grid and the width of the layout region
IlvGraphLayout.setLayoutRegion(ilog.views.IlvManagerView)
) controls the maximum width of the grid.setLayoutMode(int)
,
Constant Field Valuespublic static final int TILE_TO_GRID_FIXED_HEIGHT
setLayoutMode(int)
, the nodes
are placed in the cells of a grid and the height of the layout region
IlvGraphLayout.setLayoutRegion(ilog.views.IlvManagerView)
) controls the maximum height of the grid.setLayoutMode(int)
,
Constant Field Valuespublic static final Comparator AUTOMATIC_ORDERING
setNodeComparator(Comparator)
, the algorithm is
free to choose an order aimed at reducing the total area occupied by
the layout.setNodeComparator(Comparator)
public static final Comparator NO_ORDERING
setNodeComparator(Comparator)
, the nodes are
arranged in an arbitrary order.setNodeComparator(Comparator)
public static final Comparator DESCENDING_HEIGHT
setNodeComparator(Comparator)
, the nodes are
arranged by height, starting at the upper-left corner with the
tallest node. Ordering the nodes by height can save vertical space
and produce a more compact layout.setNodeComparator(Comparator)
public static final Comparator ASCENDING_HEIGHT
setNodeComparator(Comparator)
, the
nodes are arranged by ascending height, starting at the upper-left
corner with the shortest node. Ordering the nodes by ascending height
can save vertical space and produce a more compact layout.setNodeComparator(Comparator)
public static final Comparator ASCENDING_WIDTH
setNodeComparator(Comparator)
, the
nodes are arranged by ascending width, starting at the upper-left
corner with the narrowest node.setNodeComparator(Comparator)
public static final Comparator DESCENDING_WIDTH
setNodeComparator(Comparator)
, the
nodes are arranged by width, starting at the upper-left corner with
the widest node.setNodeComparator(Comparator)
public static final Comparator ASCENDING_AREA
setNodeComparator(Comparator)
, the
nodes are arranged by ascending area, starting at the upper-left
corner with the node that has the smallest area.setNodeComparator(Comparator)
public static final Comparator DESCENDING_AREA
setNodeComparator(Comparator)
, the
nodes are arranged by area, starting at the upper-left corner with
the node that has the largest area.setNodeComparator(Comparator)
public static final Comparator ASCENDING_INDEX
setNodeComparator(Comparator)
, the
nodes are arranged in the order of their indexes, starting at the
upper-left corner with the node that has the smallest index. Nodes
that do not have an index are placed after nodes for which an index
is specified. Ordering by index allows you to specify a particular
order for the nodes.setNodeComparator(Comparator)
,
setIndex(java.lang.Object, int)
public static final Comparator DESCENDING_INDEX
setNodeComparator(Comparator)
, the
nodes are arranged in the order of their indexes, starting at the
upper-left corner with the node that has the largest index. Nodes
that do not have an index are placed after nodes for which an index
is specified. Ordering by index allows you to specify a particular
order for the nodes.setNodeComparator(Comparator)
,
setIndex(java.lang.Object, int)
public static final int NO_INDEX
getIndex(Object)
when a node has no index value.getIndex(Object)
,
Constant Field Valuespublic IlvGridLayout()
IlvGraphLayout.attach(IlvGrapher)
. IlvGraphLayout.attach(IlvGraphModel)
. IlvGraphLayout.performLayout()
. public IlvGridLayout(IlvGridLayout source)
copy()
method. Any subclass
should provide a copy constructor.
The parameters of the source
layout are copied using the
method copyParameters(IlvGraphLayout)
.
source
- The layout instance that is copied.copy()
,
copyParameters(IlvGraphLayout)
protected void init()
You should not call this method directly. The method is called internally by the constructor without arguments and by the copy constructor. The method must be overridden by subclasses that need to initialize additional instance variables.
init
in class IlvGraphLayout
public IlvGraphLayout copy()
This method copies the layout instance by calling the copy constructor.
When performing a recursive layout on a nested graph, this method is
used by IlvLayoutProvider
to "clone" the layout instance of a
parent graph.
Note that the parameters which are specific to a node or a link are not copied. The other parameters, including the layout region specification and the node box interface, are also copied.
If a method of the type supportsXXX
is associated with a
parameter, the parameter is copied only if the corresponding method
returns true
.
copy
in class IlvGraphLayout
public void copyParameters(IlvGraphLayout source)
Note that the parameters which are specific to a node or a link are not copied. The other parameters, including the layout region specification and the node box interface, are also copied.
If a method of the type supportsXXX
is associated with a
parameter, the parameter is copied only if the corresponding method
returns true
.
copyParameters
in class IlvGraphLayout
source
- The layout instance from which the parameters are copied.protected void layout(boolean redraw) throws IlvGraphLayoutException
IlvGraphLayout.performLayout()
.layout
in class IlvGraphLayout
redraw
- If true
, the attached graph model will be
asked to redraw the graph after layout. When the layout algorithm
moves the nodes and reshapes the links, it is required to pass the
value of the redraw
argument to the methods IlvGraphModel.moveNode(java.lang.Object, double, double, boolean)
and IlvGraphModel.reshapeLink(java.lang.Object, ilog.views.IlvPoint, ilog.views.IlvPoint[], int, int, ilog.views.IlvPoint, boolean)
.IlvGraphLayoutException
- If an unusual situation occurs.
WARNING: this method can throw one of the subclasses of IlvGraphLayoutException
. Specifically, it can throw an IlvInappropriateGraphException
. It can also throw an IlvInappropriateLinkException
when inappropriate types of links
and/or link connectors are used in an IlvGrapher
. For
details, refer to the documentation of these exception classes.IlvGraphLayout.performLayout()
public void detach()
IlvGraphLayout.attach(IlvGraphModel)
.
The method performs cleaning operations on the graph model. In addition to the cleaning operations in the base class, the Grid Layout algorithm removes the alignment specifications of individual nodes.
Note that you must call this method when you no longer need the layout instance. Otherwise, some objects may not be garbage collected.
detach
in class IlvGraphLayout
IlvGraphLayout.attach(IlvGraphModel)
,
setHorizontalAlignment(Object, int)
,
setVerticalAlignment(Object, int)
public final boolean supportsLayoutRegion()
If the layout mode (see setLayoutMode(int)
) is TILE_TO_GRID_FIXED_WIDTH
, the width of the layout region determines
the maximum width of the layout (the maximum number of columns).
If the layout mode is TILE_TO_GRID_FIXED_HEIGHT
, the height
of the layout region determines the maximum height of the layout (the
maximum number of rows).
If the layout mode is TILE_TO_ROWS
, the width of the layout
region determines the maximum width of the rows.
If the layout mode is TILE_TO_COLUMNS
, the height of the
layout region determines the maximum height of the columns.
However, if the width of a node is larger than the maximum width of the layout or the height of the node is larger than the maximum height of the layout, the bounding box of the node will be placed partially out of the specified layout region.
In all layout modes, the coordinates of the top-left corner of the layout region determines the coordinates of the top-left border of the layout.
supportsLayoutRegion
in class IlvGraphLayout
true
.IlvGraphLayout.setLayoutRegion(ilog.views.IlvManagerView)
,
IlvGraphLayout.setLayoutRegion(ilog.views.IlvManagerView, ilog.views.IlvRect)
,
IlvGraphLayout.setLayoutRegion(ilog.views.IlvRect)
,
IlvGraphLayout.getSpecLayoutRegion()
,
IlvGraphLayout.getCalcLayoutRegion()
public final boolean supportsPreserveFixedNodes()
Fixed nodes are not moved during the layout if the method IlvGraphLayout.setPreserveFixedNodes(boolean)
is called with a true
argument . Nonfixed nodes are placed in such a manner that overlaps
with fixed nodes are avoided.
supportsPreserveFixedNodes
in class IlvGraphLayout
true
.IlvGrapherAdapter.setFilter(ilog.views.graphlayout.IlvLayoutGraphicFilter)
,
IlvGraphLayout.setPreserveFixedNodes(boolean)
,
IlvGraphLayout.isPreserveFixedNodes()
public final boolean supportsAllowedTime()
If the allowed time elapses before termination of the Grid Layout
algorithm, the result code in the layout report is IlvGraphLayoutReport.STOPPED_AND_INVALID
.
supportsAllowedTime
in class IlvGraphLayout
true
.IlvGraphLayout.setAllowedTime(long)
,
IlvGraphLayout.getAllowedTime()
,
IlvGraphLayoutReport.getCode()
public boolean supportsStopImmediately()
If the algorithm is stopped before termination, the result code in
the layout report is IlvGraphLayoutReport.STOPPED_AND_INVALID
.
supportsStopImmediately
in class IlvGraphLayout
true
.IlvGraphLayout.stopImmediately()
,
IlvGraphLayout.isStoppedImmediately()
public boolean supportsSaveParametersToNamedProperties()
.ivl
file.supportsSaveParametersToNamedProperties
in class IlvGraphLayout
true
.IlvGrapherAdapter.saveParametersToNamedProperties(IlvGraphLayout, boolean)
,
IlvGrapherAdapter.loadParametersFromNamedProperties(IlvGraphLayout)
,
IlvGrapherAdapter.removeParametersFromNamedProperties()
public void setLayoutMode(int mode)
TILE_TO_GRID_FIXED_WIDTH
- The nodes are placed in the
cells of a grid (matrix) that has a fixed maximum number of columns.
This number is equal to the width of the layout region parameter
divided by the horizontal grid offset (see setHorizontalGridOffset(double)
). TILE_TO_GRID_FIXED_HEIGHT
- The nodes are placed in the
cells of a grid (matrix) that has a fixed maximum number of rows.
This number is equal to the height of the layout region parameter
divided by the vertical grid offset (see setVerticalGridOffset(double)
). TILE_TO_ROWS
- The nodes are placed in rows. The
maximum width of the rows is equal to the width of the layout region
parameter. The height of each row is the maximum height of the nodes
contained in the row (plus margins). TILE_TO_COLUMNS
- The nodes are placed in columns. The
maximum height of the columns is equal to the height of the layout
region parameter. The width of each column is the maximum width of
the nodes contained in the column (plus margins).
The default value is TILE_TO_GRID_FIXED_WIDTH
.
public int getLayoutMode()
setLayoutMode(int)
public void setIncrementalMode(boolean enable)
If the incremental mode is enabled, the stability of the layout is preserved as much as possible when new nodes are added, existing ones removed, or node sizes modified. This means that the nodes are placed at the same location or in the same order as in the previous layout whenever possible. In this mode, the layout algorithm processes the changes incrementally rather than redoing the entire layout for every change.
To preserve the stability, the incremental mode can keep some regions free. Therefore, the total area of the layout can be larger than when nonincremental mode is used.
Note that the layout is redone from scratch after a change in one of the following parameters:
The default value is false
(disabled).
public boolean isIncrementalMode()
true
if the incremental mode is enabled, and
false
otherwise.setIncrementalMode(boolean)
public void setGlobalHorizontalAlignment(int alignment)
setLayoutMode(int)
) is TILE_TO_GRID_FIXED_WIDTH
or TILE_TO_GRID_FIXED_HEIGHT
, or
inside the columns if the layout mode is TILE_TO_COLUMNS
.
This parameter is not used if the layout mode (see setLayoutMode(int)
) is TILE_TO_ROWS
.
Valid values are:
CENTER
- the node is centered in its grid cell or
column.LEFT
- the node is aligned to the left border of the
cell or column.RIGHT
- the node is aligned to the left border of the
cell or column.MIXED
- each node can have a different alignment
option. In this case, the horizontal alignment of each individual
node can be set by the method setHorizontalAlignment(Object,
int)
so that different alignments can occur in the same layout.
The default value is CENTER
.
public int getGlobalHorizontalAlignment()
setGlobalHorizontalAlignment(int)
public void setHorizontalAlignment(Object node, int alignment)
MIXED
. Otherwise, all nodes have the alignment style
that is specified as the global alignment style.
This parameter controls the horizontal alignment of nodes either
inside their grid cells if the layout mode (see setLayoutMode(int)
) is TILE_TO_GRID_FIXED_WIDTH
or TILE_TO_GRID_FIXED_HEIGHT
, or within the columns if the layout mode
is TILE_TO_COLUMNS
.
This parameter is not used if the layout mode (see setLayoutMode(int)
) is TILE_TO_ROWS
.
Valid values are:
CENTER
- the node is centered in its grid cell or
column.LEFT
- the node is aligned to the left border of the
cell or column.RIGHT
- the node is aligned to the right border of the
cell or column.
The default value is CENTER
.
node
- The node instance.alignment
- The horizontal alignment style of an individual node.
Valid values are: CENTER
, LEFT
or RIGHT
.getHorizontalAlignment(Object)
,
setGlobalHorizontalAlignment(int)
public int getHorizontalAlignment(Object node)
node
- The node instance.CENTER
, LEFT
or RIGHT
.setHorizontalAlignment(Object, int)
,
setGlobalHorizontalAlignment(int)
public void setGlobalVerticalAlignment(int alignment)
setLayoutMode(int)
) is TILE_TO_GRID_FIXED_WIDTH
or TILE_TO_GRID_FIXED_HEIGHT
, or
inside the rows if the layout mode is TILE_TO_ROWS
. This
parameter is not used if the layout mode (see setLayoutMode(int)
) is TILE_TO_COLUMNS
.
Valid values are:
CENTER
- the node is centered in its grid cell or
column.TOP
- the node is aligned to the top border of the cell
or column.BOTTOM
- the node is aligned to the bottom border of
the cell or column.MIXED
- each node can have a different alignment
option. In this case, the vertical alignment of each individual node
can be set by the method setVerticalAlignment(Object, int)
so that different alignments can occur in the same layout.
The default value is CENTER
.
public int getGlobalVerticalAlignment()
setGlobalVerticalAlignment(int)
public void setVerticalAlignment(Object node, int alignment)
MIXED
. Otherwise, all nodes have the alignment style that
is specified as the global alignment style.
This parameter controls the vertical alignment of nodes either inside
their grid cell if the layout mode (see setLayoutMode(int)
)
is TILE_TO_GRID_FIXED_WIDTH
or TILE_TO_GRID_FIXED_HEIGHT
, or within the rows if the layout mode is
TILE_TO_ROWS
.
This parameter is not used if the layout mode (see setLayoutMode(int)
) is TILE_TO_COLUMNS
.
Valid values are:
CENTER
- the node is centered in its grid cell or
column.TOP
- the node is aligned to the top border of the cell
or column.BOTTOM
- the node is aligned to the bottom border of
the cell or column.
The default value is CENTER
.
node
- The node instance.alignment
- The vertical alignment style of an individual node.
Possible values are: CENTER
, TOP
, BOTTOM
.getVerticalAlignment(Object)
,
setGlobalVerticalAlignment(int)
public int getVerticalAlignment(Object node)
node
- The node instanceCENTER
, TOP
, BOTTOM
.setVerticalAlignment(Object, int)
,
setGlobalVerticalAlignment(int)
public final void setNodeComparator(Comparator comparator)
AUTOMATIC_ORDERING
- The algorithm is free to choose an
order aimed at reducing the total area occupied by the layout.NO_ORDERING
- No ordering is performed.DESCENDING_HEIGHT
- The nodes are ordered in descending
order of height.ASCENDING_HEIGHT
- The nodes are ordered in ascending
order of height.DESCENDING_WIDTH
- The nodes are ordered in descending
order of width.ASCENDING_WIDTH
- The nodes are ordered in ascending
order of width.DESCENDING_AREA
- The nodes are ordered in descending
order of area.ASCENDING_AREA
- The nodes are ordered in ascending
order of area.ASCENDING_INDEX
- The nodes are ordered in ascending
order of index value (see setIndex(Object, int)
).DESCENDING_INDEX
- The nodes are ordered in descending
order of index value (see setIndex(Object, int)
).null
- The nodes are ordered in an arbitrary
way.java.util.Comparator
interface - the nodes are ordered
according to this custom comparator . AUTOMATIC_ORDERING
.
The ordering of the nodes starts at the upper-left corner.
In incremental mode (see setIncrementalMode(boolean)
) or
when nodes are fixed (see IlvGraphLayout.setFixed(Object, boolean)
) the
order of the nodes is not guaranteed to obey the comparator, since
this specification competes with the other constraints.
If the layout mode is TILE_TO_GRID_FIXED_WIDTH
or TILE_TO_GRID_FIXED_HEIGHT
, the order options are applied only for
nodes whose size (including margins) is smaller than the grid cell
size (see setHorizontalGridOffset(double)
and setVerticalGridOffset(double)
).
getNodeComparator()
public Comparator getNodeComparator()
public void setIndex(Object node, int index)
NO_INDEX
as an index value if you want to clear
an index value that you previously specified.
Note that index
must not be negative. The values of the
indexes for consecutive nodes are not necessarily consecutive. Only
the order of the values is important.
node
- The node instance.index
- The index of the specified node. When the layout is
performed, the nodes for which indexes have been specified are
arranged in the order corresponding to their index values (starting
in the upper-left corner with the smallest index value).getIndex(Object)
public int getIndex(Object node)
NO_INDEX
if node
has no index value.node
- The node instance.NO_INDEX
if
no value is specified.setIndex(Object, int)
public void setHorizontalGridOffset(double offset)
The default value is 40
.
This parameter is not used if the layout mode (see setLayoutMode(int)
) is TILE_TO_ROWS
or TILE_TO_COLUMNS
.
setLayoutMode(int)
,
getHorizontalGridOffset()
public double getHorizontalGridOffset()
setHorizontalGridOffset(double)
public void setVerticalGridOffset(double offset)
The default value is 40
.
This parameter is not used if the layout mode (see setLayoutMode(int)
) is TILE_TO_ROWS
or TILE_TO_COLUMNS
.
setLayoutMode(int)
,
getVerticalGridOffset()
public double getVerticalGridOffset()
setVerticalGridOffset(double)
public void setTopMargin(double margin)
If the layout mode is TILE_TO_GRID_FIXED_WIDTH
or TILE_TO_GRID_FIXED_HEIGHT
, the top margin is the minimum distance
between the top border of a node (or its user-specified box - see
setNodeBoxInterface(IlvNodeBoxInterface)
) and the top border
of the grid cell.
If the layout mode is TILE_TO_ROWS
or TILE_TO_COLUMNS
, the minimum vertical distance between two nodes
(or their user-specified boxes) is the sum of the top and bottom
margins.
The default value is 5
.
public double getTopMargin()
public void setBottomMargin(double margin)
If the layout mode is TILE_TO_GRID_FIXED_WIDTH
or TILE_TO_GRID_FIXED_HEIGHT
, the bottom margin is the minimum
distance between the bottom border of a node (or its user-specified
box - see setNodeBoxInterface(IlvNodeBoxInterface)
) and the
bottom border of the grid cell.
If the layout mode is TILE_TO_ROWS
or TILE_TO_COLUMNS
, the minimum vertical distance between two nodes
(or their user-specified boxes) is the sum of the top and bottom
margins.
The default value is 5
.
public double getBottomMargin()
public void setLeftMargin(double margin)
If the layout mode is TILE_TO_GRID_FIXED_WIDTH
or TILE_TO_GRID_FIXED_HEIGHT
, the left margin is the minimum distance
between the left border of a node (or its user-specified box - see
setNodeBoxInterface(IlvNodeBoxInterface)
) and the left
border of the grid cell.
If the layout mode is TILE_TO_ROWS
or TILE_TO_COLUMNS
, the minimum horizontal distance between two nodes
(or their user-specified boxes) is the sum of the left and right
margins.
The default value is 5
.
public double getLeftMargin()
public void setRightMargin(double margin)
If the layout mode is TILE_TO_GRID_FIXED_WIDTH
or TILE_TO_GRID_FIXED_HEIGHT
, the right margin is the minimum distance
between the right border of a node (or its user-specified box - see
setNodeBoxInterface(IlvNodeBoxInterface)
) and the right
border of the grid cell.
If the layout mode is TILE_TO_ROWS
or TILE_TO_COLUMNS
, the minimum horizontal distance between two nodes
(or their user-specified boxes) is the sum of the left and right
margins.
The default value is 5
.
public double getRightMargin()
public void setMaxNumberOfNodesPerRowOrColumn(int nNodes)
In TILE_TO_ROWS
mode, the number is the maximum number of
nodes per row. In TILE_TO_COLUMNS
mode, the number is the
maximum number of nodes per column.
The layout places as many nodes on each row or column as possible given the size of the nodes, the dimensional parameters (layout region and margins) and the specified maximum number of nodes per row or column.
The minimum value is 1
. The default value is
Integer.MAX_VALUE
, that is, the number of nodes placed
in each row or column is bounded only by the size of the nodes and
the dimensional parameters. The parameter has no effect if the layout
mode is TILE_TO_GRID_FIXED_WIDTH
or TILE_TO_GRID_FIXED_HEIGHT
.
getMaxNumberOfNodesPerRowOrColumn()
,
IlvGraphLayout.setLayoutRegion(ilog.views.IlvManagerView)
,
IlvGraphLayout.setLayoutRegion(ilog.views.IlvManagerView, ilog.views.IlvRect)
,
IlvGraphLayout.setLayoutRegion(ilog.views.IlvRect)
,
IlvGraphLayout.getSpecLayoutRegion()
,
IlvGraphLayout.getCalcLayoutRegion()
,
setTopMargin(double)
,
setBottomMargin(double)
,
setLeftMargin(double)
,
setRightMargin(double)
public int getMaxNumberOfNodesPerRowOrColumn()
TILE_TO_ROWS
mode or the maximum number of nodes per column in TILE_TO_COLUMNS
mode.setMaxNumberOfNodesPerRowOrColumn(int)
public void setNodeBoxInterface(IlvNodeBoxInterface nodeBoxInterface)
This method allows a node size other than the bounding box to be taken into account by the layout algorithm.
If you do not call this method, the layout algorithm uses the
bounding box of the node (see IlvGraphModel.boundingBox(java.lang.Object)
).
The default value is null
. You can call this method with
a null
argument to restore the default behavior.
getNodeBoxInterface()
public IlvNodeBoxInterface getNodeBoxInterface()
null
.public void checkAppropriateLinks() throws IlvInappropriateLinkException
This overridden implementation does nothing, because this layout algorithm does not take the links into account.
checkAppropriateLinks
in class IlvGraphLayout
IlvInappropriateLinkException
IlvGraphLayout.performLayout(boolean, boolean, boolean)
,
IlvGraphLayout.performLayout(boolean, boolean)
,
IlvGraphLayout.checkAppropriateLink(java.lang.Object)
,
IlvGraphModel.setLinkCheckEnabled(boolean)
,
IlvGraphModel.setConnectionPointCheckEnabled(boolean)
,
IlvGraphLayoutUtil.EnsureAppropriateLinks(ilog.views.graphlayout.IlvGraphModel, ilog.views.graphlayout.IlvLayoutProvider)
,
IlvInappropriateLinkException
public IlvGraphicVector getMovingNodes()
IlvGrapherAdapter
in order to optimize for speed.getMovingNodes
in class IlvGraphLayout
protected IlvGraphLayoutGrapherProperty createLayoutGrapherProperty(String name, boolean withDefaults)
IlvGridLayoutGrapherProperty
that
stores the parameter settings of this layout class.
The method is used by IlvGrapherAdapter.saveParametersToNamedProperties(IlvGraphLayout,
boolean)
to create a named property that contains the parameter
settings of this layout instance.
createLayoutGrapherProperty
in class IlvGraphLayout
IlvGraphLayoutGrapherProperty
,
IlvGrapherAdapter.saveParametersToNamedProperties(IlvGraphLayout, boolean)
,
IlvGrapherAdapter.loadParametersFromNamedProperties(IlvGraphLayout)
,
IlvGrapherAdapter.removeParametersFromNamedProperties()
protected IlvGraphLayoutNodeProperty createLayoutNodeProperty(String name, IlvGraphic node, boolean withDefaults)
IlvGridLayoutNodeProperty
that
stores the parameter settings of this layout class for nodes.
The method is used by IlvGrapherAdapter.saveParametersToNamedProperties(IlvGraphLayout,
boolean)
to create a named property for a node that contains
parameter settings of this layout instance for the input node.
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.