org.tigris.gef.base
Class ModeCreatePolyEdge

java.lang.Object
  extended by org.tigris.gef.base.ModeImpl
      extended by org.tigris.gef.base.FigModifyingModeImpl
          extended by org.tigris.gef.base.ModeCreate
              extended by org.tigris.gef.base.ModeCreatePolyEdge
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable, java.util.EventListener, FigModifyingMode, Mode

public class ModeCreatePolyEdge
extends 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
protected  Handle _handle
           
protected  int _lastX
           
protected  int _lastY
           
protected  int _npoints
          The number of points added so far.
protected  int _startX
           
protected  int _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
ModeCreatePolyEdge()
           
ModeCreatePolyEdge(Editor par)
           
 
Method Summary
 Fig createNewItem(java.awt.event.MouseEvent me, int snapX, int snapY)
          Create the new item that will be drawn.
 void done()
          When a Mode handles a certain event that indicates that the user wants to exit that Mode (e.g., a mouse up event after a drag in ModeCreateEdge) the Mode calls done to make switching to another Mode possible.
protected  void endAttached()
           
protected  java.lang.Object getNewEdge()
           
protected  FigNode getSourceFigNode()
           
protected  java.lang.Object getStartPort()
           
protected  Fig getStartPortFig()
           
 java.lang.String instructions()
          Reply a string of instructions that should be shown in the statusbar when this mode starts.
 void keyTyped(java.awt.event.KeyEvent ke)
           
 void mouseDragged(java.awt.event.MouseEvent me)
          On mouse drag, resize the new item as the user moves the mouse.
 void mouseMoved(java.awt.event.MouseEvent me)
           
 void mousePressed(java.awt.event.MouseEvent me)
          On mousePressed determine what port the user is dragging from.
 void mouseReleased(java.awt.event.MouseEvent me)
          On mouseReleased, find the destination port, ask the GraphModel to connect the two ports.
protected  boolean nearLast(int x, int y)
          Internal function to see if the user clicked twice on the same spot.
protected  void setNewEdge(java.lang.Object edge)
           
protected  void setSourceFigNode(FigNode node)
           
protected  void setStartPort(java.lang.Object object)
           
protected  void setStartPortFig(Fig fig)
           
 
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

_npoints

protected int _npoints
The number of points added so far.


_lastX

protected int _lastX

_lastY

protected int _lastY

_startX

protected int _startX

_startY

protected int _startY

_handle

protected Handle _handle
Constructor Detail

ModeCreatePolyEdge

public ModeCreatePolyEdge()

ModeCreatePolyEdge

public ModeCreatePolyEdge(Editor par)
Method Detail

instructions

public java.lang.String instructions()
Description copied from class: FigModifyingModeImpl
Reply a string of instructions that should be shown in the statusbar when this mode starts.

Specified by:
instructions in interface FigModifyingMode
Overrides:
instructions in class FigModifyingModeImpl

createNewItem

public Fig createNewItem(java.awt.event.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.

Specified by:
createNewItem in class ModeCreate

mousePressed

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

Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class ModeCreate

mouseReleased

public void mouseReleased(java.awt.event.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.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Overrides:
mouseReleased in class ModeCreate

endAttached

protected void endAttached()

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent me)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Overrides:
mouseMoved in class ModeImpl

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent me)
Description copied from class: ModeCreate
On mouse drag, resize the new item as the user moves the mouse. Maybe the Fig createDrag() method should be removed and I should call dragHandle(). That would elimiate one method from each oif several classes, but dragging during creation is not really the same thing as dragging after creation....

Note: _newItem has not been added to any Layer yet. So you cannot use _newItem.damage(), instead use editor.damageAll(_newItem).

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Overrides:
mouseDragged in class ModeCreate

nearLast

protected boolean nearLast(int x,
                           int y)
Internal function to see if the user clicked twice on the same spot.


done

public void done()
Description copied from class: ModeImpl
When a Mode handles a certain event that indicates that the user wants to exit that Mode (e.g., a mouse up event after a drag in ModeCreateEdge) the Mode calls done to make switching to another Mode possible.

Specified by:
done in interface Mode
Overrides:
done in class FigModifyingModeImpl

keyTyped

public void keyTyped(java.awt.event.KeyEvent ke)
Specified by:
keyTyped in interface java.awt.event.KeyListener
Overrides:
keyTyped in class ModeImpl

getSourceFigNode

protected FigNode getSourceFigNode()
Returns:
the FigNode at the source of the edge draw

setSourceFigNode

protected void setSourceFigNode(FigNode node)
Parameters:
node -

getStartPort

protected java.lang.Object getStartPort()
Returns:
the port at the source of the edge draw

setStartPort

protected void setStartPort(java.lang.Object object)
Parameters:
object -

getStartPortFig

protected Fig getStartPortFig()

setStartPortFig

protected void setStartPortFig(Fig fig)
Parameters:
fig -

getNewEdge

protected java.lang.Object getNewEdge()

setNewEdge

protected void setNewEdge(java.lang.Object edge)