edu.stanford.hci.r3.pattern.coordinates
Class PatternLocationToSheetLocationMapping

java.lang.Object
  extended by edu.stanford.hci.r3.pattern.coordinates.PatternLocationToSheetLocationMapping

public class PatternLocationToSheetLocationMapping
extends java.lang.Object

This class stores mappings from regions of pattern (and their coordinates in Anoto space) to Sheets and locations on those sheets. This mapping works both ways. Given a location on the sheet, we should be able to find the pattern coordinate. Given a coordinate, we should be able to find the location on the sheet.

An instance of this object should be built when a PDF is rendered with pattern. At that moment, regions on a sheet are bound to specific physical coordinates. Each application should store this mapping per sheet.

The SheetRenderer class uses this class to save the mapping to disk, so that a future instance can load the mapping and run the application.

This software is distributed under the BSD License.


Constructor Summary
PatternLocationToSheetLocationMapping(Sheet s)
          One mapping object per sheet.
PatternLocationToSheetLocationMapping(Sheet s, java.io.File patternInfoFile)
          These XML files are created automatically when you render a patterned PDF.
 
Method Summary
 PatternCoordinateConverter getCoordinateConverterForSample(PenSample sample)
          Checks whether this mapping contains the pen sample (streamed coordinates).
 PatternCoordinateConverter getPatternBoundsOfRegion(Region r)
           
 java.util.Map<Region,PatternCoordinateConverter> getRegionToPatternMapping()
          An advanced method, to allow us to inspect the region <--> pattern mapping.
 Sheet getSheet()
           
 void initializeMap(java.util.List<Region> regions)
          For all ACTIVE regions, we need a coordinate converter that will enable us to find out where the pen is on the region.
 void loadConfigurationFromXML(java.io.File xmlFile)
          On Nov 9, 2006, I changed this to use the interface...
 void printMapping()
          For debugging.
 void saveConfigurationToXML(java.io.File xmlFile)
          Due to xstream's inability to serial/unserialize really complicated classes, we will save only a regionName+origin --> pattern info mapping
 void setPatternInformationOfRegion(Region r, PatternCoordinateConverter coordinateInfo)
          For a region on our sheet, update the coordinate information so that it can be accessed at runtime by our EventEngine.
 void setPatternInformationOfRegion(Region region, PatternDots x, PatternDots y, PatternDots width, PatternDots height)
          A convenience function for mapping a contiguous (single-tile) patterned area to a region object.
 void setSheet(Sheet s)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PatternLocationToSheetLocationMapping

public PatternLocationToSheetLocationMapping(Sheet s)
One mapping object per sheet. Create this object after you have added all the regions that you need to the sheet. This class will maintain a mapping of Regions to physical (streaming) and logical (batched) pen coordinates. This constructor will try to load the pattern configuration automatically. If you want to set the mapping manually, you will need to load the map with TiledPatternCoordinateConverters so that active regions can be accessed.

Parameters:
s -

PatternLocationToSheetLocationMapping

public PatternLocationToSheetLocationMapping(Sheet s,
                                             java.io.File patternInfoFile)
These XML files are created automatically when you render a patterned PDF.

Parameters:
s -
patternInfoFile -
Method Detail

getCoordinateConverterForSample

public PatternCoordinateConverter getCoordinateConverterForSample(PenSample sample)
Checks whether this mapping contains the pen sample (streamed coordinates). If it does, it returns the TiledPatternCoordinateConverter object for that sample. If not, it returns null.

Parameters:
sample -
Returns:

getPatternBoundsOfRegion

public PatternCoordinateConverter getPatternBoundsOfRegion(Region r)
Parameters:
r - find the coordinate converter for this region.
Returns:
the converter that enables you to figure out where on the region a sample falls.

getRegionToPatternMapping

public java.util.Map<Region,PatternCoordinateConverter> getRegionToPatternMapping()
An advanced method, to allow us to inspect the region <--> pattern mapping. We can tell if the pattern map has an area of 0, which probably means it is uninitialized!

Returns:

getSheet

public Sheet getSheet()
Returns:

initializeMap

public void initializeMap(java.util.List<Region> regions)
For all ACTIVE regions, we need a coordinate converter that will enable us to find out where the pen is on the region. We should be able to add new regions to a sheet after the fact, so we should have the ability to reinitialize this map later on.

Parameters:
regions -

loadConfigurationFromXML

public void loadConfigurationFromXML(java.io.File xmlFile)
On Nov 9, 2006, I changed this to use the interface... I'll need to run some regression tests to make sure I didn't break anything.

Parameters:
xmlFile -

printMapping

public void printMapping()
For debugging.


saveConfigurationToXML

public void saveConfigurationToXML(java.io.File xmlFile)
Due to xstream's inability to serial/unserialize really complicated classes, we will save only a regionName+origin --> pattern info mapping

Parameters:
xmlFile -

setPatternInformationOfRegion

public void setPatternInformationOfRegion(Region r,
                                          PatternCoordinateConverter coordinateInfo)
For a region on our sheet, update the coordinate information so that it can be accessed at runtime by our EventEngine. The coordinateInfo object will translate incoming samples to coordinates relative to the region.

Parameters:
r -
coordinateInfo -

setPatternInformationOfRegion

public void setPatternInformationOfRegion(Region region,
                                          PatternDots x,
                                          PatternDots y,
                                          PatternDots width,
                                          PatternDots height)
A convenience function for mapping a contiguous (single-tile) patterned area to a region object.

Parameters:
region -
x -
y -
width -
height -

setSheet

public void setSheet(Sheet s)
Parameters:
s -

toString

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

Copyright 2006 Stanford University