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, org.tigris.gef.presentation.Connecter, DelayedVChangeListener, EventListener, org.tigris.gef.ui.Highlightable, KeyListener, MouseListener, NotationContext, org.tigris.gef.ui.PopupGenerator, PropertyChangeListener, Serializable, VetoableChangeListener
Direct Known Subclasses:
FigAssociation, FigAssociationEnd, FigDependency, FigEdgeAssociationClass, FigEdgeNote, FigExtend, FigGeneralization, FigInclude, FigLink, FigLink, FigRealization, FigTransition

public abstract class FigEdgeModelElement
extends org.tigris.gef.presentation.FigEdgePoly
implements VetoableChangeListener, DelayedVChangeListener, MouseListener, KeyListener, PropertyChangeListener, NotationContext, ArgoNotationEventListener

Abstract class to display diagram arcs for UML ModelElements that look like arcs and that have editiable names.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.tigris.gef.presentation.FigEdge
 
Field Summary
protected static String BUNDLE
          BUNDLE
private  NotationName currentNotationName
          The current notation for this fig.
private  ItemUID id
           
private static Font ITALIC_LABEL_FONT
           
private static Font LABEL_FONT
           
private static Logger LOG
           
private  org.tigris.gef.presentation.FigText name
          The Fig that displays the name of this model element.
protected static int POPUP_ADD_OFFSET
          Offset from the end of the set of popup actions at which new items should be inserted by concrete figures.
private  boolean removeFromDiagram
          Set the removeFromDiagram to false if this edge may not be removed from the diagram.
private  org.tigris.gef.presentation.FigText stereo
          The Fig that displays the stereotype of this model element.
 
Fields inherited from class org.tigris.gef.presentation.FigEdgePoly
_initiallyLaidOut
 
Fields inherited from class org.tigris.gef.presentation.FigEdge
_arrowHeadEnd, _arrowHeadStart, _destFigNode, _fig, _highlight, _pathItems, _sourceFigNode, _useNearest
 
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
FigEdgeModelElement()
          Partially construct a new FigNode.
FigEdgeModelElement(Object edge)
          the constructor that hooks the Fig into the UML model element
 
Method Summary
protected  void allowRemoveFromDiagram(boolean allowed)
           
protected  boolean canEdit(org.tigris.gef.presentation.Fig f)
           
 void damage()
           
 void delayedVetoableChange(PropertyChangeEvent pce)
           
 void deleteFromModel()
           
 void finalize()
           
 NotationName getContextNotation()
          This default implementation simply requests the default notation.
protected  Object getDestination()
          Returns the destination of the edge.
static Font getItalicLabelFont()
           
 ItemUID getItemUID()
          Getter for the UID
static Font getLabelFont()
           
 org.tigris.gef.presentation.FigText getNameFig()
          Getter for name, the name Fig
 Vector getPopUpActions(MouseEvent me)
           
protected  Object getSource()
          Returns the source of the edge.
 int getSquaredDistance(Point p1, Point p2)
          distance formula: (x-h)^2 + (y-k)^2 = distance^2
 org.tigris.gef.presentation.FigText 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.
 void keyPressed(KeyEvent ke)
           
 void keyReleased(KeyEvent ke)
           
 void keyTyped(KeyEvent ke)
           
private  void layoutThisToSelf()
          helper method for updateClassifiers() in order to automatically layout an edge that is now from and to the same node type.
 org.tigris.gef.base.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 MModelElement 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.
 void paintClarifiers(Graphics g)
           
 void postLoad()
           
 void propertyChange(PropertyChangeEvent pve)
           
 void removeFromDiagram()
           
 void renderingChanged()
          Rerenders the fig if needed.
 void setItemUID(ItemUID newId)
          Setter for the UID
 void setOwner(Object newOwner)
           
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 FigEdgeModelElement.
protected  boolean updateClassifiers()
          Updates the classifiers the edge is attached to.
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
computeRoute, findAvoidPt, insertPoint, layoutEdge, makeEdgeFig, moveVertex, paint, routingRectPoint, segOK, setEndPoints, setInitiallyLaidOut, setPoint, tryRoute
 
Methods inherited from class org.tigris.gef.presentation.FigEdge
addPathItem, calcBounds, cleanUp, contains, getBetweenNearestPoints, getBounds, 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, setPoints, setPoints, setPrivateData, 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, delete, dispose, drawDashedLine, drawDashedPerimeter, endTrans, firePropChange, firePropChange, firePropChange, getAnnotationOwner, getAnnotationStrategy, 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, isCopieable, isCopyable, isCutable, isDisplayed, isLowerRightResizable, isMovable, isSelected, isVisible, OK, pointAlongPerimeter, postSave, preSave, print, redraw, removeAnnotation, removeAnnotation, removePoint, removePropertyChangeListener, reorder, routingRect, savingAllowed, setAnnotationOwner, setAnnotationStatus, setAnnotationStrategy, setBounds, setBounds, setCenter, setContext, setDashedString, setDisplayed, setEnclosingFig, setFillColor, setFilled, setGroup, setHandleBox, setHeight, setLayer, setLocation, setLocation, setLocked, setMovable, setPoint, setPoint, setPoints, setPoints, setResizable, setResource, setSavingAllowed, setSelected, setSingle, setSize, setSize, setVisible, setVisState, setWidth, setX, setY, stuffBounds, translate, 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 org.tigris.gef.ui.Highlightable
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

LOG

private static final Logger LOG

removeFromDiagram

private boolean removeFromDiagram
Set the removeFromDiagram to false if this edge may not be removed from the diagram.


BUNDLE

protected static final String BUNDLE
BUNDLE

See Also:
Constant Field Values

LABEL_FONT

private static final Font LABEL_FONT

ITALIC_LABEL_FONT

private static final Font ITALIC_LABEL_FONT

POPUP_ADD_OFFSET

protected static final int POPUP_ADD_OFFSET
Offset from the end of the set of popup actions at which new items should be inserted by concrete figures.

See Also:
Constant Field Values

name

private org.tigris.gef.presentation.FigText name
The Fig that displays the name of this model element. Use getNameFig(), no setter should be required.


stereo

private org.tigris.gef.presentation.FigText stereo
The Fig that displays the stereotype of this model element. Use getStereotypeFig(), no setter should be required.


id

private ItemUID id

currentNotationName

private NotationName currentNotationName
The current notation for this fig. The notation is for example UML 1.3 or Java

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

finalize

public void finalize()
See Also:
Object.finalize()

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

getSquaredDistance

public 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

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

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 org.tigris.gef.base.Selection makeSelection()
Returns a SelectionRerouteEdge object that manages selection and rerouting of the edge.

Returns:
the SelectionRerouteEdge.

getNameFig

public org.tigris.gef.presentation.FigText getNameFig()
Getter for name, the name Fig

Returns:
the nameFig

getStereotypeFig

public org.tigris.gef.presentation.FigText 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)

textEdited

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 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(org.tigris.gef.presentation.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:
Not used, do nothing.

keyTyped

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

modelChanged

protected void modelChanged(PropertyChangeEvent e)
This is called after any part of the UML MModelElement 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)
See Also:
Fig.setOwner(java.lang.Object)

deleteFromModel

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

getContextNotation

public NotationName getContextNotation()
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()

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)

renderingChanged

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


hit

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

removeFromDiagram

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

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

layoutThisToSelf

private void layoutThisToSelf()
helper method for updateClassifiers() in order to automatically layout an edge that is now from and to the same node type.

adapted from SelectionWButtons from line 280


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:
MModelElement

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:
Object

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


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