Class TLcdGXYNewController2

All Implemented Interfaces:
ILcdUndoableSource, ILcdAWTEventListener, ILcdStatusSource, ILcdGXYChainableController, ILcdGXYController, KeyListener, MouseListener, MouseMotionListener, Serializable, EventListener

public class TLcdGXYNewController2 extends ALcdGXYSmartController implements ILcdGXYChainableController
Controller to interactively create and initialize domain objects using mouse clicks or mouse drags. 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();
  }
 };
 TLcdGXYNewController2 controller = new TLcdGXYNewController2(controllerModel);
 view.setGXYController(controller);
 
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.
The controller responds to the backspace and escape keys, going back one step and cancelling the creation respectively.

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.

Since:
9.0
See Also: