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 classGraphicEdge.EdgeGroupAn edge group contains the set of edges between two given nodes.Nested classes/interfaces inherited from class org.graphstream.ui.graphicGraph.GraphicElement
GraphicElement.SwingElementRendererNested classes/interfaces inherited from class org.graphstream.graph.implementations.AbstractElement
AbstractElement.AttributeChangeEvent -
Field Summary
Fields Modifier and Type Field Description double[]ctrlControl points for curved edges or polylines.booleandirectedIs the edge directed ?.GraphicNodefromThe first node.GraphicEdge.EdgeGroupgroupIf non null, this gives the number of edges between the two same nodes.intmultiIn case of a multi-graph this is the index of the edge between to and from.GraphicNodetoThe 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.EdgeGroupgetGroup()If there are several edges between two nodes, this edge pertains to a group.intgetMultiIndex()This edge is the i-th between the two same nodes.NodegetNode0()First node of the edge.NodegetNode1()Second node of the edge.NodegetOpposite(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.TypegetSelectorType()Type of selector for the graphic element (Node, Edge, Sprite ?).NodegetSourceNode()Start node.NodegetTargetNode()End node.doublegetX()Abscissa of the element, always in GU (graph units).doublegetY()Ordinate of the element, always in GU (graph units).doublegetZ()Depth of the element, always in GU (graph units).booleanisCurve()True if the the edge defines control points to draw a curve or polyline.booleanisDirected()Is the edge directed ?.booleanisLoop()Does the source and target of this edge identify the same node ?.voidmove(double x, double y, double z)Try to force the element to move at the give location in graph units (GU).GraphicNodeotherNode(GraphicNode n)Obtain the node that is not "n" attached to this edge.voidremoved()voidsetControlPoints(double[] points)Change the control points array for this edge.voidsetDirected(boolean on)voidswitchDirection()Methods inherited from class org.graphstream.ui.graphicGraph.GraphicElement
getComponent, getLabel, getStyle, myGraph, setAttribute, setComponentMethods inherited from class org.graphstream.graph.implementations.AbstractElement
attributeKeys, clearAttributes, getAttribute, getAttribute, getAttributeCount, getFirstAttributeOf, getFirstAttributeOf, getId, getIndex, hasAttribute, hasAttribute, removeAttribute, toStringMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:GraphicElementType of selector for the graphic element (Node, Edge, Sprite ?).- Specified by:
getSelectorTypein 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:GraphicElementAbscissa of the element, always in GU (graph units). For edges this is the X of the "from" node.- Specified by:
getXin classGraphicElement
-
getY
public double getY()Description copied from class:GraphicElementOrdinate of the element, always in GU (graph units). For edges this is the Y of the "from" node.- Specified by:
getYin classGraphicElement
-
getZ
public double getZ()Description copied from class:GraphicElementDepth of the element, always in GU (graph units). For edges this is the Z of the "from" node.- Specified by:
getZin 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:GraphicElementTry 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:
movein classGraphicElement- Parameters:
x- The new X.y- The new Y.z- the new Z.
-
removed
public void removed() -
getNode0
Description copied from interface:EdgeFirst 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:
getNode0in interfaceEdge- Returns:
- The first node of the edge.
- See Also:
Edge.getNode1(),Edge.getSourceNode()
-
getNode1
Description copied from interface:EdgeSecond 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:
getNode1in 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:EdgeWhen 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:
getOppositein interfaceEdge- Parameters:
node- The node we search the opposite of.- Returns:
- the opposite node of the given node.
-
getSourceNode
Description copied from interface:EdgeStart 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:
getSourceNodein interfaceEdge- Returns:
- The origin node of the edge.
- See Also:
Edge.getNode0(),Edge.getTargetNode()
-
getTargetNode
Description copied from interface:EdgeEnd 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:
getTargetNodein interfaceEdge- Returns:
- The destination node of the edge.
- See Also:
Edge.getNode1(),Edge.getSourceNode()
-
isDirected
public boolean isDirected()Description copied from interface:EdgeIs the edge directed ?.- Specified by:
isDirectedin interfaceEdge- Returns:
- True if the edge is directed.
-
isLoop
public boolean isLoop()Description copied from interface:EdgeDoes the source and target of this edge identify the same node ?. -
setDirected
public void setDirected(boolean on) -
switchDirection
public void switchDirection()
-