net.sf.sdedit.drawable
Class Fragment

java.lang.Object
  extended by net.sf.sdedit.drawable.Drawable
      extended by net.sf.sdedit.drawable.Fragment
All Implemented Interfaces:
Constants

public class Fragment
extends Drawable

A Fragment consists of a sequence of messages occuring in a diagram. It appears as a frame surrounding all of the messages. A fragment has a type, appearing in the top-left corner of the frame and a text, commonly interpreted as a condition. It appears in square brackets. Fragments can have sections, separated by dashed lines. Each section has its own condition text.

Author:
Markus Strauch

Field Summary
 
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
Fragment(String type, String condition, Diagram diagram)
          Creates a new Fragment.
 
Method Summary
 void addElement(SequenceElement element)
          Adds a sequence element that is a member of this fragment.
 void addSection(String sectionCondition)
          Adds a section to this fragment with its own condition.
 void computeLayoutInformation()
          This method is called when and if the left and top positions of the drawable components of a sequence diagram are fixed.
 boolean containsElement(SequenceElement element)
          Returns true if the given sequence element is a member of this fragment.
 void draw(Graphics2D g2d)
          Draws the sequence diagram element into the given Graphics2D context, using the rectangle starting at Drawable.getTop(), Drawable.getLeft(), sized Drawable.getHeight(), Drawable.getWidth().
 String getCondition()
          Returns the condition of this fragment (to be precise, of the first section of the fragment).
 int getLabelHeight()
          Computes the height of the label of the fragment.
 void setLevel(int level)
          Sets the level of this fragment (the number of fragments that this fragment is a part of) to the maximum of the current level and the given one.
 
Methods inherited from class net.sf.sdedit.drawable.Drawable
contains, drawMultilineString, getBottom, getHeight, getLeft, getRight, getTop, getWidth, intersects, isVisible, setBottom, setHeight, setLeft, setRight, setTop, setVisible, setWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Fragment

public Fragment(String type,
                String condition,
                Diagram diagram)
Creates a new Fragment. If type is empty, the condition appears in the top-left corner of the fragment, so it should rather be interpreted as a comment on the elements inside the fragment frame.

Parameters:
type - the type of the fragment, for example "alt", "opt" or "loop"
condition - the condition of the fragment
diagram - the diagram of which the fragment is a part
Method Detail

setLevel

public void setLevel(int level)
Sets the level of this fragment (the number of fragments that this fragment is a part of) to the maximum of the current level and the given one.

Parameters:
level - the new level of this fragment, if it does not already have a higher one

getCondition

public String getCondition()
Returns the condition of this fragment (to be precise, of the first section of the fragment).

Returns:
the condition of this fragment

addElement

public void addElement(SequenceElement element)
Adds a sequence element that is a member of this fragment.

Parameters:
element - a member of this fragment

addSection

public void addSection(String sectionCondition)
Adds a section to this fragment with its own condition. It will be represented by a dashed line appearing at the current vertical position.

Parameters:
sectionCondition - the condition of the section, appearing in square brackets below the dashed line

containsElement

public boolean containsElement(SequenceElement element)
Returns true if the given sequence element is a member of this fragment.

Parameters:
element - a sequence element
Returns:
true if the element is a member of this fragment

computeLayoutInformation

public void computeLayoutInformation()
Description copied from class: Drawable
This method is called when and if the left and top positions of the drawable components of a sequence diagram are fixed. Its purpose is to use this information to compute even finer layout information, such as the width of the component.

Specified by:
computeLayoutInformation in class Drawable
See Also:
Drawable.computeLayoutInformation()

getLabelHeight

public int getLabelHeight()
Computes the height of the label of the fragment.

Returns:
the height of the label of the fragment

draw

public void draw(Graphics2D g2d)
Description copied from class: Drawable
Draws the sequence diagram element into the given Graphics2D context, using the rectangle starting at Drawable.getTop(), Drawable.getLeft(), sized Drawable.getHeight(), Drawable.getWidth().

Specified by:
draw in class Drawable
Parameters:
g2d - the Graphics2D context to draw this drawable sequence diagram element into
See Also:
Drawable.draw(java.awt.Graphics2D)


Copyright © 2011. All Rights Reserved.