kaapo.project
Class Project

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

public class Project
extends Observable
implements Serializable

Composite class that contains all diagrams, elements and connections of a project. This class is the starting point for working with the project.

Project maintains the following data structures:

See Also:
Serialized Form

Nested Class Summary
static class Project.ObservableMessage
           
 
Constructor Summary
Project()
          Constructs the project with null name.
Project(String name)
          Constructs the project with given name.
 
Method Summary
 DiagramWrapper addDiagram(Diagram diagram, DiagramWrapper parent, DiagramWrapper prevSibling)
          Adds the diagram to the project and the project tree and creates a new DiagramWrapper for it.
 boolean addDiagram(DiagramWrapper dw, DiagramWrapper parent, DiagramWrapper prevSibling)
          Adds the DiagramWrapper to the project and the project tree.
 void addDiagramComponent(DiagramComponent diagramComponent)
          Adds the diagram component (element or connection) to the project.
 boolean containsProjectComponent(ProjectComponent projectComponent)
          Tells whether given diagram, element or connection is part of the project.
 List<Diagram> getDiagrams()
          Gets list of all Diagram instances in the project.
 List<DiagramWrapper> getDiagramWrappers()
          Gets the list of top-level diagram wrappers in the diagram tree.
 String getName()
          Gets the name of the project.
 boolean removeDiagram(Diagram diagram)
          Removes the diagram completely from the project, including all diagram wrappers associated to it.
 boolean removeDiagramComponent(DiagramComponent diagramComponent)
          Removes the diagram component from the project.
 boolean removeDiagramWrapper(DiagramWrapper diagramWrapper)
          Removes diagram wrapper from the tree; also removes the diagram itself if it is no longer in any diagram wrapper.
 void setName(String name)
          Sets the name of the project.
 String toString()
           
 
Methods inherited from class kaapo.Observable
addObserver, notifyObservers, notifyObservers, removeAllObservers, removeObserver, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Project

public Project()
Constructs the project with null name.


Project

public Project(String name)
Constructs the project with given name.

Parameters:
name - Project name
Method Detail

getName

public String getName()
Gets the name of the project.

Returns:
The name

setName

public void setName(String name)
Sets the name of the project.

Parameters:
name - The new name

addDiagram

public DiagramWrapper addDiagram(Diagram diagram,
                                 DiagramWrapper parent,
                                 DiagramWrapper prevSibling)
Adds the diagram to the project and the project tree and creates a new DiagramWrapper for it.

Parameters:
diagram - The diagram to be added.
parent - Parent of the new diagram in the tree. If the new diagram gets added to the first level of the tree, parent must be null.
prevSibling - In the diagram tree, the diagram wrapper that will precede the new diagram. The new diagram will be added after the prevSibling. If the diagram will be the first child of its parent, prevSibling must be null.
Returns:
The DiagramWrapper instance that was added to the tree.

addDiagram

public boolean addDiagram(DiagramWrapper dw,
                          DiagramWrapper parent,
                          DiagramWrapper prevSibling)
Adds the DiagramWrapper to the project and the project tree.

Parameters:
dw - The DiagramWrapper to be added.
parent - Parent of the new diagram in the tree. If the new diagram gets added to the first level of the tree, parent must be null.
prevSibling - In the diagram tree, the diagram wrapper that will precede the new diagram. The new diagram will be added after the prevSibling. If the diagram will be the first child of its parent, prevSibling must be null.
Throws:
IllegalArgumentException - If prevSibling is not found in the tree

removeDiagram

public boolean removeDiagram(Diagram diagram)
Removes the diagram completely from the project, including all diagram wrappers associated to it.

Parameters:
diagram -
Returns:
True if the diagram was removed, false if it was not a member of the project.

removeDiagramWrapper

public boolean removeDiagramWrapper(DiagramWrapper diagramWrapper)
Removes diagram wrapper from the tree; also removes the diagram itself if it is no longer in any diagram wrapper.

Parameters:
diagramWrapper - The diagram wrapper to be removed
Returns:
True if the diagram wrapper was removed, false if it was not a member of the project.

getDiagrams

public List<Diagram> getDiagrams()
Gets list of all Diagram instances in the project. If you want to get the diagram tree, use getDiagramWrappers.

Returns:
List of Diagram instances.

getDiagramWrappers

public List<DiagramWrapper> getDiagramWrappers()
Gets the list of top-level diagram wrappers in the diagram tree. In other words, returns the first level of the tree.

Returns:
List of top-level diagram wrappers.

addDiagramComponent

public void addDiagramComponent(DiagramComponent diagramComponent)
Adds the diagram component (element or connection) to the project. Notice: this doesn't add it to any diagram, you must do it using a Diagram instance.

Parameters:
diagramComponent - The component to be added.

removeDiagramComponent

public boolean removeDiagramComponent(DiagramComponent diagramComponent)
Removes the diagram component from the project. This method does not remove any DiagramComponentWrappers from diagrams.

Parameters:
diagramComponent -
Returns:
True if the diagram component was removed, false if it was not a member of the project.

containsProjectComponent

public boolean containsProjectComponent(ProjectComponent projectComponent)
Tells whether given diagram, element or connection is part of the project.

Parameters:
projectComponent - Project component to be tested for membership.
Returns:
True if the project component belongs to the project, false otherwise.

toString

public String toString()
Overrides:
toString in class Object