jfig.commands
Class CreatePolygonCommand

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

public class CreatePolygonCommand
extends Command

create a polygon (closed polyline) with n points.

CreatePolygonCommand allows the user to create a polygon with n points and the current editor attributes. Each "left" mouse click will add another point to the polygon. Use a "middle" click (or "shift"+"left") to finish and create the polygon.

Note that the polygon is always displayed closed, with the last connecting segments added automatically.


Field Summary
protected  GeometryManager geometryManager
           
protected  int geometryMode
           
protected  int n_points
           
protected  FigPolyline polygon
           
 
Fields inherited from class jfig.commands.Command
editor, objectCanvas, ready
 
Constructor Summary
CreatePolygonCommand(FigBasicEditor editor, FigCanvas objectCanvas)
           
 
Method Summary
 void cancel()
          cancel the current editor command
 void execute()
          execute the current editor command
 java.lang.String getDescription()
          one-line description of this command
 java.awt.Point getGeometryManagedPoint(java.awt.Point WP)
          get the (world coordinate) point nearest to target point WP that is compatible with the current GeometryManager mode.
 int getGeometryMode()
          access the editor geometry mode (if any) via reflection
 FigObject[] getModifiedObjects()
          return an array-wrapped reference to the polygon object created by this command.
 void mousePressed(FigCanvasEvent evt)
          mousePressed: add new points to the polygon object.
 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
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

polygon

protected FigPolyline polygon

geometryManager

protected GeometryManager geometryManager

geometryMode

protected int geometryMode
Constructor Detail

CreatePolygonCommand

public CreatePolygonCommand(FigBasicEditor editor,
                            FigCanvas objectCanvas)
Method Detail

getModifiedObjects

public FigObject[] getModifiedObjects()
return an array-wrapped reference to the polygon object created by this command. The polygon reference may be null.

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

cancel

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

cancel and cleanup the current command. Note that this method is empty for class Command, but might be implemented by subclasses.

Overrides:
cancel in class Command

mousePressed

public void mousePressed(FigCanvasEvent evt)
mousePressed: add new points to the polygon object.

Each "left" mouse click will add another point to the polygon. Use a "middle" click (or "shift"+"left") to finish and create the polygon.

Overrides:
mousePressed in class Command

getGeometryMode

public int getGeometryMode()
access the editor geometry mode (if any) via reflection


getGeometryManagedPoint

public java.awt.Point getGeometryManagedPoint(java.awt.Point WP)
get the (world coordinate) point nearest to target point WP that is compatible with the current GeometryManager mode. This method dispatches to GeometryManager.getNearestAllowedPoint(), where the base point is the (so far) end point of our polyline.


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