org.argouml.uml.diagram.ui
Class FigEdgeModelElement

java.lang.Object
  extended byorg.tigris.gef.presentation.Fig
      extended byorg.tigris.gef.presentation.FigEdge
          extended byorg.tigris.gef.presentation.FigEdgePoly
              extended byorg.argouml.uml.diagram.ui.FigEdgeModelElement
All Implemented Interfaces:
ArgoEventListener, ArgoNotationEventListener, Cloneable, Connecter, DelayedVChangeListener, EventListener, org.tigris.gef.di.GraphEdge, org.tigris.gef.di.GraphicElement, Highlightable, KeyListener, MouseListener, NotationContext, PopupGenerator, PropertyChangeListener, Serializable, VetoableChangeListener
Direct Known Subclasses:
FigAssociation, FigAssociationEnd, FigDependency, FigEdgeAssociationClass, FigEdgeNote, FigExtend, FigGeneralization, FigInclude, FigLink, FigMessage, FigTransition

public abstract class FigEdgeModelElement
extends FigEdgePoly
implements VetoableChangeListener, DelayedVChangeListener, MouseListener, KeyListener, PropertyChangeListener, NotationContext, ArgoNotationEventListener, Highlightable

Abstract class to display diagram lines (edges) for UML ModelElements that look like lines and that have editable names.

See Also:
Serialized Form

Field Summary
protected  NotationProvider4 notationProviderName
           
 
Fields inherited from class org.tigris.gef.presentation.FigEdgePoly
_initiallyLaidOut
 
Fields inherited from class org.tigris.gef.presentation.FigEdge
_arrowHeadEnd, _arrowHeadStart, _destFigNode, _highlight, _pathItems, _sourceFigNode, _useNearest
 
Fields inherited from class org.tigris.gef.presentation.Fig
_allowsSaving, _context, _dashes, _dashPeriod, _dashStyle, _filled, _h, _w, _x, _y, an, annotationOwner, annotationStatus, BORDER, MIN_SIZE, plotter
 
Constructor Summary
FigEdgeModelElement()
          Partially construct a new FigNode.
FigEdgeModelElement(Object edge)
          The constructor that hooks the Fig into the UML model element.
 
Method Summary
protected  void addElementListener(Object element)
          Add an element listener and remember the registration.
protected  void addElementListener(Object element, String property)
          Add a listener and remember the registration.
protected  void addElementListener(Object element, String[] property)
          Add a listener and remember the registration.
protected  void allowRemoveFromDiagram(boolean allowed)
           
protected  boolean canEdit(Fig f)
           
 void damage()
           
 void delayedVetoableChange(PropertyChangeEvent pce)
           
 void deleteFromModel()
           
protected  Action[] getApplyStereotypeActions()
          Get the set of Actions which valid for adding/removing Stereotypes on the ModelElement of this Fig's owner.
 NotationName getContextNotation()
          Deprecated. by MVW in V0.21.3. Replaced by ProjectSettings.getNotationName()
protected  Object getDestination()
          Returns the destination of the edge.
 DiElement getDiElement()
           
 FigEdgePort getEdgePort()
           
static Font getItalicLabelFont()
           
 ItemUID getItemUID()
          Getter for the UID
static Font getLabelFont()
           
 String getName()
           
 Rectangle getNameBounds()
          Get the Rectangle in which the model elements name is displayed
protected  FigText getNameFig()
          Getter for name, the name Fig
 Vector getPopUpActions(MouseEvent me)
           
protected static int getPopupAddOffset()
           
protected  Fig getRemoveDelegate()
          Subclasses should override this to redirect a remove request from one Fig to another.
protected  Object getSource()
          Returns the source of the edge.
protected  int getSquaredDistance(Point p1, Point p2)
          distance formula: (x-h)^2 + (y-k)^2 = distance^2
protected  Fig getStereotypeFig()
          Getter for stereo, the stereotype Fig
 String getTipString(MouseEvent me)
           
 boolean hit(Rectangle r)
           
 ToDoItem hitClarifier(int x, int y)
          The user clicked on the clarifier.
protected  void indicateBounds(FigText f, Graphics g)
           
protected  void initNotationProviders(Object own)
          Create the NotationProviders.
 void keyPressed(KeyEvent ke)
           
 void keyReleased(KeyEvent ke)
           
 void keyTyped(KeyEvent ke)
           
 void makeEdgePort()
          Create a FigCommentPort if needed
 Selection makeSelection()
          Returns a SelectionRerouteEdge object that manages selection and rerouting of the edge.
protected  void modelChanged(PropertyChangeEvent e)
          This is called after any part of the UML ModelElement has changed.
 void mouseClicked(MouseEvent me)
          If the user double clicks on anu part of this FigNode, pass it down to one of the internal Figs.
 void mouseEntered(MouseEvent me)
           
 void mouseExited(MouseEvent me)
           
 void mousePressed(MouseEvent me)
           
 void mouseReleased(MouseEvent me)
           
 void notationAdded(ArgoNotationEvent event)
          Invoked when a notation has been added.
 void notationChanged(ArgoNotationEvent event)
          Invoked when any aspect of the notation has been changed.
 void notationProviderAdded(ArgoNotationEvent event)
          Invoked when a notation provider has been added.
 void notationProviderRemoved(ArgoNotationEvent event)
          Invoked when a notation provider has been removed.
 void notationRemoved(ArgoNotationEvent event)
          Invoked when a notation has been removed.
protected  void paintClarifiers(Graphics g)
           
 void postLoad()
           
 void propertyChange(PropertyChangeEvent pve)
           
protected  void removeAllElementListeners()
          Unregister all listeners registered through addElementListener
protected  void removeElementListener(Object element)
          Add an element listener and remember the registration.
 void removeFromDiagram()
           
protected  void removeFromDiagramImpl()
           
protected  void renderingChanged()
          Rerenders the fig if needed.
 void setContextNotation(NotationName nn)
           
 void setDiElement(DiElement element)
          Set the associated Diagram Interchange element.
 void setItemUID(ItemUID newId)
          Setter for the UID
 void setLayer(Layer lay)
           
 void setOwner(Object newOwner)
          This method should only be called once for any one Fig instance that represents a model element (ie not for a FigEdgeNote).
protected  void showHelp(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 superRemoveFromDiagram()
           
protected  void textEdited(FigText ft)
          This method is called after the user finishes editing a text field that is in the FigEdgeModelElement.
protected  void textEditStarted(FigText ft)
          This method is called when the user doubleclicked on the text field, and starts editing.
protected  boolean updateClassifiers()
          Updates the classifiers the edge is attached to.
protected  void updateListeners(Object oldOwner, Object newOwner)
          Implementations of this method should register/unregister the fig for all (model)events.
protected  void updateNameText()
          generate the notation for the modelelement and stuff it into the text Fig
protected  void updateStereotypeText()
          generate the notation for the stereotype and stuff it into the text Fig
 void vetoableChange(PropertyChangeEvent pce)
           
 
Methods inherited from class org.tigris.gef.presentation.FigEdgePoly
computeRouteImpl, findAvoidPt, getPolygon, insertPoint, layoutEdge, makeEdgeFig, moveVertex, paint, routingRectPoint, segOK, setEndPoints, setInitiallyLaidOut, setPoint, setPolygon, tryRoute
 
Methods inherited from class org.tigris.gef.presentation.FigEdge
addPathItem, calcBounds, cleanUp, computeRoute, contains, getBetweenNearestPoints, getBounds, getDashed, getDestArrowHead, getDestFigNode, getDestPortFig, getFig, getFirstPoint, getHighlight, getLastPoint, getLineColor, getLineWidth, getNumPoints, getPathItem, getPathItemFig, getPathItemFigs, getPathItemsRaw, getPerimeterLength, getPoint, getPoints, getPrivateData, getSourceArrowHead, getSourceFigNode, getSourcePortFig, getXs, getYs, hasFillColor, hitFig, intersects, isReshapable, isResizable, isRotatable, paintArrowHeads, paintHighlightLine, paintPathItems, removePathItem, removePathItem, setBetweenNearestPoints, setDashed, setDestArrowHead, setDestFigNode, setDestPortFig, setFig, setHighlight, setLineColor, setLineWidth, setNumPoints, setPoint, setPoints, setSourceArrowHead, setSourceFigNode, setSourcePortFig, setXs, setYs, stuffPointAlongPerimeter, translateEdge, updatePathItemLocations
 
Methods inherited from class org.tigris.gef.presentation.Fig
addAnnotation, addPoint, addPropertyChangeListener, align, center, classNameAndBounds, clone, connectionPoint, contains, contains, countCornersContained, createDrag, endTrans, firePropChange, firePropChange, firePropChange, getAnnotationOwner, getAnnotationStrategy, getBounds, getCenter, getClosestPoint, getContext, getDashed01, getDashedString, getEnclosedFigs, getEnclosingFig, getFillColor, getFilled, getFilled01, getGravityPoints, getGroup, getHalfHeight, getHalfWidth, getHandleBox, getHeight, getId, getLayer, getLocation, getLocked, getMinimumSize, getOwner, getPreferredSize, getResource, getSingle, getSize, getTrapRect, getUseTrapRect, getVisState, getWidth, getX, getY, hasLineColor, initAnnotations, intersectsPerimeter, isAnnotation, isCopyable, isCutable, isLowerRightResizable, isMovable, isRemoveStarted, isSelectable, isSelected, isVisible, paint, pointAlongPerimeter, postSave, preSave, print, redraw, removeAnnotation, removePoint, removePropertyChangeListener, reorder, routingRect, savingAllowed, setAnnotationOwner, setAnnotationStatus, setAnnotationStrategy, setBounds, setBounds, setBoundsImpl, setCenter, setContext, setDashedString, setEnclosingFig, setFillColor, setFilled, setGroup, setHandleBox, setHeight, setLocation, setLocation, setLocked, setMovable, setPoint, setPoint, setPrivateData, setResizable, setResource, setSavingAllowed, setSize, setSize, setVisible, setWidth, setX, setY, stuffBounds, translate, translateAnnotations, translateImpl, unsetAnnotationOwner, updateAnnotationPositions, within
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.argouml.cognitive.Highlightable
getHighlight, setHighlight
 
Methods inherited from interface org.tigris.gef.di.GraphicElement
getId, getOwner, routingRect
 

Field Detail

notationProviderName

protected NotationProvider4 notationProviderName
Constructor Detail

FigEdgeModelElement

public FigEdgeModelElement()
Partially construct a new FigNode. This method creates the _name element that holds the name of the model element and adds itself as a listener.


FigEdgeModelElement

public FigEdgeModelElement(Object edge)
The constructor that hooks the Fig into the UML model element.

Parameters:
edge - the UML element
Method Detail

makeEdgePort

public void makeEdgePort()
Create a FigCommentPort if needed


getEdgePort

public FigEdgePort getEdgePort()
Returns:
the FigCommentPort

setItemUID

public void setItemUID(ItemUID newId)
Setter for the UID

Parameters:
newId - the new UID

getItemUID

public ItemUID getItemUID()
Getter for the UID

Returns:
the UID

getTipString

public String getTipString(MouseEvent me)
See Also:
Fig.getTipString(java.awt.event.MouseEvent)

getPopUpActions

public Vector getPopUpActions(MouseEvent me)
Specified by:
getPopUpActions in interface PopupGenerator
See Also:
PopupGenerator.getPopUpActions(java.awt.event.MouseEvent)

getApplyStereotypeActions

protected Action[] getApplyStereotypeActions()
Get the set of Actions which valid for adding/removing Stereotypes on the ModelElement of this Fig's owner.

Returns:
array of Actions

getSquaredDistance

protected int getSquaredDistance(Point p1,
                                 Point p2)
distance formula: (x-h)^2 + (y-k)^2 = distance^2

Parameters:
p1 - point
p2 - point
Returns:
the square of the distance

paintClarifiers

protected void paintClarifiers(Graphics g)
Parameters:
g - the Graphics object

indicateBounds

protected void indicateBounds(FigText f,
                              Graphics g)
Parameters:
f - the fig to indicate the bounds of
g - the graphics

hitClarifier

public ToDoItem hitClarifier(int x,
                             int y)
The user clicked on the clarifier.

Parameters:
x - the x of the point clicked
y - the y of the point clicked
Returns:
the todo item clicked

makeSelection

public Selection makeSelection()
Returns a SelectionRerouteEdge object that manages selection and rerouting of the edge.

Returns:
the SelectionRerouteEdge.

getNameFig

protected FigText getNameFig()
Getter for name, the name Fig

Returns:
the nameFig

getNameBounds

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


getName

public String getName()

getStereotypeFig

protected Fig getStereotypeFig()
Getter for stereo, the stereotype Fig

Returns:
the stereo Fig

vetoableChange

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

delayedVetoableChange

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

propertyChange

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

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, but that seems not user-friendly.

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

showHelp

protected void showHelp(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)
This method is called after the user finishes editing a text field that is in the FigEdgeModelElement. Determine which field and update the model. This class handles the name, subclasses should override to handle other text elements.

Parameters:
ft - the text Fig that has been edited

canEdit

protected boolean canEdit(Fig f)
Parameters:
f - the Fig
Returns:
true if editable

mousePressed

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

mouseReleased

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

mouseEntered

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

mouseExited

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

mouseClicked

public void mouseClicked(MouseEvent me)
If the user double clicks on anu 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
See Also:
MouseListener.mouseClicked(java.awt.event.MouseEvent)

keyPressed

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

keyReleased

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

keyTyped

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

renderingChanged

protected void renderingChanged()
Rerenders the fig if needed. This functionality was originally the functionality of modelChanged but modelChanged takes the event now into account.

NOTE: If you override this method you probably also want to override the modelChanged() method TODO: Call this method something sensible. What it does rather than one example of when it is called. Its purpose seems to be to update everything if anything has changed. Not very efficient.


modelChanged

protected void modelChanged(PropertyChangeEvent e)
This is called after any part of the UML ModelElement has changed. This method automatically updates the name FigText. Subclasses should override and update other parts.

Parameters:
e - the event

updateNameText

protected void updateNameText()
generate the notation for the modelelement and stuff it into the text Fig


updateStereotypeText

protected void updateStereotypeText()
generate the notation for the stereotype and stuff it into the text Fig


setOwner

public void setOwner(Object newOwner)
This method should only be called once for any one Fig instance that represents a model element (ie not for a FigEdgeNote). It is called either by the constructor that takes an model element as an argument or it is called by PGMLStackParser after it has created the Fig by use of the empty constructor. The assigned model element (owner) must not change during the lifetime of the Fig. TODO: It is planned to refactor so that there is only one Fig constructor. When this is achieved this method can refactored out.

Throws:
IllegalArgumentException - if the owner given is not a model element
See Also:
Fig.setOwner(java.lang.Object)

initNotationProviders

protected void initNotationProviders(Object own)
Create the NotationProviders.

Parameters:
own - the current owner

updateListeners

protected void updateListeners(Object oldOwner,
                               Object newOwner)
Implementations of this method should register/unregister the fig for all (model)events. For FigEdgeModelElement only the fig itself is registered as listening to events fired by the owner itself. But for, for example, FigAssociation the fig must also register for events fired by the stereotypes of the owner.

This function is used in UMLDiagram, which removes all listeners to all Figs when a diagram is not displayed, and restore them when it becomes visible again.

In this case, it is not imperative that indeed ALL listeners are updated, as long as the ones removed get added again and vice versa.

Additionally, this function may be used by the modelChanged() function.

In this case, it IS imperative that all listeners get removed / added.

Parameters:
newOwner - the new owner for the listeners

setLayer

public void setLayer(Layer lay)
See Also:
Fig.setLayer(org.tigris.gef.base.Layer)

deleteFromModel

public void deleteFromModel()
See Also:
Fig.deleteFromModel()

getContextNotation

public NotationName getContextNotation()
Deprecated. by MVW in V0.21.3. Replaced by ProjectSettings.getNotationName()

This default implementation simply requests the default notation.

Specified by:
getContextNotation in interface NotationContext
Returns:
null if the context does not wish to name a specific notation
See Also:
NotationContext.getContextNotation()

setContextNotation

public void setContextNotation(NotationName nn)
Specified by:
setContextNotation in interface NotationContext
Parameters:
nn - the new notationName
See Also:
NotationContext.setContextNotation(org.argouml.notation.NotationName)

notationChanged

public void notationChanged(ArgoNotationEvent event)
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

public void notationAdded(ArgoNotationEvent event)
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

public void notationRemoved(ArgoNotationEvent event)
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

public void notationProviderAdded(ArgoNotationEvent event)
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

public void notationProviderRemoved(ArgoNotationEvent event)
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)

hit

public boolean hit(Rectangle r)
See Also:
Fig.hit(java.awt.Rectangle)

removeFromDiagram

public final void removeFromDiagram()
See Also:
Fig.removeFromDiagram()

getRemoveDelegate

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

Returns:

removeFromDiagramImpl

protected void removeFromDiagramImpl()

superRemoveFromDiagram

protected void superRemoveFromDiagram()

damage

public void damage()
See Also:
Fig.damage()

updateClassifiers

protected boolean updateClassifiers()

Updates the classifiers the edge is attached to.

Calls a helper method (layoutThisToSelf) to avoid this edge disappearing if the new source and dest are the same node.

Returns:
boolean whether or not the update was sucessful

getSource

protected Object getSource()
Returns the source of the edge. The source is the owner of the node the edge travels from in a binary relationship. For instance: for a classifierrole, this is the sender.

Returns:
a model element

getDestination

protected Object getDestination()
Returns the destination of the edge. The destination is the owner of the node the edge travels to in a binary relationship. For instance: for a classifierrole, this is the receiver.

Returns:
a model element

postLoad

public void postLoad()
See Also:
Fig.postLoad()

getLabelFont

public static Font getLabelFont()
Returns:
Returns the lABEL_FONT.

getItalicLabelFont

public static Font getItalicLabelFont()
Returns:
Returns the iTALIC_LABEL_FONT.

allowRemoveFromDiagram

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

setDiElement

public void setDiElement(DiElement element)
Set the associated Diagram Interchange element.

Parameters:
element - the element to be associated with this Fig

getDiElement

public DiElement getDiElement()
Returns:
the Diagram Interchange element associated with this Fig

getPopupAddOffset

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

addElementListener

protected void addElementListener(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(Object element,
                                  String property)
Add a listener 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(Object element,
                                  String[] property)
Add a listener 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(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)

removeAllElementListeners

protected void removeAllElementListeners()
Unregister all listeners registered through addElementListener

See Also:
addElementListener(Object, String)


ArgoUML © 1996-2006ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook