|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jfig.commands.Command jfig.commands.CreateTextCommand
create FIG text objects.
Click the mouse to specify the text position and then enter the text. If the mouse is clicked again, the unfinished text object is created and the next text object is started.
The following keys have special meaning:
To allow input of German umlauts despite the JDK bugs, this method
interprets the characters
+ a
.. + O
as umlauts
ä .. Ö respectively.
Field Summary | |
protected boolean |
debug
|
static int |
EDIT
|
protected boolean |
editExistingText
|
static int |
IDLE
|
protected java.lang.String |
newString
|
protected java.lang.String |
oldString
|
protected java.awt.Point |
P1
|
protected java.lang.String |
str
|
protected int |
textCursorIndex
|
protected FigText |
textObject
|
Fields inherited from class jfig.commands.Command |
editor, objectCanvas, ready |
Constructor Summary | |
CreateTextCommand(FigBasicEditor editor,
FigCanvas objectCanvas)
create a CreateTextCommand object. |
Method Summary | |
void |
cancel()
cancel: Cancel a CreateTextCommand. |
(package private) void |
deleteChar()
|
void |
execute()
execute: check whether we have a valid and not empty text object. |
void |
executeAndStartNewText()
this method is called whenever the user pressed the RETURN or ENTER keys during editing a text object. |
void |
executeAndStartNewText(FigCanvasEvent evt)
this method is called from mousePressed() whenever there is a non-null text object, implying that the previous text object has not already been registered with the edtior. |
java.lang.String |
getDescription()
one-line description of this command |
FigObject[] |
getModifiedObjects()
return an array-wrapped reference to the text object created by this command. |
java.awt.Point |
getOriginOfNextLine(FigText textObject)
calculate and return the point position of a text object that is exactly one line below the given line of text, where the settings for font, font size, rotation angle, and font spacing are copied from given text object. |
void |
keyPressed(java.awt.event.KeyEvent evt)
|
void |
keyReleased(java.awt.event.KeyEvent evt)
|
void |
keyTyped(java.awt.event.KeyEvent evt)
keyTyped(): this method is called by the editor to move the textCursor, append or insert a character right from the textCursor, and to delete characters. |
void |
mousePressed(FigCanvasEvent evt)
react to a mouse click on the editor canvas |
java.lang.String |
toString()
return a (possibly verbose) description of this Command object |
void |
undo()
undo a CreateTextCommand, with one of the following two variants. |
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 |
public static final int IDLE
public static final int EDIT
protected FigText textObject
protected java.lang.String str
protected java.lang.String newString
protected java.lang.String oldString
protected boolean editExistingText
protected int textCursorIndex
protected java.awt.Point P1
protected boolean debug
Constructor Detail |
public CreateTextCommand(FigBasicEditor editor, FigCanvas objectCanvas)
Note that this command class is used both for creating a new text object, as well as for direct editing of an existing text object.
Method Detail |
public FigObject[] getModifiedObjects()
getModifiedObjects
in class Command
public void cancel()
Unlike most other createXXX commands, we will want to keep the last edited text object (if any). Therefore, we will put any active text object in the editor's objectList by calling execute() from here.
cancel
in class Command
public void execute()
execute
in class Command
public void undo()
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 void executeAndStartNewText()
Then, we try to position the cursor one baseline below the previous text position and start a fresh CreateTextObject.
public java.awt.Point getOriginOfNextLine(FigText textObject)
public void executeAndStartNewText(FigCanvasEvent evt)
public void keyTyped(java.awt.event.KeyEvent evt)
Note that this method will also be called for non-standard keys like VK_LEFT and VK_RIGHT (one method instead of separate keyPressed and keyTyped).
This method contains a hack to correct a problem with compose characters under Solaris, because Solaris/JDK 1.1.x won't react to the 'COMPOSE' key on the Sun keyboard. Therefore, it will interpret the keys ALT+a, ALT+A, ALT+u, ALT+U, ALT+o, ALT+O, and ALT+s as the corresponding German Umlauts.
keyTyped
in interface java.awt.event.KeyListener
public void keyPressed(java.awt.event.KeyEvent evt)
keyPressed
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent evt)
keyReleased
in interface java.awt.event.KeyListener
void deleteChar()
public java.lang.String getDescription()
Command
return a one-line desription of this command, e.g. to label the undo/redo buttons, if any
getDescription
in class Command
public java.lang.String toString()
Command
toString
in class Command
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |