diva.sketch
Class SketchController

java.lang.Object
  extended by diva.sketch.SketchController
Direct Known Subclasses:
PanZoomController

public class SketchController
extends Object

SketchController controls the behavior of a SketchPane. It is meant to be subclassed by application specific controllers to do "intelligent" interpretation on sketched input. The interpretation is performed by using a sketch interpreter. This basic implementation allows selection of symbols. It also adds strokes to a sketch model which can be written out to a sketch file.

Version:
$Revision: 1.21 $
Author:
Michael Shilman (michaels@eecs.berkeley.edu), Heloise Hse (hwawen@eecs.berkeley.edu)
See Also:
BasicInterpreter

Field Summary
static Color DEFAULT_FILL_COLOR
          The default fill color used for sketching.
static float DEFAULT_LINE_WIDTH
          The default pen line width used for sketching.
static Color DEFAULT_PEN_COLOR
          The default pen color used for sketching.
 
Constructor Summary
SketchController()
          Create a SketchController and initialize its foreground interpreter to a BasicInterpreter.
 
Method Summary
 Iterator containedSketchFigures(Polygon2D region)
          Return an iterator over the figures that are completely contained by the given polygonal region.
 Figure figureForSymbol(Symbol symbol)
          Return a figure for the given symbol, or null if the symbol does not have a figure representation.
 Interactor getBackgroundInterpreter()
          Return the interpreter that processes strokes on the backgound event layer.
 MouseFilter getDragFilter()
          Return the mouse filter used for dragging.
 Color getFillColor()
          Return the color used to fill symbols.
 Interactor getForegroundInterpreter()
          Return the interpreter that processes strokes on the foreground event layer.
 float getLineWidth()
          Return the line width used to draw symbols.
 Color getPenColor()
          Return the color used to draw symbols.
 MouseFilter getSelectionFilter()
          Return the mouse filter used for the selection interactor.
 SelectionInteractor getSelectionInteractor()
          Return the selection interactor on all symbols.
 SelectionModel getSelectionModel()
          Get the default selection model.
 SketchModel getSketchModel()
          Return the sketch model this pane views.
 GraphicsPane getSketchPane()
          Return the parent pane of this controller.
 Iterator hitSketchFigures(Rectangle2D region)
          Return an iterator over the figures that intersect the given rectangular region.
protected  void initializeInteraction()
          Initialize all interaction on the sketch pane.
 void setBackgroundInterpreter(Interactor interactor)
          Set the interpreter that processes strokes in the background event layer.
 void setFillColor(Color c)
          Set the color used to fill symbols.
 void setForegroundInterpreter(Interactor interactor)
          Set the interpreter that processes strokes in the foreground event layer.
 void setLineWidth(float w)
          Set the line width used to draw symbols.
 void setPenColor(Color c)
          Set the color used to draw symbols.
 void setSelectionModel(SelectionModel m)
          Set the default selection model.
 void setSketchModel(SketchModel m)
          Set the sketch model in this controller.
 void setSketchPane(GraphicsPane p)
          Set the graphics pane.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PEN_COLOR

public static Color DEFAULT_PEN_COLOR
The default pen color used for sketching.


DEFAULT_FILL_COLOR

public static Color DEFAULT_FILL_COLOR
The default fill color used for sketching.


DEFAULT_LINE_WIDTH

public static float DEFAULT_LINE_WIDTH
The default pen line width used for sketching.

Constructor Detail

SketchController

public SketchController()
Create a SketchController and initialize its foreground interpreter to a BasicInterpreter. The foreground interpreter will recieve mouse events as the user sketches and forward these events to its listeners. Also add a RepaintListener to the sketch model. The repaint listener manages painting of stroke symbols as they are being added/updated/removed from the model. Most of the real work is done in the initializeInteraction() method which is not called until parent pane is set. The pane is specified by the setSketchPane() method.

Method Detail

containedSketchFigures

public Iterator containedSketchFigures(Polygon2D region)
Return an iterator over the figures that are completely contained by the given polygonal region.


figureForSymbol

public Figure figureForSymbol(Symbol symbol)
Return a figure for the given symbol, or null if the symbol does not have a figure representation.


getBackgroundInterpreter

public Interactor getBackgroundInterpreter()
Return the interpreter that processes strokes on the backgound event layer.


getDragFilter

public MouseFilter getDragFilter()
Return the mouse filter used for dragging.


getFillColor

public Color getFillColor()
Return the color used to fill symbols.


getForegroundInterpreter

public Interactor getForegroundInterpreter()
Return the interpreter that processes strokes on the foreground event layer.


getLineWidth

public float getLineWidth()
Return the line width used to draw symbols.


getPenColor

public Color getPenColor()
Return the color used to draw symbols.


getSelectionFilter

public MouseFilter getSelectionFilter()
Return the mouse filter used for the selection interactor.


getSelectionInteractor

public SelectionInteractor getSelectionInteractor()
Return the selection interactor on all symbols.


getSelectionModel

public SelectionModel getSelectionModel()
Get the default selection model.


getSketchModel

public SketchModel getSketchModel()
Return the sketch model this pane views.


getSketchPane

public GraphicsPane getSketchPane()
Return the parent pane of this controller.


hitSketchFigures

public Iterator hitSketchFigures(Rectangle2D region)
Return an iterator over the figures that intersect the given rectangular region.


initializeInteraction

protected void initializeInteraction()
Initialize all interaction on the sketch pane. This method is called by the setSketchPane() method. The initialization cannot be done in the constructor because the controller does not yet have a reference to its pane at that time.


setBackgroundInterpreter

public void setBackgroundInterpreter(Interactor interactor)
Set the interpreter that processes strokes in the background event layer. This would be useful for processing events that you'd like to go to selected objects. Remove the previous background interpreter from the background event layer before adding the new one.


setFillColor

public void setFillColor(Color c)
Set the color used to fill symbols.


setForegroundInterpreter

public void setForegroundInterpreter(Interactor interactor)
Set the interpreter that processes strokes in the foreground event layer. If these events are consumed, they don't get passed to the layers below, therefore _backgroundInterpreter will not process these strokes. Remove the previous foreground interpreter from the foreground event layer before adding this one.


setLineWidth

public void setLineWidth(float w)
Set the line width used to draw symbols. This also sets the line width in SketchLayer if a SketchPane is used.


setPenColor

public void setPenColor(Color c)
Set the color used to draw symbols. This also sets the pen color in SketchLayer if a SketchPane is used.


setSelectionModel

public void setSelectionModel(SelectionModel m)
Set the default selection model. The caller is expected to ensure that the old model is empty before calling this.


setSketchModel

public void setSketchModel(SketchModel m)
Set the sketch model in this controller. It replaces the existing model and updates the pane with figures according to the new model. Remove the repaint listener from the previous sketch model, then remove all existing figures from the pane. Add repaint listener to the new sketch model and update the pane with new figures (add symbols from the new model).


setSketchPane

public void setSketchPane(GraphicsPane p)
Set the graphics pane. This is done once by the SketchPane immediately after construction of the controller.



Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.