diva.sketch
Class SketchModel

java.lang.Object
  extended by diva.sketch.SketchModel

public class SketchModel
extends Object

A SketchModel stores sketched symbols. Symbols can either be individual strokes or groups of strokes, represented by StrokeSymbol and CompositeSymbol, respectively. When the model changes (symbols have been added, removed, or modified), it generates SketchEvents to notify its listeners that a change has occured.

Version:
$Revision: 1.11 $
Author:
Michael Shilman (michaels@eecs.berkeley.edu), Heloise Hse (hwawen@eecs.berkeley.edu)

Constructor Summary
SketchModel()
          Create a SketchModel with no symbols.
 
Method Summary
 void addSketchListener(SketchListener l)
          Add the given SketchListener to the set of listeners.
 void addSymbol(int index, Symbol s)
          Insert a symbol into the model at the given position (Z order).
 void addSymbol(Symbol s)
          Add the given symbol to the model.
 int getSymbolCount()
          Return the number of symbols in this model.
 int indexOf(Symbol s)
          Return the index of the given symbol, or -1 if the symbol is not contained by the model.
 void removeSketchListener(SketchListener l)
          Remove the specified SketchListener from the set of listeners.
 void removeSymbol(Symbol s)
          Remove the specified symbol from the model.
 Iterator symbols()
          Return an iterator over the symbols in the model.
 void updateSymbol(Symbol s)
          Provide the means for a client to notify the listeners that the specified symbol has been updated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SketchModel

public SketchModel()
Create a SketchModel with no symbols.

Method Detail

addSketchListener

public void addSketchListener(SketchListener l)
Add the given SketchListener to the set of listeners.


addSymbol

public void addSymbol(Symbol s)
Add the given symbol to the model.


addSymbol

public void addSymbol(int index,
                      Symbol s)
Insert a symbol into the model at the given position (Z order). To insert the symbol just in front of some other symbol, use getSymbol() to get the other symbol's index, and pass index as the first argument. To insert the symbol just behind some other symbol, pass index+1 as the first argument. To insert so the symbol displays over the top of other symbols, insert at zero.

Clients should assume that an implementation of this method does not check if the symbol is already contained -- clients are therefore responsible for being bug-free.


getSymbolCount

public int getSymbolCount()
Return the number of symbols in this model.


indexOf

public int indexOf(Symbol s)
Return the index of the given symbol, or -1 if the symbol is not contained by the model.


removeSketchListener

public void removeSketchListener(SketchListener l)
Remove the specified SketchListener from the set of listeners.


removeSymbol

public void removeSymbol(Symbol s)
Remove the specified symbol from the model.


symbols

public Iterator symbols()
Return an iterator over the symbols in the model.


updateSymbol

public void updateSymbol(Symbol s)
Provide the means for a client to notify the listeners that the specified symbol has been updated.



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