edu.stanford.hci.r3.pen.ink
Class InkStroke

java.lang.Object
  extended by edu.stanford.hci.r3.pen.ink.InkStroke

public class InkStroke
extends java.lang.Object

Store ink strokes (multiple samples) in here.

We assume that the units in this stroke are consistent (one reference unit), and make sense to the client class that ends up using this stroke object. For example, if the units is in PatternDots, and the values are derived directly from the streaming PenListeners, we need to make sure that the stroke samples do not jump from one page tile to another. In that case, we would assume that the streamed samples come from one Anoto pattern tile, unless otherwise specified.

This software is distributed under the BSD License.


Constructor Summary
InkStroke()
           
InkStroke(java.util.Collection<PenSample> currentStrokeSamples, Units reference)
          Copies the samples into our own arrays.
InkStroke(java.util.List<PenSample> stroke)
           
 
Method Summary
 void addSample(double x, double y, int force, long ts)
           
 void addSample(PenSample penSample)
           
 double getArea()
           
 java.awt.geom.Rectangle2D getBounds()
           
 long getDuration()
           
 PenSample getEnd()
          Returns the last sample in this stroke (end-point).
 long getFirstTimestamp()
           
 java.util.Date getFirstTimestampAsDate()
           
 int[] getForceSamples()
           
 long getLastTimestamp()
           
 java.util.Date getLastTimestampAsDate()
           
 double getMaxX()
           
 double getMaxY()
           
 double getMinX()
           
 double getMinY()
           
 int getNumSamples()
           
 Units getReferenceUnit()
           
 java.util.List<PenSample> getSamples()
           
 PenSample getStart()
          Returns the first sample in this stroke (start-point).
 long[] getTimeSamples()
           
 double getWidth()
           
 double[] getXSamples()
           
 int[] getXSamplesAsInts()
           
 double[] getYSamples()
           
 int[] getYSamplesAsInts()
           
 void setBounds(double minStrokeX, double minStrokeY, double maxStrokeX, double maxStrokeY)
           
 void setMaxX(float mxX)
           
 void setMaxY(float mxY)
           
 void setMinX(float mnX)
           
 void setMinY(float mnY)
           
 void setSamples(java.util.List<PenSample> newSamples)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InkStroke

public InkStroke()

InkStroke

public InkStroke(java.util.Collection<PenSample> currentStrokeSamples,
                 Units reference)
Copies the samples into our own arrays. The reference unit enables us to interpret the samples correctly.

Parameters:
currentStrokeSamples -
reference -

InkStroke

public InkStroke(java.util.List<PenSample> stroke)
Parameters:
stroke -
Method Detail

addSample

public void addSample(double x,
                      double y,
                      int force,
                      long ts)
Parameters:
x -
y -
force -
ts -

addSample

public void addSample(PenSample penSample)
Parameters:
penSample -

getArea

public double getArea()
Returns:
the area in pixels^2, or whatever units the ink is in (possible PatternDots^2)

getBounds

public java.awt.geom.Rectangle2D getBounds()
Returns:

getDuration

public long getDuration()
Returns:

getEnd

public PenSample getEnd()
Returns the last sample in this stroke (end-point).

Returns:

getFirstTimestamp

public long getFirstTimestamp()
Returns:
the earliest time stamp of this stroke

getFirstTimestampAsDate

public java.util.Date getFirstTimestampAsDate()

getForceSamples

public int[] getForceSamples()
Returns:

getLastTimestamp

public long getLastTimestamp()
Returns:

getLastTimestampAsDate

public java.util.Date getLastTimestampAsDate()
Returns:

getMaxX

public double getMaxX()
Returns:
the maxX

getMaxY

public double getMaxY()
Returns:
the maxY

getMinX

public double getMinX()
Returns:
the minX

getMinY

public double getMinY()
Returns:
the minY

getNumSamples

public int getNumSamples()
Returns:

getReferenceUnit

public Units getReferenceUnit()
Returns:

getSamples

public java.util.List<PenSample> getSamples()

getStart

public PenSample getStart()
Returns the first sample in this stroke (start-point).

Returns:

getTimeSamples

public long[] getTimeSamples()
Returns:

getWidth

public double getWidth()

getXSamples

public double[] getXSamples()
Returns:

getXSamplesAsInts

public int[] getXSamplesAsInts()
Returns:

getYSamples

public double[] getYSamples()
Returns:

getYSamplesAsInts

public int[] getYSamplesAsInts()
Returns:

setBounds

public void setBounds(double minStrokeX,
                      double minStrokeY,
                      double maxStrokeX,
                      double maxStrokeY)
Parameters:
minStrokeX -
minStrokeY -
maxStrokeX -
maxStrokeY -

setMaxX

public void setMaxX(float mxX)
Parameters:
mxX - the maxX to set

setMaxY

public void setMaxY(float mxY)
Parameters:
mxY - the maxY to set

setMinX

public void setMinX(float mnX)
Parameters:
mnX - the minX to set

setMinY

public void setMinY(float mnY)
Parameters:
mnY - the minY to set

setSamples

public void setSamples(java.util.List<PenSample> newSamples)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Copyright 2006 Stanford University