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

java.lang.Object
  |
  +--FigNode
        |
        +--org.argouml.uml.diagram.ui.FigNodeModelElement
              |
              +--org.argouml.uml.diagram.static_structure.ui.FigClass
All Implemented Interfaces:
ArgoEventListener, ArgoNotationEventListener, DelayedVChangeListener, java.util.EventListener, java.awt.event.KeyListener, java.awt.event.MouseListener, NotationContext, java.beans.PropertyChangeListener, 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  FigRect _attrBigPort
          The rectangle for the entire attribute box.
protected  FigGroup _attrVec
          The vector of graphics for attributes (if any).
private  boolean _newlyCreated
          Flag to indicate that we have just been created.
protected  FigRect _operBigPort
          The rectangle for the entire operations box.
protected  FigGroup _operVec
          The vector of graphics for operations (if any).
protected  FigRect _stereoLineBlinder
          A rectangle to blank out the line that would otherwise appear at the bottom of the stereotype text box.
private  Logger cat
           
protected  CompartmentFigText highlightedFigText
          Text highlighted by mouse actions on the diagram.
 
Fields inherited from class org.argouml.uml.diagram.ui.FigNodeModelElement
_bigPort, _enclosedFigs, _encloser, _name, _readyToEdit, _shadowSize, _stereo, BUNDLE, checkSize, ITALIC_LABEL_FONT, LABEL_FONT, MARGIN, POPUP_ADD_OFFSET, ROWHEIGHT, SHADOW_COLOR_ALPHA, SHADOW_COLOR_VALUE, STEREOHEIGHT, suppressCalcBounds
 
Constructor Summary
FigClass()
          Main constructor for a FigClass.
FigClass(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(FigGroup fg, java.awt.event.InputEvent ie)
           
 FigGroup getAttributesFig()
           
 java.awt.Dimension getMinimumSize()
          Gets the minimum size permitted for a class on the diagram.
protected  FigText getNextVisibleFeature(FigGroup fgVec, FigText ft, int i)
           
 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  FigText getPreviousVisibleFeature(FigGroup fgVec, 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)
           
 Selection makeSelection()
           
protected  void modelChanged(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 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(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
addFig, calcBounds, damage, delayedVetoableChange, delete, dispose, elementOrdering, enableSizeChecking, finalize, getContextNotation, getEnclosedFigs, getEnclosingFig, getItemUID, getName, getNameFig, getShadowSize, getStereotype, getStereotypeFig, getTipString, getUpdatedSize, hit, hitClarifier, isPartlyOwner, isPartlyOwner, keyReleased, keyTyped, listRoleItemSet, notationAdded, notationChanged, notationProviderAdded, notationProviderRemoved, notationRemoved, paint, paintClarifiers, postLoad, propertyChange, propertySet, recovered, removed, roleAdded, roleRemoved, setEnclosingFig, setHandleBox, setItemUID, setName, setNameFig, setOwner, setShadowSize, setStereotype, setStereotypeFig, superTranslate, updateBounds, vetoableChange
 
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
 

Field Detail

cat

private Logger cat

_attrVec

protected FigGroup _attrVec

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


_operVec

protected FigGroup _operVec

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


_attrBigPort

protected FigRect _attrBigPort

The rectangle for the entire attribute box.


_operBigPort

protected FigRect _operBigPort

The rectangle for the entire operations box.


_stereoLineBlinder

protected FigRect _stereoLineBlinder

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


highlightedFigText

protected 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.

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

Overrides:
getPopUpActions in class FigNodeModelElement
Parameters:
me - a mouse event
Returns:
a collection of menu items

getOperationsFig

public FigGroup getOperationsFig()

getAttributesFig

public 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(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
java.beans.PropertyVetoException

getPreviousVisibleFeature

protected FigText getPreviousVisibleFeature(FigGroup fgVec,
                                            FigText ft,
                                            int i)

getNextVisibleFeature

protected FigText getNextVisibleFeature(FigGroup fgVec,
                                        FigText ft,
                                        int i)

createFeatureIn

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

unhighlight

protected CompartmentFigText unhighlight()

modelChanged

protected void modelChanged(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(Object)


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