|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.vwp.j3d.loaders.DataCache
public class DataCache
This class can be used to cache objects. It can be used by the Objects 3D model loader classes e.g. to cache textures. So in case more 3D models are used which use same textures, the DataCache prevents the loader from donwloading them again. Every time an object is fetched from this DataCache, it is exchanged with the preceding object. That means, a special order is build in the underlying Vector automatically. In case the Vector is full, the upper half of it will be released and so only objects are removed which aren't fetched very often. This optimizes the caching efficiency.
| Field Summary | |
|---|---|
static int |
MODE_FIFO
Specifies the caching and sorting mode for the data, in MODE_FIFO the data put into the cache last are at the higher position and the data which are put into it first are removed first when data are flushed out of the vector. |
static int |
MODE_MOSTUSED
Specifies the caching and sorting mode for the data, in MODE_MOSTUSED the more often data are used the higher is their position in the vector and the lower is the possibility that they get lost when data are flushed out of the cache. |
| Constructor Summary | |
|---|---|
DataCache()
Constructs a new DataCache object with a maximum size of MAX_DATA_SETS and in data caching mode MODE_MOSTUSED. |
|
DataCache(int MaxCachedDataNum)
Constructs a new DataCache object using the data caching mode MODE_MOSTUSED |
|
DataCache(int MaxCachedDataNum,
int DataCacheMode)
Constructs a new DataCache object |
|
| Method Summary | |
|---|---|
boolean |
containsBranchGroup(String Identifier)
Checks if the DataCache contains a specific BranchGroup |
void |
flushAll()
Flushes all stored data to let the GC free the related memory |
XBranchGroup |
getBranchGroup(String Identifier,
boolean forceGeometryCopying)
Fetches a cached BranchGroup object from the DataCache |
byte[] |
getData(String Identifier)
Fetches a data buffer from the DataCache. |
javax.media.j3d.Shape3D |
getShape3D(String Identifier,
boolean forceGeometryCopying)
Fetches a cached Shape3D object from the DataCache. |
javax.media.j3d.Texture |
getTexture(String Identifier,
boolean forceCopying)
Fetches a cached Texture object from the DataCache |
void |
removeCachedObject(String Identifier)
Removes a cached object from the DataCache |
static void |
removeData(javax.media.j3d.Node inNode)
Removes all data from a SceneGraph to allow a more effective garbage collection and to avoid some J3D-specific memory problems. |
void |
storeBranchGroup(XBranchGroup MyBranch,
String Identifier)
Stores a duplicated BranchGroup in the DataCache. |
void |
storeBranchGroup(XBranchGroup MyBranch,
String Identifier,
boolean doCloneShape)
Stores a BranchGroup in the DataCache. |
void |
storeData(byte[] buffer,
String Identifier)
Stores a data buffer in the DataCache. |
void |
storeShape3D(javax.media.j3d.Shape3D MyShape3D,
String Identifier)
duplicates and stores a Shape3D in the DataCache. |
void |
storeShape3D(javax.media.j3d.Shape3D MyShape3D,
String Identifier,
boolean doCloneShape)
Stores a Shape3D in the DataCache. |
void |
storeTexture(javax.media.j3d.Texture MyTexture,
String Identifier)
Stores a Texture in the DataCache. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MODE_MOSTUSED
public static final int MODE_FIFO
| Constructor Detail |
|---|
public DataCache(int MaxCachedDataNum)
MaxCachedDataNum - specifies the size of the cache; if this limit of
cached objects is reached, half of the cache will be released
and the stored objects will be removed during the next garbage
collection if they are not referenced..
public DataCache(int MaxCachedDataNum,
int DataCacheMode)
MaxCachedDataNum - specifies the size of the cache; if this limit of
cached objects is reached, half of the cache will be released
and the stored objects will be removed during the next garbage
collection if they are not referenced..DataCacheMode - specifies the mode for the data caching and sortingpublic DataCache()
| Method Detail |
|---|
public static void removeData(javax.media.j3d.Node inNode)
inNode - the node which is base of the SceneGraph which has to be
disbandedpublic void flushAll()
public void removeCachedObject(String Identifier)
Identifier - string which identifies the object which has to be
removed
public javax.media.j3d.Shape3D getShape3D(String Identifier,
boolean forceGeometryCopying)
Identifier - string which identifies the object which has to be fetchedforceGeometryCopying - if this parameter is set to true all related
gemoetry data are copied, elsewhere they are referenced only so that
different retrieved Shape3Ds share the same geometry datapublic byte[] getData(String Identifier)
Identifier - string which identifies the object which has to be fetched
public boolean containsBranchGroup(String Identifier)
Identifier - string which identifies the BranchGroup object this
method looks for
public XBranchGroup getBranchGroup(String Identifier,
boolean forceGeometryCopying)
Identifier - string which identifies the object which has to be fetchedforceGeometryCopying - if this parameter is set to true all geometry
data of subsequent Shapes are copied, elsewhere they are referenced
only so that different retrieved BranchGroups' Shapes share the same
underlying geometry data
public void storeShape3D(javax.media.j3d.Shape3D MyShape3D,
String Identifier)
MyShape3D - the Shape3D object which has to be storedIdentifier - the identification string under what the object is stored
and which can be used to accessed it later
public void storeShape3D(javax.media.j3d.Shape3D MyShape3D,
String Identifier,
boolean doCloneShape)
MyShape3D - the Shape3D object which has to be storedIdentifier - the identification string under what the object is stored
and which can be used to accessed it laterdoCloneShape - specifies if the shape3D has to be duplicated (true) or
if the original has to be stored
public void storeData(byte[] buffer,
String Identifier)
buffer - the data buffer which has to be storedIdentifier - the identification string under what the object is stored
and which can be used to accessed it later
public javax.media.j3d.Texture getTexture(String Identifier,
boolean forceCopying)
Identifier - string which identifies the object which has to be fetched
public void storeBranchGroup(XBranchGroup MyBranch,
String Identifier)
MyBranch - the BranchGroup object which has to be storedIdentifier - the identification string under what the object is stored
and which can be used to accessed it later
public void storeBranchGroup(XBranchGroup MyBranch,
String Identifier,
boolean doCloneShape)
MyBranch - the BranchGroup object which has to be storedIdentifier - the identification string under what the object is stored
and which can be used to accessed it laterdoCloneShape - specifies if the shape3D has to be duplicated (true) or
if the original has to be stored
public void storeTexture(javax.media.j3d.Texture MyTexture,
String Identifier)
MyTexture - the Texture object which has to be storedIdentifier - the identification string under what the object is stored
and which can be used to accessed it later
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||