edu.princeton.toy
Class TImageManager

java.lang.Object
  extended by edu.princeton.toy.TImageManager

public class TImageManager
extends Object

TImageManager is a class that manages the jpeg and gif files which Visual X-TOY uses. It maintains a group of unscaled images and a group of scaled images which are loaded an rescaled upon request only.


Field Summary
static short MACHINE_SCALED_BUTTON_ENTER_OFF
          The index of the unlit state of the Enter button.
static short MACHINE_SCALED_BUTTON_ENTER_ON
          The index of the lit state of the Enter button.
static short MACHINE_SCALED_BUTTON_INTERRUPT_OFF
          The index of the unlit state of the Interrupt button.
static short MACHINE_SCALED_BUTTON_INTERRUPT_ON
          The index of the lit state of the Interrupt button.
static short MACHINE_SCALED_BUTTON_LOAD_OFF
          The index of the unlit state of the Load button.
static short MACHINE_SCALED_BUTTON_LOAD_ON
          The index of the lit state of the Load button.
static short MACHINE_SCALED_BUTTON_LOOK_OFF
          The index of the unlit state of the Look button.
static short MACHINE_SCALED_BUTTON_LOOK_ON
          The index of the lit state of the Look button.
static short MACHINE_SCALED_BUTTON_RESET_OFF
          The index of the unlit state of the Reset button.
static short MACHINE_SCALED_BUTTON_RESET_ON
          The index of the lit state of the Reset button.
static short MACHINE_SCALED_BUTTON_RUN_OFF
          The index of the unlit state of the Run button.
static short MACHINE_SCALED_BUTTON_RUN_ON
          The index of the lit state of the Run button.
static short MACHINE_SCALED_BUTTON_STEP_OFF
          The index of the unlit state of the Step button.
static short MACHINE_SCALED_BUTTON_STEP_ON
          The index of the lit state of the Step button.
static short MACHINE_SCALED_DIGIT_BLANK
          The index of the blank LCD digit.
static short[] MACHINE_SCALED_DIGITS
          The indices of the LCD Digits.
static byte MACHINE_SCALED_IMAGE_GROUP
          The index of the machine scaled image group.
static short MACHINE_SCALED_LABEL_ADDR
          The index of the "ADDR" label.
static short MACHINE_SCALED_LABEL_DATA
          The index of the "DATA" label.
static short MACHINE_SCALED_LABEL_INSTR
          The index of the "INSTR" label.
static short MACHINE_SCALED_LABEL_INWAIT
          The index of the "INWAIT" label.
static short MACHINE_SCALED_LABEL_PC
          The index of the "PC" label.
static short MACHINE_SCALED_LABEL_READY
          The index of the "READY" label.
static short MACHINE_SCALED_LABEL_STDOUT
          The index of the "STDOUT" label.
static short MACHINE_SCALED_LIGHT_OFF
          The index of the unlit state of the light.
static short MACHINE_SCALED_LIGHT_ON
          The index of the lit state of the light.
static short MACHINE_SCALED_SWITCH_OFF
          The index of the down state of the switch.
static short MACHINE_SCALED_SWITCH_ON
          The index of the up state of the switch.
static int[] MAX_SCALE
          The maximum scale to which the images can be scaled.
static int[] ORIGINAL_IMAGE_SCALES
          The scale by which the raw images are loaded.
static short REGULAR_UNSCALED_CHECK_SYNTAX_ICON
          The index of the check syntax icon for the toolbar.
static short REGULAR_UNSCALED_DEBUG_MODE_ICON_OFF
          The index of the debug mode off icon for the toolbar.
static short REGULAR_UNSCALED_DEBUG_MODE_ICON_ON
          The index of the debug mode on icon for the toolbar.
static short REGULAR_UNSCALED_EDIT_MODE_ICON_OFF
          The index of the edit mode off icon for the toolbar.
static short REGULAR_UNSCALED_EDIT_MODE_ICON_ON
          The index of the edit mode on icon for the toolbar.
static short REGULAR_UNSCALED_FRAME_ICON_OTHER_OS
          The index of the icon for the frame.
static short REGULAR_UNSCALED_FRAME_ICON_WINDOWS
          The index of the icon for the frame.
static byte REGULAR_UNSCALED_IMAGE_GROUP
          The index of the regular unscaled image group.
static short REGULAR_UNSCALED_INTERRUPT_ICON
          The index of the interrupt icon for the toolbar.
static short REGULAR_UNSCALED_NEW_ICON
          The index of the new icon for the toolbar.
static short REGULAR_UNSCALED_OPEN_EXAMPLE_ICON
          The index of the open example icon for the toolbar.
static short REGULAR_UNSCALED_OPEN_ICON
          The index of the open icon for the toolbar.
static short REGULAR_UNSCALED_RESET_ICON
          The index of the reset icon for the toolbar.
static short REGULAR_UNSCALED_RUN_ICON
          The index of the run icon for the toolbar.
static short REGULAR_UNSCALED_SAVE_ALL_ICON
          The index of the save all icon for the toolbar.
static short REGULAR_UNSCALED_SAVE_AS_ICON
          The index of the save as icon for the toolbar.
static short REGULAR_UNSCALED_SAVE_ICON
          The index of the save icon for the toolbar.
static short REGULAR_UNSCALED_SIM_MODE_ICON_OFF
          The index of the sim mode off icon for the toolbar.
static short REGULAR_UNSCALED_SIM_MODE_ICON_ON
          The index of the sim mode on icon for the toolbar.
static short REGULAR_UNSCALED_STEP_ICON
          The index of the step icon for the toolbar.
static String[][] SCALED_IMAGE_PATHS
          The paths to all the scaled images, relative to the root of the jar file.
static byte STARTUP_UNSCALED_IMAGE_GROUP
          The index of the startup unscaled image group.
static short STARTUP_UNSCALED_SPLASH_BACKGROUND
          The index of the splash window's background
static byte STDIO_SCALED_IMAGE_GROUP
          The index of the stdio scaled image group.
static short STDIO_SCALED_PUNCHCARD_DISABLED
          The index of the punch card in its disabled state.
static short STDIO_SCALED_PUNCHCARD_SELECTED
          The index of the punch card in its selected state.
static short STDIO_SCALED_PUNCHCARD_UNSELECTED
          The index of the punch card in its unselected state.
static String[][] UNSCALED_IMAGE_PATHS
          The paths to all the unscaled images, relative to the root of the jar file.
 
Method Summary
static Icon getIcon(byte scaledGroupId, int scale, short index)
          Returns the requested scaled image encapsulated in an icon.
static Icon getIcon(byte unscaledGroupId, short index)
          Returns the requested unscaled image encapsulated in an icon.
static Image getImage(byte scaledGroupId, int scale, short index)
          Returns the requested scaled image.
static Image getImage(byte unscaledGroupId, short index)
          Returns the requested unscaled image.
static boolean isPrepared(byte unscaledGroupId)
          Returns wheter or not a group of unscaled images has been prepared.
static boolean isPrepared(byte scaledGroupId, int scale)
          Returns wheter or not a group of scaled images has been prepared.
static void prepare(byte unscaledGroupId)
          Returns only when a group of unscaled images has been prepared.
static void prepare(byte scaledGroupId, int scale)
          Returns only when a group of scaled images has been prepared.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNSCALED_IMAGE_PATHS

public static final String[][] UNSCALED_IMAGE_PATHS
The paths to all the unscaled images, relative to the root of the jar file.


STARTUP_UNSCALED_IMAGE_GROUP

public static final byte STARTUP_UNSCALED_IMAGE_GROUP
The index of the startup unscaled image group.

See Also:
Constant Field Values

STARTUP_UNSCALED_SPLASH_BACKGROUND

public static final short STARTUP_UNSCALED_SPLASH_BACKGROUND
The index of the splash window's background

See Also:
Constant Field Values

REGULAR_UNSCALED_IMAGE_GROUP

public static final byte REGULAR_UNSCALED_IMAGE_GROUP
The index of the regular unscaled image group.

See Also:
Constant Field Values

REGULAR_UNSCALED_FRAME_ICON_WINDOWS

public static final short REGULAR_UNSCALED_FRAME_ICON_WINDOWS
The index of the icon for the frame.

See Also:
getImage(byte, short), Constant Field Values

REGULAR_UNSCALED_FRAME_ICON_OTHER_OS

public static final short REGULAR_UNSCALED_FRAME_ICON_OTHER_OS
The index of the icon for the frame.

See Also:
getImage(byte, short), Constant Field Values

REGULAR_UNSCALED_NEW_ICON

public static final short REGULAR_UNSCALED_NEW_ICON
The index of the new icon for the toolbar.

See Also:
getImage(byte, short), Constant Field Values

REGULAR_UNSCALED_OPEN_ICON

public static final short REGULAR_UNSCALED_OPEN_ICON
The index of the open icon for the toolbar.

See Also:
getImage(byte, short), Constant Field Values

REGULAR_UNSCALED_OPEN_EXAMPLE_ICON

public static final short REGULAR_UNSCALED_OPEN_EXAMPLE_ICON
The index of the open example icon for the toolbar.

See Also:
getImage(byte, short), Constant Field Values

REGULAR_UNSCALED_SAVE_ICON

public static final short REGULAR_UNSCALED_SAVE_ICON
The index of the save icon for the toolbar.

See Also:
getImage(byte, short), Constant Field Values

REGULAR_UNSCALED_SAVE_AS_ICON

public static final short REGULAR_UNSCALED_SAVE_AS_ICON
The index of the save as icon for the toolbar.

See Also:
getImage(byte, short), Constant Field Values

REGULAR_UNSCALED_SAVE_ALL_ICON

public static final short REGULAR_UNSCALED_SAVE_ALL_ICON
The index of the save all icon for the toolbar.

See Also:
getImage(byte, short), Constant Field Values

REGULAR_UNSCALED_EDIT_MODE_ICON_OFF

public static final short REGULAR_UNSCALED_EDIT_MODE_ICON_OFF
The index of the edit mode off icon for the toolbar.

See Also:
getImage(byte, short), Constant Field Values

REGULAR_UNSCALED_EDIT_MODE_ICON_ON

public static final short REGULAR_UNSCALED_EDIT_MODE_ICON_ON
The index of the edit mode on icon for the toolbar.

See Also:
getImage(byte, short), Constant Field Values

REGULAR_UNSCALED_DEBUG_MODE_ICON_OFF

public static final short REGULAR_UNSCALED_DEBUG_MODE_ICON_OFF
The index of the debug mode off icon for the toolbar.

See Also:
getImage(byte, short), Constant Field Values

REGULAR_UNSCALED_DEBUG_MODE_ICON_ON

public static final short REGULAR_UNSCALED_DEBUG_MODE_ICON_ON
The index of the debug mode on icon for the toolbar.

See Also:
getImage(byte, short), Constant Field Values

REGULAR_UNSCALED_SIM_MODE_ICON_OFF

public static final short REGULAR_UNSCALED_SIM_MODE_ICON_OFF
The index of the sim mode off icon for the toolbar.

See Also:
getImage(byte, short), Constant Field Values

REGULAR_UNSCALED_SIM_MODE_ICON_ON

public static final short REGULAR_UNSCALED_SIM_MODE_ICON_ON
The index of the sim mode on icon for the toolbar.

See Also:
getImage(byte, short), Constant Field Values

REGULAR_UNSCALED_RESET_ICON

public static final short REGULAR_UNSCALED_RESET_ICON
The index of the reset icon for the toolbar.

See Also:
getImage(byte, short), Constant Field Values

REGULAR_UNSCALED_STEP_ICON

public static final short REGULAR_UNSCALED_STEP_ICON
The index of the step icon for the toolbar.

See Also:
getImage(byte, short), Constant Field Values

REGULAR_UNSCALED_RUN_ICON

public static final short REGULAR_UNSCALED_RUN_ICON
The index of the run icon for the toolbar.

See Also:
getImage(byte, short), Constant Field Values

REGULAR_UNSCALED_INTERRUPT_ICON

public static final short REGULAR_UNSCALED_INTERRUPT_ICON
The index of the interrupt icon for the toolbar.

See Also:
getImage(byte, short), Constant Field Values

REGULAR_UNSCALED_CHECK_SYNTAX_ICON

public static final short REGULAR_UNSCALED_CHECK_SYNTAX_ICON
The index of the check syntax icon for the toolbar.

See Also:
getImage(byte, short), Constant Field Values

SCALED_IMAGE_PATHS

public static final String[][] SCALED_IMAGE_PATHS
The paths to all the scaled images, relative to the root of the jar file.


ORIGINAL_IMAGE_SCALES

public static final int[] ORIGINAL_IMAGE_SCALES
The scale by which the raw images are loaded.

See Also:
getImage(byte, int, short)

MAX_SCALE

public static final int[] MAX_SCALE
The maximum scale to which the images can be scaled.

See Also:
getImage(byte, int, short)

MACHINE_SCALED_IMAGE_GROUP

public static final byte MACHINE_SCALED_IMAGE_GROUP
The index of the machine scaled image group.

See Also:
Constant Field Values

MACHINE_SCALED_BUTTON_ENTER_OFF

public static final short MACHINE_SCALED_BUTTON_ENTER_OFF
The index of the unlit state of the Enter button.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_BUTTON_ENTER_ON

public static final short MACHINE_SCALED_BUTTON_ENTER_ON
The index of the lit state of the Enter button.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_BUTTON_INTERRUPT_OFF

public static final short MACHINE_SCALED_BUTTON_INTERRUPT_OFF
The index of the unlit state of the Interrupt button.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_BUTTON_INTERRUPT_ON

public static final short MACHINE_SCALED_BUTTON_INTERRUPT_ON
The index of the lit state of the Interrupt button.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_BUTTON_LOAD_OFF

public static final short MACHINE_SCALED_BUTTON_LOAD_OFF
The index of the unlit state of the Load button.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_BUTTON_LOAD_ON

public static final short MACHINE_SCALED_BUTTON_LOAD_ON
The index of the lit state of the Load button.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_BUTTON_LOOK_OFF

public static final short MACHINE_SCALED_BUTTON_LOOK_OFF
The index of the unlit state of the Look button.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_BUTTON_LOOK_ON

public static final short MACHINE_SCALED_BUTTON_LOOK_ON
The index of the lit state of the Look button.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_BUTTON_RESET_OFF

public static final short MACHINE_SCALED_BUTTON_RESET_OFF
The index of the unlit state of the Reset button.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_BUTTON_RESET_ON

public static final short MACHINE_SCALED_BUTTON_RESET_ON
The index of the lit state of the Reset button.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_BUTTON_RUN_OFF

public static final short MACHINE_SCALED_BUTTON_RUN_OFF
The index of the unlit state of the Run button.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_BUTTON_RUN_ON

public static final short MACHINE_SCALED_BUTTON_RUN_ON
The index of the lit state of the Run button.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_BUTTON_STEP_OFF

public static final short MACHINE_SCALED_BUTTON_STEP_OFF
The index of the unlit state of the Step button.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_BUTTON_STEP_ON

public static final short MACHINE_SCALED_BUTTON_STEP_ON
The index of the lit state of the Step button.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_LABEL_ADDR

public static final short MACHINE_SCALED_LABEL_ADDR
The index of the "ADDR" label.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_LABEL_DATA

public static final short MACHINE_SCALED_LABEL_DATA
The index of the "DATA" label.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_LABEL_INSTR

public static final short MACHINE_SCALED_LABEL_INSTR
The index of the "INSTR" label.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_LABEL_INWAIT

public static final short MACHINE_SCALED_LABEL_INWAIT
The index of the "INWAIT" label.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_LABEL_PC

public static final short MACHINE_SCALED_LABEL_PC
The index of the "PC" label.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_LABEL_READY

public static final short MACHINE_SCALED_LABEL_READY
The index of the "READY" label.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_LABEL_STDOUT

public static final short MACHINE_SCALED_LABEL_STDOUT
The index of the "STDOUT" label.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_SWITCH_OFF

public static final short MACHINE_SCALED_SWITCH_OFF
The index of the down state of the switch.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_SWITCH_ON

public static final short MACHINE_SCALED_SWITCH_ON
The index of the up state of the switch.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_LIGHT_OFF

public static final short MACHINE_SCALED_LIGHT_OFF
The index of the unlit state of the light.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_LIGHT_ON

public static final short MACHINE_SCALED_LIGHT_ON
The index of the lit state of the light.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_DIGIT_BLANK

public static final short MACHINE_SCALED_DIGIT_BLANK
The index of the blank LCD digit.

See Also:
getImage(byte, int, short), Constant Field Values

MACHINE_SCALED_DIGITS

public static final short[] MACHINE_SCALED_DIGITS
The indices of the LCD Digits.

See Also:
getImage(byte, int, short)

STDIO_SCALED_IMAGE_GROUP

public static final byte STDIO_SCALED_IMAGE_GROUP
The index of the stdio scaled image group.

See Also:
Constant Field Values

STDIO_SCALED_PUNCHCARD_DISABLED

public static final short STDIO_SCALED_PUNCHCARD_DISABLED
The index of the punch card in its disabled state.

See Also:
getImage(byte, int, short), Constant Field Values

STDIO_SCALED_PUNCHCARD_UNSELECTED

public static final short STDIO_SCALED_PUNCHCARD_UNSELECTED
The index of the punch card in its unselected state.

See Also:
getImage(byte, int, short), Constant Field Values

STDIO_SCALED_PUNCHCARD_SELECTED

public static final short STDIO_SCALED_PUNCHCARD_SELECTED
The index of the punch card in its selected state.

See Also:
getImage(byte, int, short), Constant Field Values
Method Detail

isPrepared

public static boolean isPrepared(byte unscaledGroupId)
Returns wheter or not a group of unscaled images has been prepared. Calling this method will not cause the TImageManager to begin preparing the images.

Parameters:
unscaledGroupId - The id of the group in question. An invalid value will result in an ArrayIndexOutOfBoundsException.
Returns:
True iff the entire group of unscaled images has been prepared.
See Also:
STARTUP_UNSCALED_IMAGE_GROUP, REGULAR_UNSCALED_IMAGE_GROUP

isPrepared

public static boolean isPrepared(byte scaledGroupId,
                                 int scale)
Returns wheter or not a group of scaled images has been prepared. Calling this method will not cause the TImageManager to begin preparing the images.

Parameters:
scaledGroupId - The id of the group in question. An invalid value will result in an ArrayIndexOutOfBoundsException.
scale - The scale in question. An invalid value will result in an ArrayIndexOutOfBoundsException.
Returns:
True iff the entire group of scaled images has been prepared.
See Also:
STARTUP_UNSCALED_IMAGE_GROUP, REGULAR_UNSCALED_IMAGE_GROUP

prepare

public static void prepare(byte unscaledGroupId)
Returns only when a group of unscaled images has been prepared. This method is thread-safe.

Parameters:
unscaledGroupId - The id of the group in question. An invalid value will result in an ArrayIndexOutOfBoundsException.

prepare

public static void prepare(byte scaledGroupId,
                           int scale)
Returns only when a group of scaled images has been prepared. This method is thread-safe.

Parameters:
scaledGroupId - The id of the group in question. An invalid value will result in an ArrayIndexOutOfBoundsException.
scale - The desired scale of the image. An invalid value will result in an ArrayIndexOutOfBoundsException.

getImage

public static Image getImage(byte unscaledGroupId,
                             short index)
Returns the requested unscaled image. If the group was not prepared yet, it will be prepared in this thread.

Parameters:
unscaledGroupId - The id of the group to which the image belongs. An invalid value will result in an ArrayIndexOutOfBoundsException.
index - The index of the image in that group. An invalid value will result in an ArrayIndexOutOfBoundsException.
Returns:
The unscaled image at the given index of a given group.

getIcon

public static Icon getIcon(byte unscaledGroupId,
                           short index)
Returns the requested unscaled image encapsulated in an icon. If the group was not prepared yet, it will be prepared in this thread.

Parameters:
unscaledGroupId - The id of the group to which the image belongs. An invalid value will result in an ArrayIndexOutOfBoundsException.
index - The index of the image in that group. An invalid value will result in an ArrayIndexOutOfBoundsException.
Returns:
The unscaled image at the given index of a given group.

getImage

public static Image getImage(byte scaledGroupId,
                             int scale,
                             short index)
Returns the requested scaled image. If the group/scale was not prepared yet, it will be prepared in this thread.

Parameters:
scaledGroupId - The id of the group to which the image belongs. An invalid value will result in an ArrayIndexOutOfBoundsException.
scale - The desired scale of the image. An invalid value will result in an ArrayIndexOutOfBoundsException.
index - The index of the image in that group. An invalid value will result in an ArrayIndexOutOfBoundsException.
Returns:
The unscaled image at the given index of a given group.

getIcon

public static Icon getIcon(byte scaledGroupId,
                           int scale,
                           short index)
Returns the requested scaled image encapsulated in an icon. If the group/scale was not prepared yet, it will be prepared in this thread.

Parameters:
scaledGroupId - The id of the group to which the image belongs. An invalid value will result in an ArrayIndexOutOfBoundsException.
scale - The desired scale of the image. An invalid value will result in an ArrayIndexOutOfBoundsException.
index - The index of the image in that group. An invalid value will result in an ArrayIndexOutOfBoundsException.
Returns:
The unscaled image at the given index of a given group.