net.sf.freecol.common.resources
Class ResourceManager

java.lang.Object
  extended by net.sf.freecol.common.resources.ResourceManager

public class ResourceManager
extends java.lang.Object

Class for getting resources (images, audio etc).


Constructor Summary
ResourceManager()
           
 
Method Summary
static java.awt.Color getColor(java.lang.String resource)
          Returns the Color with the given name.
static java.awt.Image getGrayscaleImage(java.lang.String resource, java.awt.Dimension size)
          Returns the a grayscale version of the image specified by the given name.
static java.awt.Image getGrayscaleImage(java.lang.String resource, double scale)
          Returns the grayscale version of the image specified by the given name.
static java.awt.Image getImage(java.lang.String resource)
          Returns the image specified by the given name.
static java.awt.Image getImage(java.lang.String resource, java.awt.Dimension size)
          Returns the image specified by the given name.
static java.awt.Image getImage(java.lang.String resource, double scale)
          Returns the image specified by the given name.
static javax.swing.ImageIcon getImageIcon(java.lang.String resource)
          Creates an ImageIcon for the image of the given name.
static SimpleZippedAnimation getSimpleZippedAnimation(java.lang.String resource)
          Returns the animation specified by the given name.
static SimpleZippedAnimation getSimpleZippedAnimation(java.lang.String resource, double scale)
          Returns the animation specified by the given name.
static Video getVideo(java.lang.String resource)
          Gets the Video represented by the given resource.
static void preload(java.awt.Dimension windowSize)
          Preload resources.
static void setBaseMapping(ResourceMapping _baseMapping)
          Sets the mappings specified in the date/base-directory
static void setCampaignMapping(ResourceMapping _campaignMapping)
          Sets the mappings specified in a campaign.
static void setModMappings(java.util.List<ResourceMapping> _modMappings)
          Sets the mappings specified by mods.
static void setScenarioMapping(ResourceMapping _scenarioMapping)
          Sets the mappings specified in a scenario.
static void setTcMapping(ResourceMapping _tcMapping)
          Sets the mappings specified for a Total Conversion (TC).
static void startBackgroundPreloading(java.awt.Dimension windowSize)
          Starts background preloading of resources.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceManager

public ResourceManager()
Method Detail

setBaseMapping

public static void setBaseMapping(ResourceMapping _baseMapping)
Sets the mappings specified in the date/base-directory

Parameters:
_baseMapping - The mapping between IDs and files.

setTcMapping

public static void setTcMapping(ResourceMapping _tcMapping)
Sets the mappings specified for a Total Conversion (TC).

Parameters:
_tcMapping - The mapping between IDs and files.

setModMappings

public static void setModMappings(java.util.List<ResourceMapping> _modMappings)
Sets the mappings specified by mods.

Parameters:
_modMappings - A list of the mapping between IDs and files.

setCampaignMapping

public static void setCampaignMapping(ResourceMapping _campaignMapping)
Sets the mappings specified in a campaign.

Parameters:
_campaignMapping - The mapping between IDs and files.

setScenarioMapping

public static void setScenarioMapping(ResourceMapping _scenarioMapping)
Sets the mappings specified in a scenario.

Parameters:
_scenarioMapping - The mapping between IDs and files.

preload

public static void preload(java.awt.Dimension windowSize)
Preload resources. This method is intended to be called when starting the application, as it blocks until resources needed for the first panels have been loaded. It also ensures that the background preloading thread is started.

Parameters:
windowSize -

startBackgroundPreloading

public static void startBackgroundPreloading(java.awt.Dimension windowSize)
Starts background preloading of resources.

Parameters:
windowSize - The window size to use when scaling full screen size images.

getSimpleZippedAnimation

public static SimpleZippedAnimation getSimpleZippedAnimation(java.lang.String resource)
Returns the animation specified by the given name.

Parameters:
resource - The name of the resource to return.
Returns:
The animation identified by resource or null if there is no animation identified by that name.

getVideo

public static Video getVideo(java.lang.String resource)
Gets the Video represented by the given resource.

Returns:
The Video in it's original size.

getSimpleZippedAnimation

public static SimpleZippedAnimation getSimpleZippedAnimation(java.lang.String resource,
                                                             double scale)
Returns the animation specified by the given name.

Parameters:
resource - The name of the resource to return.
scale - The size of the requested animation (with 1 being normal size, 2 twice the size, 0.5 half the size etc). Rescaling will be performed unless using 1.
Returns:
The animation identified by resource or null if there is no animation identified by that name.

getImage

public static java.awt.Image getImage(java.lang.String resource)
Returns the image specified by the given name.

Parameters:
resource - The name of the resource to return.
Returns:
The image identified by resource or null if there is no image identified by that name.

getImage

public static java.awt.Image getImage(java.lang.String resource,
                                      double scale)
Returns the image specified by the given name.

Parameters:
resource - The name of the resource to return.
scale - The size of the requested image (with 1 being normal size, 2 twice the size, 0.5 half the size etc). Rescaling will be performed unless using 1.
Returns:
The image identified by resource or null if there is no image identified by that name.

getImage

public static java.awt.Image getImage(java.lang.String resource,
                                      java.awt.Dimension size)
Returns the image specified by the given name.

Parameters:
resource - The name of the resource to return.
size - The size of the requested image. Rescaling will be performed if necessary.
Returns:
The image identified by resource or null if there is no image identified by that name.

getGrayscaleImage

public static java.awt.Image getGrayscaleImage(java.lang.String resource,
                                               java.awt.Dimension size)
Returns the a grayscale version of the image specified by the given name.

Parameters:
resource - The name of the resource to return.
size - The size of the requested image. Rescaling will be performed if necessary.
Returns:
The image identified by resource or null if there is no image identified by that name.

getGrayscaleImage

public static java.awt.Image getGrayscaleImage(java.lang.String resource,
                                               double scale)
Returns the grayscale version of the image specified by the given name.

Parameters:
resource - The name of the resource to return.
scale - The size of the requested image (with 1 being normal size, 2 twice the size, 0.5 half the size etc). Rescaling will be performed unless using 1.
Returns:
The image identified by resource or null if there is no image identified by that name.

getImageIcon

public static javax.swing.ImageIcon getImageIcon(java.lang.String resource)
Creates an ImageIcon for the image of the given name.

Parameters:
resource - The name of the resource to return.
Returns:
An ImageIcon created with the image identified by resource or null if there is no image identified by that name.
See Also:
getImage(String)

getColor

public static java.awt.Color getColor(java.lang.String resource)
Returns the Color with the given name.

Parameters:
resource - The name of the resource to return.
Returns:
An Color created with the image identified by resource or null if there is no color identified by that name.
See Also:
getImage(String)