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
ConstructorsConstructorDescriptionTLspCreateController(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 TypeMethodDescriptionvoidaddUndoableListener(ILcdUndoableListener aListener) Adds a listener to this source, so this listener is notified when something undoable has happened.voidcancel()Cancels the current interaction with this controller.voidcommit()Commits the current state of the object.voidfinish()Sends aTLspNextCreateStepEventto indicate that the current (dynamic) creation process is done.protected voidfireUndoableHappened(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 styler that is used to style handle labels in this controller.Returns the handle styler used to style handles in this create controller.Returns anILcdLayeredfor this controller.Gets the snapper used by this controller.Gets the snapper styler used by this create controllerReturns theILcdStringTranslatorset on this controller.handleAWTEventImpl(AWTEvent aEvent) Called byhandleAWTEvent.handleFXEventImpl(Event aEvent) Called byhandleFXEvent.booleanDetermines whether or notterminateInteraction()should cause ongoing creation operations to be cancelled.voidnextStep()Sends aTLspNextCreateStepEventto 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.voidremoveUndoableListener(ILcdUndoableListener aListener) Removes the specified listener so it is no longer notified.voidsetActionToTriggerAfterCommit(ILcdAction aActionToTriggerAfterCommit) Sets the action that should be triggered after this controller commits the object it is creating.voidsetCancelOnTerminateInteraction(boolean aCancelOnTerminate) Determines whether or notterminateInteraction()should cause ongoing creation operations to be cancelled.voidsetHandleLabelStyler(ILspStyler aHandleStyler) Sets the styler used to style handle labels in this controller.voidsetHandleStyler(ILspStyler aHandleStyler) Sets the handle styler used to style handles in this create controller.voidsetSnapperProvider(ILspSnapperProvider aSnapperProvider) Sets the snapper used by this controller.voidsetSnapperStyler(ILspStyler aStyler) Sets the snapper styler used by this create controllervoidsetStringTranslator(ILcdStringTranslator aStringTranslator) Sets theILcdStringTranslatorthat this controller should use to translate theStringsthat will be visible in the user interface.protected voidstartInteractionImpl(ILspView aView) The specific implementation ofstartInteractionfor this controller.voidterminateInteraction(ILspView aView) Terminates interaction with this controller.protected voidterminateInteractionImpl(ILspView aView) The specific implementation ofterminateInteractionfor 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:ALspControllerThe specific implementation ofstartInteractionfor this controller.- Overrides:
startInteractionImplin classALspController- Parameters:
aView- the view to start interaction with.
-
terminateInteractionImpl
Description copied from class:ALspControllerThe specific implementation ofterminateInteractionfor this controller.- Overrides:
terminateInteractionImplin 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
-
getHandleLabelStyler
Returns the styler that is used to style handle labels in this controller.- Returns:
- the handle label styler
- Since:
- 2025.0
-
setHandleLabelStyler
Sets the styler used to style handle labels in this controller.- Parameters:
aHandleStyler- The handle label styler to use- Since:
- 2025.0
-
finish
public void finish()Sends aTLspNextCreateStepEventto 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
TLspNextCreateStepEventto 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
finishmethod 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:ALspControllerCalled byhandleAWTEvent. Returnsnullwhen the controller consumed the event or a partially consumed event when the controller partially consumed the event (which could happen withTLcdTouchEvents). When the controller did not use the given event, it is returned unaltered.- Specified by:
handleAWTEventImplin classALspController- Parameters:
aEvent- the event to be handled.- Returns:
nullwhen the input event was consumed, the (possibly modified) input event when it was (partially) consumed.
-
handleFXEventImpl
Description copied from class:ALspControllerCalled byhandleFXEvent. Returnsnullwhen the controller consumed the event. When the controller did not use the given event, it is returned unaltered.- Overrides:
handleFXEventImplin classALspController- Parameters:
aEvent- the event to be handled.- Returns:
nullwhen the input event was consumed, the (possibly modified) input event when it was (partially) consumed.
-
getLayered
Description copied from interface:ILspControllerReturns an
ILcdLayeredfor this controller. Custom implementations of this method should take care to return the sameILcdLayeredinstance every time this method is called to guarantee correct working of theILcdLayeredinterface.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
ILspLayerinstances.- Specified by:
getLayeredin interfaceILspController- Overrides:
getLayeredin 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:ALspControllerPaints 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:
paintin interfaceILspController- Overrides:
paintin 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:ILcdUndoableSourceAdds a listener to this source, so this listener is notified when something undoable has happened.- Specified by:
addUndoableListenerin interfaceILcdUndoableSource- Parameters:
aListener- The listener to be notified when something undoable has happened.
-
removeUndoableListener
Description copied from interface:ILcdUndoableSourceRemoves the specified listener so it is no longer notified.- Specified by:
removeUndoableListenerin 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
ILcdStringTranslatorthat this controller should use to translate theStringsthat 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.Stringsalready created by this controller will not be translated with the specified translator. TheILcdStringTranslatorThe following list of
Stringsare 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".
ILcdStringTranslatorneeds 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- TheILcdStringTranslatorthat should be used. Must not benull.
-
getStringTranslator
Returns the
ILcdStringTranslatorset on this controller.- Returns:
- The translator set on this controller. Never
null.
-
terminateInteraction
Description copied from class:ALspControllerTerminates 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 callsterminateInteractionon the next controller. OverrideterminateInteractionImplif you want to add your own behavior to this controller.- Specified by:
terminateInteractionin interfaceILspController- Overrides:
terminateInteractionin 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
-