org.ceryle.graph
Class GraphEdge

java.lang.Object
  extended by com.touchgraph.graphlayout.Edge
      extended by org.ceryle.graph.GraphEdge

public class GraphEdge
extends Edge

Extends Edge, providing the additional ability to set edge direction. This also uses a drawing algorithm for directed edges based on drawing a triangle rather than the superclass's rather more brute force method of drawing 17 overlapping lines. On platforms that do not have a math coprocessor, the brute force method may be faster.

Version:
$Id: GraphEdge.java,v 3.11 2007-06-15 12:09:23 altheim Exp $
Author:
Murray Altheim

Field Summary
static int ALEN
           
static int ALEN2
           
static int ARROW_FORWARD
          A constant indicating an arrow-headed Edge.
static int ARROW_MULTIPLIER
          The length of arrow-style edges is determined by a multiplier upon the default length.
static int ARROW_WIDTH
          The width of half an arrowhead.
protected  AffineTransform at
          The AffineTransform used to rotate arrowheads.
static Color COLOR_EDGE
          The default color of edges.
static Color COLOR_EDGE_ARROW
          The default color of arrowhead style edges.
static Color COLOR_EDGE_DOWNSTREAM
          The default color of "downstream"-hilighted edges.
static Color COLOR_EDGE_FROM
          The color of a 'from' directed edge.
static Color COLOR_EDGE_MOUSE_OVER
          The default color of mouse-over'd edges.
static Color COLOR_EDGE_TO
          The color of a 'to' directed edge.
static Color COLOR_EDGE_UPSTREAM
          The default color of "upstream"-hilighted edges.
static int DEFAULT_ARROW_LENGTH
          The default length of arrowhead style edges.
static int DEFAULT_LENGTH
          Overrides the default value from Edge (setting the default slightly lower so that the multiplier has greater range (altered from 40 to 20).
static int DIRECTED_FROM
          A constant indicating a reverse directed ("from") Edge.
static int DIRECTED_TO
          A constant indicating a forward directed ("to") Edge.
protected  boolean hidden
          Hidden status of this GraphEdge.
protected  int m_style
          The drawing style of this Edge (DIRECTED_TO, DIRECTED_FROM, ARROW_FORWARD, or UNDIRECTED).
static boolean reflexiveTO
          When true (the default) uses two 'To' roles instead of two 'From' roles to indicate a reflexive relation.
protected  AffineTransform saveAt
          The AffineTransform used to save current state.
static int SIMPLE
          A constant indicating an Edge using a simple, undirected line.
static BasicStroke stroke2
           
static BasicStroke stroke3
           
static boolean suppressDirectedEdges
          A static variable indicating whether or not to suppress drawing of directed edges (for the sake of simplicity and/or performance).
static int UNDIRECTED
          A constant indicating an undirected Edge.
static BasicStroke widestroke
           
 
Fields inherited from class com.touchgraph.graphlayout.Edge
arrowForward, col, DEFAULT_COLOR, from, HILIGHT_COLOR, id, length, MOUSE_OVER_COLOR, simpleDraw, to, visible
 
Constructor Summary
GraphEdge(Node f, Node t)
          Constructor for an undirected edge with two Nodes and a default length.
GraphEdge(Node f, Node t, int directed)
          Constructor with two Nodes (using a default length) and edge direction.
GraphEdge(Node f, Node t, int len, int directed)
          Constructor with two Nodes, a length, and edge direction.
 
Method Summary
 Object clone()
          Clones and returns a copy of this edge.
 int getDirection()
          Returns the direction of this edge as an int.
 double[] getMidPoint()
          Returns the bisecting point on the edge's line.
 boolean isDirected()
          Returns the directedness of this edge as an boolean, true if directed, false if undirected.
static boolean isDirected(int d1, int d2)
          Returns true if the two supplied directions indicate a directed relation.
 boolean isHidden()
          Returns the hidden status of this GraphEdge.
static boolean isReflexive(int d1, int d2)
          Returns true if the two supplied directions indicate a reflexive relation.
 void paint(Graphics g, TGPanel tgPanel)
           
 void paintArrow(Graphics g, int x1, int y1, int x2, int y2, Color c, int dir)
          Overrides the method in Edge, following edge direction d.
 void setDirected(int directed)
          Set the directedness style of this edge to the int directed, as well as setting the edge color based on direction.
 void setHidden(boolean hidden)
          Sets the hidden status of this GraphEdge to the boolean hidden.
 int swapDirection()
          If this is a directed edge, this swaps its direction, returning the new direction.
 
Methods inherited from class com.touchgraph.graphlayout.Edge
containsPoint, distFromPoint, getColor, getFrom, getID, getLength, getOtherEndpt, getTo, intersects, isVisible, paintArrow, reverse, setColor, setEdgeDefaultColor, setEdgeDefaultLength, setEdgeMouseOverColor, setID, setLength, setVisible
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

suppressDirectedEdges

public static boolean suppressDirectedEdges
A static variable indicating whether or not to suppress drawing of directed edges (for the sake of simplicity and/or performance). Default is false, i.e., allow drawing of directed edges.


reflexiveTO

public static boolean reflexiveTO
When true (the default) uses two 'To' roles instead of two 'From' roles to indicate a reflexive relation.


UNDIRECTED

public static final int UNDIRECTED
A constant indicating an undirected Edge.

See Also:
Constant Field Values

DIRECTED_TO

public static final int DIRECTED_TO
A constant indicating a forward directed ("to") Edge.

See Also:
Constant Field Values

DIRECTED_FROM

public static final int DIRECTED_FROM
A constant indicating a reverse directed ("from") Edge.

See Also:
Constant Field Values

ARROW_FORWARD

public static final int ARROW_FORWARD
A constant indicating an arrow-headed Edge. This follows the same direction as DIRECTED_TO.

See Also:
Constant Field Values

SIMPLE

public static final int SIMPLE
A constant indicating an Edge using a simple, undirected line.

See Also:
Constant Field Values

hidden

protected boolean hidden
Hidden status of this GraphEdge. When true, drawing is suppressed.


COLOR_EDGE

public static Color COLOR_EDGE
The default color of edges. Ceryle property: http://purl.org/ceryle/prop/graph/color/#edgeDefault.


COLOR_EDGE_TO

public static Color COLOR_EDGE_TO
The color of a 'to' directed edge. Ceryle property: http://purl.org/ceryle/prop/graph/color/#edgeTo.


COLOR_EDGE_FROM

public static Color COLOR_EDGE_FROM
The color of a 'from' directed edge. Ceryle property: http://purl.org/ceryle/prop/graph/color/#edgeFrom.


COLOR_EDGE_MOUSE_OVER

public static Color COLOR_EDGE_MOUSE_OVER
The default color of mouse-over'd edges. Ceryle property: http://purl.org/ceryle/prop/graph/color/#edgeMouseOver.


COLOR_EDGE_DOWNSTREAM

public static Color COLOR_EDGE_DOWNSTREAM
The default color of "downstream"-hilighted edges. Ceryle property: http://purl.org/ceryle/prop/graph/color/#edgeDownstream.


COLOR_EDGE_UPSTREAM

public static Color COLOR_EDGE_UPSTREAM
The default color of "upstream"-hilighted edges. Ceryle property: http://purl.org/ceryle/prop/graph/color/#edgeUpstream.


COLOR_EDGE_ARROW

public static Color COLOR_EDGE_ARROW
The default color of arrowhead style edges. Ceryle property: http://purl.org/ceryle/prop/graph/color/#edgeArrow.


ARROW_MULTIPLIER

public static int ARROW_MULTIPLIER
The length of arrow-style edges is determined by a multiplier upon the default length. The default is 20. The range should be limited from 1 to roughly 100.


DEFAULT_LENGTH

public static int DEFAULT_LENGTH
Overrides the default value from Edge (setting the default slightly lower so that the multiplier has greater range (altered from 40 to 20).


DEFAULT_ARROW_LENGTH

public static int DEFAULT_ARROW_LENGTH
The default length of arrowhead style edges. This is the default length times the arrow multiplier.


ARROW_WIDTH

public static int ARROW_WIDTH
The width of half an arrowhead. Default is 6, making a 12 pixel-wide arrowhead.


m_style

protected int m_style
The drawing style of this Edge (DIRECTED_TO, DIRECTED_FROM, ARROW_FORWARD, or UNDIRECTED). The default is undirected.


stroke2

public static final BasicStroke stroke2

stroke3

public static final BasicStroke stroke3

widestroke

public static final BasicStroke widestroke

at

protected AffineTransform at
The AffineTransform used to rotate arrowheads.


saveAt

protected AffineTransform saveAt
The AffineTransform used to save current state.


ALEN

public static final int ALEN
See Also:
Constant Field Values

ALEN2

public static final int ALEN2
See Also:
Constant Field Values
Constructor Detail

GraphEdge

public GraphEdge(Node f,
                 Node t)
Constructor for an undirected edge with two Nodes and a default length.


GraphEdge

public GraphEdge(Node f,
                 Node t,
                 int directed)
Constructor with two Nodes (using a default length) and edge direction.


GraphEdge

public GraphEdge(Node f,
                 Node t,
                 int len,
                 int directed)
Constructor with two Nodes, a length, and edge direction.

Method Detail

isDirected

public static boolean isDirected(int d1,
                                 int d2)
Returns true if the two supplied directions indicate a directed relation. This is true when there is one DIRECTED_FROM, one DIRECTED_TO.


isReflexive

public static boolean isReflexive(int d1,
                                  int d2)
Returns true if the two supplied directions indicate a reflexive relation. This is dependent upon whether two 'TO' or two 'FROM' directions indicate reflexivity. When reflexiveTO is true, returns true when both directions are DIRECTED_TO, when reflexiveTO is false, returns true when both directions are DIRECTED_FROM.


isDirected

public boolean isDirected()
Returns the directedness of this edge as an boolean, true if directed, false if undirected.


getDirection

public int getDirection()
Returns the direction of this edge as an int. This is in actuality a style attribute, returning DIRECTED_TO, DIRECTED_FROM, ARROW_FORWARD, or UNDIRECTED).


swapDirection

public int swapDirection()
If this is a directed edge, this swaps its direction, returning the new direction. If no change occurs, returns -1. This is similar to reverse() in Edge, except it only makes a change if the edge is directed and also correctly updates the edge color.


setDirected

public void setDirected(int directed)
Set the directedness style of this edge to the int directed, as well as setting the edge color based on direction.


isHidden

public boolean isHidden()
Returns the hidden status of this GraphEdge.


clone

public Object clone()
Clones and returns a copy of this edge.

Overrides:
clone in class Object

setHidden

public void setHidden(boolean hidden)
Sets the hidden status of this GraphEdge to the boolean hidden.


getMidPoint

public double[] getMidPoint()
Returns the bisecting point on the edge's line.


paint

public void paint(Graphics g,
                  TGPanel tgPanel)
Overrides:
paint in class Edge

paintArrow

public void paintArrow(Graphics g,
                       int x1,
                       int y1,
                       int x2,
                       int y2,
                       Color c,
                       int dir)
Overrides the method in Edge, following edge direction d.



The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.