aminePlatform.guis.graphDrawing
Class VisualEdge

java.lang.Object
  extended byaminePlatform.guis.graphDrawing.VisualEdge

public class VisualEdge
extends java.lang.Object

Title : VisualGraph

Description : VisualEdge is a visual wrapper for Edge: a VisualEdge contains a reference to an Edge with visual attributes and methods. In this way, visualization (or drawing) of a Graph is separeted from the structure Graph.

Copyright : Copyright (c) Adil KABBAJ 2004-2009


Field Summary
 java.util.ArrayList arrow
           
 
Constructor Summary
VisualEdge(Edge edge)
          Create a VisualEdge for the specified Edge
VisualEdge(Edge edge, VisualNode source, VisualNode target)
          Create a VisualEdge for the specified Edge with the specified source and target.
 
Method Summary
 void constructArrow(Lexicon lexicon)
          Construct the arrow of the relation: determine the three points that compose the triangle of the arrow.
 VisualEdge copy()
          Copy the current VisualEdge
 void draw(java.awt.Graphics g, Lexicon lexicon)
          Draw the relation consists in : a) determine the color for the relation (color of segments, of the arrow and of the text) depending on being selectioned or not, b) draw the segments of the relation, c) draw the name of the relation, d) draw the arrow.
 void drawArrow(java.awt.Graphics g)
          Draw the arrow of the VisualEdge
 Edge getEdge()
          Get the edge associated to the current VisualEdge
 java.lang.Object getName(Lexicon lexicon)
          Get the name of the edge associated to the current VisualEdge
 java.awt.Point getPosVEdgeNameOnSegments(Lexicon lexicon)
          Get the position of the name of the edge associated to the current VisualEdge
 java.util.ArrayList getSegmentPoints(Lexicon lexicon)
          Get the segment points of the edge associated to the current VisualEdge
 VisualNode getSource()
          Get the source VisualNode of the current VisualEdge
 VisualNode getTarget()
          Get the target VisualNode of the current VisualEdge
 boolean isTextOnSegment(java.awt.Point p0, java.awt.Point p1, Lexicon lexicon)
          Check if the text is on the segment specified by the points p0 and p1.
 void moveVEdgeName(java.awt.Point pt, Lexicon lexicon)
          Move the name of the edge associated to the current VisualEdge to the specified point pt.
 void putTextOnSegment(java.awt.Point p0, java.awt.Point p1, Lexicon lexicon)
          Put the identifier of the relation on the segment specified by (p0, p1).
 void setEdge(Edge edge)
          Set the specified edge for the current Visual Edge
 boolean setName(java.lang.String name, Lexicon lexicon)
          Set the specified name as the name of the edge associated to the current VisualEdge
 void setPosVEdgeNameOnSegments(java.awt.Point pos)
          Set the position of the name of the edge associated to the current VisualEdge
 void setSegmentPoints(java.util.ArrayList segmentsPoints)
          Set the segment points of the edge associated to the current VisualEdge
 void setSource(VisualNode visualNode)
          Set the specified VisualNode as the source for the current VisualEdge
 void setTarget(VisualNode visualNode)
          Set the specified VisualNode as the target for the current VisualEdge
 void setVisualSegmentPoints(java.util.ArrayList segmentsPoints)
           
 java.lang.String toString(Lexicon lexicon)
          Get the name, in String, of the edge associated to the current VisualEdge
 void updateFirstSegment(Lexicon lexicon)
          Update the first segment of the edge associated to the current VisualEdge
 void updateLastSegment(Lexicon lexicon)
          Update the last segment of the edge associated to the current VisualEdge
 void updateName(java.lang.String name, Lexicon lexicon)
          Update the name of the edge associated to the current VisualEdge
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

arrow

public java.util.ArrayList arrow
Constructor Detail

VisualEdge

public VisualEdge(Edge edge)
Create a VisualEdge for the specified Edge

Parameters:
edge - An Edge

VisualEdge

public VisualEdge(Edge edge,
                  VisualNode source,
                  VisualNode target)
Create a VisualEdge for the specified Edge with the specified source and target.

Parameters:
edge - An Edge
source - A VisualNode
target - A VisualNode
Method Detail

getEdge

public Edge getEdge()
Get the edge associated to the current VisualEdge

Returns:
the edge associated to the current VisualEdge

setEdge

public void setEdge(Edge edge)
Set the specified edge for the current Visual Edge

Parameters:
edge - An Edge

copy

public VisualEdge copy()
Copy the current VisualEdge

Returns:
A copy the current VisualEdge

getTarget

public VisualNode getTarget()
Get the target VisualNode of the current VisualEdge

Returns:
the target VisualNode of the current VisualEdge

setTarget

public void setTarget(VisualNode visualNode)
Set the specified VisualNode as the target for the current VisualEdge

Parameters:
visualNode - A VisualNode

getSource

public VisualNode getSource()
Get the source VisualNode of the current VisualEdge

Returns:
the source VisualNode of the current VisualEdge

setSource

public void setSource(VisualNode visualNode)
Set the specified VisualNode as the source for the current VisualEdge

Parameters:
visualNode - A VisualNode

getName

public java.lang.Object getName(Lexicon lexicon)
Get the name of the edge associated to the current VisualEdge

Parameters:
lexicon - The Lexicon
Returns:
the name of the edge associated to the current VisualEdge

toString

public java.lang.String toString(Lexicon lexicon)
Get the name, in String, of the edge associated to the current VisualEdge

Parameters:
lexicon - The Lexicon
Returns:
the name, in String, of the edge associated to the current VisualEdge

setName

public boolean setName(java.lang.String name,
                       Lexicon lexicon)
                throws java.lang.Exception
Set the specified name as the name of the edge associated to the current VisualEdge

Parameters:
name - A String
lexicon - A Lexicon
Returns:
true if the operation succeed
Throws:
java.lang.Exception - if a problem occurs during the operation

getPosVEdgeNameOnSegments

public java.awt.Point getPosVEdgeNameOnSegments(Lexicon lexicon)
Get the position of the name of the edge associated to the current VisualEdge

Parameters:
lexicon - A Lexicon
Returns:
the position of the name of the edge associated to the current VisualEdge

setPosVEdgeNameOnSegments

public void setPosVEdgeNameOnSegments(java.awt.Point pos)
Set the position of the name of the edge associated to the current VisualEdge

Parameters:
pos - A Point that represents the position

getSegmentPoints

public java.util.ArrayList getSegmentPoints(Lexicon lexicon)
Get the segment points of the edge associated to the current VisualEdge

Parameters:
lexicon - A Lexicon
Returns:
the segment points of the edge associated to the current VisualEdge

setSegmentPoints

public void setSegmentPoints(java.util.ArrayList segmentsPoints)
Set the segment points of the edge associated to the current VisualEdge

Parameters:
segmentsPoints - An ArrayList of Point

setVisualSegmentPoints

public void setVisualSegmentPoints(java.util.ArrayList segmentsPoints)

updateFirstSegment

public void updateFirstSegment(Lexicon lexicon)
Update the first segment of the edge associated to the current VisualEdge

Parameters:
lexicon - The Lexicon

updateLastSegment

public void updateLastSegment(Lexicon lexicon)
Update the last segment of the edge associated to the current VisualEdge

Parameters:
lexicon - The Lexicon

updateName

public void updateName(java.lang.String name,
                       Lexicon lexicon)
                throws java.lang.Exception
Update the name of the edge associated to the current VisualEdge

Parameters:
name - A String
lexicon - The Lexicon
Throws:
java.lang.Exception - if problem occurs during the operation

constructArrow

public void constructArrow(Lexicon lexicon)
Construct the arrow of the relation: determine the three points that compose the triangle of the arrow.

Parameters:
lexicon - The Lexicon

draw

public void draw(java.awt.Graphics g,
                 Lexicon lexicon)
Draw the relation consists in : a) determine the color for the relation (color of segments, of the arrow and of the text) depending on being selectioned or not, b) draw the segments of the relation, c) draw the name of the relation, d) draw the arrow.

Parameters:
g - Graphics
lexicon - The Lexicon

drawArrow

public void drawArrow(java.awt.Graphics g)
Draw the arrow of the VisualEdge

Parameters:
g - Graphics

isTextOnSegment

public boolean isTextOnSegment(java.awt.Point p0,
                               java.awt.Point p1,
                               Lexicon lexicon)
Check if the text is on the segment specified by the points p0 and p1. To do this, the text is assimilated to a segment, (posTextOnSegment, posTextOnSegment + SizeText) and we search if there is an intersection.

Parameters:
p0 - A Point
p1 - A Point
lexicon - A Lexicon
Returns:
true if the text is on the segment specified by the points p0 and p1.

putTextOnSegment

public void putTextOnSegment(java.awt.Point p0,
                             java.awt.Point p1,
                             Lexicon lexicon)
Put the identifier of the relation on the segment specified by (p0, p1). By default, the identifier is put in the middle of the segment.

Parameters:
p0 - A Point
p1 - A Point
lexicon - A Lexicon

moveVEdgeName

public void moveVEdgeName(java.awt.Point pt,
                          Lexicon lexicon)
Move the name of the edge associated to the current VisualEdge to the specified point pt.

Parameters:
pt - A Point
lexicon - A Lexicon