EncoderPhidget.java
Go to the documentation of this file.
00001 
00002 /*
00003  * Copyright 2006 Phidgets Inc.  All rights reserved.
00004  */
00005 
00006 package com.phidgets;
00007 import java.util.Iterator;
00008 import java.util.LinkedList;
00009 import com.phidgets.event.*;
00019 public final class EncoderPhidget extends Phidget
00020 {
00021         public EncoderPhidget () throws PhidgetException
00022         {
00023                 super (create ());
00024         }
00025         private static native long create () throws PhidgetException;
00032         public native int getEncoderCount () throws PhidgetException;
00040         public native int getInputCount () throws PhidgetException;
00049         public native int getPosition (int index) throws PhidgetException;
00057         public native int getIndexPosition (int index) throws PhidgetException;
00062         public native int getEncoderPosition (int index) throws PhidgetException;
00072         public native void setPosition (int index, int position) throws PhidgetException;
00077         public native void setEncoderPosition (int index, int position) throws PhidgetException;
00086         public native boolean getInputState (int index) throws PhidgetException;
00094         public native boolean getEnabled (int index) throws PhidgetException;
00102         public native void setEnabled (int index, boolean state) throws PhidgetException;
00103 
00104         private final void enableDeviceSpecificEvents (boolean b)
00105         {
00106                 enableEncoderPositionChangeEvents (b && encoderPositionChangeListeners.size () > 0);
00107                 enableInputChangeEvents (b && inputChangeListeners.size () > 0);
00108         }
00119         public final void addEncoderPositionChangeListener (EncoderPositionChangeListener l)
00120         {
00121                 synchronized (encoderPositionChangeListeners)
00122                 {
00123                         encoderPositionChangeListeners.add (l);
00124                         enableEncoderPositionChangeEvents (true);
00125         }} private LinkedList encoderPositionChangeListeners = new LinkedList ();
00126         private long nativeEncoderPositionChangeHandler = 0;
00127         public final void removeEncoderPositionChangeListener (EncoderPositionChangeListener l)
00128         {
00129                 synchronized (encoderPositionChangeListeners)
00130                 {
00131                         encoderPositionChangeListeners.remove (l);
00132                         enableEncoderPositionChangeEvents (encoderPositionChangeListeners.size () > 0);
00133         }} private void fireEncoderPositionChange (EncoderPositionChangeEvent e)
00134         {
00135                 synchronized (encoderPositionChangeListeners)
00136                 {
00137                         for (Iterator it = encoderPositionChangeListeners.iterator (); it.hasNext ();)
00138                                 ((EncoderPositionChangeListener) it.next ()).encoderPositionChanged (e);
00139                 }
00140         }
00141         private native void enableEncoderPositionChangeEvents (boolean b);
00150         public final void addInputChangeListener (InputChangeListener l)
00151         {
00152                 synchronized (inputChangeListeners)
00153                 {
00154                         inputChangeListeners.add (l);
00155                         enableInputChangeEvents (true);
00156         }} private LinkedList inputChangeListeners = new LinkedList ();
00157         private long nativeInputChangeHandler = 0;
00158         public final void removeInputChangeListener (InputChangeListener l)
00159         {
00160                 synchronized (inputChangeListeners)
00161                 {
00162                         inputChangeListeners.remove (l);
00163                         enableInputChangeEvents (inputChangeListeners.size () > 0);
00164         }} private void fireInputChange (InputChangeEvent e)
00165         {
00166                 synchronized (inputChangeListeners)
00167                 {
00168                         for (Iterator it = inputChangeListeners.iterator (); it.hasNext ();)
00169                                 ((InputChangeListener) it.next ()).inputChanged (e);
00170                 }
00171         }
00172         private native void enableInputChangeEvents (boolean b);
00173 }


pedal_monitor
Author(s): Pedro Mendes
autogenerated on Fri Jun 6 2014 18:37:21