public class TLspCompositeEditor extends Object implements ILspEditor
Composite editor for ILspEditor
objects.
When an object is being edited by this editor, all editing related tasks are delegated to the first compatible editor found.
In case of delegate based editors (i.e. editors that delegate to another editor), it is both valid and recommended to have the composite editor be the delegate of the editor. So for shapelists and extruded shapes, the following construction is perfectly valid:
//We create a composite editor that can handle circles, extruded circles, shapeslists with circles //and shapelists with extruded circles in them: TLspCompositeEditor compositeEditor = new TLspCompositeEditor(); //Create and add shapelist editor with composite editor as delegate. compositeEditor.addEditor(new TLspShapeListEditor(compositeEditor)); //Create and add extruded editor with composite editor as delegate. compositeEditor.addEditor(new TLspExtrudedShapeEditor(compositeEditor)); //Create and add a circle editor compositeEditor.addEditor(new TLspCircleEditor());
Constructor and Description |
---|
TLspCompositeEditor(ILspEditor... aEditors)
Creates a new
TLspCompositeEditor , composed of the given
list of editors. |
Modifier and Type | Method and Description |
---|---|
void |
addEditor(ILspEditor aEditor)
Adds the given editor to the list of editors.
|
void |
addEditor(ILspEditor aEditor,
int aIndex)
Adds the given editor to the list of editors.
|
boolean |
canEdit(TLspEditContext aContext)
Returns
true if one of the editors this composite is composed of
can edit the given object. |
boolean |
canPerformOperation(TLspEditOperation aOperation,
TLspEditContext aContext)
Determines whether or not the editor knows how to apply the given edit operation to the
supplied geometry.
|
TLspEditOperationResult |
edit(TLspEditOperation aOperation,
ELspInteractionStatus aInteractionStatus,
TLspEditContext aContext)
Applies an interaction obtained from a handle to the object being edited.
|
ALspEditHandle |
getCreateHandle(TLspEditContext aContext)
Returns a handle that is used to create the given object.
|
List<ALspEditHandle> |
getEditHandles(TLspEditContext aContext)
Returns a set of handles for editing the given object.
|
List<ILspEditor> |
getEditors()
Gets the list of editors this composite editor delegates to.
|
void |
removeEditor(ILspEditor aEditor)
Removes the given editor from this composite.
|
public TLspCompositeEditor(ILspEditor... aEditors)
TLspCompositeEditor
, composed of the given
list of editors.aEditors
- a list of delegate editors.public void addEditor(ILspEditor aEditor)
aEditor
- the editor to addpublic void addEditor(ILspEditor aEditor, int aIndex)
aEditor
- the editor to addaIndex
- the index at which to add the editor.public void removeEditor(ILspEditor aEditor)
aEditor
- the editor to remove.public List<ILspEditor> getEditors()
addEditor
and removeEditor
).public boolean canEdit(TLspEditContext aContext)
true
if one of the editors this composite is composed of
can edit the given object.canEdit
in interface ILspEditor
aContext
- provides context information to the editortrue
if the above conditions are met, false
otherwise.public TLspEditOperationResult edit(TLspEditOperation aOperation, ELspInteractionStatus aInteractionStatus, TLspEditContext aContext)
ILspEditor
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 contextpublic boolean canPerformOperation(TLspEditOperation aOperation, TLspEditContext aContext)
ILspEditor
canPerformOperation
in interface ILspEditor
aOperation
- the operation to be appliedaContext
- the edit contextpublic ALspEditHandle getCreateHandle(TLspEditContext aContext)
ALspCreateHandle
which is a specialized handle implementation used for creating an object.
By default, this method returns an ALspCreateHandle
capable of creating the given object, if one of the editors this composite is
composed of can create the given object.getCreateHandle
in interface ILspEditor
aContext
- provides context information such as the layer for which the object
is being creatednull
if creation should not be allowed.ALspCreateHandle
,
TLspCreateController
public List<ALspEditHandle> getEditHandles(TLspEditContext aContext)
edit
method. As a way to communicate with this method,
handles will copy their properties to the edit operation properties.
The default behavior of this method is as follows. If one of the editors this composite is
composed of can edit the given object, it delegate to its getEditHandles
method. Otherwise an empty list is returned.getEditHandles
in interface ILspEditor
aContext
- provides context information such as the layer for which the object
is being editedTLspEditController