📄 sensoreventagent.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.5.0_06) on Wed Dec 13 16:20:11 PST 2006 --><TITLE>SensorEventAgent (Java 3D 1.5.0)</TITLE><META NAME="keywords" CONTENT="com.sun.j3d.utils.behaviors.sensor.SensorEventAgent class"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){ parent.document.title="SensorEventAgent (Java 3D 1.5.0)";}</SCRIPT><NOSCRIPT></NOSCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../../com/sun/j3d/utils/behaviors/sensor/SensorEvent.html" title="class in com.sun.j3d.utils.behaviors.sensor"><B>PREV CLASS</B></A> <A HREF="../../../../../../com/sun/j3d/utils/behaviors/sensor/SensorGnomonEcho.html" title="class in com.sun.j3d.utils.behaviors.sensor"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../../index.html?com/sun/j3d/utils/behaviors/sensor/SensorEventAgent.html" target="_top"><B>FRAMES</B></A> <A HREF="SensorEventAgent.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--></SCRIPT><NOSCRIPT> <A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">com.sun.j3d.utils.behaviors.sensor</FONT><BR>Class SensorEventAgent</H2><PRE>java.lang.Object <IMG SRC="../../../../../../resources/inherit.gif" ALT="extended by "><B>com.sun.j3d.utils.behaviors.sensor.SensorEventAgent</B></PRE><HR><DL><DT><PRE>public class <B>SensorEventAgent</B><DT>extends java.lang.Object</DL></PRE><P>This class works in conjunction with the <code>SensorButtonListener</code> and <code>SensorReadListener</code> 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. <p> Listeners registered with this class are invoked when its <code>dispatchEvents</code> method is called. This is usually called from the <code>processStimulus</code> method of a <code>Behavior</code>, but may also be called directly from the <code>pollAndProcessInput</code> method of an event-driven implementation of <code>InputDevice</code>. 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, <code>dispatchEvents</code> is called from the behavior scheduler thread regardless of whether any new events are available, while in the latter, the <code>InputDevice</code> implementation may choose to call <code>dispatchEvents</code> only if new events are actually generated. <p> 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 <code>dispatchEvents</code> method. Events are distributed to interested parties through the button listener interface using the <code>pressed</code> and <code>released</code> callbacks. <p> The <code>dragged</code> method is not necessarily called in response to a motion event generated by a sensor. <code>dispatchEvents</code> will call <code>dragged</code> whenever any button assigned to the listener is down and has not changed state since the last time it was called. If <code>dispatchEvents</code> is called in the <code>processStimulus</code> of a <code>Behavior</code>, then <code>dragged</code> 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. <p> Like <code>dragged</code>, the <code>read</code> method of <code>SensorReadListener</code> is not necessarily invoked in response to a real event. It is called by <code>dispatchEvents</code> 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 <code>read</code> callback. <p> A <i>mutual exclusion</i> 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 <code>read</code> callback is separated from the <code>pressed</code>, <code>released</code>, and <code>dragged</code> callbacks in a separate interface in order to support this policy. <p> The events passed to the listeners are <i>ephemeral</i>; 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 <code>SensorEvent(SensorEvent)</code> constructor. <p> It is safe to add and remove listeners in response to a callback.<P><P><DL><DT><B>Since:</B></DT> <DD>Java 3D 1.3</DD><DT><B>See Also:</B><DD><A HREF="../../../../../../com/sun/j3d/utils/behaviors/sensor/SensorEvent.html" title="class in com.sun.j3d.utils.behaviors.sensor"><CODE>SensorEvent</CODE></A>, <A HREF="../../../../../../com/sun/j3d/utils/behaviors/sensor/SensorButtonListener.html" title="interface in com.sun.j3d.utils.behaviors.sensor"><CODE>SensorButtonListener</CODE></A>, <A HREF="../../../../../../com/sun/j3d/utils/behaviors/sensor/SensorReadListener.html" title="interface in com.sun.j3d.utils.behaviors.sensor"><CODE>SensorReadListener</CODE></A></DL><HR><P><!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../../../../com/sun/j3d/utils/behaviors/sensor/SensorEventAgent.html#SensorEventAgent(java.lang.Object)">SensorEventAgent</A></B>(java.lang.Object source)</CODE><BR> Create a <code>SensorEventAgent</code> to generate and dispatch sensor events to registered listeners.</TD></TR></TABLE> <!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Method Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../../com/sun/j3d/utils/behaviors/sensor/SensorEventAgent.html#addSensorButtonListener(javax.media.j3d.Sensor, int, com.sun.j3d.utils.behaviors.sensor.SensorButtonListener)">addSensorButtonListener</A></B>(<A HREF="../../../../../../javax/media/j3d/Sensor.html" title="class in javax.media.j3d">Sensor</A> sensor, int button, <A HREF="../../../../../../com/sun/j3d/utils/behaviors/sensor/SensorButtonListener.html" title="interface in com.sun.j3d.utils.behaviors.sensor">SensorButtonListener</A> buttonListener)</CODE><BR> Creates a binding of the specified sensor button to the given <code>SensorButtonListener</code> implementation.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../../com/sun/j3d/utils/behaviors/sensor/SensorEventAgent.html#addSensorButtonListener(javax.media.j3d.Sensor, com.sun.j3d.utils.behaviors.sensor.SensorButtonListener)">addSensorButtonListener</A></B>(<A HREF="../../../../../../javax/media/j3d/Sensor.html" title="class in javax.media.j3d">Sensor</A> sensor, <A HREF="../../../../../../com/sun/j3d/utils/behaviors/sensor/SensorButtonListener.html" title="interface in com.sun.j3d.utils.behaviors.sensor">SensorButtonListener</A> buttonListener)</CODE><BR> Creates a binding from all the buttons on the specified sensor to the given <code>SensorButtonListener</code> implementation.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../../com/sun/j3d/utils/behaviors/sensor/SensorEventAgent.html#addSensorButtonListeners(javax.media.j3d.Sensor, com.sun.j3d.utils.behaviors.sensor.SensorButtonListener[])">addSensorButtonListeners</A></B>(<A HREF="../../../../../../javax/media/j3d/Sensor.html" title="class in javax.media.j3d">Sensor</A> sensor, <A HREF="../../../../../../com/sun/j3d/utils/behaviors/sensor/SensorButtonListener.html" title="interface in com.sun.j3d.utils.behaviors.sensor">SensorButtonListener</A>[] buttonListeners)</CODE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -