TiledPatternCoordinateConverter Class Reference

Inheritance diagram for TiledPatternCoordinateConverter:

PatternCoordinateConverter List of all members.

Public Member Functions

 TiledPatternCoordinateConverter (String regionName)
 A constructor for when you need to set the information later (The Lazy Approach).
 TiledPatternCoordinateConverter (String theRegionName, double leftMostPatternXCoord, double topMostPatternYCoord, int dotsAcross, int dotsDown)
 Used when you are creating a converter that lives on a SINGLE PATTERNED TILE.
 TiledPatternCoordinateConverter (String theRegionName, int startTile, int nTilesAcross, int nTilesDown, int dotsPerTileHoriz, int dotsPerTileVert, double numHorizDotsBetweenTiles, double numVertDotsBetweenTiles, double leftMostPatternX, double topMostPatternY, double numDotsAcross, double numDotsDown)
boolean contains (final double xValPatternDots, final double yValPatternDots)
 For performance, we precompute the boundaries and store just those numbers.
boolean contains (StreamedPatternCoordinates location)
 If you have the values and do not need to create a StreamedPatternCoordinates object, use the other contains(.
Override double getArea ()
String getRegionName ()
PercentageCoordinates getRelativeLocation (StreamedPatternCoordinates coord)
 Convert the input coordinate into a percentage location relative to this tile configuration (a region that has tiled pattern).
int getTileNumber (StreamedPatternCoordinates coord)
 It tries to calculate the tile number given an input coordinate.
void setOriginInDots (double leftMostPatternX, double topMostPatternY)
 What is the physical coordinate of the top-left corner of the top-left tile?
void setPatternInformationByReadingItFrom (TiledPattern p)
 Reads in the information to define this coordinate converter.
void setRegionName (String rName)
void setStartingTile (int startTile)
 The number of the first (top-left) tile; this is largely arbitrary, but _may_ correlate with a pattern file number N.pattern --> N as a starting tile number.
void setTileConfiguration (int nTilesAcross, int nTilesDown)
 The number of tiles owned by this converter.
void setTileSizeInDots (int dotsPerTileHoriz, int dotsPerTileVert)
 How wide and tall are these tiles? We assume uniform tiles (except for the rightmost and bottommost tiles).
void setTileToTileOffsetInDots (double numHorizDotsBetweenTiles, double numVertDotsBetweenTiles)
void setTotalSizeInDots (double numDotsAcross, double numDotsDown)
 Set the size of this tile configuration, irrespective of the tiling.
String toString ()

Detailed Description

Stores the bounds in physical (streaming) coordinates.

This software is distributed under the BSD License.

Author:
Ron B Yeh (ronyeh(AT)cs.stanford.edu)

Definition at line 21 of file TiledPatternCoordinateConverter.java.


Constructor & Destructor Documentation

TiledPatternCoordinateConverter ( String  regionName  ) 

A constructor for when you need to set the information later (The Lazy Approach).

Parameters:
regionName the Region that this coordinate converter was created for. The reason we don't pass in the whole region object is because this converter WILL be serialized and unserialized. Due to XStream's limitations, we will have to resolve the region at runtime using the region's name instead.

Definition at line 149 of file TiledPatternCoordinateConverter.java.

TiledPatternCoordinateConverter ( String  theRegionName,
int  startTile,
int  nTilesAcross,
int  nTilesDown,
int  dotsPerTileHoriz,
int  dotsPerTileVert,
double  numHorizDotsBetweenTiles,
double  numVertDotsBetweenTiles,
double  leftMostPatternX,
double  topMostPatternY,
double  numDotsAcross,
double  numDotsDown 
)

This object deals with physical coordinates (the type that you get when you stream coordinates from the Nokia SU-1B). They are all huge numbers, but we store them in PatternDots objects. Although we can convert the PatternDots objects into other Units, it doesn't really make sense, as the dots are specified in the world of Anoto's gargantuan pattern space. For example, if you converted the xOrigin to inches, you would get a beast of a number.

We precompute the boundaries so that we can do contains(...) tests faster.

Parameters:
theRegionName The region that this converter was created for.
startTile the number that you assign to the top-left tile
nTilesAcross width of this tile configuration, in # of tiles
nTilesDown height of this tile configuration, in # of tiles
dotsPerTileHoriz width of each tile, in # dots
dotsPerTileVert height of each tile, in # dots
leftMostPatternX left boundary in pattern dots
topMostPatternY top boundary, in pattern dots
numDotsAcross width of entire region in dots, not including the between-tile padding
numDotsDown height of entire region in dots, not including the padding in between tiles
numHorizDotsBetweenTiles the horizontal padding between adjacent tiles
numVertDotsBetweenTiles the vertical padding between adjacent tiles (tends to be 0, in our experience)

Definition at line 205 of file TiledPatternCoordinateConverter.java.

References TiledPatternCoordinateConverter.setOriginInDots(), TiledPatternCoordinateConverter.setRegionName(), TiledPatternCoordinateConverter.setStartingTile(), TiledPatternCoordinateConverter.setTileConfiguration(), TiledPatternCoordinateConverter.setTileSizeInDots(), TiledPatternCoordinateConverter.setTileToTileOffsetInDots(), and TiledPatternCoordinateConverter.setTotalSizeInDots().


Member Function Documentation

boolean contains ( StreamedPatternCoordinates  location  ) 

If you have the values and do not need to create a StreamedPatternCoordinates object, use the other contains(.

..) method.

Parameters:
location 
Returns:
whether the tile configuration contains this location

Implements PatternCoordinateConverter.

Definition at line 313 of file TiledPatternCoordinateConverter.java.

References TiledPatternCoordinateConverter.contains(), StreamedPatternCoordinates.getXVal(), and StreamedPatternCoordinates.getYVal().

boolean contains ( final double  xValPatternDots,
final double  yValPatternDots 
)

For performance, we precompute the boundaries and store just those numbers.

This method's likely faster than the other contains test, especially if you already have the x and y values and do not need to create a StreamedPatternLocation object.

Parameters:
xValPatternDots x value of the location, in PatternDots (physical/streamed coordinates)
yValPatternDots y value of the location, in PatternDots (physical/streamed coordinates)
Returns:
WARNING: POSSIBLY BUGGY, Due to New way of iterating through Pattern TODO: Fix Bug ~Here....

TODO: Implement a FASTER reject. Contains is called many many times. We want to reject as soon as is possible. Also, rejects happen a lot more than accepts.

Definition at line 285 of file TiledPatternCoordinateConverter.java.

Referenced by TiledPatternCoordinateConverter.contains(), and TiledPatternCoordinateConverter.getTileNumber().

Override double getArea (  ) 

Returns:
the area, in pattern dots squared, of this patch.

Implements PatternCoordinateConverter.

Definition at line 326 of file TiledPatternCoordinateConverter.java.

String getRegionName (  ) 

Returns:

Implements PatternCoordinateConverter.

Definition at line 333 of file TiledPatternCoordinateConverter.java.

PercentageCoordinates getRelativeLocation ( StreamedPatternCoordinates  coord  ) 

Convert the input coordinate into a percentage location relative to this tile configuration (a region that has tiled pattern).

Returns:

Implements PatternCoordinateConverter.

Definition at line 343 of file TiledPatternCoordinateConverter.java.

References TiledPatternCoordinateConverter.getTileNumber(), StreamedPatternCoordinates.getXVal(), and StreamedPatternCoordinates.getYVal().

int getTileNumber ( StreamedPatternCoordinates  coord  ) 

It tries to calculate the tile number given an input coordinate.

<blockquote> [0][1][2]
[3][4][5]
</blockquote>

This should work if the pattern space is short and wide, or thin and tall...

Parameters:
coord 
Returns:
the tile number of this coordinate. Returns -1 if this coordinate is not contained by this tile configuration.

Definition at line 384 of file TiledPatternCoordinateConverter.java.

References TiledPatternCoordinateConverter.contains().

Referenced by TiledPatternCoordinateConverter.getRelativeLocation().

void setOriginInDots ( double  leftMostPatternX,
double  topMostPatternY 
)

What is the physical coordinate of the top-left corner of the top-left tile?

Parameters:
leftMostPatternX 
topMostPatternY 

Definition at line 436 of file TiledPatternCoordinateConverter.java.

Referenced by TiledPatternCoordinateConverter.setPatternInformationByReadingItFrom(), and TiledPatternCoordinateConverter.TiledPatternCoordinateConverter().

void setPatternInformationByReadingItFrom ( TiledPattern  p  ) 

Reads in the information to define this coordinate converter.

Parameters:
p the tiled pattern object produced by sheet renderers.

Definition at line 450 of file TiledPatternCoordinateConverter.java.

References TiledPattern.getInitialPatternFileNumber(), TiledPattern.getNumDotsXFromRightMostTiles(), TiledPattern.getNumDotsXPerFullTile(), TiledPattern.getNumDotsYFromBottomMostTiles(), TiledPattern.getNumDotsYPerFullTile(), TiledPattern.getNumHorizDotsBetweenTiles(), TiledPattern.getNumTilesX(), TiledPattern.getNumTilesY(), TiledPattern.getNumTotalColumns(), TiledPattern.getNumTotalRows(), TiledPattern.getNumVertDotsBetweenTiles(), TiledPattern.getOriginXInDots(), TiledPattern.getOriginYInDots(), TiledPatternCoordinateConverter.setOriginInDots(), TiledPatternCoordinateConverter.setStartingTile(), TiledPatternCoordinateConverter.setTileConfiguration(), TiledPatternCoordinateConverter.setTileSizeInDots(), TiledPatternCoordinateConverter.setTileToTileOffsetInDots(), and TiledPatternCoordinateConverter.setTotalSizeInDots().

void setRegionName ( String  rName  ) 

Parameters:
rName the name of the region that this converter manages. It's important to keep your regions uniquely identifiable.

Definition at line 477 of file TiledPatternCoordinateConverter.java.

Referenced by TiledPatternCoordinateConverter.TiledPatternCoordinateConverter().

void setStartingTile ( int  startTile  ) 

The number of the first (top-left) tile; this is largely arbitrary, but _may_ correlate with a pattern file number N.pattern --> N as a starting tile number.

This makes calculations easier for certain operations, such as finding out which page of a notebook your user has written on.

Parameters:
startTile 

Definition at line 489 of file TiledPatternCoordinateConverter.java.

Referenced by TiledPatternCoordinateConverter.setPatternInformationByReadingItFrom(), and TiledPatternCoordinateConverter.TiledPatternCoordinateConverter().

void setTileConfiguration ( int  nTilesAcross,
int  nTilesDown 
)

The number of tiles owned by this converter.

Usually, this converter will map to a region on a sheet. This means that the tiledPatternConverter will need to know how many tiles of pattern the region contains. It will then help us find out where on the region we are.

Parameters:
nTilesAcross 
nTilesDown 

Definition at line 501 of file TiledPatternCoordinateConverter.java.

Referenced by TiledPatternCoordinateConverter.setPatternInformationByReadingItFrom(), and TiledPatternCoordinateConverter.TiledPatternCoordinateConverter().

void setTileSizeInDots ( int  dotsPerTileHoriz,
int  dotsPerTileVert 
)

How wide and tall are these tiles? We assume uniform tiles (except for the rightmost and bottommost tiles).

Parameters:
dotsPerTileHoriz 
dotsPerTileVert 

Definition at line 514 of file TiledPatternCoordinateConverter.java.

Referenced by TiledPatternCoordinateConverter.setPatternInformationByReadingItFrom(), and TiledPatternCoordinateConverter.TiledPatternCoordinateConverter().

void setTileToTileOffsetInDots ( double  numHorizDotsBetweenTiles,
double  numVertDotsBetweenTiles 
)

Parameters:
numHorizDotsBetweenTiles 
numVertDotsBetweenTiles 

Definition at line 526 of file TiledPatternCoordinateConverter.java.

Referenced by TiledPatternCoordinateConverter.setPatternInformationByReadingItFrom(), and TiledPatternCoordinateConverter.TiledPatternCoordinateConverter().

void setTotalSizeInDots ( double  numDotsAcross,
double  numDotsDown 
)

Set the size of this tile configuration, irrespective of the tiling.

This SHOULD be able to calculate the extra space on the last tile that is NOT a part of our configuration.

Parameters:
numDotsAcross 
numDotsDown 

Definition at line 547 of file TiledPatternCoordinateConverter.java.

Referenced by TiledPatternCoordinateConverter.setPatternInformationByReadingItFrom(), and TiledPatternCoordinateConverter.TiledPatternCoordinateConverter().

String toString (  ) 

See also:
java.lang.Object.toString()

Definition at line 562 of file TiledPatternCoordinateConverter.java.


The documentation for this class was generated from the following file:
Generated on Sat Apr 14 18:21:42 2007 for R3 Paper Toolkit by  doxygen 1.4.7