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, AttributesCompartmentContainer, Cloneable, org.tigris.gef.presentation.Connecter, DelayedVChangeListener, EventListener, org.tigris.gef.ui.Highlightable, KeyListener, MouseListener, NotationContext, OperationsCompartmentContainer, org.tigris.gef.ui.PopupGenerator, PropertyChangeListener, Serializable, VetoableChangeListener
Direct Known Subclasses:
FigClassAssociationClass

public class FigClass
extends FigNodeModelElement
implements AttributesCompartmentContainer, OperationsCompartmentContainer

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

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.argouml.uml.diagram.ui.FigNodeModelElement
 
Field Summary
private static int ATTRIBUTES_POSN
           
private static int BLINDER_POSN
           
private  CompartmentFigText highlightedFigText
          Text highlighted by mouse actions on the diagram.
private  boolean newlyCreated
          Flag to indicate that we have just been created.
private static int OPERATIONS_POSN
           
private  Object resident
          Manages residency of a class within a component on a deployment diagram.
 
Fields inherited from class org.argouml.uml.diagram.ui.FigNodeModelElement
ABSTRACT, ACTIVE, LEAF, POPUP_ADD_OFFSET, ROOT, ROWHEIGHT, SHADOW_COLOR_ALPHA, SHADOW_COLOR_VALUE, STEREOHEIGHT
 
Fields inherited from class org.tigris.gef.presentation.FigNode
_blinkPorts, _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, _dashPeriod, _dashStyle, _displayed, _fillColor, _filled, _group, _h, _layer, _lineColor, _lineWidth, _locked, _resource, _selected, _shown, _w, _x, _y, an, annotationOwner, annotationStatus, BORDER, MIN_SIZE
 
Constructor Summary
FigClass()
          Main constructor for a FigClass.
FigClass(org.tigris.gef.graph.GraphModel gm, Object node)
          Constructor for use if this figure is created for an existing class node in the metamodel.
 
Method Summary
 String classNameAndBounds()
          USED BY PGML.tee.
protected  void createFeatureIn(org.tigris.gef.presentation.FigGroup fg, InputEvent ie)
          Create a new "feature" in the owner fig.
 Rectangle getAttributesBounds()
           
private  org.tigris.gef.presentation.FigGroup getAttributesFig()
           
 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)
           
 Rectangle getOperationsBounds()
           
private  org.tigris.gef.presentation.FigGroup getOperationsFig()
           
 Vector getPopUpActions(MouseEvent me)
          Build a collection of menu items relevant for a right-click popup menu on a Class.
protected  org.tigris.gef.presentation.FigText getPreviousVisibleFeature(org.tigris.gef.presentation.FigGroup fgVec, org.tigris.gef.presentation.FigText ft, int i)
           
 boolean isAttributesVisible()
          Returns the status of the attribute field.
 boolean isOperationsVisible()
          Returns the status of the operation field.
 void keyPressed(KeyEvent ke)
           
 org.tigris.gef.base.Selection makeSelection()
           
protected  void modelChanged(PropertyChangeEvent mee)
          Handles changes of the model.
 void mouseClicked(MouseEvent me)
          If the user double clicks on any part of this FigNode, pass it down to one of the internal Figs.
 void mouseExited(MouseEvent me)
           
 String placeString()
          Default Reply text to be shown while placing node in diagram.
 void renderingChanged()
          Rerenders the fig if needed.
 void setAttributesVisible(boolean isVisible)
          Set the visibility of the attributes compartment.
 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 setEnclosingFig(org.tigris.gef.presentation.Fig encloser)
          Updates the modelelement container if the fig is moved in or out another fig.
 void setFillColor(Color lColor)
           
 void setLineColor(Color lColor)
           
 void setOperationsVisible(boolean isVisible)
          Set the visibility of the operations compartment.
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(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
addEnclosedFig, addFig, allowRemoveFromDiagram, buildModifierPopUp, buildVisibilityPopUp, calcBounds, clone, damage, delayedVetoableChange, deleteFromModel, displace, elementOrdering, enableSizeChecking, finalize, getBigPort, getContextNotation, getEnclosedFigs, getEncloser, getEnclosingFig, getItalicLabelFont, getItemUID, getLabelFont, getName, getNameFig, getShadowSize, getStereotype, getStereotypeFig, getStereotypeFigText, getTipString, hit, hitClarifier, isCheckSize, isPartlyOwner, isPartlyOwner, isReadyToEdit, keyReleased, keyTyped, notationAdded, notationChanged, notationProviderAdded, notationProviderRemoved, notationRemoved, paint, paintClarifiers, postLoad, propertyChange, redrawEnclosedFigs, removeEnclosedFig, removeFromDiagram, setBigPort, setEncloser, setItemUID, setName, setNameFig, setOwner, setReadyToEdit, setShadowSize, setStereotype, setStereotypeFig, setSuppressCalcBounds, updateBounds, updateFigGroupSize, vetoableChange
 
Methods inherited from class org.tigris.gef.presentation.FigNode
addFigEdge, bindPort, cleanUp, contains, deepHitPort, delete, dispose, endTrans, getBlinkPorts, getFigEdges, getFigEdges, getHighlight, getPortFig, getPortFigs, getPortSector, hidePorts, hitPort, hitPort, isBlinkPorts, isDragConnectable, mouseEntered, mousePressed, mouseReleased, removeFigEdge, removePort, setBlinkPorts, setHighlight, showPorts, superTranslate, 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, removeFig, setExtraFrameSpace, setFigs, setFigs, setFilled, setFont, setFontFamily, setFontSize, setLineWidth, setPrivateData, setTextColor, setTextFillColor, setTextFilled
 
Methods inherited from class org.tigris.gef.presentation.Fig
addAnnotation, addPoint, addPropertyChangeListener, align, center, connectionPoint, contains, contains, countCornersContained, createDrag, drawDashedLine, drawDashedPerimeter, firePropChange, firePropChange, firePropChange, getAnnotationOwner, getAnnotationStrategy, getBounds, getBounds, getClosestPoint, getContext, getDashed, getDashed01, getDashedString, getFillColor, getFilled, getFilled01, getFirstPoint, getGravityPoints, getGroup, getHalfHeight, getHalfWidth, getHandleBox, getHeight, getId, getLastPoint, getLayer, getLineColor, getLineWidth, getLocation, getLocked, getNumPoints, getOwner, getPerimeterLength, getPoint, getPoints, getPreferredSize, getResource, getSingle, getTrapRect, getUseTrapRect, getVisState, getWidth, getX, getXs, getY, getYs, hasFillColor, hasLineColor, initAnnotations, insertPoint, intersects, intersectsPerimeter, isAnnotation, isCopieable, isCopyable, isCutable, isDisplayed, 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, setHandleBox, setHeight, setLayer, setLocation, setLocation, setLocked, setMovable, setNumPoints, setPoint, setPoint, setPoint, setPoint, 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
mouseEntered, mousePressed, mouseReleased
 
Methods inherited from interface org.tigris.gef.ui.Highlightable
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

BLINDER_POSN

private static final int BLINDER_POSN
See Also:
Constant Field Values

OPERATIONS_POSN

private static final int OPERATIONS_POSN
See Also:
Constant Field Values

ATTRIBUTES_POSN

private static final int ATTRIBUTES_POSN
See Also:
Constant Field Values

highlightedFigText

private CompartmentFigText highlightedFigText
Text highlighted by mouse actions on the diagram.


newlyCreated

private boolean newlyCreated
Flag to indicate that we have just been created. This is to fix the problem with loading classes that have stereotypes already defined.


resident

private Object resident

Manages residency of a class within a component on a deployment diagram.

Constructor Detail

FigClass

public FigClass()
Main constructor for a FigClass.

Parent FigNodeModelElement will have created the main box FigNodeModelElement.getBigPort() and its name FigNodeModelElement.getNameFig() and stereotype (@link #getStereotypeFig()}. 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,
                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 String placeString()
Description copied from class: FigNodeModelElement
Default Reply text to be shown while placing node in diagram. Overrule this when the text is not "new [UMLClassName]".

Overrides:
placeString in class FigNodeModelElement
Returns:
the text to be shown while placing node in diagram
See Also:
FigNodeModelElement.placeString()

makeSelection

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

getPopUpActions

public Vector getPopUpActions(MouseEvent me)
Build a collection of menu items relevant for a right-click popup menu on a Class.

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
See Also:
PopupGenerator.getPopUpActions(java.awt.event.MouseEvent)

getOperationsBounds

public Rectangle getOperationsBounds()
Specified by:
getOperationsBounds in interface OperationsCompartmentContainer
Returns:
The bounds of the operations compartment.

getAttributesBounds

public Rectangle getAttributesBounds()
Specified by:
getAttributesBounds in interface AttributesCompartmentContainer
Returns:
The bounds of the attributes compartment.

getOperationsFig

private org.tigris.gef.presentation.FigGroup getOperationsFig()
Returns:
The vector of graphics for operations (if any). First one is the rectangle for the entire operations box.

getAttributesFig

private org.tigris.gef.presentation.FigGroup getAttributesFig()
Returns:
The vector of graphics for operations (if any). First one is the rectangle for the entire operations box.

isOperationsVisible

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

Specified by:
isOperationsVisible in interface OperationsCompartmentContainer
Returns:
true if the operations are visible, false otherwise

isAttributesVisible

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

Specified by:
isAttributesVisible in interface AttributesCompartmentContainer
Returns:
true if the attributes are visible, false otherwise

setAttributesVisible

public void setAttributesVisible(boolean isVisible)
Description copied from interface: AttributesCompartmentContainer
Set the visibility of the attributes compartment.

Specified by:
setAttributesVisible in interface AttributesCompartmentContainer
Parameters:
isVisible - true if the attribute compartment is visible

setOperationsVisible

public void setOperationsVisible(boolean isVisible)
Description copied from interface: OperationsCompartmentContainer
Set the visibility of the operations compartment.

Specified by:
setOperationsVisible in interface OperationsCompartmentContainer
Parameters:
isVisible - true if the operation compartment is visible

classNameAndBounds

public String classNameAndBounds()
USED BY PGML.tee.

Overrides:
classNameAndBounds in class FigNodeModelElement
Returns:
the class name and bounds together with compartment visibility.
See Also:
org.tigris.gef.presentation.Fig#getNameAndBounds()

getMinimumSize

public 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(Color lColor)
See Also:
Fig.setFillColor(java.awt.Color)

setLineColor

public void setLineColor(Color lColor)
See Also:
Fig.setLineColor(java.awt.Color)

translate

public void translate(int dx,
                      int dy)
See Also:
Fig.translate(int, int)

mouseExited

public void mouseExited(MouseEvent me)
Specified by:
mouseExited in interface MouseListener
See Also:
MouseListener.mouseExited(java.awt.event.MouseEvent)

keyPressed

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

textEdited

protected void textEdited(org.tigris.gef.presentation.FigText ft)
                   throws 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
Parameters:
ft - the FigText that has been edited and contains the new text
Throws:
PropertyVetoException - thrown when new text represents an unacceptable value
See Also:
FigNodeModelElement.textEdited(org.tigris.gef.presentation.FigText)

getPreviousVisibleFeature

protected org.tigris.gef.presentation.FigText getPreviousVisibleFeature(org.tigris.gef.presentation.FigGroup fgVec,
                                                                        org.tigris.gef.presentation.FigText ft,
                                                                        int i)
Parameters:
fgVec - the FigGroup
ft - the Figtext
i - get the fig before fig i
Returns:
the FigText

getNextVisibleFeature

protected org.tigris.gef.presentation.FigText getNextVisibleFeature(org.tigris.gef.presentation.FigGroup fgVec,
                                                                    org.tigris.gef.presentation.FigText ft,
                                                                    int i)
Parameters:
fgVec - the FigGroup
ft - the Figtext
i - get the fig after fig i
Returns:
the FigText

createFeatureIn

protected void createFeatureIn(org.tigris.gef.presentation.FigGroup fg,
                               InputEvent ie)
Description copied from class: FigNodeModelElement
Create a new "feature" in the owner fig. must be overridden to make sense (I didn't want to make it abstract because it might not be required)

Overrides:
createFeatureIn in class FigNodeModelElement
Parameters:
fg - The fig group to which this applies
ie - The input event that triggered us. In the current implementation a mouse double click.
See Also:
FigNodeModelElement.createFeatureIn( org.tigris.gef.presentation.FigGroup, java.awt.event.InputEvent)

unhighlight

protected CompartmentFigText unhighlight()
Returns:
the compartment

modelChanged

protected void modelChanged(PropertyChangeEvent 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
Parameters:
mee - the ModelElementEvent that caused the change
See Also:
FigNodeModelElement.modelChanged(java.beans.PropertyChangeEvent)

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

setEnclosingFig

public void setEnclosingFig(org.tigris.gef.presentation.Fig encloser)
Description copied from class: FigNodeModelElement
Updates the modelelement container if the fig is moved in or out another fig. If this fig doesn't have an enclosing fig anymore, the namespace of the diagram will be the owning modelelement. If this fig is moved inside another FigNodeModelElement the owner of that fignodemodelelement will be the owning modelelement.

Overrides:
setEnclosingFig in class FigNodeModelElement
See Also:
Fig.setEnclosingFig(org.tigris.gef.presentation.Fig)

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(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 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(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 - the new owner for the listeners
See Also:
FigNodeModelElement.updateListeners(Object)


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