topcodes
Class TopCode

java.lang.Object
  extended by topcodes.TopCode

public class TopCode
extends java.lang.Object

TopCodes (Tangible Object Placement Codes) are black-and-white circular fiducials designed to be recognized quickly by low-resolution digital cameras with poor optics. The TopCode symbol format is based on the open SpotCode format: http://www.highenergymagic.com/spotcode/symbols.html Each TopCode encodes a 13-bit number in a single data ring on the outer edge of the symbol. Zero is represented by a black sector and one is represented by a white sector.

Version:
$Revision: 1.4 $, $Date: 2007/10/15 13:12:30 $
Author:
Michael Horn

Constructor Summary
TopCode()
          Default constructor
TopCode(int code)
          Create a TopCode with the given id number.
 
Method Summary
 void annotate(java.awt.Graphics2D g, Scanner scanner)
           
 int decode(Scanner scanner, int cx, int cy)
          Decodes a symbol given any point (cx, cy) inside the center circle (bulls-eye) of the code.
 void draw(java.awt.Graphics2D g)
          Draws this spotcode with its current location and orientation
static TopCode[] generateCodes()
          Generates a list of all valid TopCodes
 float getCenterX()
          Returns the x-coordinate for the center point of the symbol.
 float getCenterY()
          Returns the y-coordinate for the center point of the symbol.
 int getCode()
          Returns the ID number for this symbol.
 float getDiameter()
          Returns the diameter of this code in pixels.
 float getOrientation()
          Returns the orientation of this code in radians and accurate to about plus or minus one degree.
 boolean isValid()
          Returns true if this code was sucessfully decoded.
 void setCode(int code)
          Sets the ID number for this symbol.
 void setDiameter(float diameter)
          Sets the diameter of this code in pixels.
 void setLocation(float x, float y)
          Sets the x- and y-coordinates for the center point of the symbol.
 void setOrientation(float orientation)
          Sets the angular orientation of this code in radians.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TopCode

public TopCode()
Default constructor


TopCode

public TopCode(int code)
Create a TopCode with the given id number.

Method Detail

getCode

public int getCode()
Returns the ID number for this symbol. Calling the decode() function will set this value automatically.


setCode

public void setCode(int code)
Sets the ID number for this symbol.


getOrientation

public float getOrientation()
Returns the orientation of this code in radians and accurate to about plus or minus one degree. This value gets set automatically by the decode() function.


setOrientation

public void setOrientation(float orientation)
Sets the angular orientation of this code in radians.


getDiameter

public float getDiameter()
Returns the diameter of this code in pixels. This value will be set automatically by the decode() function.


setDiameter

public void setDiameter(float diameter)
Sets the diameter of this code in pixels.


getCenterX

public float getCenterX()
Returns the x-coordinate for the center point of the symbol. This gets set automatically by the decode() function.


getCenterY

public float getCenterY()
Returns the y-coordinate for the center point of the symbol. This gets set automatically by the decode() function.


setLocation

public void setLocation(float x,
                        float y)
Sets the x- and y-coordinates for the center point of the symbol.


isValid

public boolean isValid()
Returns true if this code was sucessfully decoded.


decode

public int decode(Scanner scanner,
                  int cx,
                  int cy)
Decodes a symbol given any point (cx, cy) inside the center circle (bulls-eye) of the code.


annotate

public void annotate(java.awt.Graphics2D g,
                     Scanner scanner)

draw

public void draw(java.awt.Graphics2D g)
Draws this spotcode with its current location and orientation


generateCodes

public static TopCode[] generateCodes()
Generates a list of all valid TopCodes