Class TLspEditController

java.lang.Object
com.luciad.view.lightspeed.controller.ALspController
com.luciad.view.lightspeed.controller.manipulation.TLspEditController
All Implemented Interfaces:
ILcdUndoableSource, ILcdAWTEventListener, ILspController

public class TLspEditController extends ALspController implements ILcdUndoableSource
Controller that edits existing object on the view.

To do this, it first retrieves the editing candidates. To customize this, it is possible to override the getEditingCandidates method. After retrieving the editing candidates, this controller checks if there is an editor set on the respective layer and activates the handles associated with the editor.

These handles can be visualized, and styled using a handle styler. When handles have focus, they are styled using a focus handle styler. This makes it possible to highlight handles when hovering over them.

To paint handles, this controller uses a layer containing a shape painter that uses the same ILspShapeDiscretizer as the shape painter from the original layer. This makes it possible to support painting custom shape handles (e.g. the projected shape handle under an extruded custom shape) in this controller. If not shape discretizer is found in the original layer, TLspShapeDiscretizer is used instead.

During editing, 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.

This controller makes it possible to edit multiple objects at the same time. By default, it is possible to move multiple objects at the same time, without being able edit the control points of the shapes. This behavior can be customized using getMultiObjectHandles.

When objects are edited, this controller notifies the layer by calling ILspInteractivePaintableLayer.editedObjectChanged(java.lang.Object).

Since:
2012.0
  • Constructor Details

    • TLspEditController

      public TLspEditController()
      Creates a new edit controller.
  • Method Details

    • getSensitivity

      public double getSensitivity()
      Returns the sensitivity of this controller.
      Returns:
      the sensitivity of this controller
    • setSensitivity

      public void setSensitivity(double aSensitivity)
      Sets the sensitivity of this controller.
      Parameters:
      aSensitivity - the sensitivity of this controller
    • getHandleStyler

      public ILspStyler getHandleStyler()
      Returns the styler that is used for handles that are not focused. By default this is an instance of TLspEditHandleStyler
      Returns:
      the handle styler
    • setHandleStyler

      public void setHandleStyler(ILspStyler aHandleStyler)
      Sets the styler that is used for handles that are not focused.
      Parameters:
      aHandleStyler - The handle styler to use
    • getFocusHandleStyler

      public ILspStyler getFocusHandleStyler()
      Returns the styler used to style handles that have focus in this edit controller. By default this is an instance of TLspEditHandleStyler
      Returns:
      the handle styler
    • setFocusHandleStyler

      public void setFocusHandleStyler(ILspStyler aHandleStyler)
      Sets the styler used to style handles that have focus in this edit controller.
      Parameters:
      aHandleStyler - The handle styler to use
    • getHandleLabelStyler

      public ILspStyler getHandleLabelStyler()
      Returns the styler that is used for handle labels that are not focused.
      Returns:
      the handle styler
    • setHandleLabelStyler

      public void setHandleLabelStyler(ILspStyler aHandleStyler)
      Sets the handle styler used to style handle labels in this edit controller.
      Parameters:
      aHandleStyler - The handle styler to use
    • getFocusHandleLabelStyler

      public ILspStyler getFocusHandleLabelStyler()
      Returns the styler used to style handle labels that have focus in this edit controller.
      Returns:
      the handle styler
    • setFocusHandleLabelStyler

      public void setFocusHandleLabelStyler(ILspStyler aHandleStyler)
      Sets the styler used to style handle labels that have focus in this edit controller.
      Parameters:
      aHandleStyler - The handle styler to use
    • 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:

      • "Edit {0}". {0} will be replaced by the result of calling Object.toString() on the edited object. E.g. "Edit Polygon".
      • The result of calling Object.toString() on the edited objects. E.g. "Polygon".
      • "Undo {0}". {0} will be replaced by the display name of the action that is to be undone. E.g. "Undo Edit Polygon".
      • "Redo {0}". {0} will be replaced by the display name of the action that is to be redone. E.g. "Redo Edit Polygon".
      The ILcdStringTranslator needs to be able to translate what is passed in {0}, but not the entire formatted String. For example, for "Edit {0}" it needs to be able to translate "Edit {0}" itself and the edited object's Object.toString(), e.g. "Polygon", but not "Edit Polygon".
      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.
    • startInteraction

      public void startInteraction(ILspView aView)
      Description copied from class: ALspController
      Called to start interacting with the controller. This automatically happens when setting the controller on the view using ILspView.setController(com.luciad.view.lightspeed.controller.ILspController).

      This implementation sends out a status event based on the short description. It also calls startInteraction on the next controller. Override startInteractionImpl if you want to add your own behavior to this controller.

      Specified by:
      startInteraction in interface ILspController
      Overrides:
      startInteraction in class ALspController
      Parameters:
      aView - the view the controller operates on
    • startInteractionForLayer

      protected void startInteractionForLayer(ILspLayer aLayer)
      Adds listeners for various editing-related changes to the given layer. This method is called by startInteraction(com.luciad.view.lightspeed.ILspView) for every layer in the view; the listeners are used by the edit controller to maintain its internal bookkeeping. This method should only be used when the edit controller is expected to track a layer that is not in the view, such as a controller layer.
      Parameters:
      aLayer - the layer to be tracked for editing-related changes
    • 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
    • terminateInteractionForLayer

      protected void terminateInteractionForLayer(ILspLayer aLayer)
      Counterpart of startInteractionForLayer(com.luciad.view.lightspeed.layer.ILspLayer) which removes the edit controller's listeners from the given layer. This method is called by terminateInteraction(com.luciad.view.lightspeed.ILspView) for every layer in the view. This method should only be used when the edit controller is expected to track a layer that is not in the view, such as a controller layer.
      Parameters:
      aLayer - the layer from which to remove editing-related listeners
    • getEditingCandidates

      protected List<TLspDomainObjectContext> getEditingCandidates(ILspView aView)
      Retrieves objects from the view that are candidates for editing. By default this method returns all currently selected objects, but it can be overridden if different behavior is desired. Each candidate object is wrapped in a TLspDomainObjectContext so that it can be linked back to the layer in which it is contained.
      Parameters:
      aView - the view in which to look for editing candidates
      Returns:
      a list of potentially editable objects
    • getMultiObjectHandles

      protected List<ALspMultiObjectHandle> getMultiObjectHandles(Collection<TLspDomainObjectContext> aObjectsSFCT)
      Returns the multi object handles of this controller. Typically these handle operates on a collection of objects instead of a single object. By default, this method returns null if the given object count is less than or equal to 1. When the amount of objects supplied is greater, a multi-object-translation handle is returned.
      Parameters:
      aObjectsSFCT - the list of objects for which a handle should be generated
      Returns:
      a list of multi object handles to use for the editing operation
    • getSnapperProvider

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

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

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

      public void setSnapperStyler(ILspStyler aStyler)
      Sets the snapper styler used by this edit controller
      Parameters:
      aStyler - the snapper styler used by this edit controller
    • 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.
    • 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.
    • 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.
    • 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.