package edu.princeton.cs.algs4.growingtree.framework; /* * @(#)OptionEvent.java * * Last Modified: 9/01/02 */ import java.awt.AWTEvent; import java.awt.Event; /** * A semantic event which indicates that a Option-defined action occured. * This high-level event is generated by an Option component when * an action occurs (such as a key insertion). * The event is passed to every OptionListener object * that registered to receive such events using the Option's * addOptionListener method. *

* The object that implements the OptionListener interface * gets this OptionEvent when the event occurs. The listener * is therefore spared the details of processing individual selection, and can * instead process a "meaningful" (semantic) event like "key inserted". * * @see OptionJPanel * * @author Corey Sanders * @version 1.3 9/01/02 */ public class OptionEvent extends AWTEvent { public static final String INTEGER_FIELDS_ON = "Integer Fields On"; public static final String INTEGER_FIELDS_OFF = "Integer Fields Off"; /** * actionCommand passed for Insertion. */ public static final String INSERT = "Insert"; /** * actionCommand passed for Rotate. */ public static final String ROTATE_CLICK = "Rotate Click"; /** * actionCommand passed for Rotate to top. */ public static final String ROTATE_TOP_CLICK = "Rotate to top Click"; /** * actionCommand passed for Double Rotate. */ public static final String ROTATE_DOUBLE_CLICK = "Rotate Double Click"; /** * actionCommand passed for Splay. */ public static final String SPLAY_CLICK = "Splay Click"; /** * actionCommand passed for Partition. */ public static final String PARTITION_CLICK = "Partition Click"; /** * actionCommand passed for Clearing. */ public static final String CLEAR = "Clear"; /** * actionCommand passed for Clearing. */ public static final String CLEAR_ALL = "Clear All"; /** * actionCommand passes for Loading */ public static final String LOAD = "Load"; public static String getLoadCommand(int i) { return LOAD + i; } /** * actionCommand passed for Deletion. */ public static final String DELETE = "Delete"; /** * actionCommand passed for Deletion Click. */ public static final String DELETE_CLICK = "Delete Click"; /** * actionCommand passed for Change of input (Integer or Character and so forth). */ public static final String INPUT_CHANGE_ALL = "Input Change All"; /** * actionCommand passed for Change of input (Integer or Character and so forth). */ public static final String INTEGER = "Integer"; /** * actionCommand passed for Change of input (Integer or Character and so forth). */ public static final String CHARACTER = "Character"; /** * actionCommand passed for Change of input (Integer or Character and so forth). */ public static final String DOUBLE = "Double"; /** * actionCommand passed for zoom in. */ public static final String ZOOM_IN = "Zoom in"; /** * actionCommand passed for zoom out. */ public static final String ZOOM_OUT = "Zoom out"; /** * actionCommand passed for get status. */ public static final String GET_STATUS= "Get Status"; /** * actionCommand passed for get status. */ public static final String GET_STATUS_ALL= "Get Status All"; /** * actionCommand passed for balancing the tree. */ public static final String BALANCE= "Balance"; /** * actionCommand passed for balancing the tree. */ public static final String BALANCE_ALL= "Balance All"; /** * actionCommand passed for a tabbed pane. */ public static final String TABBED_PANE = "Tabbed pane"; /** * actionCommand passed for a tabbed pane. */ public static final String WINDOWS = "Windows"; /** * actionCommand passed for balancing the tree. */ public static final String BALANCE_CLICK= "Balance Click"; /** * actionCommand passed for search the tree. */ public static final String SEARCH= "Search"; /** * actionCommand passed for select the tree. */ public static final String SELECT= "Select"; /** * actionCommand passed for select the tree. */ public static final String SELECT_CLICK= "Select Click"; /** * Animation command passed for play. */ public static final String ANIMATION_PLAY = "Animation Play"; /** * Animation command passed for stop. */ public static final String ANIMATION_STOP = "Animation Stop"; /** * Animation command passed for pause. */ public static final String ANIMATION_PAUSE = "Animation Pause"; /** * Animation command passed for rewind. */ public static final String ANIMATION_REWIND = "Animation Rewind"; /** * Animation command passed for step back. */ public static final String ANIMATION_STEP_REWIND = "Animation Step Rewind"; /** * Animation command passed for step forward. */ public static final String ANIMATION_STEP_FORWARD = "Animation Step Forward"; /** * Animation command passed for step back. */ public static final String ANIMATION_FAST_REWIND = "Animation Fast Rewind"; /** * Animation command passed for step forward. */ public static final String ANIMATION_FAST_FORWARD = "Animation Fast Forward"; /** * Animation command passed for speed change. */ public static final String ANIMATION_SPEED = "Animation Speed"; /** * Animation command passed for animation toggle on. */ public static final String ANIMATION_ON = "Animation On"; /** * Animation command passed for animation toggle off. */ public static final String ANIMATION_OFF = "Animation Off"; /** * Animation command passed for step toggle on. */ public static final String ANIMATION_STEP_ON = "Animation Step On"; /** * Animation command passed for step toggle off. */ public static final String ANIMATION_STEP_OFF= "Animation Step Off"; /** * Animation command passed for quality change. */ public static final String ANIMATION_QUALITY = "Animation Quality"; /** * Definition for Animation command, must begin with this String. *

Can use startsWith to determine if the command is * an animating command. */ public static final String ANIMATION = "Animation"; /** * Animation command passed for tree information. */ public static final String TREE_INFORMATION = "Tree Information"; /** * Animation command passed for program information. */ public static final String PROGRAM_INFORMATION = "Program Information"; /** * Animation command passed for program information. */ public static final String ABOUT = "About"; /** * Animation command passed for all message to pass. */ public static final String MESSAGE_ALL = "Message All"; /** * Animation command passed for only final messages to pass. */ public static final String MESSAGE_FINAL_ONLY = "Message Final Only"; /** * Animation command passed for no messages to pass. */ public static final String MESSAGE_OFF = "Message Off"; /** * Node display turned on. */ public static final String NODE_DISPLAY_ON = "Node Display On"; /** * Node display turned on. */ public static final String NODE_DISPLAY_OFF = "Node Display Off"; /** * Animation command passed to make a random tree. */ public static final String RANDOM_TREE = "Make Random Tree"; /** * Animation command passed for a preorder traversal. */ public static final String PREORDER_TRAVERSAL = "Preorder Traversal"; /** * Animation command passed for a postorder traversal. */ public static final String POSTORDER_TRAVERSAL = "Postorder Traversal"; /** * Animation command passed for an inorder traversal. */ public static final String INORDER_TRAVERSAL = "Inorder Traversal"; /** * Animation command passed for a levelorder traversal. */ public static final String LEVELORDER_TRAVERSAL = "Levelorder Traversal"; /** * Animation command passed for a input options request. */ public static final String GET_INPUT_OPTIONS = "Get Input Options"; /** * Animation command passed for a saving of the colors. */ public static final String SAVE_TREE = "Save Tree Color Settings"; /** * Animation command passed for a saving of the colors for all trees. */ public static final String SAVE_ALL = "Save All Color Settings"; /** * Animation command passed for the reseting of colors. */ public static final String RESET = "Reset Color Settings"; /** * Animation command passed for a function color change. */ public static final String FUNCTION_CHANGE = "Function Change"; /** * Animation command passed for a color settings change. */ public static final String COLOR_SETTINGS_CHANGE = "Color Settings Change"; /** * Animation command passed for a color scheme change. */ public static final String COLOR_SCHEME_CHANGE = "Color Scheme Change"; /** * Animation command passed for a color scheme preset change. */ public static final String COLOR_SCHEME_PRESET_CHANGE = "Color Scheme Preset Change"; /** * Animation command passed for color settings all request. */ public static final String COLOR_SETTINGS_ALL = "Color Settings All"; /** * Animation command passed for color settings request. */ public static final String COLOR_SETTINGS = "Color Settings"; /** * Animation command passed for color options request. */ public static final String COLOR_OPTIONS = "Color Options"; /** * Animation command passed for display change request to binary. */ public static final String BINARY_DISPLAY = "Binary Display"; /** * Animation command passed for display change request to sectional. */ public static final String SECTIONAL_DISPLAY = "Sectional Display"; /** * Animation command passed for display change request to 234. */ public static final String TWO_THREE_FOUR_DISPLAY = "2-3-4 Display"; /** * Animation command passed for display change request. */ public static final String DISPLAY_CHANGE = "Change Display"; /** * Command passed to turn on the tool bar. */ public static final String TOOL_BAR_ON = "Tool Bar On"; /** * Command passed to turn off the tool bar. */ public static final String TOOL_BAR_OFF = "Tool Bar Off"; /** * actionCommand passed for exiting the program. */ public static final String EXIT= "Exit Program"; /** * ID for an option panel. */ public static final int OPTION_PANEL = 3001; /** * ID for an control option panel. */ public static final int CONTROL_OPTION_PANEL = 3002; /** * ID for an main option panel. */ public static final int MAIN_OPTION_PANEL = 3003; /** * ID for an animation tools option panel. */ public static final int ANIMATION_TOOLS_OPTION_PANEL = 3004; /** * ID for an tree tools option panel. */ public static final int TREE_TOOLS_OPTION_PANEL = 3005; /** * ID for an tree tools all option panel. */ public static final int TREE_TOOLS_ALL_OPTION_PANEL = 3006; /** * ID for an color tools option panel. */ public static final int COLOR_TOOLS_OPTION_PANEL = 3007; /** * ID for a center frame. */ public static final int CENTER_FRAME = 3008; /** * ID for an desktop panel. */ public static final int DESKTOP_PANEL = 3101; /** * The nonlocalized string that gives more details * of what actually caused the event. * This information is very specific to the component * that fired it. * * @see #getActionCommand() */ String actionCommand; /** * The nonlocalized Object passed for usage by whatever Object * is listening to the current OptionEvent. * * @see #getObjectValue() */ Object value; /** * Constructs an OptionEvent object. * * @param source the object that originated the event * @param id an integer that identifies the event * @param command a string that may specify a command (possibly one * of several) associated with the event */ public OptionEvent(Object source, int id, String command) { this(source, id, command, null); } /** * Constructs an OptionEvent object with the Object value. * * @param source the object that originated the event * @param id an integer that identifies the event * @param command a string that may specify a command (possibly one * of several) associated with the event * @param value the value of the Object passed */ public OptionEvent(Object source, int id, String command, Object value) { super(source, id); this.actionCommand = command; this.value = value; } /** * Returns the command string associated with this action. * This string allows a "modal" component to specify one of several * commands, depending on its state. The command string * would identify the intended action. * *@return the string identifying the command for this event */ public String getActionCommand() { return actionCommand; } /** * Returns the Object associated with the OptionEvent. * * @return the Object of the event */ public Object getObjectValue() { return value; } }