|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jfig.commands.Command jfig.commands.RotateObjectCommand
A command object to manage object rotation for jfig.
A single rotation command maintains references to the target object, an anchor point (origin) for the rotation, and the rotation angle, measured in radians. In principle, the command can be undone, but rounding errors may occur due to the use of integer coordinates. Any target object may throw an Exception if the rotation around the specified angle is impossible - for example, xfig rectangles and compounds can only be rotated around multiples of 90 degreees.
Also, note that this class maintains a static boolean field "clockwise" which should be set previous to calling the RotateObjectCommand constructor, in order, to specify the desired rotation direction.
Field Summary | |
(package private) java.awt.Point |
anchor
|
(package private) double |
angle
|
static boolean |
CCW
|
(package private) static boolean |
clockwise
|
static boolean |
CW
|
(package private) FigObject |
object
|
(package private) FigObject |
rotatedCopy
|
Fields inherited from class jfig.commands.Command |
editor, objectCanvas, ready |
Constructor Summary | |
RotateObjectCommand(FigBasicEditor editor,
FigCanvas objectCanvas)
|
Method Summary | |
void |
execute()
rotate the selected object / its newly created copy, where the rotation angle and direction are from our "clockwise" and "angle" variables. |
java.lang.String |
getDescription()
one-line description of this command |
FigObject[] |
getModifiedObjects()
return an FigObject array of length 2 with the following entries: the element at index 0 is the rotated object (or null), the element at index 1 is the copied and rotated clone (or null). |
boolean |
isReady()
check whether this command is completed/ready, or not |
void |
mousePressed(FigCanvasEvent evt)
react to a mouse click on the editor canvas |
void |
notifyEditor()
provide a callback from commands to their editor. |
static void |
setDirection(boolean _clockwise)
called by the editor to distinguis between clockwise and anti- clockwise rotations (there are two command buttons, but we use only one RotateObjectCommand class to handle both commands). |
java.lang.String |
toString()
return a (possibly verbose) description of this RotateObjectCommand object |
void |
undo()
undo this command |
Methods inherited from class jfig.commands.Command |
cancel, message, statusMessage |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final boolean CW
public static final boolean CCW
static boolean clockwise
FigObject object
FigObject rotatedCopy
java.awt.Point anchor
double angle
Constructor Detail |
public RotateObjectCommand(FigBasicEditor editor, FigCanvas objectCanvas)
Method Detail |
public static void setDirection(boolean _clockwise)
public FigObject[] getModifiedObjects()
getModifiedObjects
in class Command
public void execute()
execute
in class Command
public void undo()
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.
undo
in class Command
public void mousePressed(FigCanvasEvent evt)
Command
This method provides the central callback from the editor to its current command object. Passing a FigCanvasEvent parameter, the editor provides information both about the screen coordinates and the world coordinates of the mouse event.
Naturally, mouse presses are ignored for class Command.
mousePressed
in class Command
public boolean isReady()
isReady
in class Command
public void notifyEditor()
This method serves as a callback from command objects to their editor. Because each command object is used for one single and atomic editing operation only, the editor has to create a new command once the previous command has execute()d. This is achieved by calling notifyEditor() from within a command, once the command has executed and is ready. The typical use is to implement the xfig-style editor modes, e.g. to create a new RotateObjectCommand directly after the previous RotateObjectCommand has finished.
notifyEditor
in class Command
public java.lang.String getDescription()
getDescription
in class Command
public java.lang.String toString()
toString
in class Command
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |