lejos.robotics
Class RangeReadings

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<RangeReading>
              extended by lejos.robotics.RangeReadings
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<RangeReading>, java.util.Collection<RangeReading>, java.util.List<RangeReading>, java.util.RandomAccess, Transmittable

public class RangeReadings
extends java.util.ArrayList<RangeReading>
implements Transmittable

Represents a set of range readings.

Author:
Lawrie Griffiths
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
RangeReadings(int numReadings)
           
 
Method Summary
 void dumpObject(java.io.DataOutputStream dos)
          Dump the readings to a DataOutputStream
 float getAngle(int index)
          Get the angle of a specific reading
 int getNumReadings()
          Get the number of readings in a set
 float getRange(float angle)
          Get a range reading for a specific angle
 float getRange(int i)
          Get a specific range reading
 boolean incomplete()
          Return true if the readings are incomplete
 void loadObject(java.io.DataInputStream dis)
          Load the readings from a DataInputStream
 void printReadings()
          Print the range readings on standard out
 void setRange(int index, float angle, float range)
          Set the range reading
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

RangeReadings

public RangeReadings(int numReadings)
Method Detail

getRange

public float getRange(int i)
Get a specific range reading

Parameters:
i - the reading index
Returns:
the range value

getRange

public float getRange(float angle)
Get a range reading for a specific angle

Parameters:
angle - the reading angle
Returns:
the range value

getAngle

public float getAngle(int index)
Get the angle of a specific reading

Parameters:
index - the index of the reading
Returns:
the angle in degrees

incomplete

public boolean incomplete()
Return true if the readings are incomplete

Returns:
true iff one of the readings is not valid

getNumReadings

public int getNumReadings()
Get the number of readings in a set


setRange

public void setRange(int index,
                     float angle,
                     float range)
Set the range reading

Parameters:
index - the index of the reading in the set
angle - the angle of the reading relative to the robot heading
range - the range reading

dumpObject

public void dumpObject(java.io.DataOutputStream dos)
                throws java.io.IOException
Dump the readings to a DataOutputStream

Specified by:
dumpObject in interface Transmittable
Parameters:
dos - the stream
Throws:
java.io.IOException

loadObject

public void loadObject(java.io.DataInputStream dis)
                throws java.io.IOException
Load the readings from a DataInputStream

Specified by:
loadObject in interface Transmittable
Parameters:
dis - the stream
Throws:
java.io.IOException

printReadings

public void printReadings()
Print the range readings on standard out