|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdiva.canvas.interactor.AbstractInteractor
diva.sketch.BasicInterpreter
public class BasicInterpreter
A class that interprets changes to a stroke. BasicInterpreter is a sketch interpreter that gets called whenever a user sketches on the screen. It extends from diva.canvas.AbstractInteractor and should be added to the pane layer in order to receive mouse events. Since BasicInterpreter is a very simple implementation of a sketch interpreter, it doesn't do any interpretation on user input. In general, a sketch interpreter would receive mouse events and use a recognizer to process these events. The recognizer comes back with an answer, and depending on what the answer is, the interpreter tells the sketch controller to perform the corresponding application-specific actions. The recognizer can be arbitrarily complex (or simple). It could be a low-level recognizer that determines the geometric shape of a user stroke or a voting recognizer that uses a bunch of different recognizers. The recognizer is meant to be highly configurable.
Field Summary | |
---|---|
protected SketchController |
_controller
The sketch controller that uses this interpreter to interpret sketch input. |
protected TimedStroke |
_curStroke
The current stroke that's being drawn, gets its data from _strokeBuffer and is reallocated at the end of a stroke. |
protected StrokeSymbol |
_curSymbol
The current symbol which wraps the current stroke and keeps visual information about the stroke (color, line width). |
protected TimedStroke |
_strokeBuffer
A buffer for the stroke that's currently being drawn. |
Constructor Summary | |
---|---|
BasicInterpreter(SketchController c)
Create a BasicInterpreter which is used by the specified controller to interpret sketch input. |
Method Summary | |
---|---|
protected void |
appendStroke(LayerEvent e)
Append the given new point/timestamp to the current stroke. |
protected void |
finishStroke(LayerEvent e)
Called at the end of the mouseReleased method to finish the drawing of a stroke. |
SketchController |
getController()
Return the controller that uses this interpreter. |
TimedStroke |
getCurrentStroke()
Return the current stroke being drawn. |
Symbol |
getCurrentSymbol()
Return the symbol for current stroke being drawn. |
boolean |
isMotionEnabled()
We're consuming motion events. |
void |
mouseDragged(LayerEvent e)
Update the current stroke and its visual representation. |
void |
mouseEntered(LayerEvent e)
Consume the event, for efficiency. |
void |
mouseExited(LayerEvent e)
Consume the event, for efficiency. |
void |
mouseMoved(LayerEvent e)
Consume the event, for efficiency. |
void |
mousePressed(LayerEvent e)
Instantiate a new stroke and add its visual representation as a symbol in the pane. |
void |
mouseReleased(LayerEvent e)
Update the current stroke and its visual representation, then reset the stroke to "null". |
void |
removeCurrentSymbol()
Remove the current figure from the figure layer. |
protected void |
startStroke(LayerEvent e)
This method is invoked upon mouse down. |
Methods inherited from class diva.canvas.interactor.AbstractInteractor |
---|
accept, getMouseFilter, isConsuming, isEnabled, mouseClicked, setConsuming, setEnabled, setMotionEnabled, setMouseFilter |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected SketchController _controller
protected TimedStroke _strokeBuffer
protected TimedStroke _curStroke
protected StrokeSymbol _curSymbol
Constructor Detail |
---|
public BasicInterpreter(SketchController c)
Method Detail |
---|
protected void appendStroke(LayerEvent e)
protected void finishStroke(LayerEvent e)
public final SketchController getController()
public final TimedStroke getCurrentStroke()
public final Symbol getCurrentSymbol()
public boolean isMotionEnabled()
isMotionEnabled
in interface Interactor
isMotionEnabled
in class AbstractInteractor
public void mouseDragged(LayerEvent e)
mouseDragged
in interface LayerListener
mouseDragged
in class AbstractInteractor
public void mouseEntered(LayerEvent e)
mouseEntered
in interface LayerMotionListener
mouseEntered
in class AbstractInteractor
public void mouseExited(LayerEvent e)
mouseExited
in interface LayerMotionListener
mouseExited
in class AbstractInteractor
public void mouseMoved(LayerEvent e)
mouseMoved
in interface LayerMotionListener
mouseMoved
in class AbstractInteractor
public void mousePressed(LayerEvent e)
mousePressed
in interface LayerListener
mousePressed
in class AbstractInteractor
public void mouseReleased(LayerEvent e)
mouseReleased
in interface LayerListener
mouseReleased
in class AbstractInteractor
public void removeCurrentSymbol()
protected void startStroke(LayerEvent e)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |