org.argouml.uml.diagram.ui
Class ModeCreateAssociation

java.lang.Object
  extended byorg.tigris.gef.base.ModeImpl
      extended byorg.tigris.gef.base.FigModifyingModeImpl
          extended byorg.tigris.gef.base.ModeCreate
              extended byorg.tigris.gef.base.ModeCreatePolyEdge
                  extended byorg.argouml.uml.diagram.ui.ModeCreateAssociation
All Implemented Interfaces:
EventListener, org.tigris.gef.base.FigModifyingMode, KeyListener, org.tigris.gef.base.Mode, MouseListener, MouseMotionListener, Serializable

public class ModeCreateAssociation
extends org.tigris.gef.base.ModeCreatePolyEdge

A Mode to interpret user input while creating an association, transforming a binary association into a N-ary association and a N-ary association in a binary one as well. Basically mouse down starts creating an edge from a source port Fig or from a binary association. If it is a binary association, it creates the proper figNode (a rhomb) to transform the binary association into a N-ary association. Mouse motion paints a rubberband line, mouse up finds the destination port and finishes creating the edge if it is a binary association or several edges if several association ends must be created. So if the connection is successful, it deletes the previous simple edge and connect association ends' edges to the recently created node. If it fails, everything must be undone. The argument "edgeClass" determines the type if edge to suggest that the Editor's GraphModel construct, normally an association or an association end. The GraphModel is responsible for acutally making edges in the underlying model and connecting it to other model elements.

See Also:
Serialized Form

Field Summary
private  Object association
           
private  Collection associationEnds
           
private  org.tigris.gef.presentation.FigNode newFigNodeAssociation
           
private  org.tigris.gef.presentation.FigEdge oldFigAssociation
           
 
Fields inherited from class org.tigris.gef.base.ModeCreatePolyEdge
_handle, _lastX, _lastY, _npoints, _startX, _startY
 
Fields inherited from class org.tigris.gef.base.ModeCreate
_defaultHeight, _defaultWidth, _newItem, anchorX, anchorY
 
Fields inherited from class org.tigris.gef.base.FigModifyingModeImpl
editor
 
Fields inherited from class org.tigris.gef.base.ModeImpl
_args
 
Constructor Summary
ModeCreateAssociation()
           
 
Method Summary
protected  void endAttached()
          This will be called when the edge is successfully connected.
 void mousePressed(MouseEvent me)
           
 void mouseReleased(MouseEvent me)
           
private  org.tigris.gef.presentation.FigNode placeTempNode(MouseEvent me)
           
 
Methods inherited from class org.tigris.gef.base.ModeCreatePolyEdge
createNewItem, done, getNewEdge, getSourceFigNode, getStartPort, getStartPortFig, instructions, keyTyped, mouseDragged, mouseMoved, nearLast, setNewEdge, setSourceFigNode, setStartPort, setStartPortFig
 
Methods inherited from class org.tigris.gef.base.ModeCreate
createFig, creationDrag, getInitialCursor, keyPressed, paint
 
Methods inherited from class org.tigris.gef.base.FigModifyingModeImpl
getEditor, isFigEnclosedIn, print, setCursor, setEditor
 
Methods inherited from class org.tigris.gef.base.ModeImpl
canExit, getArg, getArgs, init, keyReleased, leave, mouseClicked, mouseEntered, mouseExited, setArg, setArgs, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.tigris.gef.base.Mode
canExit, getArg, getArgs, init, setArg, setArgs, start
 

Field Detail

newFigNodeAssociation

private org.tigris.gef.presentation.FigNode newFigNodeAssociation

oldFigAssociation

private org.tigris.gef.presentation.FigEdge oldFigAssociation

association

private Object association

associationEnds

private Collection associationEnds
Constructor Detail

ModeCreateAssociation

public ModeCreateAssociation()
Method Detail

mousePressed

public void mousePressed(MouseEvent me)
See Also:
MouseListener.mousePressed(java.awt.event.MouseEvent)

mouseReleased

public void mouseReleased(MouseEvent me)
See Also:
ModeCreatePolyEdge.mouseReleased(java.awt.event.MouseEvent)

endAttached

protected void endAttached()
This will be called when the edge is successfully connected. What we do in this class is to determine if we are creating an n-ary association. If so then FigNode representing the n-ary association is made visible. The FigEdge representing the old binary association is removed and replaced with edges representing the 2 association ends of that original fig.


placeTempNode

private org.tigris.gef.presentation.FigNode placeTempNode(MouseEvent me)


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