uci.gef
Class ModeCreatePolyEdge

java.lang.Object
  |
  +--uci.gef.Mode
        |
        +--uci.gef.ModeCreate
              |
              +--uci.gef.ModeCreatePolyEdge

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 uci.gef.ModeCreate
_defaultHeight, _defaultWidth, _newItem, anchorX, anchorY
 
Fields inherited from class uci.gef.Mode
_args, _editor
 
Constructor Summary
ModeCreatePolyEdge()
           
ModeCreatePolyEdge(Editor par)
           
 
Method Summary
 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.
protected  boolean nearLast(int x, int y)
          Internal function to see if the user clicked twice on the same spot.
 
Methods inherited from class uci.gef.ModeCreate
creationDrag, getInitialCursor, paint
 
Methods inherited from class uci.gef.Mode
canExit, getArg, getArgs, getEditor, keyPressed, keyReleased, mouseClicked, mouseEntered, mouseExited, print, setArg, setArgs, setCursor, setEditor, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 String instructions()
Overrides:
instructions in class Mode

createNewItem

public 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.
Overrides:
createNewItem in class ModeCreate

mousePressed

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

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.
Overrides:
mouseReleased in class ModeCreate

mouseMoved

public void mouseMoved(MouseEvent me)
Overrides:
mouseMoved in class Mode

mouseDragged

public void mouseDragged(MouseEvent me)
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()
Overrides:
done in class Mode

keyTyped

public void keyTyped(KeyEvent ke)
Overrides:
keyTyped in class Mode