standup.symbol
Class SymbolManager

java.lang.Object
  extended by standup.symbol.SymbolManager

public class SymbolManager
extends Object

Provides methods for retrieving literacy/AAC symbols. STANDUP currently supports the Widgit Rebus and PCS Mayer-Johnson symbol sets (note that the symbols themselves must be obtained separately).

Obtaining symbol bitmaps is typically a 2-stage process:

Author:
Ruli Manurung

Field Summary
private static Hashtable<String,String[]> cachedConceptCodeImageFilenames
           
private static boolean enableFullPCS
           
private static Hashtable<String,BufferedImage> imageCache
           
private static SymbolLoader pcsLoader
           
private static SymbolLoader rebusLoader
           
private static boolean symbolLoadersHaveBeenInitialized
           
 
Constructor Summary
SymbolManager()
           
 
Method Summary
static String getSymbolCaption(String filename)
          Returns a simple caption for the symbol with the given filename.
private static List<String> getSymbolFilenames(String[] imgFiles, SymbolType[] symbolSet)
          Given a list of symbol filenames and a SymbolType[] indicating a preference for symbol sets, returns an ordered (sub)list of the symbol filenames according to the preference.
static List<String> getSymbolFilenames(String realConceptCode, SymbolType[] symbolSet)
          Given a 'real' Widgit conceptcode, and a SymbolType[] indicating a preference for symbol sets, returns a list of symbol filenames that are ordered by preference.
static BufferedImage getSymbolImage(String filename)
          Attempts to load and render/transcode a symbol with the given filename at its default resolution.
static BufferedImage getSymbolImage(String filename, int height)
          Attempts to load and render/transcode a symbol with the given filename at a resolution such that the resulting bitmap is as tall as the given height argument.
static boolean isEnableFullPCS()
          Returns true if the symbol loaders are set up in 'full' PCS mode, or false if they are in 'message' PCS mode.
static boolean isPCSSymbolFilename(String filename)
          Returns true if the given filename points to a PCS symbol, false otherwise.
static boolean isRebusSymbolFilename(String filename)
          Returns true if the given filename points to a Rebus symbol, false otherwise.
static void loadConceptCodeImageFilenames()
          Loads a serialized hashtable that maps Widgit conceptcodes to symbol filenames.
static void setupLoadersAndRenderers()
          Sets up the required symbol loaders for the various supported symbol sets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

enableFullPCS

private static transient boolean enableFullPCS

rebusLoader

private static transient SymbolLoader rebusLoader

pcsLoader

private static transient SymbolLoader pcsLoader

symbolLoadersHaveBeenInitialized

private static transient boolean symbolLoadersHaveBeenInitialized

imageCache

private static transient Hashtable<String,BufferedImage> imageCache

cachedConceptCodeImageFilenames

private static Hashtable<String,String[]> cachedConceptCodeImageFilenames
Constructor Detail

SymbolManager

public SymbolManager()
Method Detail

getSymbolCaption

public static String getSymbolCaption(String filename)
Returns a simple caption for the symbol with the given filename.

Parameters:
filename -
Returns:

isRebusSymbolFilename

public static boolean isRebusSymbolFilename(String filename)
Returns true if the given filename points to a Rebus symbol, false otherwise.

Parameters:
filename -
Returns:

isPCSSymbolFilename

public static boolean isPCSSymbolFilename(String filename)
Returns true if the given filename points to a PCS symbol, false otherwise.

Parameters:
filename -
Returns:

getSymbolFilenames

public static List<String> getSymbolFilenames(String realConceptCode,
                                              SymbolType[] symbolSet)
                                       throws SymbolException
Given a 'real' Widgit conceptcode, and a SymbolType[] indicating a preference for symbol sets, returns a list of symbol filenames that are ordered by preference.

Parameters:
realConceptCode -
symbolSet -
Returns:
Throws:
SymbolException

getSymbolFilenames

private static List<String> getSymbolFilenames(String[] imgFiles,
                                               SymbolType[] symbolSet)
                                        throws SymbolException
Given a list of symbol filenames and a SymbolType[] indicating a preference for symbol sets, returns an ordered (sub)list of the symbol filenames according to the preference. It may return a sublist due to the fact that the given symbol set preference might not include all possible SymbolTypes.

If no appropriate symbol filenames are found, it returns null.

Parameters:
imgFiles -
symbolSet -
Returns:
Throws:
SymbolException

loadConceptCodeImageFilenames

public static void loadConceptCodeImageFilenames()
Loads a serialized hashtable that maps Widgit conceptcodes to symbol filenames. This method is automatically called when deemed necessary. However, calling it explicitly at an application's startup may increase responsiveness (i.e. prevent the slight delay incurred when called on-demand).


isEnableFullPCS

public static boolean isEnableFullPCS()
Returns true if the symbol loaders are set up in 'full' PCS mode, or false if they are in 'message' PCS mode.

Returns:

setupLoadersAndRenderers

public static void setupLoadersAndRenderers()
Sets up the required symbol loaders for the various supported symbol sets. It first tries to load the full, unencrypted symbol sets (under './pcs' for PCS and under './rebus' for Rebus). Failing that, it tries to load encrypted symbol sets (requires the standup.symbol.encrypted package and the appropriate symbols*.tzp file).

Parameters:
cla -

getSymbolImage

public static BufferedImage getSymbolImage(String filename)
                                    throws SymbolException
Attempts to load and render/transcode a symbol with the given filename at its default resolution. If successful, it returns the resulting BufferedImage. Else, it returns null.

Additionally, it caches the resulting bitmap in a hashtable where the keys are the filenames. Thus, if this method is called with the same argument again, it doesn't have to re-load and re-render the symbol.

Parameters:
filename -
Returns:
Throws:
SymbolException

getSymbolImage

public static BufferedImage getSymbolImage(String filename,
                                           int height)
                                    throws SymbolException
Attempts to load and render/transcode a symbol with the given filename at a resolution such that the resulting bitmap is as tall as the given height argument. If successful, it returns the resulting BufferedImage. Else, it returns null.

Additionally, it caches the resulting bitmap in a hashtable where the keys are the filenames plus the intended height. Thus, if this method is called with the same arguments again, it doesn't have to re-load and re-render the symbol.

Parameters:
filename -
height -
Returns:
Throws:
SymbolException