public abstract class ALspEditor extends Object implements ILspEditor
ILspEditor
.
An ALspEditor
provides a base for most editors.
This base class adds functionality to automatically support undo behavior while editing. The
only precondition is that the object has to be ILcdCloneable
for this to work. Apart from this functionality, the editor will also automatically lock
the model, while an object is being edited.
canEdit
method to indicate which objects can be edited/created by your editor (do
not forget to call super.canEdit
).getEditHandles
method to return a collection of handles suitable to edit the given
object. As an example: TLsp2DPointListEditor
returns a collection of point
handles to move the vertices of the point list as well as a handle to translate the point list. The handles should be capable of transforming incoming AWT events
into
high level edit operations
.getCreateHandle
method to return a
single handle that can be used to create the object. Typically, this handle is an
extension of ALspCreateHandle
.editImpl
method that performs the necessary actions to modify the object. This method is called from the
edit
method, after performing the necessary tasks to manage undo behavior and lock the
model being edited.canCopyGeometry
and copyGeometrySFCT
methods to handle your custom domain object (do not forget to call super.canCopyGeometry
and
super.copyGeometrySFCT
for other objects).canPerformOperation
method to allow any controller to see what operations this class supports.ALspEditHandle
or, even more conveniently, from ALsp3StepEditHandle
or from one of the provided subclasses.handleAWTEvent
method or (in case of
3-step handles) the
necessary canActivate
,
onActivate
, etc. methods to filter and
respond to the correct input events.edit
method has the correct interaction status in order for undo/redo
support to work correctly (see also below).getStyleTargetProvider
method to return a set of domain objects that constitute the
visual representation of the handle and that can be painted for the provided VisualComponentType
.setPriority
to make sure it gets the correct priority over other handles.requestsFocus
to
make sure the handle gets focus when it is highlighted.ILcdUndoableSource
interface. An undoable is created after each event
with interaction status FINISHED
. The handles in the Lightspeed API fire such an event when appropriate. For
example, TLspPointTranslationHandle
will generate such an edit operation when releasing the mouse after a drag
operation.ALspEditHandle
Modifier | Constructor and Description |
---|---|
protected |
ALspEditor()
Creates a new editor, with undo support and automatic model locking
while performing edit operations.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canCopyGeometry(Object aSourceGeometry,
Object aDestinationGeometry)
Tests whether this editor can apply the properties of a template source object to the
given target object.
|
boolean |
canEdit(TLspEditContext aContext)
Determines whether or not the
geometry inside the given context can be edited by this editor. |
boolean |
canPerformOperation(TLspEditOperation aOperation,
TLspEditContext aContext)
Determines whether or not the editor knows how to apply the given edit operation to the
supplied geometry.
|
void |
copyGeometrySFCT(Object aSourceGeometry,
Object aDestinationGeometrySFCT)
Method that takes the given source object and applies all geometry to the
destination object.
|
TLspEditOperationResult |
edit(TLspEditOperation aOperation,
ELspInteractionStatus aInteractionStatus,
TLspEditContext aContext)
Applies an interaction obtained from a handle to the object being edited.
|
protected abstract TLspEditOperationResult |
editImpl(TLspEditOperation aOperation,
ELspInteractionStatus aInteractionStatus,
TLspEditContext aContext)
Called by the
edit method to edit the given object based on the given
edit operation . |
protected void |
fireUndoableHappened(ILcdUndoable aUndoable)
Notifies the registered listeners that an undoable has happened.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCreateHandle, getEditHandles
protected ALspEditor()
public boolean canEdit(TLspEditContext aContext)
geometry inside the given context
can be edited by this editor. Override this method to provide a custom implementation.
The default implementation determines whether the given object is cloneable. This editor can
only edit cloneable objects.canEdit
in interface ILspEditor
aContext
- provides context information to the editorprotected void fireUndoableHappened(ILcdUndoable aUndoable)
aUndoable
- the undoable that has happenedpublic TLspEditOperationResult edit(TLspEditOperation aOperation, ELspInteractionStatus aInteractionStatus, TLspEditContext aContext)
Note: Only override this method if you want to bypass the undo/redo support
provided by this abstract class. For most use cases, it is preferred to override
editImpl
instead.
edit
in interface ILspEditor
aOperation
- describes the edit that should occur. This is usually generated
by the handles. It is up
to the concrete editor to determine how to handle this event.aInteractionStatus
- the interaction statusaContext
- the edit context @return the result of the edit operationeditImpl(com.luciad.view.lightspeed.editor.operation.TLspEditOperation, com.luciad.view.lightspeed.editor.operation.ELspInteractionStatus, TLspEditContext)
public boolean canPerformOperation(TLspEditOperation aOperation, TLspEditContext aContext)
true
if the model reference of the edit operation
is equal to that of the edited object.canPerformOperation
in interface ILspEditor
aOperation
- the operation to be appliedaContext
- the edit contextpublic void copyGeometrySFCT(Object aSourceGeometry, Object aDestinationGeometrySFCT)
Method that takes the given source object and applies all geometry to the destination object.
This method is called when performing an undo or redo operation. Before editing an object, a clone is created from the geometry. When performing e.g. an undo operation, the state of the clone is applied on the geometry object using this method. Something similar happens for a redo operation.
By default, this method supports all default (editable) shapes in LuciadLightspeed. Custom editors should override this method to allow this editor to apply changes to the original object given a modified instance of it.
aSourceGeometry
- A template source object to copy the geometry from.aDestinationGeometrySFCT
- A destination object to copy the geometry to.public boolean canCopyGeometry(Object aSourceGeometry, Object aDestinationGeometry)
aSourceGeometry
- a template source object from which the geometry will be copied fromaDestinationGeometry
- a destination object to which the geometry will be copied tocopyGeometrySFCT
would succeed, false otherwise.copyGeometrySFCT(java.lang.Object, java.lang.Object)
protected abstract TLspEditOperationResult editImpl(TLspEditOperation aOperation, ELspInteractionStatus aInteractionStatus, TLspEditContext aContext)
edit
method to edit the given object based on the given
edit operation
.
Note that this method does not need to lock the model of the object, this already happens in the
edit
method.aOperation
- the event that contains the information on how to edit the objectaInteractionStatus
- the interaction statusaContext
- the edit context