|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.base.Graph y.layout.LayoutGraph y.layout.DefaultLayoutGraph com.yworks.yfiles.server.graphml.flexio.data.StyledLayoutGraph
This class extends the DefaultLayoutGraph
by adding convenient methods to configure styles and labels
for nodes, edges and ports and to access and set their user tags.
INodeHierarchy
for this graph
instance which offers grouping related functionality.
Field Summary |
Fields inherited from class y.layout.DefaultLayoutGraph |
edgeLabelFeatureMap, edgeLabelMap, nodeLabelFeatureMap, nodeLabelMap |
Fields inherited from class y.layout.LayoutGraph |
z |
Fields inherited from class y.base.Graph |
AFTER, BEFORE |
Constructor Summary | |
StyledLayoutGraph()
|
Method Summary | |
void |
addLabel(Edge edge,
Label label)
Adds a label to the given edge. |
void |
addLabel(Node node,
Label label)
Adds a label to the given node. |
Port |
addPort(Node node,
IPortLocationModelParameter locationModelParameter)
Adds a port to the given node and returns it. |
void |
changeEdge(Edge e,
Node newSource,
Edge sourceReference,
int sourceD,
Node newTarget,
Edge targetReference,
int targetD)
If the source or target node changes, a new port is added to its center and assigned as source resp. target port of the edge. |
void |
changeEdge(Edge e,
Node newSource,
Node newTarget)
If the source or target node changes, a new port is added to its center and assigned as source resp. target port of the edge. |
Edge |
createEdge(Node v,
Edge e1,
Node w,
Edge e2,
int d1,
int d2)
The new edge is connected to the first free ports of the source and target node. |
protected Edge |
createEdge(Port sourcePort,
Edge e1,
Port targetPort,
Edge e2,
int d1,
int d2)
Creates a new edge in this graph and fires a corresponding notification event to inform registered listeners. |
Edge |
createEdge(Port source,
Port target)
Creates a new edge in this graph and fires a corresponding notification event to inform registered listeners. |
Node |
createNode()
|
void |
doLayout(Layouter layouter)
Calculates a layout for the styled graph using the given layout algorithm. |
java.util.List |
edgesAtPort(Port port)
Returns a list of edges attached to port . |
YDimension |
getDefaultNodeSize()
The default node size the is applied when a new node is created . |
java.util.List |
getLabels(Edge edge)
Returns the list of labels registered for the given edge. |
java.util.List |
getLabels(Node node)
Returns the list of labels registered for the given node. |
INodeHierarchy |
getNodeHierarchy()
Returns an INodeHierarchy for this graph that can be used for grouping related functionality. |
java.util.List |
getPorts(Node node)
Returns the ports of the provided node. |
Port |
getSourcePort(Edge edge)
Returns the port at the source node the edge is connected to. |
IEdgeStyle |
getStyle(Edge edge)
Returns the style that is currently registered for the given edge. |
INodeStyle |
getStyle(Node node)
Returns the style that is currently registered for the given node. |
Port |
getTargetPort(Edge edge)
Returns the port at the target node the edge is connected to. |
java.lang.Object |
getUserTag(java.lang.Object item)
Returns the user tag of the provided node, edge or Label
The usertag is retrieved using the data mapper registered with key
AbstractGraphRoundtripSupport.USERTAGS_DPKEY
|
int |
getZOrder(Edge edge)
Returns the z-order that is currently registered for the given edge. |
int |
getZOrder(Node node)
Returns the z-order that is currently registered for the given node. |
void |
removePort(Port port)
Removes a port from its owner. |
void |
reverseEdge(Edge e)
Reverses the given edge and fires corresponding notification events to inform registered listeners. |
void |
setDefaultNodeSize(YDimension defaultNodeSize)
The default node size the is applied when a new node is created . |
void |
setSourcePort(Edge edge,
Port port)
Assigns a new source port to edge .
|
void |
setStyle(Edge edge,
IEdgeStyle style)
Sets an edge style for the given edge. |
void |
setStyle(Node node,
INodeStyle style)
Sets a node style for the given node. |
void |
setTargetPort(Edge edge,
Port port)
Assigns a new target port to edge .
|
void |
setUserTag(java.lang.Object item,
java.lang.Object tag)
Sets the user tag of the provided node, edge or Label
The usertag is set on data mapper registered with key
AbstractGraphRoundtripSupport.USERTAGS_DPKEY
|
void |
setZOrder(Edge edge,
int zOrder)
Sets a z-order for the given edge. |
void |
setZOrder(Node node,
int zOrder)
Sets a z-order for the given node. |
void |
syncLabels(Edge edge,
boolean createIfNotExisting)
Synchronizes all Label instances associated with the given
edge with the EdgeLabelLayout s of this graph.
|
void |
syncLabels(Node node,
boolean createIfNotExisting)
Synchronizes all Label instances associated with the given
node with the NodeLabelLayout s of this graph.
|
Methods inherited from class y.layout.DefaultLayoutGraph |
createEdgeLayout, createGraphCopyFactory, createLabelFactory, createNodeLayout, getFeature, getFeature, getLabelLayout, getLabelLayout, getLayout, getLayout, setLabelLayout, setLabelLayout, setLabelLayout, setLayout, setLayout |
Methods inherited from class y.layout.LayoutGraph |
getBoundingBox, getCenter, getCenterX, getCenterY, getEdgeLabelLayout, getEdgeLayout, getEdgeList, getHeight, getLocation, getNodeLabelLayout, getNodeLayout, getPath, getPathList, getPointList, getPoints, getRectangle, getSize, getSourcePointAbs, getSourcePointRel, getTargetPointAbs, getTargetPointRel, getWidth, getX, getY, moveBy, setCenter, setCenter, setEndPointsAbs, setLocation, setLocation, setPath, setPath, setPoints, setPoints, setSize, setSize, setSourcePointAbs, setSourcePointRel, setTargetPointAbs, setTargetPointRel |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public StyledLayoutGraph()
Method Detail |
public INodeHierarchy getNodeHierarchy()
INodeHierarchy
for this graph that can be used for grouping related functionality.
INodeHierarchy
for this graph.public Node createNode()
public Edge createEdge(Node v, Edge e1, Node w, Edge e2, int d1, int d2)
protected Edge createEdge(Port sourcePort, Edge e1, Port targetPort, Edge e2, int d1, int d2)
e
has source port sourcePort
and target port
targetPort
. The source and target ports' owners are used as source node v and target node w,
i.e., the new edge would be written as edge e = (v, w)
.
e
is inserted in such a way that an iteration over the edges
at node v
returns e
e1
, if d1 == AFTER
e1
, if d1 == BEFORE
,
w
returns e
e2
, if d2 == AFTER
e2
, if d2 == BEFORE
.
sourcePort
- The source port of the edge.e1
- An edge with source node v
.targetPort
- The target port of the edge.e2
- An edge with target node w
.d1
- One of the object insertion specifiers Graph.BEFORE
or Graph.AFTER
.d2
- One of the object insertion specifiers Graph.BEFORE
or Graph.AFTER
.
public Edge createEdge(Port source, Port target)
source
- The source port of the source node of the edge.target
- The target port of the target node of the edge.
public void changeEdge(Edge e, Node newSource, Edge sourceReference, int sourceD, Node newTarget, Edge targetReference, int targetD)
public void changeEdge(Edge e, Node newSource, Node newTarget)
public Port addPort(Node node, IPortLocationModelParameter locationModelParameter)
The port is added using the list found in the data mapper registered with the key GraphRoundtripSupportBase.NODE_PORTS_DPKEY
If no port list is registered in the corresponding data map yet, a new port list is created.
node
- The node to add a port tolocationModelParameter
- The model parameter describing the port locationGraphRoundtripSupportBase.NODE_PORTS_DPKEY
public void removePort(Port port)
All edges connected to this port are removed first. After that, the port is removed from the list found
in the data mapper registered with the key
GraphRoundtripSupportBase.NODE_PORTS_DPKEY
port
- The port to remove from its owner.GraphRoundtripSupportBase.NODE_PORTS_DPKEY
public java.util.List getPorts(Node node)
node
- The node to provide ports for.
public Port getSourcePort(Edge edge)
edge
- The edge to get the source port to.
public void setSourcePort(Edge edge, Port port)
edge
.
The edge's source node gets updated if the old source node doesn't correspond to the new port's owner.
To assign the port as source port of the edge, the data provider found in the data mapper registered with the keyGraphRoundtripSupportBase.EDGE_SOURCE_PORT_DPKEY
is updated.
Finally the edge's layout is updated to respect the new source port's location.
edge
- The edge to assign a new source port.port
- The new source port of the edge.public Port getTargetPort(Edge edge)
edge
- The edge to get the target port to.
public void setTargetPort(Edge edge, Port port)
edge
.
The edge's target node gets updated if the old target node doesn't correspond to the new port's owner.
To assign the port as target port of the edge, the data provider found in the data mapper registered with the keyGraphRoundtripSupportBase.EDGE_TARGET_PORT_DPKEY
is updated.
Finally the edge's layout is updated to respect the new target port's location.
edge
- The edge to assign a new target port.port
- The new target port of the edge.public void reverseEdge(Edge e)
public java.util.List edgesAtPort(Port port)
port
.
port
- The port to collect the attached edges from.
port
.public INodeStyle getStyle(Node node)
GraphRoundtripSupportBase.NODE_STYLE_DPKEY
node
- The node to get the style for.
null
if no style has been registered yet.public void setStyle(Node node, INodeStyle style)
GraphRoundtripSupportBase.NODE_STYLE_DPKEY
node
- The nodestyle
- the style to use for the given nodeGraphRoundtripSupportBase.NODE_STYLE_DPKEY
public IEdgeStyle getStyle(Edge edge)
GraphRoundtripSupportBase.EDGE_STYLE_DPKEY
edge
- The edge to get the style for.
null
if no style has been registered yet.public void setStyle(Edge edge, IEdgeStyle style)
GraphRoundtripSupportBase.EDGE_STYLE_DPKEY
edge
- The edgestyle
- the style to use for the given edgeGraphRoundtripSupportBase.EDGE_STYLE_DPKEY
public int getZOrder(Node node)
GraphRoundtripSupportBase.NODE_Z_ORDER_DPKEY
node
- The node to get the z-order for.
0
if no z-order has been registered yet.public void setZOrder(Node node, int zOrder)
GraphRoundtripSupportBase.NODE_Z_ORDER_DPKEY
node
- The nodezOrder
- the z-order to use for the given nodeGraphRoundtripSupportBase.NODE_Z_ORDER_DPKEY
public int getZOrder(Edge edge)
GraphRoundtripSupportBase.EDGE_Z_ORDER_DPKEY
edge
- The edge to get the z-order for.
0
if no z-order has been registered yet.public void setZOrder(Edge edge, int zOrder)
GraphRoundtripSupportBase.EDGE_Z_ORDER_DPKEY
edge
- The edgezOrder
- the z-order to use for the given edgeGraphRoundtripSupportBase.EDGE_Z_ORDER_DPKEY
public void addLabel(Node node, Label label)
GraphRoundtripSupportBase.NODE_LABELS_DPKEY
If no label list is registered in the corresponding data map yet, a new list is created.
Adding a label will not automatically add a label layout instance to the layout graph. Therefore,
a label that was newly added using this method will not be considered in a layout calculation.
To synchronize the labels of a node with the layout graph, use syncLabels(Node, boolean)
.
node
- The node to add a label to.label
- The label to add to the node.GraphRoundtripSupportBase.NODE_LABELS_DPKEY
public void addLabel(Edge edge, Label label)
The label is added using the list found in the data mapper registered with the key GraphRoundtripSupportBase.EDGE_LABELS_DPKEY
If no label list is registered in the corresponding data map yet, a new label list is created.
Adding a label will not automatically add a label layout instance to the layout graph. Therefore,
a label that was newly added using this method will not be considered in a layout calculation.
To synchronize the labels of an edge with the layout graph, use syncLabels(y.base.Edge, boolean)
.
edge
- The edge to add a label to.label
- The label to add to the edge.GraphRoundtripSupportBase.EDGE_LABELS_DPKEY
public java.util.List getLabels(Node node)
GraphRoundtripSupportBase.NODE_LABELS_DPKEY
If no label list is registered in the corresponding data map yet, a new list is created.
node
- The node to get the registered labels for.
public java.util.List getLabels(Edge edge)
GraphRoundtripSupportBase.EDGE_LABELS_DPKEY
If no label list is registered in the corresponding data map yet, a new list is created.
edge
- The edge to retrieve the labels for.
public void syncLabels(Node node, boolean createIfNotExisting)
Label
instances associated with the given
node with the NodeLabelLayout
s of this graph.
This method can be called if a label was created on the server (e.g. using addLabel(y.base.Edge,
com.yworks.yfiles.server.graphml.flexio.data.Label)
and a label layout calculation will be executed before the
graph is sent back to the client.
Note that either a reasonable preferred size should be set on the Label instance or a style which
implements the interface LabelSizeCalculator
(e.g. SimpleLabelStyle
; in that case,
a font should be set to that style, too). If neither is set, (40,40) is used.
node
- The node to update the labels from.createIfNotExisting
- Whether to create new label layout instances for this graph, if there are more
Label instances associated with this node than label layouts known by the LayoutGraph.public void syncLabels(Edge edge, boolean createIfNotExisting)
Label
instances associated with the given
edge with the EdgeLabelLayout
s of this graph.
This method can be called if a label was created on the server (e.g. using addLabel(y.base.Edge,
com.yworks.yfiles.server.graphml.flexio.data.Label)
and a label layout calculation will be executed before the
graph is sent back to the client.
Note that either a reasonable preferred size should be set on the Label instance or a style which
implements the interface LabelSizeCalculator
(e.g. SimpleLabelStyle
; in that case,
a font should be set to that style, too). If neither is set, (40,40) is used.
edge
- The edge to update the labels from.createIfNotExisting
- Whether to create new label layout instances for this graph, if there are more
Label instances associated with this edge than label layouts known by the LayoutGraph.public java.lang.Object getUserTag(java.lang.Object item)
Label
The usertag is retrieved using the data mapper registered with key
AbstractGraphRoundtripSupport.USERTAGS_DPKEY
item
- The graph item to retrieve the tag for.
null
if no user tag has been registered for the provided item.public void setUserTag(java.lang.Object item, java.lang.Object tag)
Label
The usertag is set on data mapper registered with key
AbstractGraphRoundtripSupport.USERTAGS_DPKEY
item
- The graph item to set the tag for.tag
- The user object to set.public YDimension getDefaultNodeSize()
created
.
public void setDefaultNodeSize(YDimension defaultNodeSize)
created
.
public void doLayout(Layouter layouter)
layouter
- The layout algorithm that will be applied to the styled graph.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |