edu.stanford.hci.r3.pattern
Class PatternPackage

java.lang.Object
  extended by edu.stanford.hci.r3.pattern.PatternPackage

public class PatternPackage
extends java.lang.Object

Represents a set of pattern files. One can tile these files, and create Postscript and PDF files out of them. This package can load specific pattern files into byte[][] so that you can index them for drawing on screen or into little graphics that represent pattern buttons.

All interaction with the specific pattern files should go in this class. This class also contains the mapping between Streamed Pattern Coordinates and Batched Coordinates (from docking the pen). This mapping is read from the XML file, and determined experimentally, by the Calibration classes.

This software is distributed under the BSD License.


Constructor Summary
PatternPackage(java.io.File location)
           
 
Method Summary
static java.util.Map<java.lang.String,PatternPackage> getAvailablePatternPackages(java.io.File patternLocation)
           
 PatternDots getMinPatternX()
           
 PatternDots getMinPatternY()
           
 java.lang.String getName()
           
 double getNumDotsHorizontalBetweenPages()
           
 double getNumDotsVerticalBetweenPages()
           
 int getNumPatternColsPerFile()
           
 int getNumPatternRowsPerFile()
           
 StreamedPatternCoordinates getPatternCoordinateOfOriginOfFile(int patternFileNumber)
          Given a starting pattern file, we can determine the origin (top left corner) based on our knowledge of the origin of the first file, and the distance between each file.
 java.lang.String[] readPatternFromFile(int numPatternFile, Units originX, Units originY, Units width, Units height)
          We verify that numDotsX and numDotsY do not exceed the amount of dots in one file.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PatternPackage

public PatternPackage(java.io.File location)
Parameters:
location - this directory contains .pattern files (text files that contain the pattern as described by Anoto) and a config.xml file, which describes the physical coordinates, among other things.
Method Detail

getAvailablePatternPackages

public static java.util.Map<java.lang.String,PatternPackage> getAvailablePatternPackages(java.io.File patternLocation)
Returns:
the Pattern Packages that are available to the system. Packages are stored in the directory (pattern/). We return a Map so you can address the package by name.

getMinPatternX

public PatternDots getMinPatternX()
Returns:
the minimum horizontal physical (streamed) coordinate

getMinPatternY

public PatternDots getMinPatternY()
Returns:
the minimum vertical physical (streamed) coordinate

getName

public java.lang.String getName()
Returns:
the name of the package (same as the directory's name)

getNumDotsHorizontalBetweenPages

public double getNumDotsHorizontalBetweenPages()
Returns:

getNumDotsVerticalBetweenPages

public double getNumDotsVerticalBetweenPages()
Returns:

getNumPatternColsPerFile

public int getNumPatternColsPerFile()
Returns:

getNumPatternRowsPerFile

public int getNumPatternRowsPerFile()
Returns:

getPatternCoordinateOfOriginOfFile

public StreamedPatternCoordinates getPatternCoordinateOfOriginOfFile(int patternFileNumber)
Given a starting pattern file, we can determine the origin (top left corner) based on our knowledge of the origin of the first file, and the distance between each file.

Parameters:
patternFileNumber -
Returns:

readPatternFromFile

public java.lang.String[] readPatternFromFile(int numPatternFile,
                                              Units originX,
                                              Units originY,
                                              Units width,
                                              Units height)
We verify that numDotsX and numDotsY do not exceed the amount of dots in one file. If so, the requested number of dots are modified to fit. Thus, the dimension of the String[] may be smaller than you requested. You may want to make sure numDotsX/Y are correct if you do not want to be surprised.

Parameters:
numPatternFile - The number of the pattern file (numPatternFile.pattern).
originX - Which column of pattern to start from (0 dots is the leftmost column)
originY - Which row of pattern to start reading from (0 dots is the topmost column)
width - How many dots across do we need? (in whatever Units is most convenient for you)
height - How many dots down do we need?
Returns:
a String[] representing the requested pattern (encoded as uldr directions) each entry of the array represents one row of pattern. The columns are represented in the String. We expect this will be much easier to manipulate, especially since we do not need to index dots randomly.

toString

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

Copyright 2006 Stanford University