kaapo.project
Class Diagram

java.lang.Object
  extended by kaapo.Observable
      extended by kaapo.project.ProjectComponent
          extended by kaapo.project.Diagram
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DataFlowChart, UseCaseDiagram

public abstract class Diagram
extends ProjectComponent
implements Serializable

Diagram is a collection of related elements and connections. This class maintains a list of diagram component wrappers. Diagram is an abstract base class that concrete diagram types (such as UMLClassDiagram) must extend.

Diagram components (instances of Element and Connection) are not added to a diagram as themselves. Rathes, they are wrapped into diagram component wrappers and the wrappers are added to the diagram. This way, a element or connection can belong to several diagrams or even belong to the same diagram several times.

Author:
hkovaska, paltamaa
See Also:
DiagramComponentWrapper, Serialized Form

Nested Class Summary
static class Diagram.ObservableMessage
           
 
Field Summary
protected  Vector<DiagramComponentWrapper> dcwList
           
protected  String name
           
protected  DiagramPanel panel
           
protected  ProjectManager pm
           
 
Fields inherited from class kaapo.project.ProjectComponent
attributeMap, attributePanel
 
Constructor Summary
Diagram()
          Constructs a diagram with null name.
Diagram(String name)
          Constructs a diagram with given name.
 
Method Summary
 void addComponent(DiagramComponentWrapper dcw)
          Adds a diagram component wrapper to the diagram.
 boolean containsDiagramComponent(DiagramComponent diagramComponent)
          Tells whether given diagram component is present in the diagram.
 Vector<DiagramComponentWrapper> getDiagramComponentWrappers()
          Returns the list of DiagramComponentWrappers.
 DiagramPanel getDiagramPanel(ProjectManager pm)
          Gets the diagram panel for this diagram.
abstract  List<Class> getLegalDiagramConnections()
          Returns the list of connection classes that may legally be added to this diagram type.
abstract  List<Class> getLegalDiagramElements()
          Returns the list of element classes that may legally be added to this diagram type.
 String getName()
          Gets the diagram name.
 boolean removeComponent(DiagramComponentWrapper dcw)
          Removes the diagram component wrapper from the diagram.
 void replaceDiagramComponentWrappers(Vector<DiagramComponentWrapper> newList)
          Replaces the current list of DiagramComponentWrappers with another one.
 void setName(String name)
          Sets the diagram name.
 
Methods inherited from class kaapo.project.ProjectComponent
addAttribute, addAttribute, buildAttributePanel, getAttribute, getAttributeMap, getAttributePanel, getSmallIcon, getTypeName, hasAttribute, removeAttribute, setAttribute
 
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, toString, wait, wait, wait
 

Field Detail

dcwList

protected Vector<DiagramComponentWrapper> dcwList

name

protected String name

panel

protected transient DiagramPanel panel

pm

protected transient ProjectManager pm
Constructor Detail

Diagram

public Diagram()
Constructs a diagram with null name.


Diagram

public Diagram(String name)
Constructs a diagram with given name.

Parameters:
name - Diagram name
Method Detail

getLegalDiagramElements

public abstract List<Class> getLegalDiagramElements()
Returns the list of element classes that may legally be added to this diagram type.

Returns:
List of Class objects.

getLegalDiagramConnections

public abstract List<Class> getLegalDiagramConnections()
Returns the list of connection classes that may legally be added to this diagram type.

Returns:
List of Class objects.

getName

public String getName()
Gets the diagram name.

Returns:
The name

setName

public void setName(String name)
Sets the diagram name.

Parameters:
name - The new name.

getDiagramComponentWrappers

public Vector<DiagramComponentWrapper> getDiagramComponentWrappers()
Returns the list of DiagramComponentWrappers.

Returns:
shallow copy of DiagramComponentWrapper-Vector.

replaceDiagramComponentWrappers

public void replaceDiagramComponentWrappers(Vector<DiagramComponentWrapper> newList)
Replaces the current list of DiagramComponentWrappers with another one.

Parameters:
newList - new list of Wrappers.

addComponent

public void addComponent(DiagramComponentWrapper dcw)
                  throws IllegalArgumentException
Adds a diagram component wrapper to the diagram.

Parameters:
dcw - The wrapper to be added
Throws:
IllegalArgumentException - If the wrapper already belongs to the diagram. If you want to add several "instances" of the component, create several wrappers and add them separately.

removeComponent

public boolean removeComponent(DiagramComponentWrapper dcw)
Removes the diagram component wrapper from the diagram. Doesn't remove the diagram component itself from the project.

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

containsDiagramComponent

public boolean containsDiagramComponent(DiagramComponent diagramComponent)
Tells whether given diagram component is present in the diagram. A diagram components is present if the diagram has one or more diagram component wrappers associated to the component.

Parameters:
diagramComponent - The diagram component to be tested
Returns:
True if present, false otherwise

getDiagramPanel

public DiagramPanel getDiagramPanel(ProjectManager pm)
Gets the diagram panel for this diagram. The panel can be added to the GUI.

Parameters:
pm - The project manager that manages this project.
Returns:
Diagram panel