public class BendConverter extends Object implements ILayoutStage
BendConverter
replaces edge bends with dummy nodes for the core layout algorithm
.
core layout algorithm
on the altered graph
When the dummy elements have been inserted, edge information about
port constraints
, edge groups
and selection state
can be adopted from the original edges. That way, the core layout algorithm
can access the
mentioned information.
Modifier and Type | Field and Description |
---|---|
static EdgeDpKey<Boolean> |
DEFAULT_AFFECTED_EDGES_DPKEY
A
DataProvider key for specifying the set of edges for which this stage will replace bends
Only the bends of the marked edges will be replaced with dummy nodes. |
Constructor and Description |
---|
BendConverter()
Creates a new
BendConverter instance with default settings. |
BendConverter(double size)
Creates a new
BendConverter instance with the given size as the width and height for the dummy nodes. |
BendConverter(ILayoutAlgorithm core)
Creates a new instance of
BendConverter with the given core layout algorithm . |
Modifier and Type | Method and Description |
---|---|
protected void |
addedPathForEdge(LayoutGraph graph,
Edge edge,
NodeList dummyNodes)
Adds information to newly created dummy nodes.
|
void |
applyLayout(LayoutGraph graph)
Replaces all bends in the current
scope with dummy nodes before invoking the
core layout algorithm . |
Object |
getAffectedEdgesDpKey()
Gets the key to register a
IDataProvider which identifies edges as selected. |
ILayoutAlgorithm |
getCoreLayout()
Gets the core layout algorithm that is wrapped by this
ILayoutStage . |
boolean |
isAffectedEdgesAdoptionEnabled()
Gets whether or not the selection state of the original edge should be adopted by its replacement edges.
|
boolean |
isEdgeGroupAdoptionEnabled()
Gets whether or not edge grouping information of the original edge should be adopted by its replacement edges.
|
boolean |
isPortConstraintAdoptionEnabled()
Gets whether or not the associated
PortConstraint s of the original edge should be adopted by its replacement edges. |
protected void |
prepare(LayoutGraph graph)
Prepares the graph before calling the
core layout algorithm . |
protected void |
restore(LayoutGraph graph)
Restores the structure of the graph after the
core layout algorithm has finished. |
void |
setAffectedEdgesAdoptionEnabled(boolean value)
Sets whether or not the selection state of the original edge should be adopted by its replacement edges.
|
void |
setAffectedEdgesDpKey(Object value)
Sets the key to register a
IDataProvider which identifies edges as selected. |
void |
setCoreLayout(ILayoutAlgorithm value)
Sets the core layout algorithm that is wrapped by this
ILayoutStage . |
void |
setEdgeGroupAdoptionEnabled(boolean value)
Sets whether or not edge grouping information of the original edge should be adopted by its replacement edges.
|
void |
setPortConstraintAdoptionEnabled(boolean value)
Sets whether or not the associated
PortConstraint s of the original edge should be adopted by its replacement edges. |
public static final EdgeDpKey<Boolean> DEFAULT_AFFECTED_EDGES_DPKEY
DataProvider
key for specifying the set of edges for which this stage will replace bends
Only the bends of the marked edges will be replaced with dummy nodes.
IDataProvider
is registered with this key, the bends of all edges are replaced.public BendConverter()
BendConverter
instance with default settings.public BendConverter(double size)
BendConverter
instance with the given size as the width and height for the dummy nodes.IllegalArgumentException
- if the given size is negativesize
- the size for the dummy nodespublic BendConverter(ILayoutAlgorithm core)
BendConverter
with the given core layout algorithm
.core
- the core layout algorithmprotected void addedPathForEdge(LayoutGraph graph, Edge edge, NodeList dummyNodes)
This is a callback method that will be invoked after new elements for the given edge have been added to the given graph
by prepare(LayoutGraph)
. At this point, the original edge is still in the graph.
The current implementation does nothing.
graph
- the input graphedge
- the edge whose bends were replaced by the given dummy nodesdummyNodes
- the dummy nodes representing the bends of the edgepublic void applyLayout(LayoutGraph graph)
scope
with dummy nodes before invoking the
core layout algorithm
.
After the core layout algorithm
has finished, the edges between the dummy nodes are reconnected
and the dummy nodes are replaced by bends again.
applyLayout
in interface ILayoutAlgorithm
graph
- the input graphpublic Object getAffectedEdgesDpKey()
IDataProvider
which identifies edges as selected.
If the selection is conserved
, the selection state described by the IDataProvider
registered with this key is applied to the according dummy edges.
IllegalArgumentException
- if the specified key is null
LayoutKeys.AFFECTED_EDGES_DPKEY
IDataProvider
keysetAffectedEdgesAdoptionEnabled(boolean)
,
setAffectedEdgesDpKey(Object)
public ILayoutAlgorithm getCoreLayout()
ILayoutStage
.getCoreLayout
in interface ILayoutStage
null
. setCoreLayout(ILayoutAlgorithm)
public boolean isAffectedEdgesAdoptionEnabled()
The selection state is looked up in a IDataProvider
registered with the key returned by
AffectedEdgesDpKey
.
true
. The selection state of the original edge is applied to all corresponding dummy edges.true
if dummy edges get the selection state of their corresponding original edge, false
otherwisegetAffectedEdgesDpKey()
,
setAffectedEdgesAdoptionEnabled(boolean)
public boolean isEdgeGroupAdoptionEnabled()
true
. Original edge grouping information is applied to the dummy edges.true
if dummy edges get the edge grouping information from their corresponding originals, false
otherwisePortConstraintKeys.SOURCE_GROUP_ID_DPKEY
,
PortConstraintKeys.TARGET_GROUP_ID_DPKEY
,
setEdgeGroupAdoptionEnabled(boolean)
public boolean isPortConstraintAdoptionEnabled()
PortConstraint
s of the original edge should be adopted by its replacement edges.true
. PortConstraint
s of the original edges are applied to the dummy edges.true
if dummy edges get the PortConstraint
s of their corresponding originals, false
otherwisePortConstraintKeys.SOURCE_PORT_CONSTRAINT_DPKEY
,
PortConstraintKeys.TARGET_PORT_CONSTRAINT_DPKEY
,
setPortConstraintAdoptionEnabled(boolean)
protected void prepare(LayoutGraph graph)
core layout algorithm
.
The bends of the edges belonging to the current scope are replaced by dummy nodes and the segments between those dummy nodes are replaced by dummy edges.
Edge-specific information like PortConstraint
s, edge groups or selection state can be
applied to the dummy edges to keep this information for the core layout algorithm
.
This method is called by applyLayout(LayoutGraph)
before invoking the
core layout algorithm
. It may be overridden to extend the edge-specific information that
should be adopted by the dummy edges.
restore(LayoutGraph)
.graph
- the input graphrestore(LayoutGraph)
,
setAffectedEdgesAdoptionEnabled(boolean)
,
setPortConstraintAdoptionEnabled(boolean)
,
setEdgeGroupAdoptionEnabled(boolean)
protected void restore(LayoutGraph graph)
core layout algorithm
has finished.
This method is called by applyLayout(LayoutGraph)
after invoking the
core layout algorithm
. It may be overridden to clean up all additional information added in
prepare(LayoutGraph)
.
prepare(LayoutGraph)
should be reverted by this method.graph
- the graph arranged by the core layout algorithm
prepare(LayoutGraph)
,
setAffectedEdgesAdoptionEnabled(boolean)
,
setPortConstraintAdoptionEnabled(boolean)
,
setEdgeGroupAdoptionEnabled(boolean)
public void setAffectedEdgesAdoptionEnabled(boolean value)
The selection state is looked up in a IDataProvider
registered with the key returned by
AffectedEdgesDpKey
.
true
. The selection state of the original edge is applied to all corresponding dummy edges.value
- true
if dummy edges get the selection state of their corresponding original edge, false
otherwisegetAffectedEdgesDpKey()
,
isAffectedEdgesAdoptionEnabled()
public void setAffectedEdgesDpKey(Object value)
IDataProvider
which identifies edges as selected.
If the selection is conserved
, the selection state described by the IDataProvider
registered with this key is applied to the according dummy edges.
IllegalArgumentException
- if the specified key is null
LayoutKeys.AFFECTED_EDGES_DPKEY
value
- the IDataProvider
keysetAffectedEdgesAdoptionEnabled(boolean)
,
getAffectedEdgesDpKey()
public void setCoreLayout(ILayoutAlgorithm value)
ILayoutStage
.setCoreLayout
in interface ILayoutStage
null
. value
- the core layout routinegetCoreLayout()
public void setEdgeGroupAdoptionEnabled(boolean value)
true
. Original edge grouping information is applied to the dummy edges.value
- true
if dummy edges get the edge grouping information from their corresponding originals, false
otherwisePortConstraintKeys.SOURCE_GROUP_ID_DPKEY
,
PortConstraintKeys.TARGET_GROUP_ID_DPKEY
,
isEdgeGroupAdoptionEnabled()
public void setPortConstraintAdoptionEnabled(boolean value)
PortConstraint
s of the original edge should be adopted by its replacement edges.true
. PortConstraint
s of the original edges are applied to the dummy edges.value
- true
if dummy edges get the PortConstraint
s of their corresponding originals, false
otherwisePortConstraintKeys.SOURCE_PORT_CONSTRAINT_DPKEY
,
PortConstraintKeys.TARGET_PORT_CONSTRAINT_DPKEY
,
isPortConstraintAdoptionEnabled()