Class TLspCreateController
- All Implemented Interfaces:
ILcdUndoableSource
,ILcdAWTEventListener
,ILspController
- Direct Known Subclasses:
TLspTouchCreateController
Main workflow
This controller uses a controller model to determine the object to create and the layer to insert the object into. The layer's editor is used to interactively shape the created object. After the creation has ended, a configurableaction
is triggered and the process is restarted.A typical example of an action to configure is a
TLspSetControllerAction
,
that sets a regular navigation/select controller on the view.
Further customization
It is possible to manually cancel or finish the creation process. When cancelling the creation process, the created object is removed. To commit an object to a model as-is (in the state it is at a specific moment) call the @commit method. This will commit the object and finish editing. Finishing the creation process can for example be used to stop creating a polygon, or to advance to the next polygon when creating a complex polygon. This controller uses a specialcreation handle
, provided by the layer's
editor.
The handle is visualized by a configurable handle styler.
During creation, it is possible to snap to other shapes. For this, a snapper provider can be used. The snappers can be visualized using a snapper styler.
- Since:
- 2012.0
-
Constructor Summary
ConstructorDescriptionTLspCreateController
(ALspCreateControllerModel aCreateControllerModel) Creates a new TLspCreateController using the provided create controller model, with a default name, short description, icon, an empty context, undo support, which instantly triggers actions, a default cursor location, which does not support touch, does not consume mouse released events and does not stop creation after the next event. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addUndoableListener
(ILcdUndoableListener aListener) Adds a listener to this source, so this listener is notified when something undoable has happened.void
cancel()
Cancels the current interaction with this controller.void
commit()
Commits the current state of the object.void
finish()
Sends aTLspNextCreateStepEvent
to indicate that the current (dynamic) creation process is done.protected void
fireUndoableHappened
(ILcdUndoable aUndoable) Notify all listeners in that an undoable has happened.Returns the action that should be triggered after this controller commits the object it is creating.Returns the controller model used by this create controller.Returns the handle styler used to style handles in this create controller.Returns anILcdLayered
for this controller.Gets the snapper used by this controller.Gets the snapper styler used by this create controllerReturns theILcdStringTranslator
set on this controller.handleAWTEventImpl
(AWTEvent aEvent) Called byhandleAWTEvent
.handleFXEventImpl
(Event aEvent) Called byhandleFXEvent
.boolean
Determines whether or notterminateInteraction()
should cause ongoing creation operations to be cancelled.void
nextStep()
Sends aTLspNextCreateStepEvent
to indicate that the current (dynamic) creation process should move to the next step of creation, without finishing the current creation process.paint
(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase) Paints the visual feedback of this controller.void
removeUndoableListener
(ILcdUndoableListener aListener) Removes the specified listener so it is no longer notified.void
setActionToTriggerAfterCommit
(ILcdAction aActionToTriggerAfterCommit) Sets the action that should be triggered after this controller commits the object it is creating.void
setCancelOnTerminateInteraction
(boolean aCancelOnTerminate) Determines whether or notterminateInteraction()
should cause ongoing creation operations to be cancelled.void
setHandleStyler
(ILspStyler aHandleStyler) Sets the handle styler used to style handles in this create controller.void
setSnapperProvider
(ILspSnapperProvider aSnapperProvider) Sets the snapper used by this controller.void
setSnapperStyler
(ILspStyler aStyler) Sets the snapper styler used by this create controllervoid
setStringTranslator
(ILcdStringTranslator aStringTranslator) Sets theILcdStringTranslator
that this controller should use to translate theStrings
that will be visible in the user interface.protected void
startInteractionImpl
(ILspView aView) The specific implementation ofstartInteraction
for this controller.void
terminateInteraction
(ILspView aView) Terminates interaction with this controller.protected void
terminateInteractionImpl
(ILspView aView) The specific implementation ofterminateInteraction
for this controller.Methods inherited from class com.luciad.view.lightspeed.controller.ALspController
addPropertyChangeListener, addStatusListener, appendController, firePropertyChange, fireStatusEvent, getAWTFilter, getCursor, getFXCursor, getFXFilter, getIcon, getName, getNextController, getShortDescription, getView, handleAWTEvent, handleFXEvent, paintImpl, registerViewPropertyNameForReset, removePropertyChangeListener, removeStatusListener, setAWTFilter, setCursor, setFXCursor, setFXFilter, setIcon, setName, setShortDescription, startInteraction
-
Constructor Details
-
TLspCreateController
Creates a new TLspCreateController using the provided create controller model, with a default name, short description, icon, an empty context, undo support, which instantly triggers actions, a default cursor location, which does not support touch, does not consume mouse released events and does not stop creation after the next event.- Parameters:
aCreateControllerModel
- the create controller model.
-
-
Method Details
-
getActionToTriggerAfterCommit
Returns the action that should be triggered after this controller commits the object it is creating.- Returns:
- the action.
-
setActionToTriggerAfterCommit
Sets the action that should be triggered after this controller commits the object it is creating.- Parameters:
aActionToTriggerAfterCommit
- the action.
-
getControllerModel
Returns the controller model used by this create controller.- Returns:
- the controller model.
-
startInteractionImpl
Description copied from class:ALspController
The specific implementation ofstartInteraction
for this controller.- Overrides:
startInteractionImpl
in classALspController
- Parameters:
aView
- the view to start interaction with.
-
terminateInteractionImpl
Description copied from class:ALspController
The specific implementation ofterminateInteraction
for this controller.- Overrides:
terminateInteractionImpl
in classALspController
- Parameters:
aView
- the view to terminate interaction with.
-
cancel
public void cancel()Cancels the current interaction with this controller. Any created object is removed. -
getHandleStyler
Returns the handle styler used to style handles in this create controller. By default this is an instance ofTLspEditHandleStyler
- Returns:
- the handle styler
-
setHandleStyler
Sets the handle styler used to style handles in this create controller.- Parameters:
aHandleStyler
- The handle styler to use
-
finish
public void finish()Sends aTLspNextCreateStepEvent
to indicate that the current (dynamic) creation process is done. This method can for example be used to stop creating a polygon, to advance to the next polygon when creating a complex polygon, etc. -
nextStep
public void nextStep()Sends a
TLspNextCreateStepEvent
to indicate that the current (dynamic) creation process should move to the next step of creation, without finishing the current creation process.This method can be used to advance to the next point when creating a polygon inside a complex polygon.
If you wish to advance to the next polygon inside the complex polygon, use the
finish
method instead.The example demonstrates how this method can be used to set a point to a specific location (perhaps due to a UI event), without interrupting the creation process of a pointlist.
//The create controller and the model that contains our shape. TLspCreateController createController; ILcdModel model; //The pointlist we are currently creating with the create controller ILcd2DEditablePointList pointlist; if (pointlist != null) { try { TLcdLockUtil.writeLock(model); //Move the current point to lon-lat (10,15) as an example. pointlist.move2DPoint(pointlist.getPointCount() - 1, 10, 15); model.elementChanged(fObject, ILcdModel.FIRE_LATER); } finally { TLcdLockUtil.writeUnlock(model); } model.fireCollectedModelChanges(); //Go to next step in creation process, without ending creation or the current polyline. createController.nextStep(); }
-
commit
public void commit()Commits the current state of the object. This finishes creation for the object. The object is not removed from the model, and it is committed as is. -
handleAWTEventImpl
Description copied from class:ALspController
Called byhandleAWTEvent
. Returnsnull
when the controller consumed the event or a partially consumed event when the controller partially consumed the event (which could happen withTLcdTouchEvent
s). When the controller did not use the given event, it is returned unaltered.- Specified by:
handleAWTEventImpl
in classALspController
- Parameters:
aEvent
- the event to be handled.- Returns:
null
when the input event was consumed, the (possibly modified) input event when it was (partially) consumed.
-
handleFXEventImpl
Description copied from class:ALspController
Called byhandleFXEvent
. Returnsnull
when the controller consumed the event. When the controller did not use the given event, it is returned unaltered.- Overrides:
handleFXEventImpl
in classALspController
- Parameters:
aEvent
- the event to be handled.- Returns:
null
when the input event was consumed, the (possibly modified) input event when it was (partially) consumed.
-
getLayered
Description copied from interface:ILspController
Returns an
ILcdLayered
for this controller. Custom implementations of this method should take care to return the sameILcdLayered
instance every time this method is called to guarantee correct working of theILcdLayered
interface.The returned layered object should contain layers that are relevant to this controller. Any view using this controller should take into account the layers of its active controller.
Note that the ILcdLayered is only allowed to contain
ILspLayer
instances.- Specified by:
getLayered
in interfaceILspController
- Overrides:
getLayered
in classALspController
- Returns:
- an ILcdLayered object, or null if this controller has no layers.
-
paint
public TLspPaintProgress paint(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase) Description copied from class:ALspController
Paints the visual feedback of this controller. This method is called multiple times for different paint phases.Empty implementation. Redefine
ALspController.paintImpl(com.luciad.view.opengl.binding.ILcdGLDrawable, com.luciad.view.lightspeed.ILspView, com.luciad.view.lightspeed.TLspPaintPhase)
method to render on the ILcdGLDrawable on which the view is rendered.- Specified by:
paint
in interfaceILspController
- Overrides:
paint
in classALspController
- Parameters:
aGLDrawable
- the ILcdGLDrawable on which the view is rendered.aView
- the view.aPaintPhase
- the current paint phase- Returns:
- whether or not the painting was finished.
-
addUndoableListener
Description copied from interface:ILcdUndoableSource
Adds a listener to this source, so this listener is notified when something undoable has happened.- Specified by:
addUndoableListener
in interfaceILcdUndoableSource
- Parameters:
aListener
- The listener to be notified when something undoable has happened.
-
removeUndoableListener
Description copied from interface:ILcdUndoableSource
Removes the specified listener so it is no longer notified.- Specified by:
removeUndoableListener
in interfaceILcdUndoableSource
- Parameters:
aListener
- The listener to remove.
-
fireUndoableHappened
Notify all listeners in that an undoable has happened.- Parameters:
aUndoable
- The undoable of which the listeners should be notified.
-
setStringTranslator
Sets the
ILcdStringTranslator
that this controller should use to translate theStrings
that will be visible in the user interface.This method should be called before this controller is used. Any
does not translate the controller's name and description.Strings
already created by this controller will not be translated with the specified translator. TheILcdStringTranslator
The following list of
Strings
are translated by the given instance:- "Create object"
- "Undo {0}".
{0}
will be replaced by the display name of the action that is to be undone. E.g. "Undo Create object". - "Redo {0}".
{0}
will be replaced by the display name of the action that is to be redone. E.g. "Redo Create object".
ILcdStringTranslator
needs to be able to translate what is passed in{0}
, but not the entire formattedString
. For example, for "Undo {0}" it needs to be able to translate "Undo {0}" itself and "Create object", but not "Undo Create object".- Parameters:
aStringTranslator
- TheILcdStringTranslator
that should be used. Must not benull
.
-
getStringTranslator
Returns the
ILcdStringTranslator
set on this controller.- Returns:
- The translator set on this controller. Never
null
.
-
terminateInteraction
Description copied from class:ALspController
Terminates interaction with this controller. This automatically happens when setting a different controller on the view usingILspView.setController(com.luciad.view.lightspeed.controller.ILspController)
. This implementation also callsterminateInteraction
on the next controller. OverrideterminateInteractionImpl
if you want to add your own behavior to this controller.- Specified by:
terminateInteraction
in interfaceILspController
- Overrides:
terminateInteraction
in classALspController
- Parameters:
aView
- the view the controller was operating on
-
isCancelOnTerminateInteraction
public boolean isCancelOnTerminateInteraction()Determines whether or notterminateInteraction()
should cause ongoing creation operations to be cancelled. If false, the creation is stopped instead and the object being created is committed to the underlying model. If true, the creation is cancelled and the partially created object is discarded. By default, this property is true.- Returns:
- whether or not to cancel creation when the controller is removed from the view
-
setCancelOnTerminateInteraction
public void setCancelOnTerminateInteraction(boolean aCancelOnTerminate) Determines whether or notterminateInteraction()
should cause ongoing creation operations to be cancelled. If false, the- Parameters:
aCancelOnTerminate
- whether or not to cancel creation when the controller is removed from the view
-
getSnapperProvider
Gets the snapper used by this controller.- Returns:
- the snapper used by this controller
-
setSnapperProvider
Sets the snapper used by this controller.- Parameters:
aSnapperProvider
- the snapper used by this controller
-
getSnapperStyler
Gets the snapper styler used by this create controller- Returns:
- the snapper styler used by this create controller
-
setSnapperStyler
Sets the snapper styler used by this create controller- Parameters:
aStyler
- the snapper styler used by this create controller
-