com.partnersoft.v3x.io.formats.rover
Class RoverLib

java.lang.Object
  extended by com.partnersoft.v3x.io.formats.rover.RoverLib
All Implemented Interfaces:
RoverConstants

public class RoverLib
extends java.lang.Object
implements RoverConstants

Various disgustingly lazy static methods.


Field Summary
 
Fields inherited from interface com.partnersoft.v3x.io.formats.rover.RoverConstants
DRAW_JUSTIFIED_TEXT, DRAW_OFFSET_POINT, DRAW_OFFSET_TEXT, DRAW_POINT, DRAW_POLYGON, DRAW_POLYLINE, DRAW_TEXT, EOF, JUSTIFY_BASELINE_CENTER, JUSTIFY_BASELINE_LEFT, JUSTIFY_BASELINE_RIGHT, JUSTIFY_NOTSPECIFIED, OPCODE_TYPE_BOUNDARY, SIZE_DRAW_JUSTIFIED_TEXT_PREAMBLE, SIZE_DRAW_OFFSET_POINT, SIZE_DRAW_OFFSET_TEXT_CONCLUSION, SIZE_DRAW_OFFSET_TEXT_PREAMBLE, SIZE_DRAW_POINT, SIZE_DRAW_POLYLINE_PREAMBLE, SIZE_DRAW_TEXT_PREAMBLE, STYLE_REGION
 
Constructor Summary
RoverLib()
           
 
Method Summary
static byte[] bytesFor(RoverGraphic graphic)
          Creates a byte array containing the bytecodes for the given RoverGraphic.
static float byteToRotation(byte packed)
          Parses a rotation in radians from a single byte.
static DoubleRectangle extentsFor(java.io.InputStream roverStream)
          Returns the extents for the rovers in the provided input stream.
static float firstXCoordIn(byte[] roverBytes)
          Returns first x coordinate for the given byte array.
static float firstYCoordIn(byte[] roverBytes)
          Returns first y coordinate for the given byte array.
static byte rotationToByte(float radians)
          Formats a rotation, in radians, as a single byte.
static RoverGraphic roverGraphicFor(byte[] roverBytes)
          The opposite of bytesFor(); this creates a RoverGraphic object from the given byte array.
static void setDataID(byte[] roverBytes, int ID)
          Sets the data ID for all items in the given byte array.
static void setStyles(byte[] roverBytes, int styleCode)
           
static void setStyles(byte[] roverBytes, int pointStyle, int lineStyle, int textStyle)
          Sets the style codes for all items in the given byte array.
static int styleCodeFor(byte[] roverBytes)
          Extracts a style code from a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RoverLib

public RoverLib()
Method Detail

styleCodeFor

public static int styleCodeFor(byte[] roverBytes)
Extracts a style code from a byte array. Basically creates the stylecode from bytes 1 and 2.


firstXCoordIn

public static float firstXCoordIn(byte[] roverBytes)
Returns first x coordinate for the given byte array. Smart enough to dope out which is lines and which are points etc.


firstYCoordIn

public static float firstYCoordIn(byte[] roverBytes)
Returns first y coordinate for the given byte array. Smart enough to dope out which is lines and which are points etc.


bytesFor

public static byte[] bytesFor(RoverGraphic graphic)
Creates a byte array containing the bytecodes for the given RoverGraphic. Synchronized so that it can reuse some private globals - hey, if you want something that's not synchronized, write it yerself.

Oh, yeah, if it generates an IOException it catches it and dies - there really shouldn't be any.


roverGraphicFor

public static RoverGraphic roverGraphicFor(byte[] roverBytes)
The opposite of bytesFor(); this creates a RoverGraphic object from the given byte array.


extentsFor

public static DoubleRectangle extentsFor(java.io.InputStream roverStream)
                                  throws java.io.IOException
Returns the extents for the rovers in the provided input stream.

Throws:
java.io.IOException

rotationToByte

public static byte rotationToByte(float radians)
Formats a rotation, in radians, as a single byte. Obviously loses precision!


byteToRotation

public static float byteToRotation(byte packed)
Parses a rotation in radians from a single byte. Neat!


setDataID

public static void setDataID(byte[] roverBytes,
                             int ID)
Sets the data ID for all items in the given byte array.


setStyles

public static void setStyles(byte[] roverBytes,
                             int styleCode)

setStyles

public static void setStyles(byte[] roverBytes,
                             int pointStyle,
                             int lineStyle,
                             int textStyle)
Sets the style codes for all items in the given byte array.