org.argouml.uml.diagram.static_structure.layout
Class ClassdiagramNode

java.lang.Object
  extended byorg.argouml.uml.diagram.static_structure.layout.ClassdiagramNode
All Implemented Interfaces:
Comparable, LayoutedNode, LayoutedObject
Direct Known Subclasses:
ClassdiagramNote

class ClassdiagramNode
extends Object
implements LayoutedNode, Comparable

This class represents a node in the classdiagram (a class, interface or package).

Things a node has to know:


Field Summary
private  int column
          Attribute column represents the current column of this node.
private  Vector downlinks
          Attribute downlinks represents the nodes that contain the figures, which are sources of edges with the figure of this node as destination.
private  int edgeOffset
          Offset used for edges, which have this node as the "upper" node
private  org.tigris.gef.presentation.FigNode figure
          Attribute figure represents the figure that this ClassdiagramNode represents during the layout process.
static int NOCOLUMN
          Constant to be used as an initializer when this node is not placed at an column.
static int NORANK
          Constant to be used as an initializer when this node has no rank assigned yet.
static int NOWEIGHT
          Constant to be used as an initializer when this node has no weight.
private  int placementHint
          Attribute placementHint keeps information about preferred positioning
private  int rank
          Attribute rank represents the current rank (i.e.
private static float uplinkFactor
           
private  Vector uplinks
          Attribute uplinks represents the nodes that contain the figures, which are destinations of edges with the figure of this node as source.
private  float weight
          This attribute stores the 'weight' of this node.
 
Constructor Summary
ClassdiagramNode(org.tigris.gef.presentation.FigNode f)
          Operation ClassdiagramNode creates a new ClassdiagramNode.
 
Method Summary
 void addDownlink(ClassdiagramNode newDownlink)
          Operation setDownlinks changes the value of the attribute _downlinks.
 void addRank(int n)
          Add a constant to the rank of this node.
 void addUplink(ClassdiagramNode newUplink)
          Add an uplink to this node.
 float calculateWeight()
          Calculate the weight of this node.
 int compareTo(Object arg0)
          The "natural order" for ClassdiagramNodes is defined by: First standalone, then linked nodes First Packages, then Interfaces/Classes/Notes increasing rank (rownumber) decreasing weight name of model object increasing hashcode (for uniqueness)
 int getColumn()
          Operation getColumn returns the value of the attribute _column.
 Vector getDownlinks()
          Get the downlinks of this node.
 int getEdgeOffset()
          Get the offset which shall be used for edges with this node as parent.
 org.tigris.gef.presentation.FigNode getFigure()
          Get the underlying figure of this node
 int getLevel()
          Get the level in the inheritance hierarchy for this node.
 Point getLocation()
          Get the location of the underlying figure in the diagram.
 int getPlacementHint()
          Get the current placementhint.
 int getRank()
          Get the rank of this node.
 Dimension getSize()
          Operation getSize returns the size of the figure associated with this layout node.
 float getSubtreeWeight()
          Get the weight of the subtree defined by this node.
 int getTypeOrderNumer()
          Get the type order number of this node.
 Vector getUplinks()
          Get the uplinks of this node.
 float getWeight()
          Return the weight of this node, which is used for positioning in a row.
 boolean isComment()
          Check if this node is associated with a note.
 boolean isPackage()
          Check if this node is associated with a package.
 boolean isStandalone()
          Test whether this node has no connection to other nodes.
 void setColumn(int newColumn)
          Set the column of this node.
 void setEdgeOffset(int newOffset)
          Set the offset for edges to this node.
 void setFigure(org.tigris.gef.presentation.FigNode newFigure)
          Operation setFigure changes the value of the attribute _figure.
 void setLocation(Point newLocation)
          Operation setLocation set the new location of the associated figure in the diagram.
 void setPlacementHint(int hint)
          A placementhint gives an indication where it might be feasible to place this node.
 void setRank(int newRank)
          Operation setRank changes the value of the attribute _rank.
 void setWeight(float w)
          Set the weight for this node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOCOLUMN

public static final int NOCOLUMN
Constant to be used as an initializer when this node is not placed at an column.

See Also:
Constant Field Values

NORANK

public static final int NORANK
Constant to be used as an initializer when this node has no rank assigned yet.

See Also:
Constant Field Values

NOWEIGHT

public static final int NOWEIGHT
Constant to be used as an initializer when this node has no weight.

See Also:
Constant Field Values

column

private int column
Attribute column represents the current column of this node.


downlinks

private Vector downlinks
Attribute downlinks represents the nodes that contain the figures, which are sources of edges with the figure of this node as destination.


edgeOffset

private int edgeOffset
Offset used for edges, which have this node as the "upper" node


figure

private org.tigris.gef.presentation.FigNode figure
Attribute figure represents the figure that this ClassdiagramNode represents during the layout process.


placementHint

private int placementHint
Attribute placementHint keeps information about preferred positioning


rank

private int rank
Attribute rank represents the current rank (i.e. row) of this node.


uplinks

private Vector uplinks
Attribute uplinks represents the nodes that contain the figures, which are destinations of edges with the figure of this node as source.


weight

private float weight
This attribute stores the 'weight' of this node. This is a computed attribute that is used during the horizontal placement process. It's based on the position of the 'uplinked' objects. The actual purpose is to minimize the number of link crossings in the diagram. Since we don't compute the actual number of link crossings, we look where our uplinked objects are, and then try to place our object in a way, that we can expect to have a minimal number of crossings.


uplinkFactor

private static float uplinkFactor
Constructor Detail

ClassdiagramNode

public ClassdiagramNode(org.tigris.gef.presentation.FigNode f)
Operation ClassdiagramNode creates a new ClassdiagramNode.

Parameters:
f - represents the figure in the diagram, that peers this layout node.
Method Detail

addDownlink

public void addDownlink(ClassdiagramNode newDownlink)
Operation setDownlinks changes the value of the attribute _downlinks.

Parameters:
newDownlink - Represents the new value of _downlinks.

addRank

public void addRank(int n)
Add a constant to the rank of this node.

Parameters:
n - The value to add.

addUplink

public void addUplink(ClassdiagramNode newUplink)
Add an uplink to this node.

Parameters:
newUplink - represents the new uplinks.

calculateWeight

public float calculateWeight()
Calculate the weight of this node. The function distinguishes between note-nodes and standard-nodes, because a note shall be positioned to the right of its first related node, if it exists. Therefor the weight is a function of the weight of the related node. For standard-nodes the weight is a function of up-/downlinks, column and uplink factor.

Returns:
The weigth of this node

compareTo

public int compareTo(Object arg0)
The "natural order" for ClassdiagramNodes is defined by:

Specified by:
compareTo in interface Comparable
See Also:
Comparable.compareTo(java.lang.Object)

getColumn

public int getColumn()
Operation getColumn returns the value of the attribute _column.

Returns:
The value of the attribute _column.

getDownlinks

public Vector getDownlinks()
Get the downlinks of this node.

Returns:
The downlinks of this node.

getEdgeOffset

public int getEdgeOffset()
Get the offset which shall be used for edges with this node as parent.

Returns:
The offset

getFigure

public org.tigris.gef.presentation.FigNode getFigure()
Get the underlying figure of this node

Returns:
The figure

getLevel

public int getLevel()
Get the level in the inheritance hierarchy for this node.

Returns:
The level

getLocation

public Point getLocation()
Get the location of the underlying figure in the diagram.

Specified by:
getLocation in interface LayoutedNode
Returns:
The location

getPlacementHint

public int getPlacementHint()
Get the current placementhint.

Returns:
The placementhint for this node

getRank

public int getRank()
Get the rank of this node.

Returns:
The rank for this node.

getSize

public Dimension getSize()
Operation getSize returns the size of the figure associated with this layout node.

Specified by:
getSize in interface LayoutedNode
Returns:
The size of the associated figure.

getSubtreeWeight

public float getSubtreeWeight()
Get the weight of the subtree defined by this node. Impact on weight is decreasing with increasing hierarchical distance

Returns:
The weight of the subtree

getTypeOrderNumer

public int getTypeOrderNumer()
Get the type order number of this node. This number may be used to influence the sort order of ClassdiagramNodes.

Returns:
Type order number

getUplinks

public Vector getUplinks()
Get the uplinks of this node.

Returns:
The uplinks of this node.

getWeight

public float getWeight()
Return the weight of this node, which is used for positioning in a row.

Returns:
The weight of this node.

isComment

public boolean isComment()
Check if this node is associated with a note.

Returns:
Result of test

isPackage

public boolean isPackage()
Check if this node is associated with a package.

Returns:
Result of test

isStandalone

public boolean isStandalone()
Test whether this node has no connection to other nodes. Return true, if node has no connections, false otherwise

Returns:
Result of test

setColumn

public void setColumn(int newColumn)
Set the column of this node. A re-calculation of the weight is performed, because the column is an input parameter for the weight.


setEdgeOffset

public void setEdgeOffset(int newOffset)
Set the offset for edges to this node.


setFigure

public void setFigure(org.tigris.gef.presentation.FigNode newFigure)
Operation setFigure changes the value of the attribute _figure.

Parameters:
newFigure - represents the new value of _figure.

setLocation

public void setLocation(Point newLocation)
Operation setLocation set the new location of the associated figure in the diagram.

Specified by:
setLocation in interface LayoutedNode
Parameters:
newLocation - represents the new location for this figure.

setPlacementHint

public void setPlacementHint(int hint)
A placementhint gives an indication where it might be feasible to place this node. It is used by the layouter, and there is no guarantee that it will be used.

Parameters:
hint - x coordinate of the desired placement

setRank

public void setRank(int newRank)
Operation setRank changes the value of the attribute _rank.

Parameters:
newRank - represents the new value of _rank.

setWeight

public void setWeight(float w)
Set the weight for this node.



ArgoUML © 1996-2004 (20050222)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook