legacy.resource
Class ResourceGroup

java.lang.Object
  extended by legacy.resource.ResourceGroup

public class ResourceGroup
extends java.lang.Object

ResourceGroup.class is a container for lists of specific resouces defined in a group of resources. This includes lists of images, midi, sound, fonts and pallets which are required for use. Warning This class relies heavily on the ResourceManager to set it status paramiter and should not be modifed lightly.

Author:
Benjamin Tarrant
See Also:
ResourceManager

Field Summary
protected  java.util.Hashtable<java.lang.Integer,NativeFontFormat> fonts
          Container for fonts
protected  java.util.Hashtable<java.lang.Integer,NativeImageFormat> images
          Container for images
protected  java.util.Hashtable<java.lang.Integer,NativeMidiFormat> midis
          Container for Midis
protected  java.util.Hashtable<java.lang.Integer,NativePalletFormat> pallets
          Container for pallets
protected  java.util.Hashtable<java.lang.Integer,NativeSoundFormat> sounds
          Container for sound
 
Constructor Summary
ResourceGroup(java.lang.String group, java.util.Properties resources)
          Resource group is an arrangements of resouces in a given group.
 
Method Summary
 java.lang.String getFontesource(int definition)
          getFontesource returns the physical location for a file
 java.util.Hashtable<java.lang.Integer,java.lang.String> getFontResources()
          getFontResources returns a list of resources and their definitions.
 int getFonts()
          getFonts returns how many fonts are defined in this group
 java.lang.String getImageResource(int definition)
          getImageResource returns the physical location for a file
 java.util.Hashtable<java.lang.Integer,java.lang.String> getImageResources()
          getImageResources returns a list of resources and their definitions.
 int getImages()
          getImages returns how many images are defined in this group
 float getLoadStatus()
          Returns the load status as a fraction of 100% of loaded items in this group
 java.lang.String getMidiResource(int definition)
          getMidiResource returns the physical location for a file
 java.util.Hashtable<java.lang.Integer,java.lang.String> getMidiResources()
          getImageResources returns a list of resources and their definitions.
 int getMidis()
          getImages returns how many midi's are defined in this group
 java.lang.String getName()
          returns the name of this set of resources or group
 java.lang.String getPalletResource(int definition)
          getPalletResource returns the physical location for a file
 java.util.Hashtable<java.lang.Integer,java.lang.String> getPalletResources()
          getPalletResources returns a list of resources and their definitions.
 int getPallets()
          getImages returns how many pallets are defined in this group
 int getResources()
          getResources returns the amount of uniqure rsouces in totality.
 java.lang.String getSoundResource(int definition)
          getSoundResource returns the physical location for a file
 java.util.Hashtable<java.lang.Integer,java.lang.String> getSoundResources()
          getSoundResources returns a list of resources and their definitions.
 int getSounds()
          getImages returns how many sounds are defined in this group
 boolean isCached()
          isCached is essentialy equal to getLoadStatus()==100.00f
 boolean isReady()
          isReady returns weather or not resources are ready to use
 boolean isValid()
          isValid returns weather or not the ResourceManager has validated this group of resources
protected  void setLoadStatus(float loaded)
          setLoadStatus is only called by ResourceManager to set the currently loaded state of resources.
protected  void setValid(boolean validation)
          setValid is set by the ResourceManager after it has vilidated locations and files
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

images

protected java.util.Hashtable<java.lang.Integer,NativeImageFormat> images
Container for images


pallets

protected java.util.Hashtable<java.lang.Integer,NativePalletFormat> pallets
Container for pallets


midis

protected java.util.Hashtable<java.lang.Integer,NativeMidiFormat> midis
Container for Midis


sounds

protected java.util.Hashtable<java.lang.Integer,NativeSoundFormat> sounds
Container for sound


fonts

protected java.util.Hashtable<java.lang.Integer,NativeFontFormat> fonts
Container for fonts

Constructor Detail

ResourceGroup

public ResourceGroup(java.lang.String group,
                     java.util.Properties resources)
Resource group is an arrangements of resouces in a given group.
Usages for resources(properties file)
 1 = images/hud/face01.bmp
 2 = images/hud/face02.bmp
 3 = images/hud/face03.bmp
 4 = images/hud/bar.bmp
 5 = fonts/hud.fnt
 ...
 

Parameters:
group - Nmae of the group
resources - a properties file as described above.
Method Detail

getImageResource

public java.lang.String getImageResource(int definition)
getImageResource returns the physical location for a file

Parameters:
definition - defined name of resource
Returns:
the location of required resource.

getImageResources

public java.util.Hashtable<java.lang.Integer,java.lang.String> getImageResources()
getImageResources returns a list of resources and their definitions.

Returns:
a disposable clone of the internal resource stucture.

getImages

public int getImages()
getImages returns how many images are defined in this group

Returns:
size of image list

getPalletResource

public java.lang.String getPalletResource(int definition)
getPalletResource returns the physical location for a file

Parameters:
definition - defined id of resource
Returns:
the location of required resource.

getPalletResources

public java.util.Hashtable<java.lang.Integer,java.lang.String> getPalletResources()
getPalletResources returns a list of resources and their definitions.

Returns:
a disposable clone of the internal resource stucture.

getPallets

public int getPallets()
getImages returns how many pallets are defined in this group

Returns:
size of pallet list

getMidiResource

public java.lang.String getMidiResource(int definition)
getMidiResource returns the physical location for a file

Parameters:
definition - defined id of resource
Returns:
the location of required resource.

getMidiResources

public java.util.Hashtable<java.lang.Integer,java.lang.String> getMidiResources()
getImageResources returns a list of resources and their definitions.

Returns:
a disposable clone of the internal resource stucture.

getMidis

public int getMidis()
getImages returns how many midi's are defined in this group

Returns:
size of midi list

getSoundResource

public java.lang.String getSoundResource(int definition)
getSoundResource returns the physical location for a file

Parameters:
definition - defined id of resource
Returns:
the location of required resource.

getSoundResources

public java.util.Hashtable<java.lang.Integer,java.lang.String> getSoundResources()
getSoundResources returns a list of resources and their definitions.

Returns:
a disposable clone of the internal resource stucture.

getSounds

public int getSounds()
getImages returns how many sounds are defined in this group

Returns:
size of sound list

getFontesource

public java.lang.String getFontesource(int definition)
getFontesource returns the physical location for a file

Parameters:
definition - defined id of resource
Returns:
the location of required resource.

getFontResources

public java.util.Hashtable<java.lang.Integer,java.lang.String> getFontResources()
getFontResources returns a list of resources and their definitions.

Returns:
a disposable clone of the internal resource stucture.

getFonts

public int getFonts()
getFonts returns how many fonts are defined in this group

Returns:
size of font list

getName

public java.lang.String getName()
returns the name of this set of resources or group

Returns:
the name associated with this group

setValid

protected void setValid(boolean validation)
setValid is set by the ResourceManager after it has vilidated locations and files

Parameters:
validation - sets true if this group has been determined to be Valid false otherwise.

isValid

public boolean isValid()
isValid returns weather or not the ResourceManager has validated this group of resources

Returns:
true if valid false otherwise. set to false until the resource manager has validated resources

isReady

public boolean isReady()
isReady returns weather or not resources are ready to use

Returns:
true if valid and loaded false otherwise

setLoadStatus

protected void setLoadStatus(float loaded)
setLoadStatus is only called by ResourceManager to set the currently loaded state of resources.

Parameters:
loaded - percentage of loaded itrems in this group.

getLoadStatus

public float getLoadStatus()
Returns the load status as a fraction of 100% of loaded items in this group

Returns:
percentile of loaded resources.

isCached

public boolean isCached()
isCached is essentialy equal to getLoadStatus()==100.00f

Returns:
true if this group is determined to be cached by the ResourceManager

getResources

public int getResources()
getResources returns the amount of uniqure rsouces in totality.

Returns:
accumulated size of internal resouce references.