net.sf.latexdraw.instruments
Class DnD2AddShape

java.lang.Object
  extended by org.malai.instrument.Link<AddShape,I,Pencil>
      extended by net.sf.latexdraw.instruments.PencilLink<AbortableDnD>
          extended by net.sf.latexdraw.instruments.DnD2AddShape
All Implemented Interfaces:
InteractionHandler

 class DnD2AddShape
extends PencilLink<AbortableDnD>

This link allows to create shapes using a drag-and-drop interaction.


Field Summary
 
Fields inherited from class org.malai.instrument.Link
action, clazzAction, execute, instrument, interaction
 
Constructor Summary
protected DnD2AddShape(Pencil ins, boolean exec)
          The constructor by default.
 
Method Summary
private  double getGap(IShape shape)
           
 void initAction()
          After being created by method createAction, the action must be initialised by this method.
 void interimFeedback()
          Defines the interim feedback of the link.
 boolean isConditionRespected()
           
 void updateAction()
          Updates the current action.
private  void updateShapeFromCentre(IRectangularShape shape, IPoint startPt, double endX)
           
private  void updateShapeFromDiag(IRectangularShape shape, IPoint startPt, IPoint endPt)
           
 
Methods inherited from class org.malai.instrument.Link
addEventable, clearEvents, createAction, getAction, getInstrument, getInteraction, interactionAborts, interactionStarts, interactionStops, interactionUpdates, isActivated, isExecute, isInteractionMustBeAborted, isRunnable, isRunning, setActivated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DnD2AddShape

protected DnD2AddShape(Pencil ins,
                       boolean exec)
                throws java.lang.InstantiationException,
                       java.lang.IllegalAccessException
The constructor by default.

Parameters:
ins - The pencil.
exec - True: the action will be executed each time the interaction is updated.
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
Since:
3.0
Method Detail

initAction

public void initAction()
Description copied from class: Link
After being created by method createAction, the action must be initialised by this method.

Overrides:
initAction in class PencilLink<AbortableDnD>

isConditionRespected

public boolean isConditionRespected()
Specified by:
isConditionRespected in class Link<AddShape,AbortableDnD,Pencil>
Returns:
True if the condition of the link is respected.

updateAction

public void updateAction()
Description copied from class: Link
Updates the current action. To override.

Overrides:
updateAction in class Link<AddShape,AbortableDnD,Pencil>

getGap

private double getGap(IShape shape)
Parameters:
shape - The shape to analyse.
Returns:
The gap that must respect the pencil to not allow shape to disappear when they are too small.
Since:
3.0

updateShapeFromCentre

private void updateShapeFromCentre(IRectangularShape shape,
                                   IPoint startPt,
                                   double endX)

updateShapeFromDiag

private void updateShapeFromDiag(IRectangularShape shape,
                                 IPoint startPt,
                                 IPoint endPt)

interimFeedback

public void interimFeedback()
Description copied from class: Link
Defines the interim feedback of the link. If overridden, the interim feedback of its instrument should be define too.

Overrides:
interimFeedback in class Link<AddShape,AbortableDnD,Pencil>