papertoolkit

 

Example Code Snippets

Page history last edited by Ron Yeh 3 yrs ago


 

Note that r3 lives as a subpackage of edu.stanford.hci. All tutorials here will omit the prefix for more concise documentation.

 

 

 

Testing the Streaming Pen

Navigate to r3.pen.* and look at PenCoordinateDebugger.java.

 

Pen pen = new Pen();

pen.startLiveMode();

pen.addLivePenListener(getDebugPenListener());

 

If you run the main function (listed above), the Pen object will start a server on the local machine (which will connect to your physical pen through Bluetooth). After you start streaming by tapping the streaming on/off paper button, you will be able to write on patterned paper and see a log printed to your the console.

 

Graphics2D in Java, and Position Items to Draw

There is a usability bug (or real bug) with Java2D's Graphics2D object. MAYBE it's just my copy of Java 6, but when I call:

AffineTransform oldTransform = g2d.getTransform();

It doesn't seem to give me an actual copy of the transform. Thus, if I translate the g2d and later want to set it back to the original state, I can't just set it back to the oldTransform.

Instead, I have begun using:

// g2d.getTransform SHOULD give us a copy....

// but this line actually works

final AffineTransform currTransform = new AffineTransform(g2d.getTransform());

Comments (0)

You don't have permission to comment on this page.