multivalent.std.span
Class MoveTextSpan
public
class
MoveTextSpan
extends Span
Executable copy editor markup that will move marked text to another point in the document.
Set source text span by making selection and invoking menu CopyEd / Move Text.
Set destination point by pressing mouse button down in source text, dragging to end point, and releasing
(keyboard scrolling is still active in case the end point is not on the same screen).
Source range can be moved in same way as other span annotations, that is, by selecting the new
destination span and selecting
Morph from the span-specific popup menu.
Destination point can be moved by removing the current destination by invoking
Re-set move to point from that same menu and setting the new one as before.
Annotation can subsequently be executed by clicking in the source text.
The illegal operations of trying to place destination point in source text
or subsequently moving source text on top of destination
are checked and result in the removal of the destination point.
If the destination point is one the same line as the start of the source text,
the arrow arches up over the intervening text rather that plowing through the middle.
Implementation steps:
- Set location of class. (Put in main set of classes but could have put anywhere as long as findable by Java in CLASSPATH.)
- UI for setting source text. (Add to Anno menu by adding line to hub via SpanUI in Anno.hub patterned after ReplaceWithSpan.)
- Set display for source text, depending on whether not destination point is set. (Model after HyperlinkSpan.)
- UI in span-specific popup menu. (Add "Re-set move to point" by copying semanticEvent methods from HyperlinkSpan and editing.)
- UI for setting destination point. (Model after HyperlinkSpan.)
- Link arrow display to update when an endpoint point changes. (Override Span and Span and catch MSG_FORMATTED semantic event to recompute display, and destroy to destroy destination point as well.)
- Display of arrow from source to destination. (Override Behavior.)
- Implement move text action. (Model after action.)
- Save and restore annotation to disk. (Extend save and Span to include destination point -- superclass already saves range of source text.)
- (Tweaking to use java.awt.geom.QuadCurve instead of straight lines and for dragging within active span to revert to setting destination point.)
Version: $Revision: 1.9 $ $Date: 2003/04/28 03:56:27 $
See Also: for another elaborately commented example Behavior.
Method Summary |
boolean | appearance(Context cx, boolean all) Draw source text differently depending on whether executable or waiting for destination point. |
void | buildAfter(Document doc) Attach destination point as well. |
void | destroy() Also remove destination point and recompute display (to remove circle and arrow). |
void | event(AWTEvent e) |
boolean | eventAfter(AWTEvent e, Point rel, Node obsn)
If no destination point, click-drag to set (re-fire keyboard events out so can still scroll).
|
void | execute() Remove source text, insert at destination point. |
boolean | formatAfter(Node node) After formatted affected area, recompute coordinates of circle and arrow. |
void | moveq(Leaf ln, int lo, Leaf rn, int ro) Also recompute display. |
boolean | paintAfter(Context cx, Node node) Draw line between source and destination. |
void | restore(ESISNode n, Map<String,Object> attr, Layer layer) |
ESISNode | save() Source text location saved by superclass, so just need to save endpoint (using a Robust Location, of course). |
boolean | semanticEventAfter(SemanticEvent se, String msg) |
boolean | semanticEventBefore(SemanticEvent se, String msg) Add "Re-Set move to point" to span-specific popup menu. |
protected void | setDisplay() Set observer, compute coordinates. |
protected void | spanExit() Several exit points in event(), so collect together. |
public static final String MSG_RESET_DEST
Semantic event that removes the destination point so that it may be placed elsewhere.
"resetMoveTo": arg= MoveTextSpan instance, in= MoveTextSpan instance.
public boolean appearance(
Context cx, boolean all)
Draw source text differently depending on whether executable or waiting for destination point.
Attach destination point as well.
public void destroy()
Also remove destination point and recompute display (to remove circle and arrow).
public void event(AWTEvent e)
public boolean eventAfter(AWTEvent e, Point rel,
Node obsn)
If no destination point, click-drag to set (re-fire keyboard events out so can still scroll).
If destination set, execute.
public void execute()
Remove source text, insert at destination point.
public boolean formatAfter(
Node node)
After formatted affected area, recompute coordinates of circle and arrow.
public void moveq(
Leaf ln, int lo,
Leaf rn, int ro)
Also recompute display.
Draw line between source and destination.
public void restore(
ESISNode n, Map<String,Object> attr,
Layer layer)
Source text location saved by superclass, so just need to save endpoint (using a Robust Location, of course).
Add "Re-Set move to point" to span-specific popup menu.
protected void setDisplay()
Set observer, compute coordinates.
protected void spanExit()
Several exit points in event(), so collect together.