de.frag.umlplugin.uml
Class UMLDiagram

java.lang.Object
  extended by de.frag.umlplugin.uml.UMLDiagram
All Implemented Interfaces:
java.lang.Comparable<UMLDiagram>, java.lang.Iterable<java.lang.String>

public class UMLDiagram
extends java.lang.Object
implements java.lang.Comparable<UMLDiagram>, java.lang.Iterable<java.lang.String>

UML diagram.


Nested Class Summary
static class UMLDiagram.NodeInfo
          Stores additional node information.
 
Field Summary
static java.lang.String DIAGRAM_ELEMENT_NAME
           
static java.lang.String DIAGRAM_NAME_ATTRIBUTE
           
 
Constructor Summary
UMLDiagram(com.intellij.openapi.project.Project project, org.jdom.Element diagramElement)
          Creates a new diagram from given JDOM element
UMLDiagram(com.intellij.openapi.project.Project project, java.lang.String name)
          Creates new UML diagram.
 
Method Summary
 com.intellij.openapi.graph.base.Node addClassNode(com.intellij.psi.PsiClass psiClass)
          Creates a new node for given class and adds it to the diagram.
 void addCommand(DiagramCommand command)
          Adds given command to diagram.
 boolean canStepBack()
          Checks whether a step back in diagram creation history is possible.
 boolean canStepForward()
          Checks whether a step forward in diagram creation history is possible.
 int compareTo(UMLDiagram other)
           
 void createEdge(com.intellij.openapi.graph.base.Node sourceNode, com.intellij.openapi.graph.base.Node targetNode, UsageType usageType)
          Creates a new edge.
 org.jdom.Element createElement()
          Creates JDOM element that contains a persistent description of this diagram.
 void doLayout()
          Recomputes layout of this diagram.
 void doLayout(boolean animate)
          Recomputes layout of this diagram.
 boolean equals(java.lang.Object o)
           
 com.intellij.psi.PsiClass findPsiClass(java.lang.String qualifiedClassName)
          Finds psi class for given qualified class name.
 java.util.List<DiagramCommand> getCommands()
          Gets a copy of the diagram creation command list.
 CompartmentVisibility getCompartmentVisibility()
          Gets compartment visibility handler.
 com.intellij.openapi.graph.base.Edge getEdge(java.lang.String sourceClassName, java.lang.String targetClassName, UsageType usageType)
          Gets edge that belongs to given arguments.
 java.util.List<com.intellij.openapi.graph.base.Edge> getEdges()
          Gets all edges.
 com.intellij.openapi.graph.base.Graph getGraph()
          Gets contained graph.
 java.lang.String getName()
          Gets diagram name.
 com.intellij.openapi.graph.base.Node getNode(com.intellij.psi.PsiClass psiClass)
          Gets node that belongs to given class.
 com.intellij.openapi.graph.base.Node getNode(java.lang.String qualifiedClassName)
          Gets node that belongs to given class name.
static com.intellij.psi.PsiClass getPsiClass(com.intellij.openapi.graph.base.Node node)
          Gets psi class for given node.
static UsageType getUsageType(com.intellij.openapi.graph.base.Edge edge)
          Gets usage type for given edge.
 com.intellij.openapi.graph.view.Graph2DView getView()
          Gets contained graph view.
 int hashCode()
           
 java.util.Iterator<java.lang.String> iterator()
          Returns an iterator over all contained classes.
 void refreshDiagram()
          Refreshes the diagram by excuting all commands.
 void removeClassNode(com.intellij.openapi.graph.base.Node classNode)
          Removes given class node from diagram.
 void removeEdge(com.intellij.openapi.graph.base.Edge edge)
          Removes given edge from diagram.
 void renameClasses(ClassRenamer renamer)
          Rename all classes in all commands to keep class names in sync after refactorings were applied.
 void rewindAllCommands()
          Steps back to start of diagram command history.
 void setCommands(java.util.List<DiagramCommand> commands)
          Sets the command history to given command list.
 void setName(java.lang.String name)
          Sets name of this diagram.
 void stepBack()
          Steps back in diagram creation by removing last command.
 void stepForward()
          Steps forward in diagram creation by reappending last command.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DIAGRAM_ELEMENT_NAME

public static final java.lang.String DIAGRAM_ELEMENT_NAME
See Also:
Constant Field Values

DIAGRAM_NAME_ATTRIBUTE

public static final java.lang.String DIAGRAM_NAME_ATTRIBUTE
See Also:
Constant Field Values
Constructor Detail

UMLDiagram

public UMLDiagram(@NotNull
                  com.intellij.openapi.project.Project project,
                  @NotNull
                  java.lang.String name)
Creates new UML diagram.

Parameters:
project - associated project
name - diagram name

UMLDiagram

public UMLDiagram(@NotNull
                  com.intellij.openapi.project.Project project,
                  @NotNull
                  org.jdom.Element diagramElement)
Creates a new diagram from given JDOM element

Parameters:
project - current project
diagramElement - JDOM element that contains persistent information about diagram
Method Detail

getCommands

@NotNull
public java.util.List<DiagramCommand> getCommands()
Gets a copy of the diagram creation command list.

Returns:
flat copy of diagram creation command list

setCommands

public void setCommands(@NotNull
                        java.util.List<DiagramCommand> commands)
Sets the command history to given command list.

Parameters:
commands - list of commands to use as history

getName

@NotNull
public java.lang.String getName()
Gets diagram name.

Returns:
diagram name

setName

public void setName(@NotNull
                    java.lang.String name)
Sets name of this diagram.

Parameters:
name - new diagram name

getGraph

@NotNull
public com.intellij.openapi.graph.base.Graph getGraph()
Gets contained graph.

Returns:
contained graph

getView

@NotNull
public com.intellij.openapi.graph.view.Graph2DView getView()
Gets contained graph view.

Returns:
contained graph view

getCompartmentVisibility

@NotNull
public CompartmentVisibility getCompartmentVisibility()
Gets compartment visibility handler.

Returns:
compartment visibility handler

addCommand

public void addCommand(@NotNull
                       DiagramCommand command)
Adds given command to diagram.

Parameters:
command - command to add

rewindAllCommands

public void rewindAllCommands()
Steps back to start of diagram command history.


stepBack

public void stepBack()
Steps back in diagram creation by removing last command.


stepForward

public void stepForward()
Steps forward in diagram creation by reappending last command.


canStepBack

public boolean canStepBack()
Checks whether a step back in diagram creation history is possible.

Returns:
true, if a step back is possible; false otherwise

canStepForward

public boolean canStepForward()
Checks whether a step forward in diagram creation history is possible.

Returns:
true, if a step forward is possible; false otherwise

refreshDiagram

public void refreshDiagram()
Refreshes the diagram by excuting all commands.


doLayout

public void doLayout()
Recomputes layout of this diagram.


doLayout

public void doLayout(boolean animate)
Recomputes layout of this diagram.

Parameters:
animate - true, if layout ill be animated; false otherwise

addClassNode

@Nullable
public com.intellij.openapi.graph.base.Node addClassNode(@Nullable
                                                                  com.intellij.psi.PsiClass psiClass)
Creates a new node for given class and adds it to the diagram.

Parameters:
psiClass - class to create node for
Returns:
created node

removeClassNode

public void removeClassNode(@NotNull
                            com.intellij.openapi.graph.base.Node classNode)
Removes given class node from diagram.

Parameters:
classNode - node to remove

createEdge

public void createEdge(@Nullable
                       com.intellij.openapi.graph.base.Node sourceNode,
                       @Nullable
                       com.intellij.openapi.graph.base.Node targetNode,
                       @NotNull
                       UsageType usageType)
Creates a new edge.

Parameters:
sourceNode - source node
targetNode - target node
usageType - usage type for edge

removeEdge

public void removeEdge(@Nullable
                       com.intellij.openapi.graph.base.Edge edge)
Removes given edge from diagram.

Parameters:
edge - edge to remove

getNode

@Nullable
public com.intellij.openapi.graph.base.Node getNode(@NotNull
                                                             com.intellij.psi.PsiClass psiClass)
Gets node that belongs to given class.

Parameters:
psiClass - class
Returns:
node that belongs to given class or null, if no node belongs to class

getNode

@Nullable
public com.intellij.openapi.graph.base.Node getNode(@NotNull
                                                             java.lang.String qualifiedClassName)
Gets node that belongs to given class name.

Parameters:
qualifiedClassName - class name
Returns:
node that belongs to given class name or null, if no node belongs to class name

getEdge

@Nullable
public com.intellij.openapi.graph.base.Edge getEdge(@NotNull
                                                             java.lang.String sourceClassName,
                                                             @NotNull
                                                             java.lang.String targetClassName,
                                                             @NotNull
                                                             UsageType usageType)
Gets edge that belongs to given arguments.

Parameters:
sourceClassName - source class of edge
targetClassName - target class of edge
usageType - usage type of edge
Returns:
found edge or null, if edge could not be found

getEdges

@NotNull
public java.util.List<com.intellij.openapi.graph.base.Edge> getEdges()
Gets all edges.

Returns:
list of all edges

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getPsiClass

@Nullable
public static com.intellij.psi.PsiClass getPsiClass(@NotNull
                                                             com.intellij.openapi.graph.base.Node node)
Gets psi class for given node.

Parameters:
node - node to get class for
Returns:
found class or null, if no class could be found

getUsageType

@Nullable
public static UsageType getUsageType(@NotNull
                                              com.intellij.openapi.graph.base.Edge edge)
Gets usage type for given edge.

Parameters:
edge - edge to get usage type for
Returns:
found usage type or null, if no usage type could be found

findPsiClass

@Nullable
public com.intellij.psi.PsiClass findPsiClass(@NotNull
                                                       java.lang.String qualifiedClassName)
Finds psi class for given qualified class name.

Parameters:
qualifiedClassName - qualified class name
Returns:
found psi class or null, if no psi class with given qualified name could be found

equals

public boolean equals(@Nullable
                      java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(@NotNull
                     UMLDiagram other)
Specified by:
compareTo in interface java.lang.Comparable<UMLDiagram>

createElement

@NotNull
public org.jdom.Element createElement()
Creates JDOM element that contains a persistent description of this diagram.

Returns:
created JDOM element

iterator

@NotNull
public java.util.Iterator<java.lang.String> iterator()
Returns an iterator over all contained classes.

Specified by:
iterator in interface java.lang.Iterable<java.lang.String>
Returns:
iterator that iterates over all contained classes.

renameClasses

public void renameClasses(@NotNull
                          ClassRenamer renamer)
Rename all classes in all commands to keep class names in sync after refactorings were applied.

Parameters:
renamer - renamer to use for renaming class names