edu.stanford.hci.r3.pen
Class Pen

java.lang.Object
  extended by edu.stanford.hci.r3.pen.PenInput
      extended by edu.stanford.hci.r3.pen.Pen

public class Pen
extends PenInput

This class represents a single, physical digital pen. A pen has an identity, so you should be able to distinguish them. Pens can batch data for later upload. Alternatively, they can stream live data when connected in a streaming mode.

The Pen object abstracts the lower level connections with the streaming server/client, and dealing with batched ink input. It also interfaces with event handling in the system.

This software is distributed under the BSD License.


Field Summary
static COMPort DEFAULT_COM_PORT
          PenStreamingConnection uses this to determine which COM port to connect to when looking for pen data.
 
Fields inherited from class edu.stanford.hci.r3.pen.PenInput
liveMode, penListenersToAdd
 
Constructor Summary
Pen()
          Can't use this constructor more than once, because you can only have ONE physical pen connected to the localhost's pen server.
Pen(java.lang.String name)
           
Pen(java.lang.String name, java.lang.String penServerHostName)
           
 
Method Summary
 void addLivePenListener(PenListener penListener)
          Adds a low-level pen data listener to the live pen.
 void removeLivePenListener(PenListener penListener)
          Removes the pen listener from the live pen.
 void setLocalComPort(COMPort port)
          Customize the COM port, before going live...
 void setPenServerPort(int tcpipPort)
          Customize the port with which you will connect to the PenServer.
 void startLiveMode()
          Connects to the pen connection on the local machine, with the default com port.
 void startLiveMode(java.lang.String hostDomainNameOrIPAddr)
          Set up connection to the pen server.
 void stopLiveMode()
          Exit live mode.
 
Methods inherited from class edu.stanford.hci.r3.pen.PenInput
getName, isLive, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_COM_PORT

public static final COMPort DEFAULT_COM_PORT
PenStreamingConnection uses this to determine which COM port to connect to when looking for pen data.

Constructor Detail

Pen

public Pen()
Can't use this constructor more than once, because you can only have ONE physical pen connected to the localhost's pen server. However, you can have two pen objects listen to the same localhost server if you wish. They will just get the same data.


Pen

public Pen(java.lang.String name)
Parameters:
name - for debugging purposes, so you can identify pens by name

Pen

public Pen(java.lang.String name,
           java.lang.String penServerHostName)
Parameters:
name - name the pen so you can identify it later
penServerHostName -
Method Detail

addLivePenListener

public void addLivePenListener(PenListener penListener)
Description copied from class: PenInput
Adds a low-level pen data listener to the live pen. You SHOULD call this after starting live mode.... However, we can cache the listener for you, if you really want. This is to eliminate annoying ordering constraints. Subclasses *should* override this, and call the super, to actually make use of PenListeners.

Overrides:
addLivePenListener in class PenInput

removeLivePenListener

public void removeLivePenListener(PenListener penListener)
Description copied from class: PenInput
Removes the pen listener from the live pen. Subclasses *should* override this, and call the super's implementation if necessary, to actually make use of PenListeners.

Overrides:
removeLivePenListener in class PenInput

setLocalComPort

public void setLocalComPort(COMPort port)
Customize the COM port, before going live... This will only have an effect on the local pen, as you can't really tell the remote pen which port to connect on. For that, you should customize the PenServer or PenServerTrayApp directly.

Parameters:
port -

setPenServerPort

public void setPenServerPort(int tcpipPort)
Customize the port with which you will connect to the PenServer.

Parameters:
tcpipPort -

startLiveMode

public void startLiveMode()
Connects to the pen connection on the local machine, with the default com port. This will ensure the PenServer on the local machine is running. This will be called by the PaperToolkit when you start an application.

Specified by:
startLiveMode in class PenInput

startLiveMode

public void startLiveMode(java.lang.String hostDomainNameOrIPAddr)
Set up connection to the pen server. The pen server is mapped to a physical pen attached to a some computer somewhere in the world. Starting livemode on a pen object just "attaches" it to an external server.

Parameters:
hostDomainNameOrIPAddr -

stopLiveMode

public void stopLiveMode()
Exit live mode.

Specified by:
stopLiveMode in class PenInput

Copyright 2006 Stanford University