Java Doc for SensorEventAgent.java in  » 6.0-JDK-Modules » java-3d » com » sun » j3d » utils » behaviors » sensor » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » java 3d » com.sun.j3d.utils.behaviors.sensor 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.sun.j3d.utils.behaviors.sensor.SensorEventAgent

SensorEventAgent
public class SensorEventAgent (Code)
This class works in conjunction with the SensorButtonListener and SensorReadListener interfaces to support an event-driven model of sensor interaction. Java 3D defines sensors as delivering continuous input data which must be polled to retrieve their values, but in practice it is often convenient to structure application code to respond to events such as button state transitions.

Listeners registered with this class are invoked when its dispatchEvents method is called. This is usually called from the processStimulus method of a Behavior, but may also be called directly from the pollAndProcessInput method of an event-driven implementation of InputDevice. In either case the device is still polled by the Java 3D input device scheduling thread to get its current values; however, in the former, dispatchEvents is called from the behavior scheduler thread regardless of whether any new events are available, while in the latter, the InputDevice implementation may choose to call dispatchEvents only if new events are actually generated.

Button events are generated by changes in sensor button state, from pressed to released and vice versa. Button state changes are examined with each invocation of the dispatchEvents method. Events are distributed to interested parties through the button listener interface using the pressed and released callbacks.

The dragged method is not necessarily called in response to a motion event generated by a sensor. dispatchEvents will call dragged whenever any button assigned to the listener is down and has not changed state since the last time it was called. If dispatchEvents is called in the processStimulus of a Behavior, then dragged may be called even if the sensor value has not changed. This is as a consequence of the core Java 3D API definition of sensors as continuous devices.

Like dragged, the read method of SensorReadListener is not necessarily invoked in response to a real event. It is called by dispatchEvents whenever a button listener has not been called for that sensor. This usually means that no buttons are down, but clients are free to leave a button listener null, or to explicitly bind a null button listener to a button so that button's events are ignored. The sensor value has not necessarily changed since the last read callback.

A mutual exclusion policy can be applied between button listeners when they are grouped in an array mapped to the sensor's buttons. If multiple sensor buttons are held down at the same time, then a listener in the array is invoked only for the button that was depressed first. The read callback is separated from the pressed, released, and dragged callbacks in a separate interface in order to support this policy.

The events passed to the listeners are ephemeral; they are only valid until the listener has returned. This is done to avoid allocating large numbers of mostly temporary objects, especially for behaviors that wake up every frame. If a listener needs to retain the event it must be copied using the SensorEvent(SensorEvent) constructor.

It is safe to add and remove listeners in response to a callback.
See Also:   SensorEvent
See Also:   SensorButtonListener
See Also:   SensorReadListener
since:
   Java 3D 1.3




Constructor Summary
public  SensorEventAgent(Object source)
     Create a SensorEventAgent to generate and dispatch sensor events to registered listeners.

Method Summary
public synchronized  voidaddSensorButtonListener(Sensor sensor, int button, SensorButtonListener buttonListener)
     Creates a binding of the specified sensor button to the given SensorButtonListener implementation.
public synchronized  voidaddSensorButtonListener(Sensor sensor, SensorButtonListener buttonListener)
     Creates a binding from all the buttons on the specified sensor to the given SensorButtonListener implementation.
public synchronized  voidaddSensorButtonListeners(Sensor sensor, SensorButtonListener[] buttonListeners)
     Creates a binding of the specified sensor to the given array of SensorButtonListener implementations.
public synchronized  voidaddSensorReadListener(Sensor sensor, SensorReadListener readListener)
     Creates a binding of the specified sensor to the given SensorReadListener.
public  voiddispatchEvents()
     Reads all sensor button state and dispatches events to registered button and read listeners.
public  SensorButtonListener[]getSensorButtonListeners(Sensor sensor, int button)
     Gets the SensorButtonListener implementations bound to the given sensor and button.
public  SensorReadListener[]getSensorReadListeners(Sensor sensor)
     Gets the SensorReadListeners bound to the specified sensor.
public  Sensor[]getSensors()
     Returns an array of references to all sensors that have been bound to listeners.
public synchronized  voidremoveSensorBinding(Sensor sensor)
     Remove all sensor listeners bound to the given sensor.
public synchronized  voidremoveSensorButtonListener(Sensor sensor, SensorButtonListener listener)
     Remove the given SensorButtonListener binding from the specified sensor.
public synchronized  voidremoveSensorButtonListener(SensorButtonListener listener)
     Remove the given SensorButtonListener from all sensors.
public synchronized  voidremoveSensorReadListener(Sensor sensor, SensorReadListener listener)
     Remove the given SensorReadListener binding from the specified sensor.
public synchronized  voidremoveSensorReadListener(SensorReadListener listener)
     Remove the given SensorReadListener from all sensors.
public  StringtoString()
    


Constructor Detail
SensorEventAgent
public SensorEventAgent(Object source)(Code)
Create a SensorEventAgent to generate and dispatch sensor events to registered listeners.
Parameters:
  source - reference to the originating object for inclusion ingenerated SensorEvents; intended to refer to theinstantiating Behavior but may be any reference, or null




Method Detail
addSensorButtonListener
public synchronized void addSensorButtonListener(Sensor sensor, int button, SensorButtonListener buttonListener)(Code)
Creates a binding of the specified sensor button to the given SensorButtonListener implementation.
Parameters:
  sensor - the sensor with the button to be bound
Parameters:
  button - the index of the button to be bound on the specifiedsensor; may range from 0 to(sensor.getSensorButtonCount() - 1)
Parameters:
  buttonListener - the SensorButtonListenerimplementation that will be invoked for the sensor's button



addSensorButtonListener
public synchronized void addSensorButtonListener(Sensor sensor, SensorButtonListener buttonListener)(Code)
Creates a binding from all the buttons on the specified sensor to the given SensorButtonListener implementation. If multiple sensor buttons are held down at the same time, the press and release callbacks are called for each button in the order that they occur. This allows actions to be bound to combinations of button presses, but is also convenient for listeners that don't care which button was pressed.
Parameters:
  sensor - the sensor to be bound
Parameters:
  buttonListener - the SensorButtonListenerimplementation that will be called for all button events



addSensorButtonListeners
public synchronized void addSensorButtonListeners(Sensor sensor, SensorButtonListener[] buttonListeners)(Code)
Creates a binding of the specified sensor to the given array of SensorButtonListener implementations. The array index of the listener indicates the index of the sensor button to which it will be bound.

This method enforces a mutually exclusive callback policy among the listeners specified in the array. If multiple sensor buttons are held down at the same time, callbacks are invoked only for the button that was depressed first.
Parameters:
  sensor - the sensor to be bound
Parameters:
  buttonListeners - array of implementations ofSensorButtonListener; array entries may be null orduplicates but the array length must equal the sensor's buttoncount




addSensorReadListener
public synchronized void addSensorReadListener(Sensor sensor, SensorReadListener readListener)(Code)
Creates a binding of the specified sensor to the given SensorReadListener. The read listener is invoked every time dispatchEvents is called and a button listener is not invoked.
Parameters:
  sensor - the sensor to be bound
Parameters:
  readListener - the SensorReadListenerimplementation



dispatchEvents
public void dispatchEvents()(Code)
Reads all sensor button state and dispatches events to registered button and read listeners. This method is intended to be called from the processStimulus implementation of a Behavior or the pollAndProcessInput method of an event-driven implementation of InputDevice.



getSensorButtonListeners
public SensorButtonListener[] getSensorButtonListeners(Sensor sensor, int button)(Code)
Gets the SensorButtonListener implementations bound to the given sensor and button.
Parameters:
  sensor - the sensor of interest
Parameters:
  button - the button of interest array of SensorButtonListener implementationsbound to the given sensor and button, or null



getSensorReadListeners
public SensorReadListener[] getSensorReadListeners(Sensor sensor)(Code)
Gets the SensorReadListeners bound to the specified sensor.
Parameters:
  sensor - the sensor of interest array of SensorReadListeners bound to thegiven sensor, or null



getSensors
public Sensor[] getSensors()(Code)
Returns an array of references to all sensors that have been bound to listeners. an array of sensors, or null if no sensors have been bound



removeSensorBinding
public synchronized void removeSensorBinding(Sensor sensor)(Code)
Remove all sensor listeners bound to the given sensor.



removeSensorButtonListener
public synchronized void removeSensorButtonListener(Sensor sensor, SensorButtonListener listener)(Code)
Remove the given SensorButtonListener binding from the specified sensor.
Parameters:
  sensor - the sensor from which to remove the listener
Parameters:
  listener - the listener to be removed



removeSensorButtonListener
public synchronized void removeSensorButtonListener(SensorButtonListener listener)(Code)
Remove the given SensorButtonListener from all sensors.
Parameters:
  listener - the listener to remove



removeSensorReadListener
public synchronized void removeSensorReadListener(Sensor sensor, SensorReadListener listener)(Code)
Remove the given SensorReadListener binding from the specified sensor.
Parameters:
  sensor - the sensor from which to remove the listener
Parameters:
  listener - the listener to be removed



removeSensorReadListener
public synchronized void removeSensorReadListener(SensorReadListener listener)(Code)
Remove the given SensorReadListener from all sensors.
Parameters:
  listener - the listener to remove



toString
public String toString()(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.