org.argouml.uml.diagram.ui
Class ModeCreateEdgeAndNode

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

public class ModeCreateEdgeAndNode
extends org.tigris.gef.base.ModeCreate

A Mode to interpret user input while creating an edge. Basically mouse down starts creating an edge from a source port Fig, mouse motion paints a rubberband line, mouse up finds the destination port and finishes creating the edge and makes an FigEdge and sends it to the back of the Layer. The argument "edgeClass" determines the type if edge to suggest that the Editor's GraphModel construct. The GraphModel is responsible for acutally making an edge in the underlying model and connecting it to other model elements.

See Also:
Serialized Form

Field Summary
private  boolean destToSource
          False if drawing from source and destination.
private static int dragsToExisting
           
private static int dragsToNew
           
private  org.tigris.gef.presentation.FigEdge fe
           
private  org.tigris.gef.presentation.FigNode fn
           
private  org.tigris.gef.presentation.Handle handle
          The number of points added so far.
private static Logger LOG
          Logger.
private  Object newEdge
          The new NetEdge that is being created.
private  boolean postProcessEdge
           
(package private) static long serialVersionUID
           
private  org.tigris.gef.presentation.FigNode sourceFigNode
          The FigNode on the NetNode that owns the start port.
private  Object startPort
          The NetPort where the arc is paintn from.
private  org.tigris.gef.presentation.Fig startPortFig
          The Fig that presents the starting NetPort.
 
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
ModeCreateEdgeAndNode()
          The constructor.
ModeCreateEdgeAndNode(org.tigris.gef.base.Editor ed, Object edgeType, Object nodeType, boolean post)
          The constructor.
 
Method Summary
 org.tigris.gef.presentation.Fig createNewItem(MouseEvent me, int snapX, int snapY)
          Create the new item that will be drawn.
 void done()
           
 String instructions()
           
 void keyTyped(KeyEvent ke)
           
 void mouseDragged(MouseEvent me)
           
 void mouseMoved(MouseEvent me)
           
 void mousePressed(MouseEvent me)
          On mousePressed determine what port the user is dragging from.
 void mouseReleased(MouseEvent me)
          On mouseReleased, find the destination port, ask the GraphModel to connect the two ports.
private  void postProcessEdge()
           
 void setup(org.tigris.gef.presentation.FigNode fignode, Object port, int x, int y, boolean reverse)
           
 
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

LOG

private static final Logger LOG
Logger.


dragsToExisting

private static int dragsToExisting

dragsToNew

private static int dragsToNew

startPort

private Object startPort
The NetPort where the arc is paintn from.


startPortFig

private org.tigris.gef.presentation.Fig startPortFig
The Fig that presents the starting NetPort.


sourceFigNode

private org.tigris.gef.presentation.FigNode sourceFigNode
The FigNode on the NetNode that owns the start port.


newEdge

private Object newEdge
The new NetEdge that is being created.


destToSource

private boolean destToSource
False if drawing from source and destination. True if drawing from destination to source.


handle

private org.tigris.gef.presentation.Handle handle
The number of points added so far.


fn

private org.tigris.gef.presentation.FigNode fn

fe

private org.tigris.gef.presentation.FigEdge fe

postProcessEdge

private boolean postProcessEdge

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

ModeCreateEdgeAndNode

public ModeCreateEdgeAndNode()
The constructor.


ModeCreateEdgeAndNode

public ModeCreateEdgeAndNode(org.tigris.gef.base.Editor ed,
                             Object edgeType,
                             Object nodeType,
                             boolean post)
The constructor.

Parameters:
ed - the parent editor of this mode. Each Mode instance belongs to exactly one Editor instance.
edgeType - the class of the edge
nodeType - the class of the node
post - if true, then the edge is postprocessed. See postProcessEdge().
Method Detail

setup

public void setup(org.tigris.gef.presentation.FigNode fignode,
                  Object port,
                  int x,
                  int y,
                  boolean reverse)
Parameters:
fignode - the source fignode
port - the port
x - the x to start from
y - the y to start from
reverse - true if the direction is reversed, i.e. from destination to source

instructions

public String instructions()
See Also:
FigModifyingMode.instructions()

createNewItem

public org.tigris.gef.presentation.Fig createNewItem(MouseEvent me,
                                                     int snapX,
                                                     int snapY)
Create the new item that will be drawn. In this case I would rather create the FigEdge when I am done. Here I just create a rubberband FigLine to show during dragging.

See Also:
ModeCreate.createNewItem( java.awt.event.MouseEvent, int, int)

done

public void done()
See Also:
Mode.done()

mousePressed

public void mousePressed(MouseEvent me)
On mousePressed determine what port the user is dragging from. The mousePressed event is sent via ModeSelect.

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

mouseReleased

public void mouseReleased(MouseEvent me)
On mouseReleased, find the destination port, ask the GraphModel to connect the two ports. If that connection is allowed, then construct a new FigEdge and add it to the Layer and send it to the back.

See Also:
MouseListener.mouseReleased(java.awt.event.MouseEvent)

mouseMoved

public void mouseMoved(MouseEvent me)
See Also:
MouseMotionListener.mouseMoved(java.awt.event.MouseEvent)

mouseDragged

public void mouseDragged(MouseEvent me)
See Also:
MouseMotionListener.mouseDragged(java.awt.event.MouseEvent)

keyTyped

public void keyTyped(KeyEvent ke)
See Also:
KeyListener.keyTyped(java.awt.event.KeyEvent)

postProcessEdge

private void postProcessEdge()


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