org.argouml.uml.diagram.ui
Class FigNodeModelElement

java.lang.Object
  extended by FigNode
      extended by org.argouml.uml.diagram.ui.FigNodeModelElement
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.beans.PropertyChangeListener, java.beans.VetoableChangeListener, java.util.EventListener, ArgoEventListener, ArgoDiagramAppearanceEventListener, ArgoNotationEventListener, Highlightable, DelayedVChangeListener, DiagramElement, PathContainer, ArgoFig, Clarifiable, StereotypeStyled, IItemUID
Direct Known Subclasses:
AbstractFigComponent, AbstractFigNode, FigActor, FigClassifierRole, FigClassifierRole, FigClassifierRole, FigComment, FigCompartmentBox, FigEdgePort, FigMessage, FigNodeAssociation, FigObject, FigObjectFlowState, FigPackage, FigPartition, FigPool, FigStateVertex

public abstract class FigNodeModelElement
extends FigNode
implements java.beans.VetoableChangeListener, DelayedVChangeListener, java.awt.event.MouseListener, java.awt.event.KeyListener, java.beans.PropertyChangeListener, PathContainer, ArgoDiagramAppearanceEventListener, ArgoNotationEventListener, Highlightable, IItemUID, Clarifiable, ArgoFig, StereotypeStyled, DiagramElement

Abstract class to display diagram icons for UML ModelElements that look like nodes and that have editable names and can be resized.

NOTE: This will drop the ArgoNotationEventListener and ArgoDiagramAppearanceEventListener interfaces in the next release. The corresponding methods have been marked as deprecated.


Field Summary
protected static int ABSTRACT
          Used for #buildModifierPopUp().
protected static int ACTIVE
          Used for #buildModifierPopUp().
protected  boolean invisibleAllowed
          True if an instance is allowed to be invisible.
protected static int LEAF
          Used for #buildModifierPopUp().
protected static int NAME_FIG_HEIGHT
          The default minimum height of the name fig, computed to allow room for the Critics "clarifiers" (red squiggly line) with the default font.
protected static int NAME_V_PADDING
          Padding to be used above and below the name.
protected static int ROOT
          Used for #buildModifierPopUp().
protected static int WIDTH
          Default width for a node fig.
 
Fields inherited from interface org.argouml.uml.diagram.ui.ArgoFig
DEBUG, DEBUG_COLOR, FILL_COLOR, INVISIBLE_LINE_COLOR, LINE_COLOR, LINE_WIDTH, ROWHEIGHT, SOLID_FILL_COLOR, STEREOHEIGHT, TEXT_COLOR, X0, Y0
 
Constructor Summary
protected FigNodeModelElement(java.lang.Object element, java.awt.Rectangle bounds, DiagramSettings renderSettings)
          Construct a figure at a specific position for a given model element with the given settings.
 
Method Summary
protected  void addElementListener(java.lang.Object element)
          Add an element listener and remember the registration.
protected  void addElementListener(java.lang.Object element, java.lang.String property)
          Add a listener for a given property name and remember the registration.
protected  void addElementListener(java.lang.Object element, java.lang.String[] property)
          Add a listener for an array of property names and remember the registration.
 void addEnclosedFig(Fig fig)
          Add a Fig that is enclosed by this figure.
protected  void allowRemoveFromDiagram(boolean allowed)
           
 void bindPort(java.lang.Object port, Fig f)
           
protected  java.lang.Object buildModifierPopUp(int items)
          Build a pop-up menu item for the various modifiers.
protected  ArgoJMenu buildShowPopUp()
           
protected  java.lang.Object buildVisibilityPopUp()
           
 void calcBounds()
           
 java.lang.String classNameAndBounds()
          Deprecated. 
 java.lang.Object clone()
          Clone this figure.
protected  Fig createBigPortFig()
          Overrule this if a rectangle is not usable.
protected  void createContainedModelElement(FigGroup fg, java.awt.event.InputEvent me)
          Create a new model element contained in the fig owner.
protected  FigStereotypesGroup createStereotypeFig()
           
 void delayedVetoableChange(java.beans.PropertyChangeEvent pce)
           
 void deleteFromModel()
           
protected  void determineDefaultPathVisible()
          At creation time of the Fig, we determine if the path should be visible by default.
 void diagramFontChanged(ArgoDiagramAppearanceEvent e)
          Deprecated. for 0.27.2 by tfmorris. The owning diagram manages global changes to rendering defaults.
 void displace(int xInc, int yInc)
          To redraw each element correctly when changing its location with X and Y additions.
 void enableSizeChecking(boolean flag)
          The setter for checkSize.
 Fig getBigPort()
           
 DiElement getDiElement()
           
 java.util.Vector<Fig> getEnclosedFigs()
           
protected  Fig getEncloser()
           
 Fig getEnclosingFig()
           
 ItemUID getItemUID()
           
 java.awt.Dimension getMinimumSize()
          Returns the minimum size of the Fig.
 java.lang.String getName()
          Get the name of the model element this Fig represents.
 java.awt.Rectangle getNameBounds()
          Get the Rectangle in which the model elements name is displayed
protected  FigText getNameFig()
          Get the Fig that displays the model element name.
protected  int getNameFigFontStyle()
          Determines the font style based on the UML model.
protected  int getNotationProviderType()
          Overrule this for subclasses that need a different NotationProvider.
protected  NotationSettings getNotationSettings()
           
 java.util.Vector getPopUpActions(java.awt.event.MouseEvent me)
          This method returns a Vector of one of these 4 types: AbstractAction, JMenu, JMenuItem, JSeparator.
protected static int getPopupAddOffset()
           
 Project getProject()
          Deprecated. for 0.27.2 by tfmorris. Implementations should have all the information that they require in the DiagramSettings object.
protected  Fig getRemoveDelegate()
          Subclasses should override this to redirect a remove request from one Fig to another.
 DiagramSettings getSettings()
           
 int getStereotypeCount()
          Get the number of stereotypes contained in this FigNode
protected  FigStereotypesGroup getStereotypeFig()
          Get the Fig containing the stereotype(s).
 DiagramSettings.StereotypeStyle getStereotypeStyle()
           
 int getStereotypeView()
          Deprecated. for 0.27.2 by tfmorris. Use getStereotypeStyle().
 java.lang.String getTipString(java.awt.event.MouseEvent me)
           
 boolean hit(java.awt.Rectangle r)
           
protected  ToDoItem hitClarifier(int x, int y)
           
protected  void initNotationProviders(java.lang.Object own)
          Replace the NotationProvider(s).
protected  boolean isCheckSize()
           
 boolean isDragConnectable()
           
 boolean isEditable()
          Determine if this node can be edited.
protected  boolean isPartlyOwner(Fig fig, java.lang.Object o)
           
protected  boolean isPartlyOwner(java.lang.Object o)
           
 boolean isPathVisible()
          Determine if the path is visible.
protected  boolean isReadyToEdit()
           
protected  boolean isSingleTarget()
          Determine if this Fig is the sole selected target in the TargetManager
 void keyPressed(java.awt.event.KeyEvent ke)
           
 void keyReleased(java.awt.event.KeyEvent ke)
           
 void keyTyped(java.awt.event.KeyEvent ke)
           
 Selection makeSelection()
           
protected  void modelChanged(java.beans.PropertyChangeEvent event)
          This is a template method called by the ArgoUML framework as the result of a change to a model element.
 void mouseClicked(java.awt.event.MouseEvent me)
           
protected  void moveIntoComponent(Fig newEncloser)
          Handle the case where this fig is moved into a Component.
 void notationAdded(ArgoNotationEvent event)
          Deprecated. for 0.27.2 by tfmorris.
 void notationChanged(ArgoNotationEvent event)
          Deprecated. for 0.27.2 by tfmorris. Changes to notatation provider are now handled by the owning diagram.
 void notationProviderAdded(ArgoNotationEvent event)
          Deprecated. for 0.27.2 by tfmorris.
 void notationProviderRemoved(ArgoNotationEvent event)
          Deprecated. for 0.27.2 by tfmorris.
 void notationRemoved(ArgoNotationEvent event)
          Deprecated. for 0.27.2 by tfmorris.
 void paintClarifiers(java.awt.Graphics g)
          Displays visual indications of pending ToDoItems.
 java.lang.String placeString()
          Default Reply text to be shown while placing node in diagram.
 void propertyChange(java.beans.PropertyChangeEvent pve)
           
protected  void removeAllElementListeners()
          Unregister all listeners registered through addElementListener
protected  void removeElementListener(java.lang.Object element)
          Remove an element listener and remembered registration.
 void removeEnclosedFig(Fig fig)
          Removes the given Fig from the list of enclosed Figs.
 void removeFromDiagram()
           
protected  void removeFromDiagramImpl()
          If you override this method, make sure to remove all listeners: If you don't, objects in a deleted project will still receive events.
 void renderingChanged()
          Rerender the entire fig.
protected  void setBigPort(Fig bp)
          Deprecated. by MVW since V0.28.1. Use createBigPortFig() instead, to guarantee correct initialization.
protected  void setBoundsImpl(int x, int y, int w, int h)
          Sets the bounds of this node taking the stereotype view into consideration.
Do not override this method, override setStandardBounds(int, int, int, int) instead.
 void setDiElement(DiElement element)
           
protected  void setEditable(boolean canEdit)
          By default a node is directly editable by simply selecting that node and starting to type.
protected  void setEncloser(Fig e)
           
 void setEnclosingFig(Fig newEncloser)
           
 void setItemUID(ItemUID id)
          Set the item UID.
 void setLayer(Layer lay)
          This is the final call at creation time of the Fig, i.e.
 void setLineWidth(int w)
           
 void setName(java.lang.String n)
          Change the name of the model element this Fig represents.
protected  void setNameFig(FigText fig)
          Set the Fig that displays the model element name.
 void setOwner(java.lang.Object owner)
          Deprecated. for 0.27.3 by tfmorris. Set owner in constructor. This method is implemented in GEF, so we'll leave this implementation here to block any attempts to use it within ArgoUML.
 void setPathVisible(boolean visible)
          Set the visibility of the path.
 void setProject(Project project)
          Deprecated.  
protected  void setReadyToEdit(boolean v)
           
 void setSettings(DiagramSettings renderSettings)
          Set the rendering settings to be used for this fig.
protected  void setStandardBounds(int x, int y, int w, int h)
          Replaces setBoundsImpl(int, int, int, int).
 void setStereotypeStyle(DiagramSettings.StereotypeStyle style)
          Set the stereotype style to be used for rendering this fig.
 void setStereotypeView(int s)
          Deprecated. for 0.27.2 by tfmorris. Use #setStereotypeStyle(StereotypeStyle).
protected  void setSuppressCalcBounds(boolean scb)
          TODO: Move this in FigGroup (in GEF).
 void setVisible(boolean visible)
          Set visibility of figure.
protected  void showHelp(java.lang.String s)
          Utility function to localize the given string with help text, and show it in the status bar of the ArgoUML window.
protected  void textEdited(FigText ft)
          This method is called after the user finishes editing a text field that is in the FigNodeModelElement.
protected  void textEditStarted(FigText ft)
          This method is called when the user doubleclicked on the text field, and starts editing.
protected  void updateBounds()
          Determine new bounds.
protected  void updateElementListeners(java.util.Set<java.lang.Object[]> listenerSet)
          Update the set of registered listeners to match the given set using a minimal update strategy to remove unneeded listeners and add new listeners.
protected  void updateFont()
          This function should, for all FigTexts, recalculate the font-style (plain, bold, italic, bold/italic), and apply it by calling FigText.setFont().
protected  void updateLayout(UmlChangeEvent event)
          This is a template method called by the ArgoUML framework as the result of a change to a model element.
protected  void updateListeners(java.lang.Object oldOwner, 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 updateStereotypeIcon()
           
protected  void updateStereotypeText()
          Updates the text of the stereotype FigText.
 void vetoableChange(java.beans.PropertyChangeEvent pce)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.awt.event.MouseListener
mouseEntered, mouseExited, mousePressed, mouseReleased
 
Methods inherited from interface org.argouml.cognitive.Highlightable
getHighlight, setHighlight
 

Field Detail

WIDTH

protected static final int WIDTH
Default width for a node fig. Used to be 60 (up to V0.20), later (from V0.22) it was 90. Now 64 to align to grid better.

See Also:
Constant Field Values

NAME_FIG_HEIGHT

protected static final int NAME_FIG_HEIGHT
The default minimum height of the name fig, computed to allow room for the Critics "clarifiers" (red squiggly line) with the default font. This should really go away and be managed internally to the name figs and fetched through getMinimumSize(). The final height can change based on the font selected.

See Also:
Constant Field Values

NAME_V_PADDING

protected static final int NAME_V_PADDING
Padding to be used above and below the name.

See Also:
Constant Field Values

invisibleAllowed

protected boolean invisibleAllowed
True if an instance is allowed to be invisible. This is currently only set true by FigEdgePort. TODO: FigEdgePort should be removed from the FigNodeModelElement hierarchy and so the need for this removed.


ROOT

protected static final int ROOT
Used for #buildModifierPopUp().

See Also:
Constant Field Values

ABSTRACT

protected static final int ABSTRACT
Used for #buildModifierPopUp().

See Also:
Constant Field Values

LEAF

protected static final int LEAF
Used for #buildModifierPopUp().

See Also:
Constant Field Values

ACTIVE

protected static final int ACTIVE
Used for #buildModifierPopUp().

See Also:
Constant Field Values
Constructor Detail

FigNodeModelElement

protected FigNodeModelElement(java.lang.Object element,
                              java.awt.Rectangle bounds,
                              DiagramSettings renderSettings)
Construct a figure at a specific position for a given model element with the given settings. This is the constructor used by the PGML parser when loading a diagram from a file.

Beware: the width and height in the given Rectangle are currently ignored. According issue 5604 this is a bug.

Parameters:
element - ModelElement associated with figure
bounds - x & y are used to set position, width & height are ignored
renderSettings - the rendering settings to use for the Fig
Method Detail

createBigPortFig

protected Fig createBigPortFig()
Overrule this if a rectangle is not usable.

Returns:
the Fig to be used as bigPort

createStereotypeFig

protected FigStereotypesGroup createStereotypeFig()

setLayer

public void setLayer(Layer lay)
This is the final call at creation time of the Fig, i.e. here it is put on a Diagram.

Parameters:
lay - the Layer (which has a 1..1 relation to the Diagram)
See Also:
org.tigris.gef.presentation.Fig#setLayer(org.tigris.gef.base.Layer)

clone

public java.lang.Object clone()
Clone this figure. After the base clone method has been called determine which child figs of the clone represent the name, stereotype and port.

TODO: enclosedFigs, encloser and eventSenders may also need to be cloned.

Returns:
the cloned figure
See Also:
Object.clone()

placeString

public java.lang.String placeString()
Default Reply text to be shown while placing node in diagram. Overrule this when the text is not "new [UMLClassName]".

Returns:
the text to be shown while placing node in diagram

setItemUID

public void setItemUID(ItemUID id)
Description copied from interface: IItemUID
Set the item UID.

Specified by:
setItemUID in interface IItemUID
Parameters:
id - UID

getItemUID

public ItemUID getItemUID()
Specified by:
getItemUID in interface IItemUID
Returns:
UID

getNameFig

protected FigText getNameFig()
Get the Fig that displays the model element name.

Returns:
the name Fig

getNameBounds

public java.awt.Rectangle getNameBounds()
Get the Rectangle in which the model elements name is displayed

Returns:
bounding box for name

setNameFig

protected void setNameFig(FigText fig)
Set the Fig that displays the model element name.

Parameters:
fig - the name Fig

getName

public java.lang.String getName()
Get the name of the model element this Fig represents.

Returns:
the name of the model element

setName

public void setName(java.lang.String n)
Change the name of the model element this Fig represents.

Parameters:
n - the name of the model element

getPopUpActions

public java.util.Vector getPopUpActions(java.awt.event.MouseEvent me)
This method returns a Vector of one of these 4 types: AbstractAction, JMenu, JMenuItem, JSeparator.


buildShowPopUp

protected ArgoJMenu buildShowPopUp()

buildVisibilityPopUp

protected java.lang.Object buildVisibilityPopUp()
Returns:
the pop-up menu item for Visibility

buildModifierPopUp

protected java.lang.Object buildModifierPopUp(int items)
Build a pop-up menu item for the various modifiers.

This function is designed to be easily extendable with new items.

Parameters:
items - bitwise OR of the items: ROOT, ABSTRACT, LEAF, ACTIVE.
Returns:
the menu item

getEnclosingFig

public Fig getEnclosingFig()

setEnclosingFig

public void setEnclosingFig(Fig newEncloser)

moveIntoComponent

protected void moveIntoComponent(Fig newEncloser)
Handle the case where this fig is moved into a Component.

Parameters:
newEncloser - the new encloser for this Fig

addEnclosedFig

public void addEnclosedFig(Fig fig)
Add a Fig that is enclosed by this figure.

Parameters:
fig - The fig to be added

removeEnclosedFig

public void removeEnclosedFig(Fig fig)
Removes the given Fig from the list of enclosed Figs.

Parameters:
fig - The Fig to be removed

getEnclosedFigs

public java.util.Vector<Fig> getEnclosedFigs()

makeSelection

public Selection makeSelection()

paintClarifiers

public void paintClarifiers(java.awt.Graphics g)
Displays visual indications of pending ToDoItems. Please note that the list of advices (ToDoList) is not the same as the list of element known by the FigNode (_figs). Therefore, it is necessary to check if the graphic item exists before drawing on it. See ClAttributeCompartment for an example.

Specified by:
paintClarifiers in interface Clarifiable
Parameters:
g - the graphics device
See Also:
ClAttributeCompartment

hitClarifier

protected ToDoItem hitClarifier(int x,
                                int y)
Parameters:
x - the x of the hit
y - the y of the hit
Returns:
the todo item of which the clarifier has been hit

getTipString

public java.lang.String getTipString(java.awt.event.MouseEvent me)

vetoableChange

public void vetoableChange(java.beans.PropertyChangeEvent pce)
Specified by:
vetoableChange in interface java.beans.VetoableChangeListener

delayedVetoableChange

public void delayedVetoableChange(java.beans.PropertyChangeEvent pce)
Specified by:
delayedVetoableChange in interface DelayedVChangeListener
Parameters:
pce - the event

updateBounds

protected void updateBounds()
Determine new bounds.

This algorithm makes the box grow (if the calculated minimum size grows), but then it can never shrink again (not even if the calculated minimum size is smaller).

If the user can not resize the fig, e.g. like the FigActor or FigFinalState, then we return the original size.


propertyChange

public void propertyChange(java.beans.PropertyChangeEvent pve)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

textEditStarted

protected void textEditStarted(FigText ft)
This method is called when the user doubleclicked on the text field, and starts editing. Subclasses should overrule this field to e.g. supply help to the user about the used format.

It is also possible to alter the text to be edited already here, e.g. by adding the stereotype in front of the name, by using setFullyHandleStereotypes(true) in the NotationSettings argument of the NotationProvider.toString() function, but that seems not user-friendly. See issue 3838.

Parameters:
ft - the FigText that will be edited and contains the start-text

showHelp

protected void showHelp(java.lang.String s)
Utility function to localize the given string with help text, and show it in the status bar of the ArgoUML window. This function is used in favour of the inline call to enable later improvements; e.g. it would be possible to show a help-balloon.

TODO: Work this out. One matter to possibly improve: show multiple lines.

Parameters:
s - the given string to be localized and shown

textEdited

protected void textEdited(FigText ft)
                   throws java.beans.PropertyVetoException
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, the stereotype, and any CompartmentFigTexts. Subclasses should override to handle other text elements.

Parameters:
ft - the FigText that has been edited and contains the new text
Throws:
java.beans.PropertyVetoException - thrown when new text represents an unacceptable value

mouseClicked

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

keyPressed

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

keyReleased

public void keyReleased(java.awt.event.KeyEvent ke)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent ke)
Specified by:
keyTyped in interface java.awt.event.KeyListener

modelChanged

protected void modelChanged(java.beans.PropertyChangeEvent event)
This is a template method called by the ArgoUML framework as the result of a change to a model element. Do not call this method directly yourself.

Override this in any subclasses in order to change what model elements the FigNode is listening to as a result of change to the model.

This method is guaranteed by the framework to be running on the same thread as the model subsystem.

TODO: Lets refactor this at some time to take UmlChangeEvent argument

Parameters:
event - the UmlChangeEvent that caused the change

updateLayout

protected void updateLayout(UmlChangeEvent event)
This is a template method called by the ArgoUML framework as the result of a change to a model element. Do not call this method directly yourself.

Override this in any subclasses in order to restructure the FigNode due to change of any model element that this FigNode is listening to.

This method automatically updates the stereotype rendering.

The default behavior is to update the name and stereotype text.

For e.g. a Package, if the visibility is changed via the properties panel, then the display of it on the diagram has to follow the change. This is not handled here, but by the notationProviderName.

This method is guaranteed by the framework to be running on the Swing/AWT thread.

Parameters:
event - the UmlChangeEvent that caused the change

createContainedModelElement

protected void createContainedModelElement(FigGroup fg,
                                           java.awt.event.InputEvent me)
Create a new model element contained in the fig owner. Used by subclasses to, for example, create an attribute within a class.

Parameters:
fg - The fig group to which this applies
me - The input event that triggered us. In the current implementation a mouse double click.

isPartlyOwner

protected boolean isPartlyOwner(java.lang.Object o)
Parameters:
o - the given object
Returns:
true if one of my figs has the given object as owner

isPartlyOwner

protected boolean isPartlyOwner(Fig fig,
                                java.lang.Object o)
Parameters:
fig - the given fig (may be a group)
o - the given object
Returns:
true if one of the given figs has the given object as owner

deleteFromModel

public void deleteFromModel()

initNotationProviders

protected void initNotationProviders(java.lang.Object own)
Replace the NotationProvider(s).

This method shall not be used for the initial creation of notation providers, but only for replacing them when required. Initialization must be done in the constructor using methods which can't be overridden.

NotationProviders can not be updated - they are lightweight throw-away objects. Hence this method creates a (new) NotationProvider whenever needed. E.g. when the notation language is changed by the user, then the NPs are to be re-created. So, this method shall not be called from a Fig constructor.

After the removal of the deprecated method setOwner(), this method shall contain the following statement: assert notationProviderName != null

Parameters:
own - owning UML element

getNotationProviderType

protected int getNotationProviderType()
Overrule this for subclasses that need a different NotationProvider.

Returns:
the type of the notation provider

updateStereotypeText

protected void updateStereotypeText()
Updates the text of the stereotype FigText. Override in subclasses to get wanted behaviour.


updateNameText

protected void updateNameText()
Updates the text of the name FigText. This includes text changes, but also changes in rendering like bold.


isPathVisible

public boolean isPathVisible()
Description copied from interface: PathContainer
Determine if the path is visible.

Specified by:
isPathVisible in interface PathContainer
Returns:
true if the path is visible.

setPathVisible

public void setPathVisible(boolean visible)
Description copied from interface: PathContainer
Set the visibility of the path.

Specified by:
setPathVisible in interface PathContainer
Parameters:
visible - the new path status.

determineDefaultPathVisible

protected void determineDefaultPathVisible()
At creation time of the Fig, we determine if the path should be visible by default.

The path is a concatenation of the names of all packages by which this modelelement is contained, seperated by "::" (for UML at least).

If the default namespace of the diagram corresponds to the namespace of the modelelement, then we do NOT show the path. Otherwise, we do.

RRose uses the same heuristic algorithm, but shows "(from <path>)" below the name, while we follow the UML syntax.


classNameAndBounds

@Deprecated
public java.lang.String classNameAndBounds()
Deprecated. 


updateListeners

protected void updateListeners(java.lang.Object oldOwner,
                               java.lang.Object newOwner)
Implementations of this method should register/unregister the fig for all (model)events. For FigNodeModelElement only the fig itself is registered as listening to (all) 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.

An explanation of the original purpose of this method is given in issue 1321.

This function is used by the modelChanged() function.

In certain cases, it is imperative that indeed ALL listeners are updated, since they are ALL removed by a call to removeElementListener.

IF this method is called with both the oldOwner and the newOwner equal and not null, AND we listen only to the owner itself, THEN we can safely ignore the call, but ELSE we need to update the listeners of the related elements, since the related elements may have been replaced.

Parameters:
newOwner - null, or the owner of this. The former means that all listeners have to be removed.
oldOwner - null, or the previous owner The former means that all listeners have to be set.

notationChanged

@Deprecated
public void notationChanged(ArgoNotationEvent event)
Deprecated. for 0.27.2 by tfmorris. Changes to notatation provider are now handled by the owning diagram.

Description copied from interface: ArgoNotationEventListener
Invoked when any aspect of the notation has been changed.

Specified by:
notationChanged in interface ArgoNotationEventListener
Parameters:
event - ArgoNotationEvent describing the change.
See Also:
ArgoNotationEventListener.notationChanged(org.argouml.application.events.ArgoNotationEvent)

notationAdded

@Deprecated
public void notationAdded(ArgoNotationEvent event)
Deprecated. for 0.27.2 by tfmorris.

Description copied from interface: ArgoNotationEventListener
Invoked when a notation has been added.

Specified by:
notationAdded in interface ArgoNotationEventListener
Parameters:
event - ArgoNotationEvent describing the added notation.
See Also:
ArgoNotationEventListener.notationAdded(org.argouml.application.events.ArgoNotationEvent)

notationRemoved

@Deprecated
public void notationRemoved(ArgoNotationEvent event)
Deprecated. for 0.27.2 by tfmorris.

Description copied from interface: ArgoNotationEventListener
Invoked when a notation has been removed.

Specified by:
notationRemoved in interface ArgoNotationEventListener
Parameters:
event - ArgoNotationEvent describing the removed notation.
See Also:
ArgoNotationEventListener.notationRemoved(org.argouml.application.events.ArgoNotationEvent)

notationProviderAdded

@Deprecated
public void notationProviderAdded(ArgoNotationEvent event)
Deprecated. for 0.27.2 by tfmorris.

Description copied from interface: ArgoNotationEventListener
Invoked when a notation provider has been added.

Specified by:
notationProviderAdded in interface ArgoNotationEventListener
Parameters:
event - ArgoNotationEvent describing the added notation provider.
See Also:
ArgoNotationEventListener.notationProviderAdded(org.argouml.application.events.ArgoNotationEvent)

notationProviderRemoved

@Deprecated
public void notationProviderRemoved(ArgoNotationEvent event)
Deprecated. for 0.27.2 by tfmorris.

Description copied from interface: ArgoNotationEventListener
Invoked when a notation provider has been removed.

Specified by:
notationProviderRemoved in interface ArgoNotationEventListener
Parameters:
event - ArgoNotationEvent describing the removed notation provider.
See Also:
ArgoNotationEventListener.notationProviderRemoved(org.argouml.application.events.ArgoNotationEvent)

renderingChanged

public void renderingChanged()
Rerender the entire fig.

This is may be an expensive operation for subclasses which are complex, so should be used sparingly. This functionality was originally the functionality of modelChanged but modelChanged takes the event now into account.

Specified by:
renderingChanged in interface ArgoFig

updateStereotypeIcon

protected void updateStereotypeIcon()

calcBounds

public void calcBounds()

enableSizeChecking

public void enableSizeChecking(boolean flag)
The setter for checkSize.

Parameters:
flag - the new value

hit

public boolean hit(java.awt.Rectangle r)

removeFromDiagram

public final void removeFromDiagram()

getRemoveDelegate

protected Fig getRemoveDelegate()
Subclasses should override this to redirect a remove request from one Fig to another. e.g. FigClassAssociationClass uses this to delegate the remove to its attached FigAssociationClass.

Returns:
the fig that handles the remove request

removeFromDiagramImpl

protected void removeFromDiagramImpl()
If you override this method, make sure to remove all listeners: If you don't, objects in a deleted project will still receive events.

Also important for remove from diagram!


getStereotypeFig

protected FigStereotypesGroup getStereotypeFig()
Get the Fig containing the stereotype(s).

Returns:
the stereotype FigGroup

setBigPort

protected void setBigPort(Fig bp)
Deprecated. by MVW since V0.28.1. Use createBigPortFig() instead, to guarantee correct initialization.

Parameters:
bp - the bigPort, which is the port where edges connect to this node

getBigPort

public Fig getBigPort()
Returns:
the fig which is the port where edges connect to this node

isCheckSize

protected boolean isCheckSize()
Returns:
Returns the checkSize.

isDragConnectable

public boolean isDragConnectable()

setEncloser

protected void setEncloser(Fig e)
Parameters:
e - The _encloser to set.

getEncloser

protected Fig getEncloser()
Returns:
Returns the _encloser.

isReadyToEdit

protected boolean isReadyToEdit()
Returns:
Returns the ReadyToEdit.

setReadyToEdit

protected void setReadyToEdit(boolean v)
Parameters:
v - if ready to edit

setSuppressCalcBounds

protected void setSuppressCalcBounds(boolean scb)
TODO: Move this in FigGroup (in GEF).

Parameters:
scb - The suppressCalcBounds to set.

setVisible

public void setVisible(boolean visible)
Set visibility of figure. If the field invisibleAllowed is not true and this method is passed a parameter of false it will throw an IllegalArgumentException.

Parameters:
visible - new visibility - true = visible.
See Also:
org.tigris.gef.presentation.Fig#setVisible(boolean)

displace

public void displace(int xInc,
                     int yInc)
To redraw each element correctly when changing its location with X and Y additions. Also manages relocation of enclosed Figs.

Parameters:
xInc - the increment in the x direction
yInc - the increment in the y direction

allowRemoveFromDiagram

protected void allowRemoveFromDiagram(boolean allowed)
Parameters:
allowed - true if the function RemoveFromDiagram is allowed

setDiElement

public void setDiElement(DiElement element)

getDiElement

public DiElement getDiElement()

getPopupAddOffset

protected static int getPopupAddOffset()
Returns:
Returns the popupAddOffset.

isEditable

public boolean isEditable()
Determine if this node can be edited.

Returns:
editable state

setEditable

protected void setEditable(boolean canEdit)
By default a node is directly editable by simply selecting that node and starting to type. Should a subclass of FigNodeModelElement not desire this behaviour then it should call setEditable(false) in its constructor.

Parameters:
canEdit - new state, false = editing disabled.

addElementListener

protected void addElementListener(java.lang.Object element)
Add an element listener and remember the registration.

Parameters:
element - element to listen for changes on
See Also:
ModelEventPump.addModelEventListener(PropertyChangeListener, Object, String)

addElementListener

protected void addElementListener(java.lang.Object element,
                                  java.lang.String property)
Add a listener for a given property name and remember the registration.

Parameters:
element - element to listen for changes on
property - name of property to listen for changes of
See Also:
ModelEventPump.addModelEventListener(PropertyChangeListener, Object, String)

addElementListener

protected void addElementListener(java.lang.Object element,
                                  java.lang.String[] property)
Add a listener for an array of property names and remember the registration.

Parameters:
element - element to listen for changes on
property - array of property names (Strings) to listen for changes of
See Also:
ModelEventPump.addModelEventListener(PropertyChangeListener, Object, String)

removeElementListener

protected void removeElementListener(java.lang.Object element)
Remove an element listener and remembered registration.

Parameters:
element - element to listen for changes on
See Also:
ModelEventPump.addModelEventListener(PropertyChangeListener, Object, String)

removeAllElementListeners

protected void removeAllElementListeners()
Unregister all listeners registered through addElementListener

See Also:
addElementListener(Object, String)

updateElementListeners

protected void updateElementListeners(java.util.Set<java.lang.Object[]> listenerSet)
Update the set of registered listeners to match the given set using a minimal update strategy to remove unneeded listeners and add new listeners.

Parameters:
listenerSet - a set of arrays containing a tuple of a UML element to be listened to and a set of property to be listened for.

setProject

@Deprecated
public void setProject(Project project)
Deprecated. 

This optional method is not implemented. It will throw an UnsupportedOperationException if used. Figs are added to a GraphModel which is, in turn, owned by a project.

Specified by:
setProject in interface ArgoFig
Parameters:
project - the project

getProject

@Deprecated
public Project getProject()
Deprecated. for 0.27.2 by tfmorris. Implementations should have all the information that they require in the DiagramSettings object.

Description copied from interface: ArgoFig
Get the owning project for this fig.

Specified by:
getProject in interface ArgoFig
Returns:
the owning project
See Also:
ArgoFig.getProject()

isSingleTarget

protected boolean isSingleTarget()
Determine if this Fig is the sole selected target in the TargetManager

Returns:
true if this is the sole target.

getStereotypeView

public int getStereotypeView()
Deprecated. for 0.27.2 by tfmorris. Use getStereotypeStyle().

Returns:
current stereotype view

getStereotypeStyle

public DiagramSettings.StereotypeStyle getStereotypeStyle()
Specified by:
getStereotypeStyle in interface StereotypeStyled
Returns:
See Also:
StereotypeStyled.getStereotypeStyle()

getStereotypeCount

public int getStereotypeCount()
Get the number of stereotypes contained in this FigNode

Returns:
the number of stereotypes contained in the FigNode

setStereotypeView

public void setStereotypeView(int s)
Deprecated. for 0.27.2 by tfmorris. Use #setStereotypeStyle(StereotypeStyle).

Sets the stereotype view.

Parameters:
s - the stereotype view to be set

setStereotypeStyle

public void setStereotypeStyle(DiagramSettings.StereotypeStyle style)
Set the stereotype style to be used for rendering this fig.

Specified by:
setStereotypeStyle in interface StereotypeStyled
Parameters:
style - the stereotype style to be set

setBoundsImpl

protected void setBoundsImpl(int x,
                             int y,
                             int w,
                             int h)
Sets the bounds of this node taking the stereotype view into consideration.
Do not override this method, override setStandardBounds(int, int, int, int) instead.


getMinimumSize

public java.awt.Dimension getMinimumSize()
Returns the minimum size of the Fig. This is the smallest size that the user can make this Fig by dragging.

Do not call this function if the Fig is not resizable! In ArgoUML we decided that it is not needed to implement suitable getMinimumSize() methods for Figs that are not resizable.


setStandardBounds

protected void setStandardBounds(int x,
                                 int y,
                                 int w,
                                 int h)
Replaces setBoundsImpl(int, int, int, int).

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
See Also:
org.tigris.gef.presentation.Fig#setBoundsImpl(int, int, int, int)

diagramFontChanged

public void diagramFontChanged(ArgoDiagramAppearanceEvent e)
Deprecated. for 0.27.2 by tfmorris. The owning diagram manages global changes to rendering defaults.

Handles diagram font changing.

Specified by:
diagramFontChanged in interface ArgoDiagramAppearanceEventListener
Parameters:
e - the event or null
See Also:
ArgoDiagramAppearanceEventListener.diagramFontChanged(org.argouml.application.events.ArgoDiagramAppearanceEvent)

updateFont

protected void updateFont()
This function should, for all FigTexts, recalculate the font-style (plain, bold, italic, bold/italic), and apply it by calling FigText.setFont().

If the "deepUpdateFont" function does not work for a subclass, then override this method.


getNameFigFontStyle

protected int getNameFigFontStyle()
Determines the font style based on the UML model. Overrule this in Figs that have to show bold or italic based on the UML model they represent. E.g. abstract classes show their name in italic.

Returns:
the font style for the nameFig.

getSettings

public DiagramSettings getSettings()
Specified by:
getSettings in interface ArgoFig
Returns:
the rendering settings for the Fig

setSettings

public void setSettings(DiagramSettings renderSettings)
Description copied from interface: ArgoFig
Set the rendering settings to be used for this fig. Currently this normally will be a diagram-wide or project-wide settings object that is shared by all Figs.

Specified by:
setSettings in interface ArgoFig
Parameters:
renderSettings - the rendering settings to use

getNotationSettings

protected NotationSettings getNotationSettings()

setLineWidth

public void setLineWidth(int w)

setOwner

@Deprecated
public void setOwner(java.lang.Object owner)
Deprecated. for 0.27.3 by tfmorris. Set owner in constructor. This method is implemented in GEF, so we'll leave this implementation here to block any attempts to use it within ArgoUML.

Setting the owner of the Fig must be done in the constructor and not changed afterwards for all ArgoUML figs.

Specified by:
setOwner in interface ArgoFig
Parameters:
owner - owning UML element
Throws:
java.lang.UnsupportedOperationException
See Also:
org.tigris.gef.presentation.Fig#setOwner(java.lang.Object)

bindPort

public void bindPort(java.lang.Object port,
                     Fig f)


ArgoUML © 1996-2006ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook