TPTP 4.4.0 Platform Project
Public API Specification

org.eclipse.hyades.uml2sd.ui.core
Class GraphNode

java.lang.Object
  extended byorg.eclipse.hyades.uml2sd.ui.core.GraphNode
Direct Known Subclasses:
BaseMessage, BasicExecutionOccurrence, BasicFrame, Lifeline, Stop

public abstract class GraphNode
extends java.lang.Object

The base class used for all UML2 graph nodes displayed in the Sequence Diagram SDWidget.


Field Summary
protected  java.util.HashMap bnodes
           
protected  java.util.HashMap bSort
           
protected  int endEventOccurrence
           
protected  java.util.HashMap fnodes
           
protected  java.util.HashMap fSort
           
protected  boolean hasChilds
           
protected  java.util.HashMap indexes
           
protected  java.util.HashMap nodes
           
 java.lang.String prefId
          Preference ColorId to use to draw font
protected  int startEventOccurrence
           
 
Constructor Summary
GraphNode()
           
 
Method Summary
 void addNode(GraphNode nodeToAdd)
          Add a GraphNode into the receiver
abstract  boolean contains(int x, int y)
          Returns true if the graph node contains the point given in parameter, return false otherwise.
static boolean contains(int x, int y, int width, int height, int px, int py)
          Determine if the given point (px,py) is contained in the rectangle (x,y,width,height)
protected abstract  void draw(IGC context)
          Draws the graph node in the given context
protected  void drawChildsNodes(IGC context)
          Draws the childs nodes on the given context.
 void drawFocus(IGC context)
           
abstract  java.lang.String getArrayId()
          Return the node type for all class instances.
 java.util.Comparator getBackComparator()
          If needed, return a different comparator to backward scan the GraphNode array
 java.util.Comparator getComparator()
          Return a comparator to sort the GraphNode of the same type This comparator is used to order the GraphNode array of the given node type.
 int getEndOccurrence()
          Returns the end event occurrence attached to this graphNode
abstract  int getHeight()
          Returns the graph node height
 java.lang.String getName()
          Returns the graph node name.
 GraphNode getNodeAt(int x, int y)
          Returns the graph node which contains the point given in parameter WARNING: Only graph nodes in the current visible area can be returned
protected  GraphNode getNodeFromListAt(int x, int y, java.util.List list, int fromIndex)
          Returns the graph node which contains the point given in parameter for the given graph node list and starting the iteration at the given index
WARNING: Only graph nodes with smaller coordinates than the current visible area can be returned.
 java.util.ArrayList getNodeList(GraphNode from, GraphNode to)
           
 int getStartOccurrence()
          Returns the start event occurrence attached to this graphNode.
abstract  int getWidth()
          Returns the graph node width
abstract  int getX()
          Returns the x coordinate of the graph node
abstract  int getY()
          Returns the y coordinate of the graph node
 boolean hasFocus()
          Returns true if the graph node is focused, false otherwise.
 boolean isSameAs(GraphNode node)
          Compare two graphNodes
 boolean isSelected()
          Returns true if the graph node is selected, false otherwise.
 boolean isVisible(int x, int y, int width, int height)
          Returns the GraphNode visibility for the given visible area.
 boolean positiveDistanceToPoint(int x, int y)
          Return true if the distance from the GraphNode to the given point is positif
 void resetIndex()
          Reset the internal index of the first visible GraphNode for each ordered GraphNode lists
 void setFocused(boolean focus)
          Tags the the graph node as focused.
 void setName(java.lang.String nodeName)
          Set the graph node name.
 void setSelected(boolean selection)
          Tags the the graph node has selected.
 void updateIndex(int x, int y, int width, int height)
          Computes the index of the first visible GraphNode for each ordered graph node lists depending on the visible area given in parameter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

startEventOccurrence

protected int startEventOccurrence

endEventOccurrence

protected int endEventOccurrence

prefId

public java.lang.String prefId
Preference ColorId to use to draw font


hasChilds

protected boolean hasChilds

nodes

protected java.util.HashMap nodes

fnodes

protected java.util.HashMap fnodes

bnodes

protected java.util.HashMap bnodes

indexes

protected java.util.HashMap indexes

fSort

protected java.util.HashMap fSort

bSort

protected java.util.HashMap bSort
Constructor Detail

GraphNode

public GraphNode()
Method Detail

resetIndex

public void resetIndex()
Reset the internal index of the first visible GraphNode for each ordered GraphNode lists


addNode

public void addNode(GraphNode nodeToAdd)
Add a GraphNode into the receiver

Parameters:
nodeToAdd - the node to add

setName

public void setName(java.lang.String nodeName)
Set the graph node name.
It is the name display in the view to label the graph node.


getName

public java.lang.String getName()
Returns the graph node name.
It is the name display in the view to label the graph node.

Returns:
the graph node name

setSelected

public void setSelected(boolean selection)
Tags the the graph node has selected.
WARNING: This method is only used to draw the graph node using the system selection colors.
To use the complete SDViewer selection mechanism (selection management, notification, etc..) see SDWidget class

Parameters:
selection - - true to set selected, false to set unselected
See Also:
SDWidget.addSelection(GraphNode), SDWidget.removeSelection(GraphNode), SDWidget.clearSelection()

setFocused

public void setFocused(boolean focus)
Tags the the graph node as focused.
WARNING: This method is only used to draw the graph node using the system focus style.
To use the complete SDViewer focus mechanism see SDWidget class

Parameters:
focus - - true to set focued, false otherwise
See Also:
SDWidget.addSelection(GraphNode), SDWidget.removeSelection(GraphNode), SDWidget.clearSelection()

isSelected

public boolean isSelected()
Returns true if the graph node is selected, false otherwise.
The returned value is used to highlight the graph node in the View.

Returns:
true if selected, false otherwise

hasFocus

public boolean hasFocus()
Returns true if the graph node is focused, false otherwise.
The returned value is used to highlight the graph node in the View.

Returns:
true if focued, false otherwise

contains

public abstract boolean contains(int x,
                                 int y)
Returns true if the graph node contains the point given in parameter, return false otherwise.

Parameters:
x - the x coordinate of the point to test containment
y the y coordinate of the point to test containment
Returns:
true if contained, false otherwise

getX

public abstract int getX()
Returns the x coordinate of the graph node

Returns:
the x coordinate

getY

public abstract int getY()
Returns the y coordinate of the graph node

Returns:
the y coordinate

getHeight

public abstract int getHeight()
Returns the graph node height

Returns:
the graph node height

getWidth

public abstract int getWidth()
Returns the graph node width

Returns:
the graph node width

draw

protected abstract void draw(IGC context)
Draws the graph node in the given context

Parameters:
context - the graphical context to draw in

isVisible

public boolean isVisible(int x,
                         int y,
                         int width,
                         int height)
Returns the GraphNode visibility for the given visible area. Wrong visibity calculation, may strongly impact drawing performance

Returns:
true if visible false otherwise

getComparator

public java.util.Comparator getComparator()
Return a comparator to sort the GraphNode of the same type This comparator is used to order the GraphNode array of the given node type. (see getArrayId).

Returns:
the comparator

getBackComparator

public java.util.Comparator getBackComparator()
If needed, return a different comparator to backward scan the GraphNode array

Returns:
the backward comparator or null if not needed

isSameAs

public boolean isSameAs(GraphNode node)
Compare two graphNodes

Parameters:
node - the node to compare to
Returns:
true if equal false otherwise

getArrayId

public abstract java.lang.String getArrayId()
Return the node type for all class instances. This id is used to store the same nodes kind in the same ordered array.

Returns:
the node type identifier

positiveDistanceToPoint

public boolean positiveDistanceToPoint(int x,
                                       int y)
Return true if the distance from the GraphNode to the given point is positif

Parameters:
x - the point x coordinate
y - the point y coordinate
Returns:
true if positif false otherwise

getNodeAt

public GraphNode getNodeAt(int x,
                           int y)
Returns the graph node which contains the point given in parameter WARNING: Only graph nodes in the current visible area can be returned

Parameters:
x - the x coordinate of the point to test
y - the y coordinate of the point to test
Returns:
the graph node containing the point given in parameter, null otherwise

getNodeList

public java.util.ArrayList getNodeList(GraphNode from,
                                       GraphNode to)

getNodeFromListAt

protected GraphNode getNodeFromListAt(int x,
                                      int y,
                                      java.util.List list,
                                      int fromIndex)
Returns the graph node which contains the point given in parameter for the given graph node list and starting the iteration at the given index
WARNING: Only graph nodes with smaller coordinates than the current visible area can be returned.

Parameters:
x - the x coordinate of the point to test
y - the y coordinate of the point to test
list - the list to search in
fromIndex - list browsing starting point
Returns:
the graph node containing the point given in parameter, null otherwise

getStartOccurrence

public int getStartOccurrence()
Returns the start event occurrence attached to this graphNode.

Returns:
the start event occurrence attached to the graphNode

getEndOccurrence

public int getEndOccurrence()
Returns the end event occurrence attached to this graphNode

Returns:
the start event occurrence attached to the graphNode

updateIndex

public void updateIndex(int x,
                        int y,
                        int width,
                        int height)
Computes the index of the first visible GraphNode for each ordered graph node lists depending on the visible area given in parameter

Parameters:
x - visible area top left corner x coordinate
y - visible area top left corner y coordinate
width - visible area width
height - visible area height

drawChildsNodes

protected void drawChildsNodes(IGC context)
Draws the childs nodes on the given context.
This method start width GraphNodes ordering if neeeded.
After, depending on the visible area, only visible GraphNodes are drawn.

Parameters:
context - the context to draw to
See Also:
draw(IGC)

drawFocus

public void drawFocus(IGC context)

contains

public static boolean contains(int x,
                               int y,
                               int width,
                               int height,
                               int px,
                               int py)
Determine if the given point (px,py) is contained in the rectangle (x,y,width,height)

Parameters:
x - the rectangle x coordinate
y - the rectangle y coordinate
width - the rectangle width
height - the rectangle height
px - the x coordinate of the point to test
py - the y coordinate of the point to test
Returns:
true if contained false otherwise

TPTP 4.4.0 Platform Project
Public API Specification