org.robokind.api.animation.compiled
Class CompiledMap

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<Integer,CompiledPath>
          extended by org.robokind.api.animation.compiled.CompiledMap
All Implemented Interfaces:
Serializable, Cloneable, Map<Integer,CompiledPath>

public class CompiledMap
extends HashMap<Integer,CompiledPath>

A HashMap of ServoIDs and corresponding CompiledPath. All CompiledPaths must have the same stepLength. All CompiledPaths are normalized to have the same start and end times; The start and stop times are pulled from the CompiledPaths added.

Author:
Matthew Stevenson
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
CompiledMap(long stepLen)
          Creates an empty CompiledMap with the given stepLength.
CompiledMap(long stepLen, long start, long end)
          Creates an empty CompiledMap with the given stepLength, and time range.
 
Method Summary
 Object clone()
           
 long getEndTime()
          Returns the time of the last position contained in the CompiledMap.
 long getStartTime()
          Returns animation start offset time in milliseconds.
 CompiledPath put(Integer key, CompiledPath value)
          Same as HashMap.put() but does not allow null keys or values, and checks the stepLength of the given path.
 void putAll(Map<? extends Integer,? extends CompiledPath> m)
          Same as HashMap.put() but does not allow null keys or values, and checks the stepLength of the given path.
 void setTimes(long start, long end, boolean normalizeTimes)
          Adjusts all CompiledPaths to use the given times.
 
Methods inherited from class java.util.HashMap
clear, containsKey, containsValue, entrySet, get, isEmpty, keySet, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

CompiledMap

public CompiledMap(long stepLen)
Creates an empty CompiledMap with the given stepLength.

Parameters:
stepLen - milliseconds between positions

CompiledMap

public CompiledMap(long stepLen,
                   long start,
                   long end)
Creates an empty CompiledMap with the given stepLength, and time range.

Parameters:
stepLen - milliseconds between positions
start - start time
end - end time
Method Detail

getStartTime

public long getStartTime()
Returns animation start offset time in milliseconds. This is the length of the expected pause before movement.

Returns:
animation start offset time in milliseconds

getEndTime

public long getEndTime()
Returns the time of the last position contained in the CompiledMap.

Returns:
time of the last position contained in the CompiledMap

put

public CompiledPath put(Integer key,
                        CompiledPath value)
                 throws IllegalArgumentException
Same as HashMap.put() but does not allow null keys or values, and checks the stepLength of the given path. If the key exists, the paths are combined with the current path taking precedent.

Specified by:
put in interface Map<Integer,CompiledPath>
Overrides:
put in class HashMap<Integer,CompiledPath>
Parameters:
key - logical servo id
value - CompiledPath for the given servo
Returns:
resulting CompiledPath for servo id
Throws:
IllegalArgumentException - if key or value is null or if the stepLengths do not match

putAll

public void putAll(Map<? extends Integer,? extends CompiledPath> m)
            throws IllegalArgumentException
Same as HashMap.put() but does not allow null keys or values, and checks the stepLength of the given path. If the key exists, the paths are combined with the current path taking precedent.

Specified by:
putAll in interface Map<Integer,CompiledPath>
Overrides:
putAll in class HashMap<Integer,CompiledPath>
Parameters:
m - map containing servo id and CompiledPath pairs
Throws:
IllegalArgumentException - if null key or value is given or if the stepLengths do not match

setTimes

public void setTimes(long start,
                     long end,
                     boolean normalizeTimes)
Adjusts all CompiledPaths to use the given times.

Parameters:
start - new start time
end - new end time
normalizeTimes - if true, the start and end times are set to multiples of the stepLength. If not normalized, some value < stepLength can be added or removed

clone

public Object clone()
Overrides:
clone in class HashMap<Integer,CompiledPath>


Copyright © 2011-2013. All Rights Reserved.