Aviatrix3D
2.1.0

org.j3d.aviatrix3d.iutil
Class GLStateMap

java.lang.Object
  extended by org.j3d.aviatrix3d.iutil.GLStateMap

public class GLStateMap
extends java.lang.Object

A very hacked up HashMap variant that is built to maintain simple boolean state values so that multiple contexts can individually track whether state has changed and needs to be updated.

When running in a multi-context environment, such as large-format displays, CAVEs etc, each screen will have it's own GL context. Since each is individually processed by the rendering pipeline, it's very possible that objects appearing on one screen are not on another. When this happens and an update is received to a scenegraph object instance, you will get a situation where one context will flush the state change to create a new display list, but the other context(s) will not, because they were never passed to their respective local graphics pipe. This class manages the simple boolean state that is needed to track whether these changes on a per-GL context have been made or not.

This implementation is not thread-safe, so caution must be exercised about how items are added and removed from the instance. However, since we're only dealing with adding and removing new GL contexts, that should happen very, very rarely. Any state change notifications are made in-place.

Version:
$Revision: 1.6 $
Author:
Justin Couch
See Also:
HashMap

Constructor Summary
GLStateMap()
          Constructs a new, empty state map with a default capacity and load factor, which is 20 and 0.75 respectively.
GLStateMap(int initialCapacity, float loadFactor)
          Constructs a new, empty state map with the specified initial capacity and the specified load factor.
 
Method Summary
 void clear()
          Clears this state map so that it contains no keys.
 boolean containsKey(java.lang.Object key)
          Tests if the specified object is a key in this state map.
 boolean getState(java.lang.Object key)
          Returns the state to which the specified key is set.
 boolean isEmpty()
          Tests if this state map maps no keys to values.
 void put(java.lang.Object key, boolean value)
          Maps the specified key to the specified value in this state map.
 boolean remove(java.lang.Object key)
          Removes the key (and its corresponding value) from this state map.
 void setAll(boolean state)
          Set all the items to the given state.
 int size()
          Returns the number of keys in this state map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GLStateMap

public GLStateMap()
Constructs a new, empty state map with a default capacity and load factor, which is 20 and 0.75 respectively.


GLStateMap

public GLStateMap(int initialCapacity,
                  float loadFactor)
Constructs a new, empty state map with the specified initial capacity and the specified load factor.

Parameters:
initialCapacity - the initial capacity of the state map.
loadFactor - the load factor of the state map.
Throws:
java.lang.IllegalArgumentException - if the initial capacity is less than zero, or if the load factor is nonpositive.
Method Detail

size

public int size()
Returns the number of keys in this state map.

Returns:
the number of keys in this state map.

isEmpty

public boolean isEmpty()
Tests if this state map maps no keys to values.

Returns:
true if this state map maps no keys to values; false otherwise.

containsKey

public boolean containsKey(java.lang.Object key)
Tests if the specified object is a key in this state map.

Parameters:
key - possible key.
Returns:
true if and only if the specified object is a key in this state map, as determined by the equals method; false otherwise.

getState

public boolean getState(java.lang.Object key)
Returns the state to which the specified key is set.

Parameters:
key - a key in the state map.
Returns:
True or false depending on the state set

put

public void put(java.lang.Object key,
                boolean value)
Maps the specified key to the specified value in this state map. The key cannot be null.

The value can be retrieved by calling the get method with a key that is equal to the original key.

Parameters:
key - the state map key.
value - the value to associate with the key
Throws:
java.lang.NullPointerException - if the key is null.

remove

public boolean remove(java.lang.Object key)
Removes the key (and its corresponding value) from this state map. This method does nothing if the key is not in the state map.

Parameters:
key - the key that needs to be removed.
Returns:
the value to which the key had been mapped in this state map, or null if the key did not have a mapping.

setAll

public void setAll(boolean state)
Set all the items to the given state.


clear

public void clear()
Clears this state map so that it contains no keys.


Aviatrix3D
2.1.0

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2009 j3d.org