iRex DR1000 Manager v0.5.2

it.andynaz.irex.dr1000.scribble
Class Parser

java.lang.Object
  extended by it.andynaz.irex.dr1000.scribble.Parser

public class Parser
extends Object

Parses the blob to create the pages with the scribbles. The scribbles are organized as a list of Stroke objects, which have a list of Stroke.Point objects.

Scribbles are stored in the annotations.data column (see documentation of class ScribbleMgr for information about the structure of the database), as a binary blob with the following structure. The not-used parts are represented in gray (in this case the meaning is not sure) and the bytes in the examples are represented as a couple of hexadecimal digits. Note that the bytes are stored in a reversed order, so that the pair of bytes "01 00" has to be read as the hex number "0001", which corresponds to 1 (and not to 256)

The first 40 bytes are the ones related to the page data:

length type meaning example
2 version 01 00
4 orientation 00 00 00 00
8 page_pixel 00 00 00 00 00 00 00 00
2 page_r 00 00
2 page_g 00 00
2 page_b 00 00
4 ul_x 00 00 00 00
4 ul_y 00 00 00 00
4 lr_x D7 04 00 00
4 lr_y DA 06 00 00
4 int number of strokes A3 00 00 00

Only the last one is actually used, as it indicates the number of strokes in the page.

After that 40 bytes, there are the strokes.
Each stroke begin with a 24-bytes sequence, representing the properties of a stroke, and the list of points.
The 24 bytes are strucutred according to the following schema:

length type meaning example
4 color 03 00 00 00
4 float zoom D7 A0 89 42
4 layer 00 00 00 00
4 shape 00 00 00 00
4 int width 01 00 00 00
4 int number of points 35 00 00 00

Each point is represented as a 12-bytes blocks:

length type meaning example
4 int x coordinate 48 00 00 00
4 int y coordinate 6C 00 00 00
4 pressure 00 00 00 00

After the sequence of points, another stroke begins (or the end of the blob is reached).

Version:
2013/09/23
Author:
andynaz

Constructor Summary
private Parser()
           
 
Method Summary
static Page build(byte[] blob)
          Create a Page from the blob.
private static void safeSkip(ByteArrayInputStream bIn, long l)
          Skips l bytes from the ByteArrayInputStream bIn.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Parser

private Parser()
Method Detail

build

public static Page build(byte[] blob)
                  throws IOException
Create a Page from the blob. This method also creates all the Stroke objects inside the Page object.

Parameters:
blob - the blob, as taken from the SQLite database file
Returns:
a Page with all the scribbles in the blob, or null if the blob array is empty or null
Throws:
IOException - in an error occours while reading the blob

safeSkip

private static void safeSkip(ByteArrayInputStream bIn,
                             long l)
                      throws IOException
Skips l bytes from the ByteArrayInputStream bIn. After skipping, check if the actually skipped bytes are exactly l; if not, throws an IOException (the number of bytes actually skipped is in the IOException message).

Parameters:
bIn - stream from whom skip the bytes
l - number of bytes to skip
Throws:
IOException - if the method skipped less than l bytes or if an IO error occours

iRex DR1000 Manager v0.5.2

© 2013 andynaz - http://andynaz.altervista.org