Class TLcdGXYTouchNewController

All Implemented Interfaces:
ILcdUndoableSource, ILcdAWTEventListener, ILcdStatusSource, ILcdGXYChainableController, ILcdGXYController, Serializable

public class TLcdGXYTouchNewController extends ALcdGXYChainableController implements ILcdUndoableSource
Controller to interactively create and initialize domain objects using touches or drag gestures. This controller needs a controller model that determines the following:
  • the object to create;
  • the initialization of the object through a series of edit steps;
  • the comitting of the domain object to a model.

Typical use

To interactively create a new object, implement a controller model providing a target layer and an uninitialized new domain object, and configure a corresponding controller on the view:

 ALcdGXYNewControllerModel2 controllerModel = new ALcdGXYNewControllerModel2() {

 public ILcdGXYLayer getGXYLayer(Graphics aGraphics, MouseEvent aMouseEvent, ILcdGXYLayerSubsetList aSnappables, ILcdGXYContext aContext) {
 return myLayer;
 }

 public Object create(int aEditCount, Graphics aGraphics, MouseEvent aMouseEvent, ILcdGXYLayerSubsetList aSnappables, ILcdGXYContext aContext) {
 return new MyDomainObject();
 }
 };
 TLcdGXYTouchNewController controller = new TLcdGXYTouchNewController(controllerModel);
 view.setGXYController(controller);
 
Typically you also want user interface elements to indicate if creation should end (e.g. when creating a polyline). See samples.gxy.touch.editing.TouchNewController for an example of this.
This controller supports snapping if snapping candidates are configured.

Undo behavior

This controller supports undo operations while creating, as well as after the creation has been finalized. The methods canUndo() and canRedo() can be used to check whether an undo or redo operation is possible at any given time during the creation process. The methods doUndo() and doRedo() will respectively undo the last creation interaction or redo the last action that was undone. After creation has finished (the object is committed), all registered ILcdUndoableListeners are notified with an undoable that will remove the object from the layer.

Customizing the editing process

The methods shouldCommit, shouldEdit, and shouldUndo can be overridden to map mouse events to specific editing behaviour.
In addition, some actions can be called programmatically. The methods canUndo(), canRedo(), canCommit() and canCancel() indicate whether or not an undo, redo, commit or cancel action are possible at the moment. The methods doUndo(), doRedo(), doCommit() and doCancel() will execute the actions when possible.

See ALcdGXYNewControllerModel2 for a more detailed explanation of the interaction with the controller model.

Use in a controller chain

This controller implements ILcdGXYChainableController, which means it can choose to disregard received AWTEvents and pass them on to an other component. This controller will automatically pass on all events but instances of TLcdTouchEvent. Even so it will only use one touch at a time. A second touch while the first isn't lifted will be delegated.

This controller only handles TLcdTouchPoints which are not-consumed, and marks the TLcdTouchPoints it uses as consumed, similar to the ALcdGXYTouchChainableController

Since:
10.0
See Also: