net.sf.sdedit.diagram
Class Diagram

java.lang.Object
  extended by net.sf.sdedit.diagram.Diagram
All Implemented Interfaces:
Constants

public final class Diagram
extends Object
implements Constants

This class encapsulates the data for and the process of the generation of a sequence diagram. That process consists - roughly spoken - of these steps:

  1. Read object specifications and create lifelines for them
  2. For each message specification:
    1. Find the lifeline objects that correspond to the sender and the receiver of the message.
    2. If activating the sender implies sending answers, send these answers (which are taken from the answer message stack), so create arrows for them and add them to the PaintDevice. This is applied to all of the answers that lie above the answer with the sender as a receiver.
    3. Create a message object representing the message
    4. Add a message arrow to the PaintDevice
    5. Get the corresponding answer message and push it onto the answer message stack
  3. Pop all remaining answers from the stack and draw the arrows
When that process has finished, the image of the diagram display can be shown on the user interface.

Author:
Markus Strauch

Field Summary
 int arrowSize
           
 int mainLifelineWidth
           
 int messageLabelSpace
           
 int messagePadding
           
 boolean returnArrowVisible
           
 int subLifelineWidth
           
 Color[] threadColors
           
 
Fields inherited from interface net.sf.sdedit.Constants
ACTIVE_LIFELINE_COLOR, ANTI_ALIAS, dashed, DEFAULT_CODE_FONT, DEFAULT_CURSOR, DEFAULT_ENCODING_SCHEME, dotted, emptyStroke, GLOBAL_CONF_FILE, HAND_CURSOR, MOVE_CURSOR, SAVE_AS_FILE_PROPERTY, SAVE_AS_TYPE_PROPERTY, solid, TEST_FREEHEP_CLASSNAME, thick, thick_dashed, THREAD_COLORS
 
Constructor Summary
Diagram(Configuration configuration, DiagramDataProvider provider, PaintDevice paintDevice)
          Creates a new diagram that is to be generated based on the data delivered by the given DiagramDataProvider.
 
Method Summary
 void associateLifeline(String lifelineName, String mnemonic, Lifeline lifeline)
           
 void associateMessage(int number, Message msg)
           
 void clearMnemonic(Lifeline lifeline)
           
 void extendLifelines(int amount)
           
 void finish()
          All pending answers are sent back to the callers, all lifelines become inactive.
 void generate()
          Generates the diagram, based on the data of the DiagramDataProvider passed to the constructor.
 Collection<Lifeline> getAllLifelines()
          Returns a collection of all lifelines, whether visible or not, and whether already destroyed or not.
 int getCallerThread()
           
 Configuration getConfiguration()
          Returns the diagram configuration
 DiagramDataProvider getDataProvider()
          Returns the text handler that reads the text line by line and creates objects and message data from them.
 Drawable getDrawableForState(Object state)
           
 FragmentManager getFragmentManager()
           
 Lifeline getLifeline(String name)
           
 Lifeline getLifelineAt(int position)
           
 Lifeline getLifelineByMnemonic(String lifelineName, String mnemonic)
           
 Collection<Lifeline> getLifelines()
          Returns a collection of the (not yet destroyed) lifelines appearing in the diagram.
 int getNextFreeNoteNumber()
           
 int getNumberOfLifelines()
           
 int getNumberOfThreads()
           
 PaintDevice getPaintDevice()
           
 Object getStateForDrawable(Drawable drawable)
          Returns the state, represented by an Object, the DiagramDataProvider used by this Diagram was in when the data from which the given Drawable object has been created, was read.
 int getVerticalPosition()
           
 boolean isFinished()
           
 boolean isThreaded()
           
 void removeLifeline(String name)
          Removes a lifeline, denoted by its name, from the diagram, including all of its sub lifelines.
 void sendAnswer(Message answer)
           
 void sendAnswer(Message answer, boolean removeFromStack)
           
 void setCallerThread(int callerThread)
           
 void toggleWaitingStatus(int thread)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

arrowSize

public final int arrowSize

messagePadding

public final int messagePadding

subLifelineWidth

public final int subLifelineWidth

mainLifelineWidth

public final int mainLifelineWidth

messageLabelSpace

public final int messageLabelSpace

returnArrowVisible

public final boolean returnArrowVisible

threadColors

public final Color[] threadColors
Constructor Detail

Diagram

public Diagram(Configuration configuration,
               DiagramDataProvider provider,
               PaintDevice paintDevice)
Creates a new diagram that is to be generated based on the data delivered by the given DiagramDataProvider.

Parameters:
configuration - the configuration of the diagram
provider - for reading the object and message specifications
paintDevice - for storing and drawing the boxes, arrows etc.
Method Detail

generate

public void generate()
              throws SemanticError,
                     SyntaxError
Generates the diagram, based on the data of the DiagramDataProvider passed to the constructor.

Throws:
SyntaxError - if a message or object specification is syntactically wrong
SemanticError - if a message or object specification is semantically wrong

isFinished

public final boolean isFinished()

getNextFreeNoteNumber

public int getNextFreeNoteNumber()

getFragmentManager

public FragmentManager getFragmentManager()

getStateForDrawable

public Object getStateForDrawable(Drawable drawable)
Returns the state, represented by an Object, the DiagramDataProvider used by this Diagram was in when the data from which the given Drawable object has been created, was read.

Parameters:
drawable - a drawable corresponding to some data
Returns:
the state the DiagramDataProvider was in when the data has been provided

getDrawableForState

public Drawable getDrawableForState(Object state)

extendLifelines

public final void extendLifelines(int amount)

isThreaded

public boolean isThreaded()

getCallerThread

public int getCallerThread()

setCallerThread

public void setCallerThread(int callerThread)

getPaintDevice

public PaintDevice getPaintDevice()

getDataProvider

public DiagramDataProvider getDataProvider()
Returns the text handler that reads the text line by line and creates objects and message data from them.

Returns:
the text handler that reads the text line by line and creates messages and objects from them

getConfiguration

public Configuration getConfiguration()
Returns the diagram configuration

Returns:
the diagram configuration

getLifelines

public Collection<Lifeline> getLifelines()
Returns a collection of the (not yet destroyed) lifelines appearing in the diagram.

Returns:
a collection of the (not yet destroyed) lifelines appearing in the diagram

getAllLifelines

public Collection<Lifeline> getAllLifelines()
Returns a collection of all lifelines, whether visible or not, and whether already destroyed or not.

Returns:
a collection of all lifelines, whether visible or not, and whether already destroyed or not

removeLifeline

public void removeLifeline(String name)
Removes a lifeline, denoted by its name, from the diagram, including all of its sub lifelines.

Parameters:
name - the name of the object of which the lifeline is to be removed

sendAnswer

public void sendAnswer(Message answer)

sendAnswer

public void sendAnswer(Message answer,
                       boolean removeFromStack)

finish

public void finish()
All pending answers are sent back to the callers, all lifelines become inactive.


getLifelineAt

public Lifeline getLifelineAt(int position)

getLifeline

public Lifeline getLifeline(String name)

getNumberOfLifelines

public int getNumberOfLifelines()

getVerticalPosition

public int getVerticalPosition()

getNumberOfThreads

public int getNumberOfThreads()

getLifelineByMnemonic

public Lifeline getLifelineByMnemonic(String lifelineName,
                                      String mnemonic)

associateLifeline

public void associateLifeline(String lifelineName,
                              String mnemonic,
                              Lifeline lifeline)
                       throws SemanticError
Throws:
SemanticError

associateMessage

public void associateMessage(int number,
                             Message msg)

clearMnemonic

public void clearMnemonic(Lifeline lifeline)

toggleWaitingStatus

public void toggleWaitingStatus(int thread)


Copyright © 2011. All Rights Reserved.