|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object hermes.postoffice.PostOffice
public class PostOffice
Listens for OSC, mouse, and keyboard messages; can also send OSC messages.
Objects can register "subscriptions" with the P.O. for a particular type of message. When that type of message is received, P.O. tells subscribers and passes along the information stored in the message.
Constructor Summary | |
---|---|
PostOffice()
Constructor with no OSC. |
|
PostOffice(int portIn,
int portOut)
Constructor with OSC running locally. |
|
PostOffice(int portIn,
int portOut,
java.lang.String netAddress)
Constructor for PostOffice that sends messages to non-local address (ie over the internet). |
Method Summary | |
---|---|
void |
acceptMessage(java.util.Date time,
com.illposed.osc.OSCMessage message)
Accepts and handles messages recieved by osc server. |
void |
checkMail()
Command that sends all messages queued by the PostOffice to subscribers. |
static POCodes.Button |
getMouseButton(java.awt.event.MouseEvent e)
Finds the proper mouse button code from a Swing mouse event. |
PVector |
getMouseLocation()
Utility for obtaining current mouse location |
PVector |
getPMouseLocation()
Utility for obtaining previous mouse location |
boolean |
isKeyPressed(int keyCode)
Utility for checking if key is pressed |
boolean |
isMouseInRegion(HShape region)
Utility for checking if mouse is in a region |
void |
keyPressed(java.awt.event.KeyEvent e)
On a key press, make a new KeyMessage and add it to the queue. |
void |
keyReleased(java.awt.event.KeyEvent e)
On a key release, make a new KeyMessage and add it to the queue. |
void |
keyTyped(java.awt.event.KeyEvent e)
Ignore keyTyped events. |
void |
mouseClicked(java.awt.event.MouseEvent e)
Ignore mouseClicked events. |
void |
mouseDragged(java.awt.event.MouseEvent e)
When the mouse is dragged, create a MouseMessage and add it to the group. |
void |
mouseEntered(java.awt.event.MouseEvent e)
Ignore mouseEntered events. |
void |
mouseExited(java.awt.event.MouseEvent e)
Ignore mouseExited events. |
void |
mouseMoved(java.awt.event.MouseEvent e)
When the mouse is moved, create a MouseMessage and add it to the queue. |
void |
mousePressed(java.awt.event.MouseEvent e)
On a mouse press, make a new MouseMessage and add it to the queue. |
void |
mouseReleased(java.awt.event.MouseEvent e)
On a mouse button release, make a new MouseMessage and add it to the queue. |
void |
mouseWheelMoved(java.awt.event.MouseWheelEvent e)
When the mouse wheel is moved, create a MouseWheelMessage and add it to the queue. |
boolean |
removeAllSubscriptions(HObject sub)
Helper method to remove all subscriptions for given HObject |
boolean |
removeKeySubscriptions(KeySubscriber sub)
Removes a key subscription |
boolean |
removeMouseSubscriptions(MouseSubscriber sub)
Removes a mouse subscription |
boolean |
removeMouseWheelSubscriptions(KeySubscriber sub)
Removes a mouse wheel subscription |
boolean |
removeOSCSubscriptions(KeySubscriber sub)
Removes an OSC subscription |
void |
resetSubscriptions()
Resets all subscriptions Use if passing subscriptions between Worlds |
void |
sendBoolean(java.lang.String address,
boolean send)
Sends an OscMessage on the given address containing only the given boolean. |
void |
sendFloat(java.lang.String address,
float send)
Sends an OscMessage on the given address containing only the given float. |
void |
sendInt(java.lang.String address,
int send)
Sends an OscMessage on the given address containing only the given int. |
void |
sendList(java.lang.String address,
java.util.ArrayList<java.lang.Object> send)
Sends an OscMessage on the given address containing the contents of the given list. |
void |
subscribe(KeySubscriber sub,
char key)
Registers a subscription to messages sent by a specific keyboard key. |
void |
subscribe(KeySubscriber sub,
int key)
Registers a subscription to messages sent by a specific keyboard key. |
void |
subscribe(MouseSubscriber sub,
POCodes.Button button)
Registers a subscription to messages sent by a specific mouse button. |
void |
subscribe(MouseSubscriber sub,
POCodes.Button button,
HShape region)
A version of registerMouseSubscription that subscribes only to the requested button events that occur in the given region. |
void |
subscribe(MouseWheelSubscriber sub)
Registers a subscription to the mouse wheel (one subscription gets you everything). |
void |
subscribe(OscSubscriber sub,
java.lang.String address)
Registers a subscription to messages received on a specific OSC address. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PostOffice()
public PostOffice(int portIn, int portOut)
portIn
- port to receive messages onportOut
- port to send messages onpublic PostOffice(int portIn, int portOut, java.lang.String netAddress)
portIn
- port to receive messages onportOut
- port to send messages onnetAddress
- url of location to send messages toMethod Detail |
---|
public void subscribe(KeySubscriber sub, int key)
sub
- the KeySubscriber signing upkey
- the code of the keyboard key whose messages the subscriber wants (use value from POConstants)public void subscribe(KeySubscriber sub, char key)
sub
- the KeySubscriber signing upkey
- the char of the keyboard key whose messages the subscriber wantspublic void subscribe(MouseSubscriber sub, POCodes.Button button)
Buttons are defined by constants in the POConstants class; subscribe with "NO_BUTTON" to receive information about mouse movements when no button is pressed.
sub
- the MouseSubscriber signing upbutton
- the code of the button whose messages the subscriber wants (use value from POContants)public void subscribe(MouseSubscriber sub, POCodes.Button button, HShape region)
sub
- the MouseSubscriber signing upbutton
- the code of the button whose messages the subscriber wants (use value from POContants)region
- the region on screen the subscriber wants to limit its subscription topublic void subscribe(MouseWheelSubscriber sub)
sub
- the MouseWheelSubscriber signing uppublic void subscribe(OscSubscriber sub, java.lang.String address)
sub
- the OscSubscriber signing upaddress
- the address whose messages the subscriber wantspublic boolean removeMouseSubscriptions(MouseSubscriber sub)
sub
- the subscriber to be removed
public boolean removeKeySubscriptions(KeySubscriber sub)
sub
- the subscriber to be removed
public boolean removeMouseWheelSubscriptions(KeySubscriber sub)
sub
- the subscriber to be removed
public boolean removeOSCSubscriptions(KeySubscriber sub)
sub
- the subscriber to be removed
public boolean removeAllSubscriptions(HObject sub)
sub
- HObject to remove from PostOffice
public void resetSubscriptions()
public boolean isKeyPressed(int keyCode)
keyCode
- the key being checked
public boolean isMouseInRegion(HShape region)
region
- region to check
public PVector getMouseLocation()
public PVector getPMouseLocation()
public void sendInt(java.lang.String address, int send)
address
- address message is to be sent onsend
- integer to be sentpublic void sendFloat(java.lang.String address, float send)
address
- address message is to be sent onsend
- float to be sentpublic void sendBoolean(java.lang.String address, boolean send)
address
- address message is to be sent onsend
- boolean to be sentpublic void sendList(java.lang.String address, java.util.ArrayList<java.lang.Object> send)
address
- address message is to be sent onsend
- List to be sentpublic void checkMail()
Called at end of update loop (for thread safety).
public void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener
public void keyPressed(java.awt.event.KeyEvent e)
keyPressed
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent e)
keyReleased
in interface java.awt.event.KeyListener
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
mouseWheelMoved
in interface java.awt.event.MouseWheelListener
public void acceptMessage(java.util.Date time, com.illposed.osc.OSCMessage message)
acceptMessage
in interface com.illposed.osc.OSCListener
public static POCodes.Button getMouseButton(java.awt.event.MouseEvent e)
e
- the MouseEvent
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |