org.argouml.uml.diagram.sequence.ui
Class FigObject

java.lang.Object
  extended byorg.tigris.gef.presentation.Fig
      extended byorg.tigris.gef.presentation.FigGroup
          extended byorg.tigris.gef.presentation.FigNode
              extended byorg.argouml.uml.diagram.ui.FigNodeModelElement
                  extended byorg.argouml.uml.diagram.sequence.ui.FigObject
All Implemented Interfaces:
ArgoEventListener, ArgoNotationEventListener, java.lang.Cloneable, DelayedVChangeListener, java.util.EventListener, org.tigris.gef.ui.Highlightable, java.awt.event.KeyListener, ru.novosoft.uml.MElementListener, java.awt.event.MouseListener, NotationContext, org.tigris.gef.ui.PopupGenerator, java.beans.PropertyChangeListener, java.io.Serializable, java.beans.VetoableChangeListener

public class FigObject
extends FigNodeModelElement
implements java.awt.event.MouseListener

Fig to show an object on a sequence diagram. The fig consists of an upper box that shows the name of the object (the owner) and a lifeline. The lifeline consists of lifeline elements. An element can be a dashed line (no link attached) or a rectangle (link attached).

See Also:
Serialized Form

Field Summary
private  org.tigris.gef.presentation.FigRect _backgroundBox
          The filled box for the object box (object fig without lifeline).
private  java.lang.String _baseNames
          The comma seperated list of base names of the classifierRole(s) that this object represents.
private  java.lang.String _classifierRoleNames
          The comma seperated list of names of the classifierRole(s) that this object represents.
private  java.util.List _figActivations
          The list where the figrects are stored that are the activation boxes.
private  java.util.List _figFigLinkPorts
          The list with the figLinkPorts.
private  org.tigris.gef.presentation.FigLine _lifeLine
          The lifeline (dashed line under the object box to which activations are attached)
private  LifeLinePort _lifeLinePort
          The owner of the lifeline.
private  java.util.List _linkPositions
          The list where the nodes to which links can be attached are stored
private  java.lang.String _objectName
          The name of the object (the owner of this fig).
private  org.tigris.gef.presentation.FigRect _outerBox
          The outer black rectangle of the object box (object fig without lifeline).
static int DEFAULT_HEIGHT
          The defaultheight of the object rectangle.
static int DEFAULT_WIDTH
          The defaultwidth of the object rectangle
static int MARGIN
          The margin between the outer box and the name and stereotype text box.
static int ROWDISTANCE
          The distance between two rows in the object rectangle.
static int WIDTH
          The width of an activation box
 
Fields inherited from class org.argouml.uml.diagram.ui.FigNodeModelElement
_bigPort, _enclosedFigs, _encloser, _name, _readyToEdit, _shadowSize, _stereo, BUNDLE, checkSize, ITALIC_LABEL_FONT, LABEL_FONT, POPUP_ADD_OFFSET, ROWHEIGHT, SHADOW_COLOR_ALPHA, SHADOW_COLOR_VALUE, STEREOHEIGHT, suppressCalcBounds
 
Fields inherited from class org.tigris.gef.presentation.FigNode
_blinkPorts, _figEdges, _highlight, ang135, ang225, ang315, ang45
 
Fields inherited from class org.tigris.gef.presentation.FigGroup
_dynObjects, _extraFrameSpace
 
Fields inherited from class org.tigris.gef.presentation.Fig
_allowsSaving, _context, _dashes, _displayed, _fillColor, _filled, _g2dashes, _group, _h, _layer, _lineColor, _lineWidth, _locked, _resource, _selected, _shown, _w, _x, _y, an, annotationOwner, annotationStatus, BORDER, DASH_ARRAYS, DASHED_CHOICES, MIN_SIZE
 
Constructor Summary
FigObject()
          Default constructor.
FigObject(java.lang.Object node)
           
 
Method Summary
private  void addActivations()
           
 void addNode(int position, Node node)
           
 void calcBounds()
           
private  void center(org.tigris.gef.presentation.FigText figText)
           
 java.lang.Object deepHitPort(int x, int y)
          Returns the port for a given coordinate pair.
 java.util.List getActivationNodes(Node node)
          Returns a list with all nodes that belong to the same activation as the given node.
private  java.lang.String getBeautifiedName(java.lang.Object o)
          Returns a beautified name to show in the name text box.
 FigLink getFigLink(FigLinkPort portFig)
          Gets the FigLink that is attached to the given FigLinkPort.
 java.awt.Color getFillColor()
           
 boolean getFilled()
           
 int getIndexOf(Node node)
          Returns the index of a given node.
 org.tigris.gef.presentation.FigLine getLifeLine()
           
 java.awt.Color getLineColor()
           
 int getLineWidth()
           
 ObjectNode getObjectNode()
          Returns the ObjectNode.
 org.tigris.gef.presentation.Fig getPortFig(java.lang.Object np)
           
 java.util.List getPreviousActivation(Node node)
          Returns a list with the start, end and all nodes in between them of the activation that is prior to the given node.
private  int getYCoordinate(Node node)
           
private  int getYCoordinateForActivationBox(Node node, boolean start)
           
 boolean hasActivations()
          Returns true if this FigObject has activations.
 void makeActivation(int startIndex, int endIndex)
          Makes an activation from the node with index startindex to the node with index endindex.
 void makeActivation(Node startNode, Node endNode)
          See makeActivation(int startIndex, int endIndex)
protected  void modelChanged(ru.novosoft.uml.MElementEvent mee)
          This is called aftern any part of the UML MModelElement has changed.
 void mouseReleased(java.awt.event.MouseEvent me)
          When the mouse button is released, this fig will be moved into position
 Node nextNode(Node node)
          Returns the node that's next to the given node.
 Node previousNode(Node node)
          Returns the node that's before the given node in the nodes list.
private  void removeActivations()
           
 void removeFig(org.tigris.gef.presentation.Fig f)
          Removes the fig from both the figs list as from the _figActivations list and the _figLinkPorts.
 void renderingChanged()
          Rerenders the fig if needed.
private  void reSize(org.tigris.gef.presentation.Fig f, int x, int y, int w, int h)
          Scales the given fig that must be part of this FigObject.
 void setBounds(int x, int y, int w, int h)
          Sets the bounds and coordinates of this Fig.
 void setFillColor(java.awt.Color col)
           
 void setFilled(boolean filled)
           
 void setLineWidth(int w)
          Changing the line width should only change the line width of the outerbox and the lifeline.
 void setNode(int index, Node node)
          Sets the given node on the given index in linkPositions.
 void setOwner(java.lang.Object own)
           
 void updateActivations()
          First removes all current activation boxes, then add new ones to the figobject depending on the state of the nodes.
private  void updateBaseNames()
           
protected  void updateBounds()
          The width of the FigObject should be equal to the width of the name or stereo text box.
private  void updateClassifierRoleNames()
           
protected  void updateListeners(java.lang.Object newOwner)
          Implementations of this method should register/unregister the fig for all (model)events.
protected  void updateNameText()
          Constructs the contents of the name text box and upates the name text box accordingly.
private  void updateObjectName()
           
protected  void updateStereotypeText()
          Updates the text of the sterotype FigText.
 
Methods inherited from class org.argouml.uml.diagram.ui.FigNodeModelElement
addFig, createFeatureIn, damage, delayedVetoableChange, delete, dispose, elementOrdering, enableSizeChecking, finalize, getContextNotation, getEnclosedFigs, getEnclosingFig, getItemUID, getName, getNameFig, getPopUpActions, getShadowSize, getStereotype, getStereotypeFig, getTipString, getUpdatedSize, hit, hitClarifier, isPartlyOwner, isPartlyOwner, keyPressed, keyReleased, keyTyped, listRoleItemSet, makeSelection, mouseClicked, notationAdded, notationChanged, notationProviderAdded, notationProviderRemoved, notationRemoved, paint, paintClarifiers, placeString, postLoad, propertyChange, propertySet, recovered, removed, roleAdded, roleRemoved, setEnclosingFig, setHandleBox, setItemUID, setName, setNameFig, setShadowSize, setStereotype, setStereotypeFig, superTranslate, textEdited, vetoableChange
 
Methods inherited from class org.tigris.gef.presentation.FigNode
addFigEdge, bindPort, cleanUp, clone, contains, endTrans, getBlinkPorts, getFigEdges, getHighlight, getPortFigs, getPortFigs, getPortSector, hidePorts, hitPort, hitPort, isBlinkPorts, isDragConnectable, mouseEntered, mouseExited, mousePressed, removeFigEdge, removePort, setBlinkPorts, setHighlight, showPorts, translate, updateEdges
 
Methods inherited from class org.tigris.gef.presentation.FigGroup
addFigs, deepSelect, elements, getDisplayedFigs, getExtraFrameSpace, getFigAt, getFigs, getFigs, getFont, getFontFamily, getFontSize, getPrivateData, getSize, getSubFigBounds, getTextColor, getTextFillColor, getTextFilled, hitFig, isReshapable, isRotatable, iterator, parseDynObjects, removeAll, setExtraFrameSpace, setFigs, setFigs, setFont, setFontFamily, setFontSize, setLineColor, setPrivateData, setTextColor, setTextFillColor, setTextFilled
 
Methods inherited from class org.tigris.gef.presentation.Fig
addAnnotation, addPoint, addPropertyChangeListener, align, center, classNameAndBounds, connectionPoint, contains, contains, countCornersContained, createDrag, drawDashedLine, drawDashedPerimeter, firePropChange, firePropChange, firePropChange, getAnnotationOwner, getAnnotationStrategy, getBounds, getBounds, getClosestPoint, getContext, getDashed, getDashed01, getDashedString, getFilled01, getFirstPoint, getGravityPoints, getGroup, getHalfHeight, getHalfWidth, getHandleBox, getHeight, getId, getLastPoint, getLayer, getLocation, getLocked, getMinimumSize, getNumPoints, getOwner, getPerimeterLength, getPoints, getPoints, getPreferedSize, getResource, getSingle, getTrapRect, getUseTrapRect, getVisState, getWidth, getX, getXs, getY, getYs, hasFillColor, hasLineColor, initAnnotations, insertPoint, intersects, intersectsPerimeter, isAnnotation, isCopieable, isCopyable, isCutable, isDisplayed, isFactoryConstructed, isLowerRightResizable, isMovable, isResizable, isSelected, isVisible, OK, pointAlongPerimeter, postSave, preSave, print, redraw, removeAnnotation, removeAnnotation, removePoint, removePropertyChangeListener, reorder, routingRect, savingAllowed, setAnnotationOwner, setAnnotationStatus, setAnnotationStrategy, setBounds, setCenter, setContext, setDashed, setDashedString, setDisplayed, setGroup, setHeight, setLayer, setLocation, setLocation, setLocked, setMovable, setNumPoints, setPoints, setPoints, setPoints, setPoints, setPoints, setResizable, setResource, setSavingAllowed, setSelected, setSingle, setSize, setSize, setVisible, setVisState, setWidth, setX, setXs, setY, setYs, stuffBounds, stuffPointAlongPerimeter, translateAnnotations, unsetAnnotationOwner, updateAnnotationPositions, updateVisState, within
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.awt.event.MouseListener
mouseClicked, mouseEntered, mouseExited, mousePressed
 
Methods inherited from interface org.tigris.gef.ui.Highlightable
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

WIDTH

public static final int WIDTH
The width of an activation box

See Also:
Constant Field Values

MARGIN

public static final int MARGIN
The margin between the outer box and the name and stereotype text box.

See Also:
Constant Field Values

ROWDISTANCE

public static final int ROWDISTANCE
The distance between two rows in the object rectangle.

See Also:
Constant Field Values

DEFAULT_HEIGHT

public static final int DEFAULT_HEIGHT
The defaultheight of the object rectangle. That's 3 times the rowheight + 3 times a distance of 2 between the rows + the stereoheight.

See Also:
Constant Field Values

DEFAULT_WIDTH

public static final int DEFAULT_WIDTH
The defaultwidth of the object rectangle

See Also:
Constant Field Values

_outerBox

private org.tigris.gef.presentation.FigRect _outerBox
The outer black rectangle of the object box (object fig without lifeline).


_backgroundBox

private org.tigris.gef.presentation.FigRect _backgroundBox
The filled box for the object box (object fig without lifeline).


_lifeLine

private org.tigris.gef.presentation.FigLine _lifeLine
The lifeline (dashed line under the object box to which activations are attached)


_lifeLinePort

private LifeLinePort _lifeLinePort
The owner of the lifeline.


_linkPositions

private java.util.List _linkPositions
The list where the nodes to which links can be attached are stored


_figActivations

private java.util.List _figActivations
The list where the figrects are stored that are the activation boxes. The list is only here for performance issues. When removing a figrect, it should also be removed from this list, not only from the figs list.


_figFigLinkPorts

private java.util.List _figFigLinkPorts
The list with the figLinkPorts. The list is only here for performance issues. When deleting a figLinkPort, it should also be removed from this list, not only from the figs list.


_baseNames

private java.lang.String _baseNames
The comma seperated list of base names of the classifierRole(s) that this object represents.


_classifierRoleNames

private java.lang.String _classifierRoleNames
The comma seperated list of names of the classifierRole(s) that this object represents.


_objectName

private java.lang.String _objectName
The name of the object (the owner of this fig).

Constructor Detail

FigObject

public FigObject()
Default constructor. Constructs the object rectangle, the lifeline, the name box and the stereotype box.


FigObject

public FigObject(java.lang.Object node)
Parameters:
node -
Method Detail

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent me)
When the mouse button is released, this fig will be moved into position

Specified by:
mouseReleased in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseReleased(MouseEvent)

updateNameText

protected void updateNameText()
Constructs the contents of the name text box and upates the name text box accordingly. The contents of the name text box itself are NOT updated.

Overrides:
updateNameText in class FigNodeModelElement
See Also:
FigNodeModelElement.updateNameText()

updateStereotypeText

protected void updateStereotypeText()
Description copied from class: FigNodeModelElement
Updates the text of the sterotype FigText. Override in subclasses to get wanted behaviour. TODO: remove all 'misuses' of the stereotype figtexts (like in FigInterface)

Overrides:
updateStereotypeText in class FigNodeModelElement
See Also:
FigNodeModelElement.updateStereotypeText()

center

private void center(org.tigris.gef.presentation.FigText figText)

setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)
Sets the bounds and coordinates of this Fig. The outerbox (the black box around the upper box) and the background box (the white box at the background) are scaled to the given size. The name text box and the stereo text box are moved to a correct position.

See Also:
Fig.setBounds(int, int, int, int)

reSize

private void reSize(org.tigris.gef.presentation.Fig f,
                    int x,
                    int y,
                    int w,
                    int h)
Scales the given fig that must be part of this FigObject.

Parameters:
f - the fig to scale
x - the new x coordinate for the FigObject
y - the new y coordinate for the FigObject
w - the new w coordinate for the FigObject
h - the new h coordinate for the FigObject

getBeautifiedName

private java.lang.String getBeautifiedName(java.lang.Object o)
Returns a beautified name to show in the name text box.

Parameters:
o - is the object
Returns:
a name

calcBounds

public void calcBounds()
Overrides:
calcBounds in class FigNodeModelElement
See Also:
Fig.calcBounds(), FigNodeModelElement.calcBounds()

removeActivations

private void removeActivations()

addActivations

private void addActivations()

updateActivations

public void updateActivations()
First removes all current activation boxes, then add new ones to the figobject depending on the state of the nodes.


updateBounds

protected void updateBounds()
The width of the FigObject should be equal to the width of the name or stereo text box.

Overrides:
updateBounds in class FigNodeModelElement
See Also:
FigNodeModelElement.updateBounds()

setLineWidth

public void setLineWidth(int w)
Changing the line width should only change the line width of the outerbox and the lifeline. 0 Values are ignored.

See Also:
Fig.setLineWidth(int)

setFillColor

public void setFillColor(java.awt.Color col)
See Also:
Fig.setFillColor(java.awt.Color)

setFilled

public void setFilled(boolean filled)
See Also:
Fig.setFilled(boolean)

getFillColor

public java.awt.Color getFillColor()
See Also:
Fig.getFillColor()

getFilled

public boolean getFilled()
See Also:
Fig.getFilled()

getLineColor

public java.awt.Color getLineColor()
See Also:
Fig.getLineColor()

getLineWidth

public int getLineWidth()
See Also:
Fig.getLineWidth()

updateListeners

protected void updateListeners(java.lang.Object newOwner)
Description copied from class: FigNodeModelElement
Implementations of this method should register/unregister the fig for all (model)events. For FigNodeModelElement only the fig itself is registred as listening to events fired by the owner itself. But for, for example, FigClass the fig must also register for events fired by the operations and attributes of the owner.

Overrides:
updateListeners in class FigNodeModelElement
Parameters:
newOwner -
See Also:
FigNodeModelElement.updateListeners(java.lang.Object)

modelChanged

protected void modelChanged(ru.novosoft.uml.MElementEvent mee)
Description copied from class: FigNodeModelElement
This is called aftern any part of the UML MModelElement has changed. This method automatically updates the name FigText. Subclasses should override and update other parts.

Overrides:
modelChanged in class FigNodeModelElement
See Also:
FigNodeModelElement.modelChanged(MElementEvent)

updateClassifierRoleNames

private void updateClassifierRoleNames()

updateBaseNames

private void updateBaseNames()

updateObjectName

private void updateObjectName()

renderingChanged

public void renderingChanged()
Description copied from class: FigNodeModelElement
Rerenders the fig if needed. This functionality was originally the functionality of modelChanged but modelChanged takes the event now into account.

Overrides:
renderingChanged in class FigNodeModelElement
See Also:
FigNodeModelElement.renderingChanged()

deepHitPort

public java.lang.Object deepHitPort(int x,
                                    int y)
Returns the port for a given coordinate pair. Normally deepHitPort returns the owner of the fig in the FigGroup that is present at the given coordinate pair (returning figs that are added later first). In this case it returns a LinkPort.

This method has a side effect of creating a FigLinkPort if ???

See Also:
FigNode.deepHitPort(int, int)

getYCoordinate

private int getYCoordinate(Node node)

getYCoordinateForActivationBox

private int getYCoordinateForActivationBox(Node node,
                                           boolean start)

setOwner

public void setOwner(java.lang.Object own)
Overrides:
setOwner in class FigNodeModelElement
See Also:
Fig.setOwner(java.lang.Object)

getFigLink

public FigLink getFigLink(FigLinkPort portFig)
Gets the FigLink that is attached to the given FigLinkPort.

Parameters:
portFig -
Returns:
the FigLink that is attached.

getLifeLine

public org.tigris.gef.presentation.FigLine getLifeLine()

getActivationNodes

public java.util.List getActivationNodes(Node node)
Returns a list with all nodes that belong to the same activation as the given node.

TODO: Does not work for EmptyNode atm.

Parameters:
node - is the given node
Returns:
a List

getIndexOf

public int getIndexOf(Node node)
Returns the index of a given node.

Parameters:
node - is the given node
Returns:
the index

makeActivation

public void makeActivation(Node startNode,
                           Node endNode)
See makeActivation(int startIndex, int endIndex)

Parameters:
startNode -
endNode -

makeActivation

public void makeActivation(int startIndex,
                           int endIndex)
Makes an activation from the node with index startindex to the node with index endindex. An activation means in this context that the starting and ending node will be an activation node after a call to this method. The starting node is designated via the start property that's a starting node. The same is true for the ending node via the end property.

Parameters:
startIndex -
endIndex -

nextNode

public Node nextNode(Node node)
Returns the node that's next to the given node.

Parameters:
node - is the given node
Returns:
the Node

previousNode

public Node previousNode(Node node)
Returns the node that's before the given node in the nodes list.

Parameters:
node - is the given node
Returns:
the node

hasActivations

public boolean hasActivations()
Returns true if this FigObject has activations. An activation is in this case a start ActivationNode and an end ActivationNode in the Nodes list (_linkPositions).

Returns:
true if this FigObject has activations.

getPortFig

public org.tigris.gef.presentation.Fig getPortFig(java.lang.Object np)
See Also:
FigNode.getPortFig(java.lang.Object)

setNode

public void setNode(int index,
                    Node node)
Sets the given node on the given index in linkPositions.

Parameters:
index -
node -

getObjectNode

public ObjectNode getObjectNode()
Returns the ObjectNode. This is the port that represents the object Figrect.

Returns:
the ObjectNode.

removeFig

public void removeFig(org.tigris.gef.presentation.Fig f)
Removes the fig from both the figs list as from the _figActivations list and the _figLinkPorts. This assures us that removal will indeed remove all 'pointers' to the object.

See Also:
FigGroup.removeFig(Fig)

getPreviousActivation

public java.util.List getPreviousActivation(Node node)
Returns a list with the start, end and all nodes in between them of the activation that is prior to the given node. If the node is part of an activation, that activation is returned. If the node is null an empty list is returned.

Parameters:
node - is the given node
Returns:
a List

addNode

public void addNode(int position,
                    Node node)


ArgoUML © 1996-2004 (20040316)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook