org.argouml.uml.diagram.static_structure.ui
Class FigClass

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.static_structure.ui.FigClass
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 FigClass
extends FigNodeModelElement

Class to display graphics for a UML Class in a diagram.

See Also:
Serialized Form

Field Summary
protected  org.tigris.gef.presentation.FigRect _attrBigPort
          The rectangle for the entire attribute box.
protected  org.tigris.gef.presentation.FigGroup _attrVec
          The vector of graphics for attributes (if any).
protected  org.tigris.gef.presentation.FigRect _operBigPort
          The rectangle for the entire operations box.
protected  org.tigris.gef.presentation.FigGroup _operVec
          The vector of graphics for operations (if any).
protected  org.tigris.gef.presentation.FigRect _stereoLineBlinder
          A rectangle to blank out the line that would otherwise appear at the bottom of the stereotype text box.
protected  CompartmentFigText highlightedFigText
          Text highlighted by mouse actions on the diagram.
 ru.novosoft.uml.foundation.core.MElementResidence resident
          Manages residency of a class within a component on a deployment diagram.
 
Fields inherited from class org.argouml.uml.diagram.ui.FigNodeModelElement
_bigPort, _enclosedFigs, _encloser, _name, _readyToEdit, _shadowSize, _stereo, checkSize, ITALIC_LABEL_FONT, LABEL_FONT, MARGIN, ROWHEIGHT, 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, _figs
 
Fields inherited from class org.tigris.gef.presentation.Fig
_allowsSaving, _context, _dashes, _displayed, _fillColor, _filled, _group, _h, _layer, _lineColor, _lineWidth, _locked, _resource, _shown, _w, _x, _y, an, annotationOwner, annotationStatus, BORDER, DASH_ARRAYS, DASHED_CHOICES, MIN_SIZE
 
Constructor Summary
FigClass()
          Main constructor for a FigClass.
FigClass(org.tigris.gef.graph.GraphModel gm, java.lang.Object node)
          Constructor for use if this figure is created for an existing class node in the metamodel.
 
Method Summary
 java.lang.Object clone()
           
protected  void createFeatureIn(org.tigris.gef.presentation.FigGroup fg, java.awt.event.InputEvent ie)
           
 org.tigris.gef.presentation.FigGroup getAttributesFig()
           
 java.awt.Dimension getMinimumSize()
          Gets the minimum size permitted for a class on the diagram.
protected  org.tigris.gef.presentation.FigText getNextVisibleFeature(org.tigris.gef.presentation.FigGroup fgVec, org.tigris.gef.presentation.FigText ft, int i)
           
 org.tigris.gef.presentation.FigGroup getOperationsFig()
           
 java.util.Vector getPopUpActions(java.awt.event.MouseEvent me)
          Build a collection of menu items relevant for a right-click popup menu on a Package.
protected  org.tigris.gef.presentation.FigText getPreviousVisibleFeature(org.tigris.gef.presentation.FigGroup fgVec, org.tigris.gef.presentation.FigText ft, int i)
           
 boolean isAttributeVisible()
          Returns the status of the attribute field.
 boolean isOperationVisible()
          Returns the status of the operation field.
 void keyPressed(java.awt.event.KeyEvent ke)
           
 org.tigris.gef.base.Selection makeSelection()
           
protected  void modelChanged(ru.novosoft.uml.MElementEvent mee)
          Handles changes of the model.
 void mouseClicked(java.awt.event.MouseEvent me)
          If the user double clicks on any part of this FigNode, pass it down to one of the internal Figs.
 void mouseExited(java.awt.event.MouseEvent me)
           
 java.lang.String placeString()
          Reply text to be shown while placing node in diagram
 void postLoad()
           
 void renderingChanged()
          Rerenders the fig if needed.
 void setAttributeVisible(boolean isVisible)
           
 void setBounds(int x, int y, int w, int h)
          Sets the bounds, but the size will be at least the one returned by getMinimumSize(), unless checking of size is disabled.
 void setFillColor(java.awt.Color lColor)
           
 void setLineColor(java.awt.Color lColor)
           
 void setOperationVisible(boolean isVisible)
           
protected  void textEdited(org.tigris.gef.presentation.FigText ft)
          This method is called after the user finishes editing a text field that is in the FigNodeModelElement.
 void translate(int dx, int dy)
           
protected  CompartmentFigText unhighlight()
           
protected  void updateAbstract()
          Updates the name if modelchanged receives an "isAbstract" event
protected  void updateAttributes()
          Updates the attributes in the fig.
protected  void updateListeners(java.lang.Object newOwner)
          Implementations of this method should register/unregister the fig for all (model)events.
protected  void updateNameText()
          Updates the text of the name FigText.
protected  void updateOperations()
          Updates the operations box.
protected  void updateStereotypeText()
          Updates the text of the sterotype FigText.
 
Methods inherited from class org.argouml.uml.diagram.ui.FigNodeModelElement
calcBounds, damage, delayedVetoableChange, delete, dispose, elementOrdering, enableSizeChecking, finalize, getContextNotation, getEnclosedFigs, getEnclosingFig, getItemUID, getNameFig, getShadowSize, getTipString, getUpdatedSize, hit, hitClarifier, isPartlyOwner, isPartlyOwner, keyReleased, keyTyped, listRoleItemSet, notationAdded, notationChanged, notationProviderAdded, notationProviderRemoved, notationRemoved, paintClarifiers, propertyChange, propertySet, recovered, removed, roleAdded, roleRemoved, setEnclosingFig, setItemUID, setOwner, setShadowSize, updateBounds, vetoableChange
 
Methods inherited from class org.tigris.gef.presentation.FigNode
addFigEdge, bindPort, cleanUp, contains, deepHitPort, endTrans, getBlinkPorts, getFigEdges, getHighlight, getPortFig, getPortFigs, getPortSector, hidePorts, hitPort, hitPort, mouseEntered, mousePressed, mouseReleased, paint, removeFigEdge, removePort, setBlinkPorts, setHighlight, showPorts, startTrans, superTranslate, updateEdges
 
Methods inherited from class org.tigris.gef.presentation.FigGroup
addFig, elements, getDisplayedFigs, getFigs, getFillColor, getFilled, getFont, getFontFamily, getFontSize, getLineColor, getLineWidth, getPrivateData, getTextColor, getTextFillColor, getTextFilled, hitFig, isReshapable, isResizable, isRotatable, parseDynObjects, removeAll, removeFig, setFigs, setFilled, setFont, setFontFamily, setFontSize, setLineWidth, 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, getClosestPoint, getContext, getDashed, getDashed01, getDashedString, getFilled01, getFirstPoint, getGravityPoints, getGroup, getHalfHeight, getHalfWidth, getHandleBox, getHeight, getId, getLastPoint, getLayer, getLocation, getLocked, getNumPoints, getOwner, getPerimeterLength, getPoints, getPoints, getPreferedSize, getResource, getSize, getTrapRect, getUseTrapRect, getVisState, getWidth, getX, getXs, getY, getYs, initAnnotations, insertPoint, intersects, isAnnotation, isDisplayed, isLowerRightResizable, isMovable, OK, pointAlongPerimeter, postSave, preSave, print, removeAnnotation, removeAnnotation, removePoint, removePropertyChangeListener, reorder, routingRect, savingAllowed, setAnnotationOwner, setAnnotationStatus, setAnnotationStrategy, setBounds, setCenter, setContext, setDashed, setDashedString, setDisplayed, setGroup, setHandleBox, setHeight, setLayer, setLocation, setLocation, setLocked, setNumPoints, setPoints, setPoints, setPoints, setPoints, setPoints, setResource, setSavingAllowed, setSize, setSize, setVisState, setWidth, setX, setXs, setY, setYs, stuffBounds, stuffPointAlongPerimeter, 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
mouseEntered, mousePressed, mouseReleased
 
Methods inherited from interface org.tigris.gef.ui.Highlightable
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

_attrVec

protected org.tigris.gef.presentation.FigGroup _attrVec

The vector of graphics for attributes (if any). First one is the rectangle for the entire attributes box.


_operVec

protected org.tigris.gef.presentation.FigGroup _operVec

The vector of graphics for operations (if any). First one is the rectangle for the entire operations box.


_attrBigPort

protected org.tigris.gef.presentation.FigRect _attrBigPort

The rectangle for the entire attribute box.


_operBigPort

protected org.tigris.gef.presentation.FigRect _operBigPort

The rectangle for the entire operations box.


_stereoLineBlinder

protected org.tigris.gef.presentation.FigRect _stereoLineBlinder

A rectangle to blank out the line that would otherwise appear at the bottom of the stereotype text box.


resident

public ru.novosoft.uml.foundation.core.MElementResidence resident

Manages residency of a class within a component on a deployment diagram. Not clear why it is public, or even why it is an instance variable (rather than local to the method).


highlightedFigText

protected CompartmentFigText highlightedFigText

Text highlighted by mouse actions on the diagram.

Constructor Detail

FigClass

public FigClass()

Main constructor for a FigClass.

Parent FigNodeModelElement will have created the main box FigNodeModelElement._bigPort and its name FigNodeModelElement._name and stereotype (@link #_stereo}. This constructor creates a box for the attributes and operations.

The properties of all these graphic elements are adjusted appropriately. The main boxes are all filled and have outlines.

For reasons I don't understand the stereotype is created in a box with lines. So we have to created a blanking rectangle to overlay the bottom line, and avoid four compartments showing.

There is some complex logic to allow for the possibility that stereotypes may not be displayed (unlike operations and attributes this is not a standard thing for UML). Some care is needed to ensure that additional space is not added, each time a stereotyped class is loaded.

There is a particular problem when loading diagrams with stereotyped classes. Because we create a FigClass indicating the stereotype is not displayed, we then add extra space for such classes when they are first rendered. This ought to be fixed by correctly saving the class dimensions, but that needs more work. The solution here is to use a simple flag to indicate the FigClass has just been created.

Warning. Much of the graphics positioning is hard coded. The overall figure is placed at location (10,10). The name compartment (in the parent FigNodeModelElement is 21 pixels high. The stereotype compartment is created 15 pixels high in the parent, but we change it to 19 pixels, 1 more than (FigNodeModelElement.STEREOHEIGHT here. The attribute and operations boxes are created at 19 pixels, 2 more than FigNodeModelElement.ROWHEIGHT.

CAUTION: This constructor (with no arguments) is the only one that does enableSizeChecking(false), all others must set it true. This is because this constructor is the only one called when loading a project. In this case, the parsed size must be maintained.


FigClass

public FigClass(org.tigris.gef.graph.GraphModel gm,
                java.lang.Object node)

Constructor for use if this figure is created for an existing class node in the metamodel.

Set the figure's name according to this node. This is used when the user click's on 'add to diagram' in the navpane. Don't know if this should rather be done in one of the super classes, since similar code is used in FigInterface.java etc. Andreas Rueckert <a_rueckert@gmx.net>

Parameters:
gm - Not actually used in the current implementation
node - The UML object being placed.
Method Detail

placeString

public java.lang.String placeString()
Description copied from class: FigNodeModelElement
Reply text to be shown while placing node in diagram

Overrides:
placeString in class FigNodeModelElement

clone

public java.lang.Object clone()

makeSelection

public org.tigris.gef.base.Selection makeSelection()
Overrides:
makeSelection in class FigNodeModelElement

getPopUpActions

public java.util.Vector getPopUpActions(java.awt.event.MouseEvent me)
Build a collection of menu items relevant for a right-click popup menu on a Package.

Specified by:
getPopUpActions in interface org.tigris.gef.ui.PopupGenerator
Overrides:
getPopUpActions in class FigNodeModelElement
Parameters:
me - a mouse event
Returns:
a collection of menu items

getOperationsFig

public org.tigris.gef.presentation.FigGroup getOperationsFig()

getAttributesFig

public org.tigris.gef.presentation.FigGroup getAttributesFig()

isOperationVisible

public boolean isOperationVisible()
Returns the status of the operation field.

Returns:
true if the operations are visible, false otherwise

isAttributeVisible

public boolean isAttributeVisible()
Returns the status of the attribute field.

Returns:
true if the attributes are visible, false otherwise

setAttributeVisible

public void setAttributeVisible(boolean isVisible)

setOperationVisible

public void setOperationVisible(boolean isVisible)

getMinimumSize

public java.awt.Dimension getMinimumSize()

Gets the minimum size permitted for a class on the diagram.

Parts of this are hardcoded, notably the fact that the name compartment has a minimum height of 21 pixels.

Returns:
the size of the minimum bounding box.

setFillColor

public void setFillColor(java.awt.Color lColor)

setLineColor

public void setLineColor(java.awt.Color lColor)

translate

public void translate(int dx,
                      int dy)

mouseExited

public void mouseExited(java.awt.event.MouseEvent me)

keyPressed

public void keyPressed(java.awt.event.KeyEvent ke)
Specified by:
keyPressed in interface java.awt.event.KeyListener
Overrides:
keyPressed in class FigNodeModelElement

textEdited

protected void textEdited(org.tigris.gef.presentation.FigText ft)
                   throws java.beans.PropertyVetoException
Description copied from class: FigNodeModelElement
This method is called after the user finishes editing a text field that is in the FigNodeModelElement. Determine which field and update the model. This class handles the name, subclasses should override to handle other text elements.

Overrides:
textEdited in class FigNodeModelElement
Throws:
java.beans.PropertyVetoException

getPreviousVisibleFeature

protected org.tigris.gef.presentation.FigText getPreviousVisibleFeature(org.tigris.gef.presentation.FigGroup fgVec,
                                                                        org.tigris.gef.presentation.FigText ft,
                                                                        int i)

getNextVisibleFeature

protected org.tigris.gef.presentation.FigText getNextVisibleFeature(org.tigris.gef.presentation.FigGroup fgVec,
                                                                    org.tigris.gef.presentation.FigText ft,
                                                                    int i)

createFeatureIn

protected void createFeatureIn(org.tigris.gef.presentation.FigGroup fg,
                               java.awt.event.InputEvent ie)
Overrides:
createFeatureIn in class FigNodeModelElement

unhighlight

protected CompartmentFigText unhighlight()

modelChanged

protected void modelChanged(ru.novosoft.uml.MElementEvent mee)
Handles changes of the model. Takes into account the event that occured. If you need to update the whole fig, consider using renderingChanged.

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

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

setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)

Sets the bounds, but the size will be at least the one returned by getMinimumSize(), unless checking of size is disabled.

If the required height is bigger, then the additional height is equally distributed among all figs (i.e. compartments), such that the cumulated height of all visible figs equals the demanded height

.

Some of this has "magic numbers" hardcoded in. In particular there is a knowledge that the minimum height of a name compartment is 21 pixels.

Parameters:
x - Desired X coordinate of upper left corner
y - Desired Y coordinate of upper left corner
w - Desired width of the FigClass
h - Desired height of the FigClass

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent me)
Description copied from class: FigNodeModelElement
If the user double clicks on any part of this FigNode, pass it down to one of the internal Figs. This allows the user to initiate direct text editing.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Overrides:
mouseClicked in class FigNodeModelElement
See Also:
MouseListener.mouseClicked(java.awt.event.MouseEvent)

updateAttributes

protected void updateAttributes()
Updates the attributes in the fig. Called from modelchanged if there is a modelevent effecting the attributes and from renderingChanged in all cases.


updateOperations

protected void updateOperations()
Updates the operations box. Called from modelchanged if there is a modelevent effecting the attributes and from renderingChanged in all cases.


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()

updateNameText

protected void updateNameText()
Description copied from class: FigNodeModelElement
Updates the text of the name FigText.

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

updateAbstract

protected void updateAbstract()
Updates the name if modelchanged receives an "isAbstract" event


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)

postLoad

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


ArgoUML © 1996-2003 (20040125)ArgoUML Project HomeArgoUML Cookbook