edu.mit.sketch.clocksketch.penIO
Class PenIO

java.lang.Object
  extended by edu.mit.sketch.clocksketch.penIO.PenIO

public class PenIO
extends java.lang.Object

Author:
David Pitman May 7, 2005

Field Summary
static java.lang.String StrokeRandomID
           
static java.lang.String StrokeTimeStringID
           
 
Constructor Summary
PenIO()
          Empty constructor?
 
Method Summary
static double convertFromAnotoUnit(double auNum)
          Converts a double from the Anoto unit (.3mm, w/ accuracty of 1/8th Anoto Unit) to millimeters
static java.util.HashMap getClockSketchData(java.lang.String filePath)
          This method is used to load metadata in the first version of the clocksketch file format.
static java.util.LinkedList<Stroke> getData(java.lang.String filename)
          This method loads the raw data the Anoto Pen Service dumps into a file and returns a LinkedList of PenStrokes.
static java.lang.StringBuffer getDataContents(java.lang.String filename)
          Returns the pen data as it is found in the file
 java.util.HashMap getXMLClockSketchData(org.jdom.Document doc)
          Retrieves all the meta-data from the ClockSketch XML file as a HashMap with keys as PenTags or PenTags combinations
 org.jdom.Document getXMLDocument(java.lang.String rootLabel)
          Creates a new XML Document
 java.util.List<PenDrawing> getXMLPenData(org.jdom.Document doc)
          Parses the data in an XML document to create a Drawing.
static void main(java.lang.String[] args)
           
static void makeSpreadsheetFile(java.util.ArrayList<double[][]> strokeData, java.util.ArrayList<long[]> timeStampsData, java.lang.String[] headers, java.io.File file)
          Deprecated, this would create a simple SpreadSheet for analyzing data (used to work on the classifier originally)
 org.jdom.Document openXMLDocument(java.net.URL url)
          Given a URL, attempts to retrieve and parse the raw file, and return a document
 void setXMLClockSketchData(org.jdom.Document doc, java.util.HashMap data)
           
 void setXMLPenData(org.jdom.Document doc, java.util.List<PenDrawing> drawings)
          Converts the PenDrawing to an XML document, and also saves a field with the raw data.
static void writeClockSketchFile(java.util.HashMap clockSketchData, java.lang.String penData, java.io.File fileToWrite)
          This method was used to write meta data and payload information for the first version of the clocksketch file format.
 boolean writeXMLClockSketchFile(java.io.File file, java.util.List<PenDrawing> drawings, java.util.HashMap clockData)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

StrokeTimeStringID

public static java.lang.String StrokeTimeStringID

StrokeRandomID

public static java.lang.String StrokeRandomID
Constructor Detail

PenIO

public PenIO()
Empty constructor?

Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

openXMLDocument

public org.jdom.Document openXMLDocument(java.net.URL url)
                                  throws org.jdom.JDOMException,
                                         java.io.IOException
Given a URL, attempts to retrieve and parse the raw file, and return a document

Parameters:
url -
Returns:
Document
Throws:
java.io.IOException
org.jdom.JDOMException

writeXMLClockSketchFile

public boolean writeXMLClockSketchFile(java.io.File file,
                                       java.util.List<PenDrawing> drawings,
                                       java.util.HashMap clockData)
                                throws java.io.IOException
Throws:
java.io.IOException

getXMLDocument

public org.jdom.Document getXMLDocument(java.lang.String rootLabel)
Creates a new XML Document


setXMLPenData

public void setXMLPenData(org.jdom.Document doc,
                          java.util.List<PenDrawing> drawings)
Converts the PenDrawing to an XML document, and also saves a field with the raw data.

Parameters:
doc -
drawings -

setXMLClockSketchData

public void setXMLClockSketchData(org.jdom.Document doc,
                                  java.util.HashMap data)

getXMLPenData

public java.util.List<PenDrawing> getXMLPenData(org.jdom.Document doc)
Parses the data in an XML document to create a Drawing. The data should look like (Ignoring the forward slashes)- \ \

Parameters:
doc -

getXMLClockSketchData

public java.util.HashMap getXMLClockSketchData(org.jdom.Document doc)
Retrieves all the meta-data from the ClockSketch XML file as a HashMap with keys as PenTags or PenTags combinations

Parameters:
doc -

getDataContents

public static java.lang.StringBuffer getDataContents(java.lang.String filename)
Returns the pen data as it is found in the file

Parameters:
filename -
Returns:
A string of the data.

getData

public static java.util.LinkedList<Stroke> getData(java.lang.String filename)
                                            throws java.io.FileNotFoundException
This method loads the raw data the Anoto Pen Service dumps into a file and returns a LinkedList of PenStrokes.

Parameters:
filename - - An absolute path used by new File() to load the data file
Returns:
LinkedList
Throws:
java.io.FileNotFoundException
See Also:
PenStroke

getClockSketchData

public static java.util.HashMap getClockSketchData(java.lang.String filePath)
                                            throws java.io.IOException
This method is used to load metadata in the first version of the clocksketch file format.

Parameters:
filePath -
Throws:
java.io.IOException

makeSpreadsheetFile

public static void makeSpreadsheetFile(java.util.ArrayList<double[][]> strokeData,
                                       java.util.ArrayList<long[]> timeStampsData,
                                       java.lang.String[] headers,
                                       java.io.File file)
Deprecated, this would create a simple SpreadSheet for analyzing data (used to work on the classifier originally)

Parameters:
strokeData -
timeStampsData -
headers -
file -

writeClockSketchFile

public static void writeClockSketchFile(java.util.HashMap clockSketchData,
                                        java.lang.String penData,
                                        java.io.File fileToWrite)
This method was used to write meta data and payload information for the first version of the clocksketch file format.

Parameters:
clockSketchData -
penData -
fileToWrite -

convertFromAnotoUnit

public static double convertFromAnotoUnit(double auNum)
Converts a double from the Anoto unit (.3mm, w/ accuracty of 1/8th Anoto Unit) to millimeters

Parameters:
auNum -
Returns:
double