kaapo.project
Class DiagramWrapper

java.lang.Object
  extended by kaapo.project.DiagramWrapper
All Implemented Interfaces:
Serializable

public class DiagramWrapper
extends Object
implements Serializable

Diagram wrapper is a node in the project diagram tree. Diagram wrapper has a parent and may have children. Diagram wrapper has one associated Diagram instance.

When adding a new diagram wrapper to the tree, you usually use the Project.addDiagram method and don't need to invoke the constructors of this class directly.

See Also:
Diagram, Serialized Form

Constructor Summary
protected DiagramWrapper()
           
  DiagramWrapper(Diagram diagram)
          Constructs the wrapper with null parent.
  DiagramWrapper(Diagram diagram, DiagramWrapper parent)
          Constructs the wrapper with given parent.
 
Method Summary
 void addChild(int index, DiagramWrapper child)
          Add child node into diagram wrapper.
 List<DiagramWrapper> getChildren()
          Returns the children of this diagram wrapper.
 Diagram getDiagram()
          Returns the diagram associated to this wrapper.
 DiagramWrapper getParent()
          Returns the parent of this wrapper.
 boolean removeChild(DiagramWrapper child)
          Removes a child from diagram wrapper.
 void setParent(DiagramWrapper parent)
          Sets the parent of this wrapper.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiagramWrapper

protected DiagramWrapper()

DiagramWrapper

public DiagramWrapper(Diagram diagram)
Constructs the wrapper with null parent.

Parameters:
diagram - The Diagram instance associated to this wrapper.

DiagramWrapper

public DiagramWrapper(Diagram diagram,
                      DiagramWrapper parent)
Constructs the wrapper with given parent.

Parameters:
diagram - The Diagram instance associated to this wrapper.
parent - The parent of this diagram wrapper.
Method Detail

getDiagram

public Diagram getDiagram()
Returns the diagram associated to this wrapper.

Returns:
Diagram

getParent

public DiagramWrapper getParent()
Returns the parent of this wrapper. The parent is null if the wrapper is at the top level of the diagram tree.

Returns:
Parent, may be null

setParent

public void setParent(DiagramWrapper parent)
Sets the parent of this wrapper. The parent may be null.

Parameters:
parent - New parent

getChildren

public List<DiagramWrapper> getChildren()
Returns the children of this diagram wrapper. The list is empty (but not null) if this diagram wrapper has no children.

Returns:
Children as list

addChild

public void addChild(int index,
                     DiagramWrapper child)
Add child node into diagram wrapper.

Parameters:
index - The index for the new child. Index 0 adds the child to the first child.
child - The child to be added

removeChild

public boolean removeChild(DiagramWrapper child)
Removes a child from diagram wrapper.

Parameters:
child - The child to be removed
Returns:
True if the child was removed succesfully, false if the diagram wrapper given was not a child of this wrapper.