public class TLspCreateController extends ALspController implements ILcdUndoableSource
action
is triggered and the process is restarted.TLspSetControllerAction
,
that sets a regular navigation/select controller on the view.
creation 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.
Constructor and Description |
---|
TLspCreateController(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.
|
Modifier and Type | Method and Description |
---|---|
void |
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 a
TLspNextCreateStepEvent to indicate that the current (dynamic) creation process is done. |
protected void |
fireUndoableHappened(ILcdUndoable aUndoable)
Notify all listeners in that an undoable has happened.
|
ILcdAction |
getActionToTriggerAfterCommit()
Returns the action that should be triggered after this controller commits the object it is creating.
|
ALspCreateControllerModel |
getControllerModel()
Returns the controller model used by this create controller.
|
ILspStyler |
getHandleStyler()
Returns the handle styler used to style handles in this create controller.
|
ILcdLayered |
getLayered()
Returns an
ILcdLayered for this controller. |
ILspSnapperProvider |
getSnapperProvider()
Gets the snapper used by this controller.
|
ILspStyler |
getSnapperStyler()
Gets the snapper styler used by this create controller
|
ILcdStringTranslator |
getStringTranslator()
Returns the
ILcdStringTranslator set on this controller. |
AWTEvent |
handleAWTEventImpl(AWTEvent aEvent)
Called by
handleAWTEvent . |
javafx.event.Event |
handleFXEventImpl(javafx.event.Event aEvent)
Called by
handleFXEvent . |
boolean |
isCancelOnTerminateInteraction()
Determines whether or not
terminateInteraction()
should cause ongoing creation operations to be cancelled. |
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. |
TLspPaintProgress |
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 not
terminateInteraction()
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 controller
|
void |
setStringTranslator(ILcdStringTranslator aStringTranslator)
Sets the
ILcdStringTranslator that this controller should use to
translate the Strings that will be visible in the user interface. |
protected void |
startInteractionImpl(ILspView aView)
The specific implementation of
startInteraction for this controller. |
void |
terminateInteraction(ILspView aView)
Terminates interaction with this controller.
|
protected void |
terminateInteractionImpl(ILspView aView)
The specific implementation of
terminateInteraction for this controller. |
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
public TLspCreateController(ALspCreateControllerModel aCreateControllerModel)
aCreateControllerModel
- the create controller model.public ILcdAction getActionToTriggerAfterCommit()
public void setActionToTriggerAfterCommit(ILcdAction aActionToTriggerAfterCommit)
aActionToTriggerAfterCommit
- the action.public ALspCreateControllerModel getControllerModel()
protected void startInteractionImpl(ILspView aView)
ALspController
startInteraction
for this controller.startInteractionImpl
in class ALspController
aView
- the view to start interaction with.protected void terminateInteractionImpl(ILspView aView)
ALspController
terminateInteraction
for this controller.terminateInteractionImpl
in class ALspController
aView
- the view to terminate interaction with.public void cancel()
public ILspStyler getHandleStyler()
TLspEditHandleStyler
public void setHandleStyler(ILspStyler aHandleStyler)
aHandleStyler
- The handle styler to usepublic void finish()
TLspNextCreateStepEvent
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.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();
}
public void commit()
public AWTEvent handleAWTEventImpl(AWTEvent aEvent)
ALspController
handleAWTEvent
.
Returns null
when the controller consumed the event or a partially consumed event
when the controller partially consumed the event (which could happen with
TLcdTouchEvent
s). When the controller did not use the given event, it is returned
unaltered.handleAWTEventImpl
in class ALspController
aEvent
- the event to be handled.null
when the input event was consumed, the (possibly modified) input
event when it was (partially) consumed.public javafx.event.Event handleFXEventImpl(javafx.event.Event aEvent)
ALspController
handleFXEvent
.
Returns null
when the controller consumed the event. When the controller did not use the
given event, it is returned unaltered.handleFXEventImpl
in class ALspController
aEvent
- the event to be handled.null
when the input event was consumed, the (possibly modified) input
event when it was (partially) consumed.public ILcdLayered getLayered()
ILspController
Returns an ILcdLayered
for this controller. Custom
implementations of this method should take care to return the same ILcdLayered
instance every time this method is called to guarantee correct working of the ILcdLayered
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.
getLayered
in interface ILspController
getLayered
in class ALspController
public TLspPaintProgress paint(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase)
ALspController
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.
paint
in interface ILspController
paint
in class ALspController
aGLDrawable
- the ILcdGLDrawable on which the view is rendered.aView
- the view.aPaintPhase
- the current paint phasepublic void addUndoableListener(ILcdUndoableListener aListener)
ILcdUndoableSource
addUndoableListener
in interface ILcdUndoableSource
aListener
- The listener to be notified when something undoable has happened.public void removeUndoableListener(ILcdUndoableListener aListener)
ILcdUndoableSource
removeUndoableListener
in interface ILcdUndoableSource
aListener
- The listener to remove.protected void fireUndoableHappened(ILcdUndoable aUndoable)
aUndoable
- The undoable of which the listeners should be notified.public void setStringTranslator(ILcdStringTranslator aStringTranslator)
Sets the ILcdStringTranslator
that this controller should use to
translate the Strings
that will be visible in the user interface.
This method should be called before this controller is used. Any Strings
already
created by this controller will not be translated with the specified translator. The
ILcdStringTranslator
The following list of Strings
are translated by the given instance:
{0}
will be replaced by the display name of the action that is to be undone. E.g. "Undo Create object".{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 formatted String
. For example, for "Undo {0}" it needs to be able to translate "Undo {0}" itself
and "Create object", but not "Undo Create object".aStringTranslator
- The ILcdStringTranslator
that should be used. Must not be
null
.public ILcdStringTranslator getStringTranslator()
Returns the ILcdStringTranslator
set on this controller.
null
.public void terminateInteraction(ILspView aView)
ALspController
ILspView.setController(com.luciad.view.lightspeed.controller.ILspController)
.
This implementation also calls terminateInteraction
on the next controller.
Override terminateInteractionImpl
if you want to add your own behavior
to this controller.terminateInteraction
in interface ILspController
terminateInteraction
in class ALspController
aView
- the view the controller was operating onpublic boolean isCancelOnTerminateInteraction()
terminateInteraction()
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.public void setCancelOnTerminateInteraction(boolean aCancelOnTerminate)
terminateInteraction()
should cause ongoing creation operations to be cancelled. If false, theaCancelOnTerminate
- whether or not to cancel creation when the controller is removed from the viewpublic ILspSnapperProvider getSnapperProvider()
public void setSnapperProvider(ILspSnapperProvider aSnapperProvider)
aSnapperProvider
- the snapper used by this controllerpublic ILspStyler getSnapperStyler()
public void setSnapperStyler(ILspStyler aStyler)
aStyler
- the snapper styler used by this create controller