hades.gui
Class CreateSignalCommand

java.lang.Object
  extended byjava.util.EventObject
      extended byhades.gui.Command
          extended byhades.gui.CreateSignalCommand
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, FigCanvasListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable

public class CreateSignalCommand
extends Command

CreateSignalCommand - create and connect a Signal between SimObjects.

The command works as follows. If the user clicks on a SimObject's port, we create a new Signal and connect it to the corresponding port. Afterwards, we create a new intermediate Signal vertex on each mouse click, until the user clicks on another SimObject's port, which finishes this command. We won't allow to connect to a port already connected to another Signal, unless the user uses +click. In the latter case, the new and the existing Signals are merged. With +click it is also possible to start a Signal without a port connection on its first vertex.

See Also:
Serialized Form

Field Summary
(package private)  ObjectCanvas canvas
           
(package private)  int n_points
           
(package private)  Port port0
           
(package private)  Port port1
           
(package private)  boolean shiftDown
           
(package private)  Signal signal
           
(package private)  java.awt.Point startPoint
           
(package private)  FigCompound tmpCompound
           
(package private)  Signal victim
           
(package private)  WireSegment ws
           
 
Fields inherited from class hades.gui.Command
console, debug, editor, ready, versionString
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
CreateSignalCommand(Editor editor)
          The default constructor for a CreateSignalCommand in Editor 'editor'
 
Method Summary
 void cancel()
           
 void execute()
          perform the action corresponding to this CreateSignalCommand object and register it with the UndoStack.
 java.lang.String getDescription()
           
(package private)  void insertVertexAt(Signal signal, WireSegment originalSegment, java.awt.Point newVertex)
           
 void mousePressed(FigCanvasEvent ME)
          extract the screen and world coordinates of this Event, and dispatch to setPosition().
 void setPosition(java.awt.Point SP, java.awt.Point WP)
          this method should be called twice for a create-Signal command.
 void setShiftDown(boolean b)
          utility function to set the shiftDown variable read by setPosition().
 java.lang.String toString()
          toString(): identify this CreateSignalCommand
 void undo()
          try to undo the action corresponding to this CreateSignalCommand object: we simply delete the Signal again.
 
Methods inherited from class hades.gui.Command
actionPerformed, dbg, getLogExtraArguments, initialize, isReady, keyPressed, keyReleased, keyTyped, message, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, statusMessage, writePositionLogMessage
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

signal

Signal signal

victim

Signal victim

canvas

ObjectCanvas canvas

n_points

int n_points

ws

WireSegment ws

startPoint

java.awt.Point startPoint

port0

Port port0

port1

Port port1

tmpCompound

FigCompound tmpCompound

shiftDown

boolean shiftDown
Constructor Detail

CreateSignalCommand

public CreateSignalCommand(Editor editor)
The default constructor for a CreateSignalCommand in Editor 'editor'

Method Detail

execute

public void execute()
perform the action corresponding to this CreateSignalCommand object and register it with the UndoStack.

Overrides:
execute in class Command

undo

public void undo()
try to undo the action corresponding to this CreateSignalCommand object: we simply delete the Signal again.

Overrides:
undo in class Command

cancel

public void cancel()
Overrides:
cancel in class Command

mousePressed

public void mousePressed(FigCanvasEvent ME)
extract the screen and world coordinates of this Event, and dispatch to setPosition().

Specified by:
mousePressed in interface FigCanvasListener
Overrides:
mousePressed in class Command

setShiftDown

public void setShiftDown(boolean b)
utility function to set the shiftDown variable read by setPosition(). With shiftDown() set to true, it is possible to create a Signal unconnected at its first point.


setPosition

public void setPosition(java.awt.Point SP,
                        java.awt.Point WP)
this method should be called twice for a create-Signal command.

Overrides:
setPosition in class Command

insertVertexAt

void insertVertexAt(Signal signal,
                    WireSegment originalSegment,
                    java.awt.Point newVertex)

toString

public java.lang.String toString()
toString(): identify this CreateSignalCommand

Overrides:
toString in class Command

getDescription

public java.lang.String getDescription()
Overrides:
getDescription in class Command