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

java.lang.Object
  extended byorg.argouml.uml.diagram.static_structure.layout.ClassdiagramLayouter
All Implemented Interfaces:
Layouter

public class ClassdiagramLayouter
extends java.lang.Object
implements Layouter

This class implements a layout algoritms for class diagrams.


Field Summary
private  int _hGap
          The horizontal gap between nodes.
private  java.util.Vector _layoutedClassNodes
          _layoutedClassNodes is a convenience which holds a subset of _layoutedObjects (only ClassNodes)
private  java.util.Vector _layoutedObjects
          Attribute _layoutedObjects holds the objects to layout.
private  int _maxPackageRank
           
private  int _vGap
          The vertical gap between nodes.
private  int _vMax
          The maximum of elements in a particular row
static org.apache.log4j.Logger cat
          Logger for logging events
private  UMLDiagram diagram
          stores the current diagram *
(package private)  java.util.Collection nodes
          stores all the nodes which will be layouted
private  int xPos
          internal
private  int yPos
          internal
 
Constructor Summary
ClassdiagramLayouter(UMLDiagram theDiagram)
          This constructor is mainly for convenience, so we don't have add every node manually to the layouter.
 
Method Summary
 void add(ClassdiagramNode obj)
          Add a ClassdiagramNode to layout.
 void add(LayoutedObject obj)
          Add a object to layout.
private  void centerPlacedRows()
          center the rows according to the biggest/widest row.
 ClassdiagramNode getClassdiagramNode(int index)
          Get a ClassdiagramNode from the layouted objects.
private  ClassdiagramNode getClassdiagramNode4owner(java.lang.Object m)
          Search the nodes in this classdiagram for a node with a given owner.
private  java.util.Vector getClassdiagramNodes()
          extract the ClassdiagramNodes from all layouted objects
private  int getColumns(int row)
          Get the number of elements in a given row
protected  int getHGap()
          Get the horizontal gap between nodes.
 java.awt.Dimension getMinimumDiagramSize()
          Operation getMinimumDiagramSize returns the minimum diagram size after the layout process.
 LayoutedObject getObject(int index)
          Operation getObject returns a object with a given index from the layouter.
 LayoutedObject[] getObjects()
          Operation getObjects returns all the objects currently participating in the layout process.
private  ClassdiagramNode[] getObjectsInRow(int row)
          Operation getObject InRow returns all the objects for a given row.
private  int getRowHeight(int row)
          calculate the height of the row
private  int getRows()
          Get the number of rows in this diagram.
private  int getRowWidth(int row)
          calculate the width of the row
protected  int getVGap()
          Get the vertical gap between nodes.
 void layout()
          Operation layout implements the actual layout algorithm
(package private)  void layoutPackages()
          position the packages of the diagram
private  void rankPackagesAndMoveClassesBelow()
           
 void remove(LayoutedObject obj)
          Remove a object from the layout process.
private  void weightAndPlaceClasses()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cat

public static final org.apache.log4j.Logger cat
Logger for logging events


diagram

private UMLDiagram diagram
stores the current diagram *


nodes

java.util.Collection nodes
stores all the nodes which will be layouted


_layoutedObjects

private java.util.Vector _layoutedObjects
Attribute _layoutedObjects holds the objects to layout.


_layoutedClassNodes

private java.util.Vector _layoutedClassNodes
_layoutedClassNodes is a convenience which holds a subset of _layoutedObjects (only ClassNodes)


_maxPackageRank

private int _maxPackageRank

_hGap

private int _hGap
The horizontal gap between nodes.


_vGap

private int _vGap
The vertical gap between nodes.


_vMax

private int _vMax
The maximum of elements in a particular row


xPos

private int xPos
internal


yPos

private int yPos
internal

Constructor Detail

ClassdiagramLayouter

public ClassdiagramLayouter(UMLDiagram theDiagram)
This constructor is mainly for convenience, so we don't have add every node manually to the layouter.

Method Detail

add

public void add(LayoutedObject obj)
Add a object to layout.

Specified by:
add in interface Layouter
Parameters:
obj - represents the object to layout.

add

public void add(ClassdiagramNode obj)
Add a ClassdiagramNode to layout.

Parameters:
obj - represents the object to layout.

remove

public void remove(LayoutedObject obj)
Remove a object from the layout process.

Specified by:
remove in interface Layouter
Parameters:
obj - represents the object to remove.

getObjects

public LayoutedObject[] getObjects()
Operation getObjects returns all the objects currently participating in the layout process.

Specified by:
getObjects in interface Layouter
Returns:
An array holding all the object in the layouter.

getObject

public LayoutedObject getObject(int index)
Operation getObject returns a object with a given index from the layouter.

Specified by:
getObject in interface Layouter
Parameters:
index - represents the index of this object in the layouter.
Returns:
The LayoutedObject for the given index.

getClassdiagramNode

public ClassdiagramNode getClassdiagramNode(int index)
Get a ClassdiagramNode from the layouted objects.

Parameters:
index - represents the index of this ClassdiagramNode.
Returns:
The ClassdiagramNode for this index.

getClassdiagramNodes

private java.util.Vector getClassdiagramNodes()
extract the ClassdiagramNodes from all layouted objects


layout

public void layout()
Operation layout implements the actual layout algorithm

Specified by:
layout in interface Layouter

rankPackagesAndMoveClassesBelow

private void rankPackagesAndMoveClassesBelow()

weightAndPlaceClasses

private void weightAndPlaceClasses()

centerPlacedRows

private void centerPlacedRows()
center the rows according to the biggest/widest row. Instead of placing the rows like this:
 ABC
 DEFGH
 I
 
place them like this:
   ABC
  DEFGH
    I
 

Since:
0.9.7

layoutPackages

void layoutPackages()
position the packages of the diagram


getClassdiagramNode4owner

private ClassdiagramNode getClassdiagramNode4owner(java.lang.Object m)
Search the nodes in this classdiagram for a node with a given owner.

Returns:
The classdiagram node for this owner, if it's in this diagram, or null if not.

getMinimumDiagramSize

public java.awt.Dimension getMinimumDiagramSize()
Operation getMinimumDiagramSize returns the minimum diagram size after the layout process.

Specified by:
getMinimumDiagramSize in interface Layouter
Returns:
The minimum diagram size after the layout process.

getRows

private int getRows()
Get the number of rows in this diagram.

Returns:
The number of rows in this layout.

getRowHeight

private int getRowHeight(int row)
calculate the height of the row

Parameters:
row - the row to calculate
Returns:
the height

getRowWidth

private int getRowWidth(int row)
calculate the width of the row

Parameters:
row - the row to calculate
Returns:
the width

getColumns

private int getColumns(int row)
Get the number of elements in a given row

Parameters:
row - The row to check.
Returns:
The number of elements in the given row.

getObjectsInRow

private ClassdiagramNode[] getObjectsInRow(int row)
Operation getObject InRow returns all the objects for a given row.

Parameters:
row - represents the row of the returned objects.

getVGap

protected int getVGap()
Get the vertical gap between nodes.

Returns:
The vertical gap between nodes.

getHGap

protected int getHGap()
Get the horizontal gap between nodes.

Returns:
The horizontal gap between nodes.


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