|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--de.jaetzold.art.platform.BaseSensorPeer
Base class for easier implementation of the interface SensorPeer
.
The only thing really required is to implement the method getValue()
. Maybe the properties connected
, precision
and deliversFloatingPoint
need an implementation too to produce correct results.
For a more efficient update()
-method it is advisable to assign a de.jaetzold.Queue
to eventQueue
. This queue then may hold instances of SensorEvent
s and must be emptied regularly by some thread which passes the events in the queue to the method processEvent(SensorEvent)
.
For a more efficient handling of Events it is advisable to implement enable/disableEvent(SensorEventDescriptor)
.
Field Summary | |
protected PropertyChangeSupport |
changes
|
protected Queue |
eventQueue
If this is non-null events generated by update() are posted there. |
Constructor Summary | |
BaseSensorPeer()
|
Method Summary | |
void |
addPropertyChangeListener(PropertyChangeListener l)
The SensorEvents get deliverd to all registered PropertyChangeListener s. |
void |
disableEvent(SensorEventDescriptor eventDescriptor)
Disable delivering the Events described by the given SensorEventDescriptor . |
void |
enableEvent(SensorEventDescriptor eventDescriptor)
Enable delivering the Events described by the given SensorEventDescriptor . |
boolean |
getDeliversFloatingPoint()
Returns true. |
int |
getIntValue()
Calls (int)getValue() . |
double |
getPrecision()
Returns 0. |
boolean |
isConnected()
Returns true. |
void |
processEvent(SensorEvent event)
Deliver the given SensorEvent to all Listeners. |
void |
removePropertyChangeListener(PropertyChangeListener l)
Remove the specified listener. |
void |
update()
Generate and deliver a SensorEvent for the current sensors state. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface de.jaetzold.art.platform.SensorPeer |
getValue |
Field Detail |
protected PropertyChangeSupport changes
protected Queue eventQueue
update()
are posted there. Otherwise they get delivered by some Thread controlled by the implementation of update()
.Constructor Detail |
public BaseSensorPeer()
Method Detail |
public int getIntValue()
(int)getValue()
.SensorPeer.getValue()
public boolean isConnected()
isConnected
in interface SensorPeer
de.jaetzold.art.platform.SensorPeer
RobotInterface.isConnected()
public boolean getDeliversFloatingPoint()
getDeliversFloatingPoint
in interface SensorPeer
public double getPrecision()
getPrecision
in interface SensorPeer
public void enableEvent(SensorEventDescriptor eventDescriptor)
SensorPeer
SensorEventDescriptor
. Not fully used. Implementors may enable more than the descibed Events an this is pretty much "all" in the current implementations.enableEvent
in interface SensorPeer
de.jaetzold.art.platform.SensorPeer
SensorEventDescriptor
public void disableEvent(SensorEventDescriptor eventDescriptor)
SensorPeer
SensorEventDescriptor
. Not fully used. Implementors may disable less than the descibed Events an this is pretty much "none" in the current implementations.disableEvent
in interface SensorPeer
de.jaetzold.art.platform.SensorPeer
SensorEventDescriptor
public void addPropertyChangeListener(PropertyChangeListener l)
SensorPeer
PropertyChangeListener
s.
The PropertyChangeEvent has the SensorEvent as it's new value and the last SensorEvent as the old value. The property name used for this is value
.
This mechanism in the SensorPeer is not really used for anything else right now but may be in future releases.addPropertyChangeListener
in interface SensorPeer
de.jaetzold.art.platform.SensorPeer
Sensor.addPropertyChangeListener(PropertyChangeListener)
,
SensorPeer.processEvent(SensorEvent)
public void removePropertyChangeListener(PropertyChangeListener l)
SensorPeer
removePropertyChangeListener
in interface SensorPeer
de.jaetzold.art.platform.SensorPeer
SensorPeer.addPropertyChangeListener(PropertyChangeListener)
public void update()
SensorPeer
update
in interface SensorPeer
public void processEvent(SensorEvent event)
SensorPeer
SensorEvent
to all Listeners. Maybe update internal cache of the value.processEvent
in interface SensorPeer
de.jaetzold.art.platform.SensorPeer
SensorPeer.addPropertyChangeListener(PropertyChangeListener)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |