org.graphstream.ui.graphicGraph
Class GraphicEdge

java.lang.Object
  extended by org.graphstream.graph.implementations.AbstractElement
      extended by org.graphstream.ui.graphicGraph.GraphicElement
          extended by org.graphstream.ui.graphicGraph.GraphicEdge
All Implemented Interfaces:
Edge, Element

public class GraphicEdge
extends GraphicElement
implements Edge

Graphical 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
 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
 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
GraphicEdge(String id, GraphicNode from, GraphicNode to, boolean dir, HashMap<String,Object> attributes)
          New graphic edge.
 
Method Summary
 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.
<T extends Node>
T
getNode0()
          First node of the edge.
<T extends Node>
T
getNode1()
          Second node of the edge.
<T extends Node>
T
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 ?).
<T extends Node>
T
getSourceNode()
          Start node.
<T extends Node>
T
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()
          The graphic element was removed from the graphic graph, clean up.
 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
addAttribute, getComponent, getLabel, getStyle, myGraph, setComponent
 
Methods inherited from class org.graphstream.graph.implementations.AbstractElement
addAttributes, changeAttribute, clearAttributes, getArray, getAttribute, getAttribute, getAttributeCount, getAttributeKeyIterator, getAttributeKeySet, getEachAttributeKey, getFirstAttributeOf, getFirstAttributeOf, getHash, getId, getIndex, getLabel, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasHash, hasLabel, hasNumber, hasVector, removeAttribute, setAttribute, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.graphstream.graph.Element
addAttribute, addAttributes, changeAttribute, clearAttributes, getArray, getAttribute, getAttribute, getAttributeCount, getAttributeKeyIterator, getAttributeKeySet, getFirstAttributeOf, getFirstAttributeOf, getHash, getId, getIndex, getLabel, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasHash, hasLabel, hasNumber, hasVector, removeAttribute, setAttribute
 

Field Detail

from

public GraphicNode from
The first node.


to

public GraphicNode to
The second node.


directed

public boolean directed
Is the edge directed ?.


multi

public int multi
In case of a multi-graph this is the index of the edge between to and from.


group

public GraphicEdge.EdgeGroup group
If non null, this gives the number of edges between the two same nodes.


ctrl

public double[] ctrl
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.

Constructor Detail

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 Detail

getSelectorType

public Selector.Type getSelectorType()
Description copied from class: GraphicElement
Type of selector for the graphic element (Node, Edge, Sprite ?).

Specified by:
getSelectorType in class GraphicElement

otherNode

public GraphicNode otherNode(GraphicNode n)
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 class GraphicElement

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 class GraphicElement

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 class GraphicElement

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 the getControlPoints() 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 class GraphicElement
Parameters:
x - The new X.
y - The new Y.
z - the new Z.

removed

public void removed()
Description copied from class: GraphicElement
The graphic element was removed from the graphic graph, clean up.


getNode0

public <T extends Node> T 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.

This method is implicitly generic and return something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :

 ExtendedNode n = edge.getNode0();
 
the method will return an ExtendedNode. If no left part exists, method will just return a Node.

Specified by:
getNode0 in interface Edge
Returns:
The first node of the edge.
See Also:
Edge.getNode1(), Edge.getSourceNode()

getNode1

public <T extends Node> T 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.

This method is implicitly generic and return something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :

 ExtendedNode n = edge.getNode1();
 
the method will return an ExtendedNode. If no left part exists, method will just return a Node.

Specified by:
getNode1 in interface Edge
Returns:
The second node of the edge.
See Also:
Edge.getNode0(), Edge.getTargetNode()

getGroup

public GraphicEdge.EdgeGroup 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

public <T extends Node> T getOpposite(Node node)
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.

This method is implicitly generic and return something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :

 ExtendedNode n = edge.getOppositeNode((ExtendedNode) m);
 
the method will return an ExtendedNode. If no left part exists, method will just return a Node.

Specified by:
getOpposite in interface Edge
Parameters:
node - The node we search the opposite of.
Returns:
the opposite node of the given node.

getSourceNode

public <T extends Node> T 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 the Edge.getNode0() method but may be clearer in the source code if the graph you are using is directed.

This method is implicitly generic and return something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :

 ExtendedNode n = edge.getSourceNode();
 
the method will return an ExtendedNode. If no left part exists, method will just return a Node.

Specified by:
getSourceNode in interface Edge
Returns:
The origin node of the edge.
See Also:
Edge.getNode0(), Edge.getTargetNode()

getTargetNode

public <T extends Node> T 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 the Edge.getNode1() method but may be clearer in the source code if the graph you are using is directed.

This method is implicitly generic and return something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :

 ExtendedNode n = edge.getTargetNode();
 
the method will return an ExtendedNode. If no left part exists, method will just return a Node.

Specified by:
getTargetNode in interface Edge
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 interface Edge
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 ?.

Specified by:
isLoop in interface Edge
Returns:
True if this edge is a loop.

setDirected

public void setDirected(boolean on)

switchDirection

public void switchDirection()


Copyright © 2013. All Rights Reserved.