org.argouml.uml.diagram.ui
Class FigEdgeModelElement

java.lang.Object
  |
  +--FigEdgePoly
        |
        +--org.argouml.uml.diagram.ui.FigEdgeModelElement
All Implemented Interfaces:
ArgoEventListener, ArgoNotationEventListener, DelayedVChangeListener, java.util.EventListener, java.awt.event.KeyListener, java.awt.event.MouseListener, NotationContext, java.beans.PropertyChangeListener, java.beans.VetoableChangeListener
Direct Known Subclasses:
FigAssociation, FigDependency, FigEdgeNote, FigExtend, FigGeneralization, FigInclude, FigLink, FigLink, FigRealization, FigTransition

public abstract class FigEdgeModelElement
extends FigEdgePoly
implements java.beans.VetoableChangeListener, DelayedVChangeListener, java.awt.event.MouseListener, java.awt.event.KeyListener, java.beans.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

Field Summary
private  NotationName _currentNotationName
          The current notation for this fig.
private  ItemUID _id
           
protected  FigText _name
           
protected  FigText _stereo
           
protected static java.lang.String BUNDLE
           
protected static Logger cat
          Deprecated. by Linus Tolke as of 0.15.4. Use your own logger in your class. This will be removed.
static java.awt.Font ITALIC_LABEL_FONT
           
static java.awt.Font LABEL_FONT
           
private static Logger LOG
           
 int MARGIN
           
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.
 
Constructor Summary
FigEdgeModelElement()
          Partially construct a new FigNode.
FigEdgeModelElement(java.lang.Object edge)
           
 
Method Summary
protected  boolean canEdit(Fig f)
           
 void damage()
           
 void delayedVetoableChange(java.beans.PropertyChangeEvent pce)
           
 void delete()
           
 void dispose()
           
 void finalize()
           
 NotationName getContextNotation()
          This default implementation simply requests the default notation.
protected  java.lang.Object getDestination()
          Returns the destination of the edge.
 ItemUID getItemUID()
           
 FigText getNameFig()
           
 java.util.Vector getPopUpActions(java.awt.event.MouseEvent me)
           
protected  java.lang.Object getSource()
          Returns the source of the edge.
 int getSquaredDistance(java.awt.Point p1, java.awt.Point p2)
           
 FigText getStereotypeFig()
           
 java.lang.String getTipString(java.awt.event.MouseEvent me)
           
 ToDoItem hitClarifier(int x, int y)
           
private  boolean isPolyDistLessThan(java.awt.Polygon poly, int x, int y, double maxDist)
          helper method for hit(Rectangle).
 void keyPressed(java.awt.event.KeyEvent ke)
           
 void keyReleased(java.awt.event.KeyEvent ke)
          not used, do nothing.
 void keyTyped(java.awt.event.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.
 void listRoleItemSet(MElementEvent mee)
           
 Selection makeSelection()
          Returns a SelectionRerouteEdge object that manages selection and rerouting of the edge.
protected  void modelChanged(MElementEvent e)
          This is called aftern any part of the UML MModelElement has changed.
 void mouseClicked(java.awt.event.MouseEvent me)
          If the user double clicks on anu part of this FigNode, pass it down to one of the internal Figs.
 void mouseEntered(java.awt.event.MouseEvent me)
           
 void mouseExited(java.awt.event.MouseEvent me)
           
 void mousePressed(java.awt.event.MouseEvent me)
           
 void mouseReleased(java.awt.event.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(java.awt.Graphics g)
           
 void postLoad()
           
 void propertyChange(java.beans.PropertyChangeEvent pve)
           
 void propertySet(MElementEvent mee)
           
 void recovered(MElementEvent mee)
           
 void removed(MElementEvent mee)
           
 void renderingChanged()
          Rerenders the fig if needed.
 void roleAdded(MElementEvent mee)
           
 void roleRemoved(MElementEvent mee)
           
 void setItemUID(ItemUID id)
           
 void setOwner(java.lang.Object newOwner)
           
 void setPoints(Handle h, int x, int y)
          Overridden to notify project that save is needed when edge is moved.
protected  void textEdited(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()
           
protected  void updateStereotypeText()
           
 void vetoableChange(java.beans.PropertyChangeEvent pce)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cat

protected static Logger cat
Deprecated. by Linus Tolke as of 0.15.4. Use your own logger in your class. This will be removed.


LOG

private static final Logger LOG

BUNDLE

protected static final java.lang.String BUNDLE
See Also:
Constant Field Values

LABEL_FONT

public static java.awt.Font LABEL_FONT

ITALIC_LABEL_FONT

public static java.awt.Font ITALIC_LABEL_FONT

MARGIN

public final int MARGIN
See Also:
Constant Field Values

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

protected FigText _name

_stereo

protected FigText _stereo

_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(java.lang.Object edge)
Method Detail

finalize

public void finalize()

setItemUID

public void setItemUID(ItemUID id)

getItemUID

public ItemUID getItemUID()

getTipString

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

getPopUpActions

public java.util.Vector getPopUpActions(java.awt.event.MouseEvent me)

getSquaredDistance

public int getSquaredDistance(java.awt.Point p1,
                              java.awt.Point p2)

paintClarifiers

public void paintClarifiers(java.awt.Graphics g)

hitClarifier

public ToDoItem hitClarifier(int x,
                             int y)

makeSelection

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


getNameFig

public FigText getNameFig()

getStereotypeFig

public FigText getStereotypeFig()

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

propertyChange

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

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 FigEdgeModelElement. Determine which field and update the model. This class handles the name, subclasses should override to handle other text elements.

java.beans.PropertyVetoException

canEdit

protected boolean canEdit(Fig f)

mousePressed

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

mouseReleased

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

mouseEntered

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

mouseExited

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

mouseClicked

public void mouseClicked(java.awt.event.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 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)
not used, do nothing.

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(MElementEvent e)
This is called aftern any part of the UML MModelElement has changed. This method automatically updates the name FigText. Subclasses should override and update other parts.


updateNameText

protected void updateNameText()

updateStereotypeText

protected void updateStereotypeText()

setOwner

public void setOwner(java.lang.Object newOwner)

propertySet

public void propertySet(MElementEvent mee)

listRoleItemSet

public void listRoleItemSet(MElementEvent mee)

recovered

public void recovered(MElementEvent mee)

removed

public void removed(MElementEvent mee)

roleAdded

public void roleAdded(MElementEvent mee)

roleRemoved

public void roleRemoved(MElementEvent mee)

dispose

public void dispose()
See Also:
org.tigris.gef.presentation.Fig#dispose()

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

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.

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.

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.

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.

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.

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.


isPolyDistLessThan

private boolean isPolyDistLessThan(java.awt.Polygon poly,
                                   int x,
                                   int y,
                                   double maxDist)
helper method for hit(Rectangle). Checks if a point (x, y) is within maxDist units of a polygon poly. This is true if there is a point on some leg of the polygon such that the point is located orthogonally to it and the distance to the point is not greater than maxDist.

Parameters:
poly - is the Polygon.
x - is the x-coordinate of the point.
y - is the y-coordinate of the point.
maxDist - is the longest acceptable distance.
Returns:
true if the point is not further than maxDist away from the polygon, otherwise false.

delete

public void delete()
See Also:
org.tigris.gef.presentation.Fig#delete()

damage

public void damage()
See Also:
org.tigris.gef.presentation.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 java.lang.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 java.lang.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. Since we don't support n-array associations but only binary relations, source/destination works for all edges.

Returns:
Object

postLoad

public void postLoad()
See Also:
org.tigris.gef.presentation.Fig#postLoad()

setPoints

public void setPoints(Handle h,
                      int x,
                      int y)
Overridden to notify project that save is needed when edge is moved.



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