public class IlvGraphLayoutRenderer extends IlvFilterSDMRenderer implements IlvAutoLayoutHandler
IlvGraphLayoutRenderer
is a
filtering renderer that applies a graph layout algorithm
to the links and/or the nodes of the graph.
You must specify the layout algorithm that you want to use by adding a declaration in the style sheet:
SDM { GraphLayout : "Hierarchical"; }
You can use any graph layout algorithm of the Perforce JViews library.
You can specify an abbreviated graph layout name (for example
"Hierarchical"
), or a fully qualified class name
(for example, "ilog.views.graphlayout.hierarchical.IlvHierarchicalLayout"
).
The properties of the IlvGraphLayout
instance can be customized
in the style sheet. For example:
SDM { GraphLayout : "Hierarchical"; } GraphLayout { globalLinkStyle : "ORTHOGONAL_STYLE"; flowDirection : "Bottom"; }
Perforce JViews layout algorithms (that is, subclasses of
IlvGraphLayout
) provide many parameters
that control how a specific layout will be applied to a particular node
or link. Starting with Perforce JViews 5.5, the graph layout renderer lets you
set all these per-object parameters from the style sheet as in the following
examples:
node.tag1 { class : "..."; ... Fixed : "true"; } link.tag2 { class : "..."; ... ToPortSide : "NORTH"; FromPortSide : "SOUTH"; }
The first rule will cause the method
IlvGraphLayout.setFixed(java.lang.Object, boolean)
to be called for all the nodes that match the rule.
The second rule will cause the method
IlvHierarchicalLayout.setToPortSide(java.lang.Object, int)
to be called for all the links that match the rule.
The general mechanism is the following. A parameter property is created for each method
of the IlvGraphLayout
subclass that matches the following criteria:
"set"
.
Object
(this first
argument is assumed to be a graphic object).
The name of the parameter property is the name of the method, without the
"set"
prefix. The initial capital letter is preserved; this
is consistent with the naming of SDM rendering properties, and avoids
ambiguities with the Bean properties of graphic objects.
The right-hand-side value of the CSS declaration contains the parameters of the method, not including the first argument (the graphic object). If the method expects more than two arguments, the declaration must be a comma-separated list. For example, the following declaration:
node.tag1 { class : "..."; ... NumberOfPorts : "EAST,5"; }
will cause the method
IlvHierarchicalLayout.setNumberOfPorts(java.lang.Object, int, int)
to be called as follows: layout.setNumberOfPorts(graphic, EAST, 5)
.
The values in the CSS declaration will be converted automatically to the
type expected by the corresponding method. For example, "EAST"
will be converted to the value of the field
IlvHierarchicalLayout.EAST
.
You can also use a fully qualified field name, for example
"ilog.views.graphlayout.hierarchical.IlvHierarchicalLayout.EAST"
.
It is also possible to call the same method several times as follows:
node.tag1 { NumberOfPorts : "WEST,3;EAST,5"; }This will call
layout.setNumberOfPorts(graphic, WEST, 3)
and
layout.setNumberOfPorts(graphic, EAST, 5)
. Note that the
parameters of the different calls are separated by semi-colons.
The default introspection mechanism for setting per-object parameters can be
overridden if needed. You can provide an explicit piece of Java code to set
a parameter, using the method addParameterSetter(ilog.views.sdm.renderer.graphlayout.IlvGraphLayoutRenderer.ParameterSetter)
and the class
IlvGraphLayoutRenderer.ParameterSetter
.
In addition, the following two properties are handled directly by the renderer:
LayoutIgnored
- If this property is set to true
,
the object will be completely ignored by the
graph model (using an IlvLayoutGraphicFilter
).
LayoutGroup
- This property is used to apply the layout
algorithm successively to different groups of objects.
For each different value of the property, the layout algorithm
is applied only to the objects whose LayoutGroup
property is set to the same value.
If the layout algorithm is an IlvHierarchicalLayout
,
the property MarkedForIncremental
can be used. When this property is set to
true
for an object, the method
IlvHierarchicalLayout.markForIncremental(java.lang.Object)
is called
for this object, which means that the position of the object will be recomputed during the
next incremental layout. This property has an effect only if the incrementalMode
of the layout itself was set to true
. For example:
GraphLayout { incrementalMode: "true"; } node:selected { MarkedForIncremental : "true"; }
If the layout algorithm is an IlvCircularLayout
,
you can add a node to several clusters by setting the ClusterId
property
several times:
node[name="foo"] { ClusterId : "cluster1;cluster2;cluster3"; }
You can optionally specify an index inside each cluster:
ClusterId : "cluster1,5;cluster2,1;cluster3,4";
Note: Starting with JViews 6.5, if you are not using any node or link parameters,
you can disable this mechanism using
setUsePerObjectParameters(false)
.
This will remove the overhead of testing the parameters, which can speed up
the SDM rendering process significantly.
The property GraphLayout
can be set on a subgraph node.
This lets you use a different layout algorithm for each subgraph.
For example, the following rule says that subgraph nodes of tag
group
must be laid out using an
IlvGridLayout
algorithm:
node.group { GraphLayout : "Grid"; }You can also use an
"@#"
construct, which lets you customize
the parameters of the subgraph's layout:
node.group { GraphLayout : "@#grid"; } Subobject#grid { class : "ilog.views.graphlayout.grid.IlvGridLayout"; layoutMode : "TILE_TO_ROWS"; }
The following rendering properties were used in Perforce JViews 5.0 and previous versions. They are now superseded by the new method introspection mechanism, but can still be used for compatibility:
LayoutFixed
- Equivalent to Fixed
, calls IlvGraphLayout.setFixed(java.lang.Object, boolean)
.
LayoutCluster
- Equivalent to ClusterId
, calls IlvCircularLayout.setClusterId(java.lang.Object, ilog.views.graphlayout.circular.IlvClusterId)
.
LayoutStarCenter
- Equivalent to StarCenter
, calls IlvCircularLayout.setStarCenter(java.lang.Object, boolean)
.
If an IlvGraphLayoutRenderer
and an IlvLinkLayoutRenderer
are used at the same time, you may sometimes encounter conflicts between
node or link properties that have the same name in the two layout algorithms.
A common example of this is the linkStyle
property:
SDM { GraphLayout : "Hierarchical"; LinkLayout : "true"; } link { linkStyle : "POLYLINE_STYLE"; }With these rules, since both
IlvHierarchicalLayout
and
IlvLinkLayout
classes define a setLinkStyle
method, the declaration
will call the method for the two layout objects. Unfortunately, the
value POLYLINE_STYLE
is valid only for the hierarchical
layout, not for the link layout, so an exception will be thrown.
To solve this problem, you have to specify that the declaration must
be applied only to the hierarchical layout. This is done using the
pseudoclass graphLayoutRenderer
:
link:graphLayoutRenderer { linkStyle : "POLYLINE_STYLE"; }Similarly, you could use the pseudo-class
linkLayoutRenderer
to specify that a declaration applies only to the link layout object.
Furthermore, you can specify rules for nodes and links that are only applied for a given layout style, by using the layout name as pseudo-class:
link:graphLayoutRenderer:hierarchical { linkStyle : "POLYLINE_STYLE"; }
If the graph layout algorithm is an instance of
IlvHierarchicalLayout
,
you can define constraints
(see IlvHierarchicalConstraint
)
between the nodes of the graph by setting special properties in the
style sheet.
The following rule says that all participant
nodes should
be placed on the "east" side of the hierarchy (that is, on the right
for a top-bottom layout):
node.participant { ExtremityConstraint : "EAST"; }
The following rule says that the source node and the destination node
of a link of tag application_link
should be placed at the
same level in the hierarchy:
link.application_link { GroupSpreadConstraint : "true"; }In addition, you could use the
SideBySideConstraint
property
to say that the two nodes should be kept "side by side," that is,
without any node between them:
node.application_link { GroupSpreadConstraint : "true"; SideBySideConstraint : "true"; }
The following rule separates the graph into two "swimlanes," one
the activity
nodes and one for the participant
nodes:
node.activity { SwimLaneConstraint : "Activities"; } node.participant { SwimLaneConstraint : "Participants"; }
The following rule says that all selected nodes should be placed at a higher level in the hierarchy than unselected nodes:
node:selected { HigherRelativeLevelConstraint : "selection"; } node { LowerRelativeLevelConstraint : "selection"; }Note that the "higher" and "lower" groups are associated by setting the two properties to the same value. The value is arbitrary. You can use different values to define several "relative level" constraints.
The following rule says that all selected nodes should be placed at a higher position in each level than unselected nodes:
node:selected { HigherRelativePositionConstraint : "selection"; } node { LowerRelativePositionConstraint : "selection"; }
The next sections explain the mechanism in more detail, but the examples should generally be sufficient.
IlvGroupSpreadConstraint
can be used to keep a group of nodes at the same level in the hierarchy.
Node groups are built according to the values of the constraint properties. Two nodes belong to the same node group if the values of a constraint property for these two nodes are equal. Here is an example:
node.activity { GroupSpreadConstraint : "@participant_id"; } node.participant { GroupSpreadConstraint : "@__ID"; }The
activity
nodes are assumed to have a property participant_id
that holds the ID of the participant assigned to the activity. So, the value
of the GroupSpreadConstraint
property in both rules is the same
(the ID of the participant), and thus the two nodes form a node group.
Note that node groups are not limited to two nodes; if the GroupSpreadConstraint
of a third node had the same value, it would have been included in the node group as well.
When two nodes are connected by a link, you can use a simpler syntax to define
a node group containing these two nodes. Assuming the activity and the participant
were connected by a link of tag participant_link
, you could
have written:
participant_link { GroupSpreadConstraint : "true"; }This would create a constraint between the two extremities of the link.
GroupSpread
constraint. These additional parameters can be specified
after the node group identifier, separated by commas. For example:
participant_link { GroupSpreadConstraint : "true,1"; // spread size = 1 }
IlvHierarchicalConstraint
.
ExtremityConstraint
: Defines one or more
IlvExtremityConstraint
instances.
The value of the property is the side where the node should be placed;
it must be one of "NORTH"
, "SOUTH"
, "EAST"
, "WEST"
.
Note that this constraint does not act on node groups. Instead, a new constraint
is created for each node that has the property.
GroupSpreadConstraint
: Defines one or more
IlvGroupSpreadConstraint
instances.
All the nodes that have the same value for this property will be kept at
the same level in the hierarchy.
This constraint accepts one additional integer parameter: the "spread size",
that is, the number of levels on which the nodes are allowed to be spread.
The spread size is optional; by default it is 0
(all nodes strictly
at the same level).
If the property is set on a link, the
constraint is defined between the source and the destination of the link.
LevelRangeConstraint
: Defines one or more
IlvLevelRangeConstraint
instances.
All the nodes that have the same value for this property will be kept in
a specified range of levels in the hierarchy.
This constraint needs two additional
parameters: a minimum and a maximum level.
If the property is set on a link, the
constraint is defined for the source and the destination of the link.
LowerRelativeLevelConstraint
, HigherRelativeLevelConstraint
:
These two properties are used together to define one or more
IlvRelativeLevelConstraint
instances.
The value of the properties identify two groups of nodes: a "lower" group and
a "higher" group. The nodes of the "lower" group will be placed at a lower level
in the hierarchy (that is, nearer to the top for a top-bottom layout).
The values of the matching "lower" and "higher" properties must be the same.
This constraint accepts one additional floating-point parameter, which is the priority of
the constraint. The priority is optional; by default it is 0
.
LowerRelativePositionConstraint
, HigherRelativePositionConstraint
:
These two properties are used together to define one or more
IlvRelativePositionConstraint
instances.
The values of the properties identify two groups of nodes: a "lower" group and
a "higher" group. The nodes of the "lower" group will be placed at a lower position
in a given level of the hierarchy (that is, nearer to the left for a top-bottom layout).
The values of the matching "lower" and "higher" properties must be the same.
This constraint accepts one additional floating-point parameter, which is the priority of
the constraint. The priority is optional; by default it is 0
.
SideBySideConstraint
: Defines one or several
IlvSideBySideConstraint
instances.
All the nodes that have the same value for this property will be kept side by side,
that is, no other nodes will be placed between any two nodes of the
group in the same level of the hierarchy.
This constraint accepts one additional floating-point parameter, which is the priority of
the constraint. The priority is optional; by default it is 0
.
If the property is set on a link, the
constraint is defined between the source and the destination of the link.
SwimLaneConstraint
: Defines one or several
IlvSwimLaneConstraint
instances.
All the nodes that have the same value for this property will be placed in the same
swimlane.
This constraint accepts three additional floating-point parameters: the relative size of the
swimlane, the position index, and the minimum margin. By default, the relative size
is -1
, the position index is -1
, and the margin
is 20
. See
IlvSwimLaneConstraint
for more explanation
of swimlanes. See also the class IlvSwimLanesRenderer
which is responsible
for displaying the swimlanes graphically.
Note: Starting with JViews 6.5, if you are not using any
hierarchical constraints, nor any node or link parameters, you can disable
this mechanism using
setUsePerObjectParameters(false)
.
This will remove the overhead of testing the presence of constraints, which can speed up
the SDM rendering process significantly.
IlvGraphLayout
,
Serialized FormModifier and Type | Class and Description |
---|---|
class |
IlvGraphLayoutRenderer.DefaultGraphLayoutParametersProvider
The default provider to allocate the
IlvGraphLayoutParameters
for the knows layout styles. |
static class |
IlvGraphLayoutRenderer.GraphLayoutParametersBean
This auxiliary class is internally used to encapsulate graph layout
parameters as Java Beans.
|
static class |
IlvGraphLayoutRenderer.ParameterSetter
This inner class is used to register custom graph layout
parameters with the
IlvGraphLayoutRenderer . |
_renderer
PSEUDOCLASS_PREFIX
Constructor and Description |
---|
IlvGraphLayoutRenderer()
Creates a new layout renderer with a
null
filtered renderer. |
IlvGraphLayoutRenderer(IlvSDMRenderer renderer)
Creates a new layout renderer for a specified
filtered renderer.
|
Modifier and Type | Method and Description |
---|---|
void |
addGraphLayoutRendererListener(SDMGraphLayoutRendererListener listener)
Adds the specified listener to receive events from the renderer when its layout is performed.
|
static void |
addParameterSetter(IlvGraphLayoutRenderer.ParameterSetter setter)
Registers a custom parameter setter.
|
protected void |
addViewListeners(IlvManagerView view)
Adds the listeners that recompute the link layout when the view
is zoomed or unzoomed.
|
void |
customize(IlvSDMEngine engine,
Object object,
IlvGraphic g,
String[] pseudoClasses)
Sets the layout parameters for the customized object.
|
Object[] |
getAuxiliaryBeans()
Returns an array containing the
IlvGraphLayout object
returned by getGraphLayout() . |
URL |
getConstraintsURL()
Returns the URL of the file that specifies the layout constraints.
|
IlvGraphLayout |
getGraphLayout()
Returns the graph layout algorithm that this renderer
will apply to the grapher.
|
IlvGraphLayout |
getGraphLayout(IlvSDMEngine engine,
IlvGrapher grapher)
Returns the
IlvGraphLayout instance attached
to the specified IlvGrapher . |
IlvGraphLayout |
getGraphLayout(IlvSDMEngine engine,
IlvGraphic graphic)
Returns the
IlvGraphLayout instance attached
to the IlvGrapher containing a graphic object. |
IlvLayoutProvider |
getLayoutProvider()
Returns the layout provider that is responsible for creating
the sublayouts when the SDM engine's grapher contains subgraphers.
|
Enumeration<IlvGraphLayout> |
getLayouts(IlvSDMEngine engine,
boolean preOrder)
Returns the graph layout objects associated with the top-level grapher
and all its subgraphs.
|
int |
getLinkConnectorMode()
Returns the link connector mode.
|
Comparator<?> |
getLinkOrderingComparator()
Returns the comparator used for sorting the links.
|
Comparator<?> |
getNodeOrderingComparator()
Returns the comparator used for sorting the nodes.
|
String |
getParameter()
This method calls
getGraphLayout() . |
int |
getParametersMode()
This method is part of the JViews implementation,
do not use it.
|
IlvGraphLayoutParametersProvider |
getParametersProvider()
Returns the provider for the
IlvGraphLayoutParameters . |
double |
getRotationAngle()
Returns the rotation angle of the graph model.
|
IlvTransformer |
getRotationTransformer()
Returns the rotation transformer of the graph model.
|
boolean |
isConnectingLinksToShape()
Returns the flag that specifies whether the graph layout algorithm
should connect the links to the shape of the nodes or to the global
bounding box of the nodes.
|
boolean |
isEnabled()
Returns a Boolean specifying whether the graph layout algorithm
is enabled or disabled.
|
boolean |
isEnsureAppropriateLinks()
Returns
true if the renderer automatically makes sure that
appropriate links and link connectors are used when needed. |
boolean |
isEnsureModelOrdering()
Returns
true if the graphic nodes and links are
internally sorted in the same order as the corresponding SDM
model objects, before the layout is applied. |
boolean |
isGraphLayoutExceptionPassedOn()
Returns
true if the graph layout exception is passed on. |
boolean |
isIncrementalLayout()
Returns
true when the incremental mode is enabled. |
boolean |
isPartialLayout()
Returns
true when the partial mode is enabled. |
boolean |
isPerformingLayoutOnZoom()
Returns a
boolean specifying whether the layout algorithm should be
applied every time the transformer of the reference view
changes, or only when the data is initially rendered. |
boolean |
isSavingNodePositions()
Returns a Boolean specifying whether the positions of the nodes,
as computed by the graph layout algorithm,
will be saved to the data model, or if the data model
will be left unchanged.
|
boolean |
isUsePerObjectParameters()
Returns
true if per-object layout parameters
are enabled (the default), or false otherwise. |
void |
linkGraphicAdded(IlvSDMEngine engine,
Object object,
IlvGraphic graphic,
boolean redraw)
Sets the layout parameters for the new object.
|
protected boolean |
needsViewListeners()
Returns
true , because this renderer needs to install
listeners on all the views. |
void |
nodeGraphicAdded(IlvSDMEngine engine,
Object object,
IlvGraphic graphic,
boolean redraw)
Sets the layout parameters for the new object.
|
void |
nodeGraphicBBoxChanged(IlvSDMEngine engine,
Object node,
IlvGraphic graphic,
IlvRect oldBBox,
IlvRect newBBox,
String[] pseudoClasses)
Performs the layout algorithm whenever a node
is moved.
|
void |
performAutoLayout(Object layout,
Vector objects)
Implementation of the
IlvAutoLayoutHandler interface. |
void |
performLayout(IlvSDMEngine engine)
Performs the layout algorithm.
|
void |
prepareRendering(IlvSDMEngine engine)
Attaches the graph layout algorithm to the grapher
of the SDM engine.
|
void |
propertiesChanged(IlvSDMEngine engine,
Object object,
Collection<String> propertyNames,
IlvGraphic graphic)
Sets the layout parameters for the modified object.
|
void |
readConstraints(Reader reader)
Reads the layout constraints.
|
void |
reloadConstraintsURL()
Reloads the URL that specifies the layout constraints.
|
void |
removeAll(IlvSDMEngine engine)
Detaches the graph layout algorithm from the grapher.
|
void |
removeGraphLayoutRendererListener(SDMGraphLayoutRendererListener listener)
Removes the specified listener so that it no longer receives events from the renderer when its layout is performed.
|
static void |
removeParameterSetter(IlvGraphLayoutRenderer.ParameterSetter setter)
Deregisters a custom parameter setter.
|
protected void |
removeViewListeners(IlvManagerView view)
Removes the listeners that recompute the link layout when the view
is zoomed or unzoomed.
|
void |
renderingDone(IlvSDMEngine engine)
This is where the graph layout algorithm is performed.
|
void |
setConnectingLinksToShape(boolean yes)
Specifies whether the graph layout algorithm should connect
the links to the shape of the nodes or to the global bounding box
of the nodes.
|
void |
setConstraintsURL(URL url)
Sets the URL that specifies the layout constraints.
|
void |
setEnabled(boolean enabled)
Enables or disables the graph layout algorithm.
|
void |
setEnsureAppropriateLinks(boolean ensure)
Sets whether the renderer automatically makes sure that
appropriate links and link connectors are used when needed.
|
void |
setEnsureModelOrdering(boolean yes)
Specifies that the graphic nodes and links should be ordered during
graph layout in the same order as the corresponding SDM model objects.
|
void |
setGraphLayout(IlvGraphLayout layout)
Sets the graph layout algorithm that this renderer
will apply to the grapher.
|
void |
setGraphLayoutExceptionPassedOn(boolean passOn)
Sets whether the graph layout exception is passed on.
|
void |
setIncrementalLayout(boolean incremental)
Enables or disables the incremental mode of the hierarchical
layout.
|
void |
setLinkConnectorMode(int mode)
Sets the link connector mode.
|
void |
setLinkOrderingComparator(Comparator<Object> c)
Specifies the comparator that determines the order of links during
graph layout.
|
void |
setNodeOrderingComparator(Comparator<Object> c)
Specifies the comparator that determines the order of nodes during
graph layout.
|
void |
setParameter(String parameter)
This method calls
setGraphLayout(ilog.views.graphlayout.IlvGraphLayout) with the name of the
graph layout (the parameter) converted to its Java class
(for example, "tree" becomes an instance of
ilog.views.graphlayout.tree.IlvTreeLayout ). |
void |
setParametersMode(int mode)
This method is part of the JViews implementation,
do not use it.
|
void |
setParametersProvider(IlvGraphLayoutParametersProvider provider)
Sets the provider for the
IlvGraphLayoutParameters
The provider returns an instance of IlvGraphLayoutParameters
for each layout instance. |
void |
setPartialLayout(boolean partial)
Enables or disables the partial layout mode of the
layout.
|
void |
setPerformingLayoutOnZoom(boolean b)
Specifies whether the layout algorithm should be
applied every time the transformer of the reference view
changes, or only when the data is initially rendered.
|
void |
setRotationAngle(double angle)
Sets the rotation angle of the graph model.
|
void |
setRotationTransformer(IlvTransformer t)
Sets the rotation transformer of the graph model.
|
void |
setSavingNodePositions(boolean saving)
Specifies whether the positions of the nodes, as computed
by the graph layout algorithm, will be saved to the data model,
or if the data model will be left unchanged.
|
void |
setUsePerObjectParameters(boolean use)
Enables or disables per-object layout parameters.
|
void |
writeConstraints(PrintWriter writer)
Writes the layout constraints.
|
addLinkGraphic, addNodeGraphic, computeBBox, createLinkGraphic, createNodeGraphic, getEncapsulatedGraphic, getFilteredRenderer, getGraphicProperty, getLinkConnectionRectangle, moveResizeNodeGraphic, processServerAction, removeLinkGraphic, removeNodeGraphic, setFilteredRenderer, updateObjectProperties
callMoveResizeNodeGraphic, convert, convert, getAlias, getAuxiliaryBean, getEngine, getLinkConnectionRectangle, getLocation, propertyChanged, setAlias, setEngine, setLayerName
public IlvGraphLayoutRenderer(IlvSDMRenderer renderer)
renderer
- The filtered renderer.public IlvGraphLayoutRenderer()
null
filtered renderer.public void setGraphLayout(IlvGraphLayout layout)
layout
- The graph layout object.public IlvGraphLayout getGraphLayout()
public Object[] getAuxiliaryBeans()
IlvGraphLayout
object
returned by getGraphLayout()
.getAuxiliaryBeans
in class IlvSDMRenderer
public void setParameter(String parameter)
setGraphLayout(ilog.views.graphlayout.IlvGraphLayout)
with the name of the
graph layout (the parameter) converted to its Java class
(for example, "tree" becomes an instance of
ilog.views.graphlayout.tree.IlvTreeLayout
).setParameter
in class IlvSDMRenderer
parameter
- The value of the parameter.public String getParameter()
getGraphLayout()
.getParameter
in class IlvSDMRenderer
IlvSDMRenderer.setParameter(java.lang.String)
public void setEnabled(boolean enabled)
enabled
- If true
,
this renderer will perform the graph layout algorithm
every time a data model is loaded or a node is added to
the model. If false
,
the graph layout is disabled, and the renderer does
nothing.public boolean isEnabled()
public void setSavingNodePositions(boolean saving)
saving
- If true
,
this renderer will attempt to save the positions computed
by the graph layout algorithm in the data model. This is done
by calling the method
IlvSDMEngine.updateNodePositions()
,
and will succeed only if the model is editable.
If false
, the data model will be
left unchanged.
The default value is true
.IlvSDMEngine.updateNodePositions()
public boolean isSavingNodePositions()
public void setEnsureAppropriateLinks(boolean ensure)
IlvPolylineLinkImage
and subclasses of IlvFreeLinkConnector
are suitable for
all layout algorithms.
If layout cannot be performed because an inappropriate link or link connector is detected, then the following happens:
IlvInappropriateLinkException
is thrown.
IlvPolylineLinkImage
, and the inappropriate link connectors
are replaced by instances of IlvSDMFreeLinkConnector
.
Then layout is performed.
ensure
- If true
, makes sure that appropriate links are used.isEnsureAppropriateLinks()
,
setGraphLayoutExceptionPassedOn(boolean)
public boolean isEnsureAppropriateLinks()
true
if the renderer automatically makes sure that
appropriate links and link connectors are used when needed.setEnsureAppropriateLinks(boolean)
public void setGraphLayoutExceptionPassedOn(boolean passOn)
IlvGraphLayoutException
are passed to the outside as runtime exceptions. If disabled, the
exceptions are caught and handled internally.
This option is disabled by default.
It is useful only for debugging purpose to pass on the graph layout
exception.
Independently of whether the exception is passed on or not, the exception
is logged at the logger "ilog.views.sdm.renderer.graphlayout".passOn
- If true
, the exception is passed on.isGraphLayoutExceptionPassedOn()
public boolean isGraphLayoutExceptionPassedOn()
true
if the graph layout exception is passed on.
Otherwise, exceptions during graph layout are caught and handled
internally.setGraphLayoutExceptionPassedOn(boolean)
public void setConnectingLinksToShape(boolean yes)
Some nodes (for example, the IlvGeneralNode
)
have a basic shape and a label that may be outside the shape. If this method is
called with a true
parameter, the links will be connected to
the shape, and the label will not be considered part of the node. If the
method is called with a false
parameter, the links will be
connected to the global bounding rectangle of the node, that is,
the union of the shape's bounding rectangle and the label's bounding rectangle.
The bounding rectangle of the shape is the rectangle returned by the
IlvSDMRenderer.getLinkConnectionRectangle(ilog.views.sdm.IlvSDMEngine, ilog.views.IlvGraphic, ilog.views.IlvTransformer)
.
The global bounding rectangle of the node is the rectangle returned by the
IlvGraphic.boundingBox(ilog.views.IlvTransformer)
.
yes
- If true
, the links will be connected to the
bounding rectangle of the shape only. If false
,
the links will be connected to the
bounding rectangle of the shape and the label.public boolean isConnectingLinksToShape()
setConnectingLinksToShape(boolean)
public int getLinkConnectorMode()
IlvStyleSheetRenderer.setAddingLinkConnectors(boolean)
.
This method calls simply
IlvStyleSheetRenderer.getLinkConnectorMode()
.public void setLinkConnectorMode(int mode)
IlvStyleSheetRenderer.CENTER
-
Link connector mode: Use IlvSDMLinkConnector
for all nodes.
The links will be connected to the node center.
IlvStyleSheetRenderer.FREE
-
Link connector mode: Use IlvSDMFreeLinkConnector
for all nodes.
The links will be connected to the node border.
IlvStyleSheetRenderer.CLIP
-
Use IlvSDMClippingLinkConnector
for all nodes.
The links will point to the node but end on the outline of
the shape of the node. How the outline of a node is calculated
depends on the implementation of
IlvGraphic.getIntersectionWithOutline(ilog.views.IlvPoint, ilog.views.IlvPoint, ilog.views.IlvTransformer)
.
IlvStyleSheetRenderer.setLinkConnectorMode(int)
.public double getRotationAngle()
public void setRotationAngle(double angle)
IlvRotatedGraphModel
that rotates all coordinates by
the specific angle.
The bounding box of nodes remains upright despite of the rotation.
Specifying a rotation angle is only suitable for flat graphs.
It is not suitable for nested graphs with intergraph links, since those
are routed incorrectly when a rotation is specified.
When using a rotation angle, it is recommended to the the link
connector mode to IlvStyleSheetRenderer.CLIP
, otherwise the
links do not end at the nodes.
Rotation works well with most layout styles on flat graphs. It does not work well with Bus Layout and Long Link Layout since those layouts are not fully rotatable.
Setting the rotation angle modifies the rotation transformer.
angle
- The rotation angle.setRotationTransformer(ilog.views.IlvTransformer)
,
setLinkConnectorMode(int)
public IlvTransformer getRotationTransformer()
null
if not rotated graph model is used.public void setRotationTransformer(IlvTransformer t)
null
, the renderer uses
a IlvRotatedGraphModel
that transform all coordinates.
The bounding box of nodes remains upright despite of the rotation.
Specifying a rotation transformer is only suitable for flat graphs.
It is not suitable for nested graphs with intergraph links, since those
are routed incorrectly when a rotation transformer is specified.
When using a rotation transformer, it is recommended to the the link
connector mode to IlvStyleSheetRenderer.CLIP
, otherwise the
links do not end at the nodes.
Rotation works well with most layout styles on flat graphs. It does not work well with Bus Layout and Long Link Layout since those layouts are not fully rotatable.
t
- The rotation transformer, or null
.setLinkConnectorMode(int)
public void setEnsureModelOrdering(boolean yes)
The option is enabled by default. Only when the option is disabled, it is possible to specify a node or link comparator.
yes
- If true
, the graphic nodes and links are
internally sorted in the same order as the corresponding SDM
model objects, before the layout is applied.isEnsureModelOrdering()
,
setNodeOrderingComparator(Comparator)
,
setLinkOrderingComparator(Comparator)
public boolean isEnsureModelOrdering()
true
if the graphic nodes and links are
internally sorted in the same order as the corresponding SDM
model objects, before the layout is applied.setEnsureModelOrdering(boolean)
public void setNodeOrderingComparator(Comparator<Object> c)
null
is passed, no comparator
is used.
The node comparator has only an effect when the option
isEnsureModelOrdering()
is disabled, because otherwise a
model ordering comparator is used.
Some layouts produce different results if the order of the
nodes change. The node comparator allows to specify a
fixed order that is invariant from the order of objects in
the underlying grapher.
The default value is null
(no comparator).
getNodeOrderingComparator()
,
setEnsureModelOrdering(boolean)
public Comparator<?> getNodeOrderingComparator()
setNodeOrderingComparator(Comparator)
public void setLinkOrderingComparator(Comparator<Object> c)
null
is passed, no comparator
is used.
The link comparator has only an effect when the option
isEnsureModelOrdering()
is disabled, because otherwise a
model ordering comparator is used.
Some layouts produce different results if the order of the
links change. The link comparator allows to specify a
fixed order that is invariant from the order of objects in
the underlying grapher.
The default value is null
(no comparator).
getLinkOrderingComparator()
,
setEnsureModelOrdering(boolean)
public Comparator<?> getLinkOrderingComparator()
setLinkOrderingComparator(Comparator)
public void prepareRendering(IlvSDMEngine engine)
prepareRendering
in class IlvFilterSDMRenderer
engine
- The SDM engine.public void nodeGraphicAdded(IlvSDMEngine engine, Object object, IlvGraphic graphic, boolean redraw)
nodeGraphicAdded
in class IlvFilterSDMRenderer
engine
- The SDM engine associated with the grapher to which
the graphic object has been added.object
- The object that is being translated into an IlvGraphic
.graphic
- The graphic object that has just been added to the grapher.redraw
- If true
, the region covered by the new
graphic object must be redrawn.IlvSDMRenderer.addNodeGraphic(ilog.views.sdm.IlvSDMEngine, java.lang.Object, ilog.views.IlvGraphic, boolean)
public void linkGraphicAdded(IlvSDMEngine engine, Object object, IlvGraphic graphic, boolean redraw)
linkGraphicAdded
in class IlvFilterSDMRenderer
engine
- The SDM engine associated with the grapher to which
the graphic object has been added.object
- The object that is being translated into an IlvGraphic
.graphic
- The graphic object that has just been added to the grapher.redraw
- If true
, the region covered by the new
graphic object must be redrawn.IlvSDMRenderer.addLinkGraphic(ilog.views.sdm.IlvSDMEngine, java.lang.Object, ilog.views.IlvGraphic, boolean)
public void propertiesChanged(IlvSDMEngine engine, Object object, Collection<String> propertyNames, IlvGraphic graphic)
propertiesChanged
in class IlvFilterSDMRenderer
engine
- The SDM engine associated with the grapher in
which the graphic object is displayed.object
- The data object whose property has changed.propertyNames
- The names of the properties that have been modified.graphic
- The graphic object associated with object
.public void nodeGraphicBBoxChanged(IlvSDMEngine engine, Object node, IlvGraphic graphic, IlvRect oldBBox, IlvRect newBBox, String[] pseudoClasses)
nodeGraphicBBoxChanged
in class IlvFilterSDMRenderer
engine
- The SDM engine.node
- The data node that the graphic object represents.graphic
- The graphic object that has been moved and/or resized.oldBBox
- The bounding box of the graphic object before
the change.newBBox
- The bounding box of the graphic object after
the change.pseudoClasses
- The pseudo-classes of the object.
This parameter can be null
.public void customize(IlvSDMEngine engine, Object object, IlvGraphic g, String[] pseudoClasses)
customize
in class IlvFilterSDMRenderer
engine
- The SDM engine.object
- The data object that the graphic object represents.g
- The graphic object to customize.pseudoClasses
- The pseudo-classes of the object. This parameter
can be null
.public void removeAll(IlvSDMEngine engine)
removeAll
in class IlvFilterSDMRenderer
engine
- The SDM engine.public void renderingDone(IlvSDMEngine engine)
renderingDone
in class IlvFilterSDMRenderer
engine
- The SDM engine.public void performLayout(IlvSDMEngine engine)
renderingDone(ilog.views.sdm.IlvSDMEngine)
.engine
- The SDM engine.public void performAutoLayout(Object layout, Vector objects)
IlvAutoLayoutHandler
interface.
Performs an automatic layout that was caused by a structural or
geometric change of some graphic objects.
performAutoLayout
in interface IlvAutoLayoutHandler
layout
- The graph layout to be performed.objects
- The vector of graphic objects that caused the need for
layout. These objects were added, removed or have moved.
If null
is passed, the need for layout has
no specific reason (e.g., when all nodes and links have
moved).public IlvGraphLayout getGraphLayout(IlvSDMEngine engine, IlvGraphic graphic)
IlvGraphLayout
instance attached
to the IlvGrapher
containing a graphic object.engine
- The SDM engine.graphic
- The graphic object.public IlvGraphLayout getGraphLayout(IlvSDMEngine engine, IlvGrapher grapher)
IlvGraphLayout
instance attached
to the specified IlvGrapher
.engine
- The SDM engine.grapher
- The grapher.public IlvLayoutProvider getLayoutProvider()
public Enumeration<IlvGraphLayout> getLayouts(IlvSDMEngine engine, boolean preOrder)
engine
- The SDM engine to which this renderer is attached.preOrder
- Determines the order in which the layout objects are returned.IlvGraphLayout
objects.IlvGraphModel.getLayouts(ilog.views.graphlayout.IlvLayoutProvider, boolean)
public void setUsePerObjectParameters(boolean use)
This method can be used to disable or re-enable the mechanism that sets per-node or per-link parameters, as explained in the class description.
By default, per-object parameters are enabled. You can disable them if you are sure that your style sheet does not use any per-object layout parameters. Disabling per-object parameters speeds up the SDM rendering process.
use
- If this parameter is true
, per-object
layout parameters can be set in the style sheet, as explained
in the class description. If this parameter is false
,
per-object layout parameters are ignored.public boolean isUsePerObjectParameters()
true
if per-object layout parameters
are enabled (the default), or false
otherwise.setUsePerObjectParameters(boolean)
public void setParametersMode(int mode)
public int getParametersMode()
public static void addParameterSetter(IlvGraphLayoutRenderer.ParameterSetter setter)
Most per-object layout parameters are handled automatically
by the IlvGraphLayoutRenderer
. For example,
if you want to have the hierarchical layout algorithm
connect links to the left of nodes, you can add the
the following declaration in the SDM style sheet:
link { ToPortSide : "EAST"; }
The IlvGraphLayoutRenderer
will automatically
call (through the Java introspection mechanism) the method
IlvHierarchicalLayout.setToPortSide(java.lang.Object, int)
with a parameter equal to IlvHierarchicalLayout.EAST
.
In some cases, though, it may be necessary to bypass this automatic introspection mechanism. This method lets you specify an explicit piece of Java code that you want executed when a layout parameter is set for an object.
setter
- A new parameter setter that will be used instead
of the automatic introspection mechanism to set a specified
graph layout parameter.IlvGraphLayoutRenderer.ParameterSetter
public static void removeParameterSetter(IlvGraphLayoutRenderer.ParameterSetter setter)
setter
- The parameter setter to remove.addParameterSetter(ilog.views.sdm.renderer.graphlayout.IlvGraphLayoutRenderer.ParameterSetter)
,
IlvGraphLayoutRenderer.ParameterSetter
public IlvGraphLayoutParametersProvider getParametersProvider()
IlvGraphLayoutParameters
.public void setParametersProvider(IlvGraphLayoutParametersProvider provider)
IlvGraphLayoutParameters
The provider returns an instance of IlvGraphLayoutParameters
for each layout instance. The class
IlvGraphLayoutParameters
is used to add custom setters for
graph layout parameters to transfer the CSS specification into the
graph layout instance. It is also used to handle layout contraints.
Usually, a graph layout parameters provider is only needed when you
implement a new graph layout class that has new paramaeters.public void addGraphLayoutRendererListener(SDMGraphLayoutRendererListener listener)
listener
- The listener to add.public void removeGraphLayoutRendererListener(SDMGraphLayoutRendererListener listener)
listener
- The listener to remove.public void setPartialLayout(boolean partial)
true
, and objects are selected,
all the nodes except the selected nodes are marked as fixed, so that the
layout is applied only on the selected nodes.partial
- If true
, and if there are selected objects, only
those objects will be laid out by subsequent node layout operations.
If false
, all the objects will be laid out regardless of the
selection.public boolean isPartialLayout()
true
when the partial mode is enabled.setPartialLayout(boolean)
public void setIncrementalLayout(boolean incremental)
true
, objects are selected, and
the graph layout supports incremental mode, then the layout is
performed using the incremental mode. The default value is false
.incremental
- The new value.isIncrementalLayout()
public boolean isIncrementalLayout()
true
when the incremental mode is enabled.setIncrementalLayout(boolean)
public void setConstraintsURL(URL url)
public URL getConstraintsURL()
public void reloadConstraintsURL()
public void writeConstraints(PrintWriter writer)
The method should be called after rendering is done; otherwise, the constraints are not yet known to the renderer. For the hierarchical layout, it writes out all constraints that are currently known to the renderer, including those that were explicitly specified in the style sheet and those that were loaded from an URL.
writer
- The writer.setConstraintsURL(java.net.URL)
public void readConstraints(Reader reader) throws IOException
The method should be called after prepareRendering(ilog.views.sdm.IlvSDMEngine)
or after
setGraphLayout(ilog.views.graphlayout.IlvGraphLayout)
; otherwise, the graph layout instance
is not yet attached and the method does nothing.
This method is called if the constraint URL has changed, just before
layout starts. If you call this method explicitly, you replace the
constraints loaded from the URL by those specified by the reader.
reader
- The reader.IOException
setConstraintsURL(java.net.URL)
public void setPerformingLayoutOnZoom(boolean b)
b
- If true
, the link layout
will be performed every time the zoom factor of the view
changes. Otherwise, the link layout is performed only when
the data model is loaded or when new objects are added.public boolean isPerformingLayoutOnZoom()
boolean
specifying whether the layout algorithm should be
applied every time the transformer of the reference view
changes, or only when the data is initially rendered.protected boolean needsViewListeners()
true
, because this renderer needs to install
listeners on all the views.needsViewListeners
in class IlvSDMRenderer
IlvSDMRenderer.addViewListeners(ilog.views.IlvManagerView)
,
IlvSDMRenderer.removeViewListeners(ilog.views.IlvManagerView)
protected void addViewListeners(IlvManagerView view)
addViewListeners
in class IlvSDMRenderer
view
- The manager view.IlvSDMRenderer.needsViewListeners()
protected void removeViewListeners(IlvManagerView view)
removeViewListeners
in class IlvSDMRenderer
view
- The manager view.IlvSDMRenderer.needsViewListeners()
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.