jfig.commands
Class DeleteObjectCommand

java.lang.Object
  extended byjfig.commands.Command
      extended byjfig.commands.DeleteObjectCommand

public class DeleteObjectCommand
extends Command

delete one or multiple jfig objects.

DeleteObjectCommand allows to delete a single object or all objects contained inside a user-specified region from a jfig drawing, with optional undo.

To delete a single object, simply click on/near one of its control points, e.g. a rectangle corner. To avoid deleting the wrong objects, the DeleteObjectCommand is quite strict about the mouse position, and it will only delete objects nearer than one snap-distance to the mouse position.

To delete a region of objects, click the "right" mouse button or use "alt"+"left". The DeleteObjectCommand will use the mouse position as the first corner of the selection rectangle and will prompt for the opposition corner.


Field Summary
protected  java.awt.Point endPoint
           
protected  int n_points
           
protected  FigObject object
           
protected  java.awt.Point startPoint
           
protected  java.util.Stack victims
           
 
Fields inherited from class jfig.commands.Command
editor, objectCanvas, ready
 
Constructor Summary
DeleteObjectCommand(FigBasicEditor editor, FigCanvas objectCanvas)
           
 
Method Summary
 void execute()
          execute the current editor command
 java.lang.String getDescription()
          one-line description of this command
 FigObject[] getModifiedObjects()
          return an array with all objects (to be) deleted by this command.
 void mousePressed(FigCanvasEvent evt)
          select the object to delete (at position startPoint), or the region of objects to delete.
 java.lang.String toString()
          return a (possibly verbose) description of this Command object
 void undo()
          undo this command
 
Methods inherited from class jfig.commands.Command
cancel, isReady, message, notifyEditor, statusMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

n_points

protected int n_points

object

protected FigObject object

startPoint

protected java.awt.Point startPoint

endPoint

protected java.awt.Point endPoint

victims

protected java.util.Stack victims
Constructor Detail

DeleteObjectCommand

public DeleteObjectCommand(FigBasicEditor editor,
                           FigCanvas objectCanvas)
Method Detail

getModifiedObjects

public FigObject[] getModifiedObjects()
return an array with all objects (to be) deleted by this command.

Overrides:
getModifiedObjects in class Command

execute

public void execute()
Description copied from class: Command
execute the current editor command

This method is empty for class Command.

Overrides:
execute in class Command

undo

public void undo()
Description copied from class: Command
undo this command

Try to undo this command as far as possible. Don't try to undo() a command that has never been execute()d before. This method is empty for class Command.

Overrides:
undo in class Command

mousePressed

public void mousePressed(FigCanvasEvent evt)
select the object to delete (at position startPoint), or the region of objects to delete.

To allow for selection of stacked objects at/near startPoint, we use the following algorithm: If the users holds down the SHIFT-key while clicking the mouse, we use editor.findObjectAt() to find and select the topmost object at or near startPoint. If the user clicks again on/near startPoint - and with the SHIFT-key hold down, the editor.findNextObjectAt() method is called repeatedly, to find the next objects.

On the next mouse click without the SHIFT-modifier key, the selected object, if any, is deleted.

If this command is initiated with the RIGHT-mouse button (ALT modifier), the user is prompted to mark the opposite corner of the region of objects to delete.

Overrides:
mousePressed in class Command

getDescription

public java.lang.String getDescription()
Description copied from class: Command
one-line description of this command

return a one-line desription of this command, e.g. to label the undo/redo buttons, if any

Overrides:
getDescription in class Command

toString

public java.lang.String toString()
Description copied from class: Command
return a (possibly verbose) description of this Command object

Overrides:
toString in class Command