Class TLspCreateController

java.lang.Object
com.luciad.view.lightspeed.controller.ALspController
com.luciad.view.lightspeed.controller.manipulation.TLspCreateController
All Implemented Interfaces:
ILcdUndoableSource, ILcdAWTEventListener, ILspController
Direct Known Subclasses:
TLspTouchCreateController

public class TLspCreateController extends ALspController implements ILcdUndoableSource
Controller that interactively creates new objects and inserts them into a layer on the view.

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 configurable action 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 special 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.

Since:
2012.0
  • Constructor Details

    • TLspCreateController

      public 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.
      Parameters:
      aCreateControllerModel - the create controller model.
  • Method Details

    • getActionToTriggerAfterCommit

      public ILcdAction getActionToTriggerAfterCommit()
      Returns the action that should be triggered after this controller commits the object it is creating.
      Returns:
      the action.
    • setActionToTriggerAfterCommit

      public void setActionToTriggerAfterCommit(ILcdAction aActionToTriggerAfterCommit)
      Sets the action that should be triggered after this controller commits the object it is creating.
      Parameters:
      aActionToTriggerAfterCommit - the action.
    • getControllerModel

      public ALspCreateControllerModel getControllerModel()
      Returns the controller model used by this create controller.
      Returns:
      the controller model.
    • startInteractionImpl

      protected void startInteractionImpl(ILspView aView)
      Description copied from class: ALspController
      The specific implementation of startInteraction for this controller.
      Overrides:
      startInteractionImpl in class ALspController
      Parameters:
      aView - the view to start interaction with.
    • terminateInteractionImpl

      protected void terminateInteractionImpl(ILspView aView)
      Description copied from class: ALspController
      The specific implementation of terminateInteraction for this controller.
      Overrides:
      terminateInteractionImpl in class ALspController
      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

      public ILspStyler getHandleStyler()
      Returns the handle styler used to style handles in this create controller. By default this is an instance of TLspEditHandleStyler
      Returns:
      the handle styler
    • setHandleStyler

      public void setHandleStyler(ILspStyler aHandleStyler)
      Sets the handle styler used to style handles in this create controller.
      Parameters:
      aHandleStyler - The handle styler to use
    • finish

      public void finish()
      Sends a 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.
    • 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

      public AWTEvent handleAWTEventImpl(AWTEvent aEvent)
      Description copied from class: ALspController
      Called by 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 TLcdTouchEvents). When the controller did not use the given event, it is returned unaltered.
      Specified by:
      handleAWTEventImpl in class ALspController
      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

      public Event handleFXEventImpl(Event aEvent)
      Description copied from class: ALspController
      Called by handleFXEvent. Returns null when the controller consumed the event. When the controller did not use the given event, it is returned unaltered.
      Overrides:
      handleFXEventImpl in class ALspController
      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

      public ILcdLayered getLayered()
      Description copied from interface: 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.

      Specified by:
      getLayered in interface ILspController
      Overrides:
      getLayered in class ALspController
      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 interface ILspController
      Overrides:
      paint in class ALspController
      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

      public void addUndoableListener(ILcdUndoableListener aListener)
      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 interface ILcdUndoableSource
      Parameters:
      aListener - The listener to be notified when something undoable has happened.
    • removeUndoableListener

      public void removeUndoableListener(ILcdUndoableListener aListener)
      Description copied from interface: ILcdUndoableSource
      Removes the specified listener so it is no longer notified.
      Specified by:
      removeUndoableListener in interface ILcdUndoableSource
      Parameters:
      aListener - The listener to remove.
    • fireUndoableHappened

      protected void fireUndoableHappened(ILcdUndoable aUndoable)
      Notify all listeners in that an undoable has happened.
      Parameters:
      aUndoable - The undoable of which the listeners should be notified.
    • setStringTranslator

      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

      does not translate the controller's name and description.

      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".
      The 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".
      Parameters:
      aStringTranslator - The ILcdStringTranslator that should be used. Must not be null.
    • getStringTranslator

      public ILcdStringTranslator getStringTranslator()

      Returns the ILcdStringTranslator set on this controller.

      Returns:
      The translator set on this controller. Never null.
    • terminateInteraction

      public void terminateInteraction(ILspView aView)
      Description copied from class: ALspController
      Terminates interaction with this controller. This automatically happens when setting a different controller on the view using 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.

      Specified by:
      terminateInteraction in interface ILspController
      Overrides:
      terminateInteraction in class ALspController
      Parameters:
      aView - the view the controller was operating on
    • isCancelOnTerminateInteraction

      public boolean isCancelOnTerminateInteraction()
      Determines whether or not 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.

      Returns:
      whether or not to cancel creation when the controller is removed from the view
    • setCancelOnTerminateInteraction

      public void setCancelOnTerminateInteraction(boolean aCancelOnTerminate)
      Determines whether or not terminateInteraction() 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

      public ILspSnapperProvider getSnapperProvider()
      Gets the snapper used by this controller.
      Returns:
      the snapper used by this controller
    • setSnapperProvider

      public void setSnapperProvider(ILspSnapperProvider aSnapperProvider)
      Sets the snapper used by this controller.
      Parameters:
      aSnapperProvider - the snapper used by this controller
    • getSnapperStyler

      public ILspStyler getSnapperStyler()
      Gets the snapper styler used by this create controller
      Returns:
      the snapper styler used by this create controller
    • setSnapperStyler

      public void setSnapperStyler(ILspStyler aStyler)
      Sets the snapper styler used by this create controller
      Parameters:
      aStyler - the snapper styler used by this create controller