Class GraphicEdge
public class GraphicEdge extends GraphicElement implements Edge
The graphic edge defines its source and target node as well as a direction, a string label and a style from the style sheet.
- See Also:
GraphicGraph
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
GraphicEdge.EdgeGroup
An edge group contains the set of edges between two given nodes.Nested classes/interfaces inherited from class org.graphstream.ui.graphicGraph.GraphicElement
GraphicElement.SwingElementRenderer
Nested classes/interfaces inherited from class org.graphstream.graph.implementations.AbstractElement
AbstractElement.AttributeChangeEvent
-
Field Summary
Fields Modifier and Type Field Description double[]
ctrl
Control points for curved edges or polylines.boolean
directed
Is the edge directed ?.GraphicNode
from
The first node.GraphicEdge.EdgeGroup
group
If non null, this gives the number of edges between the two same nodes.int
multi
In case of a multi-graph this is the index of the edge between to and from.GraphicNode
to
The second node.Fields inherited from class org.graphstream.ui.graphicGraph.GraphicElement
component, hidden, label, style
-
Constructor Summary
Constructors Constructor Description GraphicEdge(String id, GraphicNode from, GraphicNode to, boolean dir, HashMap<String,Object> attributes)
New graphic edge. -
Method Summary
Modifier and Type Method Description double[]
getControlPoints()
Control points for curved edges or polylines.GraphicEdge.EdgeGroup
getGroup()
If there are several edges between two nodes, this edge pertains to a group.int
getMultiIndex()
This edge is the i-th between the two same nodes.Node
getNode0()
First node of the edge.Node
getNode1()
Second node of the edge.Node
getOpposite(Node node)
When knowing one node and one edge of this node, this method return the node at the other end of the edge.Selector.Type
getSelectorType()
Type of selector for the graphic element (Node, Edge, Sprite ?).Node
getSourceNode()
Start node.Node
getTargetNode()
End node.double
getX()
Abscissa of the element, always in GU (graph units).double
getY()
Ordinate of the element, always in GU (graph units).double
getZ()
Depth of the element, always in GU (graph units).boolean
isCurve()
True if the the edge defines control points to draw a curve or polyline.boolean
isDirected()
Is the edge directed ?.boolean
isLoop()
Does the source and target of this edge identify the same node ?.void
move(double x, double y, double z)
Try to force the element to move at the give location in graph units (GU).GraphicNode
otherNode(GraphicNode n)
Obtain the node that is not "n" attached to this edge.void
removed()
void
setControlPoints(double[] points)
Change the control points array for this edge.void
setDirected(boolean on)
void
switchDirection()
Methods inherited from class org.graphstream.ui.graphicGraph.GraphicElement
getComponent, getLabel, getStyle, myGraph, setAttribute, setComponent
Methods inherited from class org.graphstream.graph.implementations.AbstractElement
attributeKeys, clearAttributes, getAttribute, getAttribute, getAttributeCount, getFirstAttributeOf, getFirstAttributeOf, getId, getIndex, hasAttribute, hasAttribute, removeAttribute, toString
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.graphstream.graph.Element
attributeKeys, clearAttributes, getArray, getAttribute, getAttribute, getAttributeCount, getFirstAttributeOf, getFirstAttributeOf, getId, getIndex, getLabel, getMap, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasLabel, hasMap, hasNumber, hasVector, removeAttribute, setAttribute, setAttributes
-
Field Details
-
from
The first node. -
to
The second node. -
directed
public boolean directedIs the edge directed ?. -
multi
public int multiIn case of a multi-graph this is the index of the edge between to and from. -
group
If non null, this gives the number of edges between the two same nodes. -
ctrl
public double[] ctrlControl points for curved edges or polylines. This contains the control points of an edge. If the edge is in 2D each sequence of two cells gives the x and y coordinates of a control point. Else each sequence of three cells gives the x, y and z coordinates. Therefore the number of control points can be obtained by dividing by 2 or 3 the length of this array. For example for cubic Bezier curves in 2D this array contains four cells. The control points are ordered from node0 to node1.
-
-
Constructor Details
-
GraphicEdge
public GraphicEdge(String id, GraphicNode from, GraphicNode to, boolean dir, HashMap<String,Object> attributes)New graphic edge.- Parameters:
id
- The edge unique identifier.from
- The source node.to
- The target node.dir
- True if the edge is directed in the direction from-to.attributes
- A set of initial attributes.
-
-
Method Details
-
getSelectorType
Description copied from class:GraphicElement
Type of selector for the graphic element (Node, Edge, Sprite ?).- Specified by:
getSelectorType
in classGraphicElement
-
otherNode
Obtain the node that is not "n" attached to this edge.- Parameters:
n
- One of the node of this edge.- Returns:
- The other node of this edge.
-
getX
public double getX()Description copied from class:GraphicElement
Abscissa of the element, always in GU (graph units). For edges this is the X of the "from" node.- Specified by:
getX
in classGraphicElement
-
getY
public double getY()Description copied from class:GraphicElement
Ordinate of the element, always in GU (graph units). For edges this is the Y of the "from" node.- Specified by:
getY
in classGraphicElement
-
getZ
public double getZ()Description copied from class:GraphicElement
Depth of the element, always in GU (graph units). For edges this is the Z of the "from" node.- Specified by:
getZ
in classGraphicElement
-
getControlPoints
public double[] getControlPoints()Control points for curved edges or polylines. This contains the control points of an edge. If the edge is in 2D each sequence of two cells gives the x and y coordinates of a control point. Else each sequence of three cells gives the x, y and z coordinates. Therefore the number of control points can be obtained by dividing by 2 or 3 the length of this array. For example for cubic Bezier curves in 2D this array contains four cells. The control points are ordered from node0 to node1. The units are "graph units".- Returns:
- The control points coordinates or null if this edge is a straight line.
-
isCurve
public boolean isCurve()True if the the edge defines control points to draw a curve or polyline. This does not mean the edge style asks to paint the edge as a curve, only that control points are defined.- Returns:
- True if control points are available.
-
setControlPoints
public void setControlPoints(double[] points)Change the control points array for this edge.- Parameters:
points
- The new set of points. See thegetControlPoints()
method for an explanation on the organisation of this array.- See Also:
getControlPoints()
-
getMultiIndex
public int getMultiIndex()This edge is the i-th between the two same nodes.- Returns:
- The edge index between the two nodes if there are several such edges.
-
move
public void move(double x, double y, double z)Description copied from class:GraphicElement
Try to force the element to move at the give location in graph units (GU). For edges, this may move the two attached nodes.- Specified by:
move
in classGraphicElement
- Parameters:
x
- The new X.y
- The new Y.z
- the new Z.
-
removed
public void removed() -
getNode0
Description copied from interface:Edge
First node of the edge.This is equivalent to the
Edge.getSourceNode()
method, but may be clearer in the source code if the graph you are using is not directed.- Specified by:
getNode0
in interfaceEdge
- Returns:
- The first node of the edge.
- See Also:
Edge.getNode1()
,Edge.getSourceNode()
-
getNode1
Description copied from interface:Edge
Second node of the edge.This is equivalent to the
Edge.getTargetNode()
method, but may be clearer in the source code if the graph you are using is not directed.- Specified by:
getNode1
in interfaceEdge
- Returns:
- The second node of the edge.
- See Also:
Edge.getNode0()
,Edge.getTargetNode()
-
getGroup
If there are several edges between two nodes, this edge pertains to a group. Else this method returns null.- Returns:
- The group of edges between two same nodes, null if the edge is alone between the two nodes.
-
getOpposite
Description copied from interface:Edge
When knowing one node and one edge of this node, this method return the node at the other end of the edge.Return null if the given node is not at any end of the edge.
- Specified by:
getOpposite
in interfaceEdge
- Parameters:
node
- The node we search the opposite of.- Returns:
- the opposite node of the given node.
-
getSourceNode
Description copied from interface:Edge
Start node.When the edge is directed this is the source node, in this case you can get the opposite node using
Edge.getTargetNode()
. This is equivalent to theEdge.getNode0()
method but may be clearer in the source code if the graph you are using is directed.- Specified by:
getSourceNode
in interfaceEdge
- Returns:
- The origin node of the edge.
- See Also:
Edge.getNode0()
,Edge.getTargetNode()
-
getTargetNode
Description copied from interface:Edge
End node.When the edge is directed this is the target node, in this case you can get the opposite node using
Edge.getSourceNode()
. This is equivalent to theEdge.getNode1()
method but may be clearer in the source code if the graph you are using is directed.- Specified by:
getTargetNode
in interfaceEdge
- Returns:
- The destination node of the edge.
- See Also:
Edge.getNode1()
,Edge.getSourceNode()
-
isDirected
public boolean isDirected()Description copied from interface:Edge
Is the edge directed ?.- Specified by:
isDirected
in interfaceEdge
- Returns:
- True if the edge is directed.
-
isLoop
public boolean isLoop()Description copied from interface:Edge
Does the source and target of this edge identify the same node ?. -
setDirected
public void setDirected(boolean on) -
switchDirection
public void switchDirection()
-