edu.neu.ccs.jpf
Class JPFApplication

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byedu.neu.ccs.gui.DisplayPanel
                      extended byedu.neu.ccs.jpf.JPFApplication
All Implemented Interfaces:
Accessible, AlertListener, ConsoleAware, Displayable, EventListener, ImageObserver, JPTConstants, MalformedDataListener, MenuContainer, Serializable, SwingConstants

class JPFApplication
extends DisplayPanel
implements JPTConstants, ConsoleAware

This is the main application that sets up a console, a graphics window, and installs a list of actions to select one of several tasks to run from a given collection of "proper" methods.


Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int BUFFER_HEIGHT
          Default buffer height.
static int BUFFER_WIDTH
          Default buffer width.
protected  TablePanel buttonsPanel
          Buttons table panel for method buttons and common actions.
protected  Action clearGraphics
          Clear graphics action.
private static Color commonButtonColor
          The color of the common buttons except exit.
(package private)  JButton[] commonButtons
          The common action buttons.
protected  ActionsPanel commonButtonsPanel
          Buttons panel for common actions.
private static Color exitButtonColor
          The color of the exit button.
protected  Action exitFramework
          Application closing action.
protected  JPTFrame frame
          Application frame.
protected  String frameTitle
          Application frame title.
protected  JPF initializer
          Initializer object for the class with the methods.
protected  Class initializerClass
          Class of the initializer object.
protected  DisplayPanel LHS
          LHS of main GUI panel.
protected  TablePanel mainPanel
          Main GUI panel.
private static Color methodButtonColor
          The color of the method buttons when enabled.
private static Color methodButtonColorDisabled
          The color of the method buttons when disabled.
(package private)  JButton[] methodButtons
          The method buttons.
protected  ActionsPanel methodButtonsPanel
          Buttons panel for method buttons.
protected  DisplayPanel RHS
          RHS of main GUI panel.
protected  boolean showGraphicsWindow
          Whether or not to show graphics window.
protected  Action toggleConsole
          Toggle graphics action.
protected  Action toggleGraphics
          Toggle graphics action.
protected  BufferedPanel window
          Default graphics buffered panel.
 
Fields inherited from class edu.neu.ccs.gui.DisplayPanel
background, codec, CODEC
 
Fields inherited from class javax.swing.JPanel
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface edu.neu.ccs.util.JPTConstants
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface edu.neu.ccs.console.ConsoleAware
console
 
Fields inherited from interface edu.neu.ccs.gui.Displayable
DEFAULT_VIEW_STATE, VIEW_STATE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JPFApplication(JPF initializer, String title)
          Constructs the GUI.
 
Method Summary
protected  JButton addOneButton(ActionsPanel panel, Action action, String tooltip)
          Adds one button with the given action and tool tip to the panel and then returns the button.
protected  void buildButtons()
          Builds the buttons.
protected  void buildGUI()
          Builds the main panel.
protected static String className(Class c)
          Returns the unqualified name of the given Class
 void clearGraphics()
          Clears the graphics window.
protected  void exitFramework()
          Exits the framework by closing the Java Virtual Machine.
protected  Method[] getExtraMethods(Class c, Class d)
          Gets the methods in Class c that do not come from Class d.
 String getFrameTitle()
          Returns the title for the framework window.
 BufferedPanel getGraphicsWindow()
          Returns the graphics window.
protected  Method[] getMethodList()
          Returns a list of the "proper" methods, that is, methods for which we can instantiate buttons in the main GUI.
protected  String getMethodToolTip(Method method)
          Returns a tool tip appropriate for this method.
protected  String getParameterNames(Method method)
          Returns a String representing the parameters of the method.
protected  void handleMethodException(Throwable exception, String name)
          Handles exception produced by Method invocation.
 void iconifyConsole()
          Sets the state of an activated console window to iconified.
protected  boolean isAcceptableMethodForGUI(Method method)
          Returns true if the parameter types and return type are acceptable for the automatic MethodGUI and if the method is either non-void or has parameters.
protected  boolean isAcceptableTypeForParameter(Class c)
          Returns true if the type is acceptable for a method parameter.
protected  boolean isAcceptableTypeForReturn(Class c)
          Returns true if the type is acceptable for a method return.
protected  boolean isDuplicate(Method method1, Method method2)
          Returns true if the two methods have the same signature.
protected  boolean isDuplicateParameterList(Method method1, Method method2)
          Returns true if the two methods have the same parameter list.
 boolean isGraphicsVisible()
          Returns whether or not the graphics window is visible.
protected  boolean isGUIMethod(Method method)
          Returns true if the method should be converted to a button with GUI.
protected  boolean isSimpleMethod(Method method)
          Returns true if the method should be converted to a simple button.
protected  boolean isStatic(Method method)
           
protected  Method[] joinMethodArrays(Method[] listA, Method[] listB)
          Joins two Method arrays into one.
protected  Action makeActionFromMethod(Method method)
          Makes a ThreadedAction from the given method.
 void normalConsole()
          Sets the state of an activated console window to normal.
protected  void performAction(Method method)
          Performs the given method and assures that the method calls are synchronized.
 void performActionUsingGUI(Method method)
          Performs the given method using an automatice GUI and assures that the method calls are synchronized.
protected  void printExceptionTrace(Throwable exception, String name)
          Prints the exception trace minus references to Java reflection.
protected  void removeDuplicateVirtualMethods(Method[] methods)
          Removes duplicate virtual methods defined in several classes.
 void setFrameTitle(String title)
          Sets the title for the framework window to the given title.
 void setGraphicsVisible(boolean visible)
          Sets the visibility of the graphics window.
protected  void setMethodButtonsEnabled(boolean enable)
          Enable or disable the method buttons.
protected  void showConsole()
          Shows the console using color text.
 void toggleConsole()
          Toggles the state of an activated console window between normal and iconified.
 void toggleGraphics()
          Toggles the visibility of the graphics window.
 
Methods inherited from class edu.neu.ccs.gui.DisplayPanel
add, add, add, add, add, addBorder, addObject, addObject, addObject, addObject, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, compoundBorder, compoundBorder, dataMalformed, emptyBorder, emptyBorder, emptyBorder, endAlert, etchBorderLowered, etchBorderLowered, etchBorderLowered, etchBorderRaised, etchBorderRaised, etchBorderRaised, frame, frame, frame, frame, frame, frame, generalDialog, generalDialog, generalDialog, generalDialog, getCodec, getDefaultViewState, getDefaultViewStates, getDisplayables, getViewState, getViewStates, lineBorder, lineBorder, lineBorder, lineBorder, makeComponent, matteBorder, matteBorder, matteBorder, matteBorder, matteBorder, matteBorder, OKCancelDialog, OKCancelDialog, OKDialog, OKDialog, refreshComponent, remove, remove, removeAll, removeBorder, reset, sandwichBorder, setCodec, setDeepBackground, setDeepBackground, setDefaultViewState, setDefaultViewStates, setEnabled, setViewState, setViewStates, startAlert, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, uniformizeHeight, uniformizeSize, uniformizeWidth, YesNoCancelDialog, YesNoCancelDialog
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BUFFER_WIDTH

public static final int BUFFER_WIDTH
Default buffer width.

See Also:
Constant Field Values

BUFFER_HEIGHT

public static final int BUFFER_HEIGHT
Default buffer height.

See Also:
Constant Field Values

commonButtonColor

private static final Color commonButtonColor
The color of the common buttons except exit.


exitButtonColor

private static final Color exitButtonColor
The color of the exit button.


methodButtonColor

private static final Color methodButtonColor
The color of the method buttons when enabled.


methodButtonColorDisabled

private static final Color methodButtonColorDisabled
The color of the method buttons when disabled.


window

protected BufferedPanel window
Default graphics buffered panel.


initializer

protected JPF initializer
Initializer object for the class with the methods.


initializerClass

protected Class initializerClass
Class of the initializer object.


frame

protected JPTFrame frame
Application frame.


frameTitle

protected String frameTitle
Application frame title.


showGraphicsWindow

protected boolean showGraphicsWindow
Whether or not to show graphics window.


methodButtonsPanel

protected ActionsPanel methodButtonsPanel
Buttons panel for method buttons.


commonButtonsPanel

protected ActionsPanel commonButtonsPanel
Buttons panel for common actions.


buttonsPanel

protected TablePanel buttonsPanel
Buttons table panel for method buttons and common actions.


RHS

protected DisplayPanel RHS
RHS of main GUI panel.


LHS

protected DisplayPanel LHS
LHS of main GUI panel.


methodButtons

JButton[] methodButtons
The method buttons.


commonButtons

JButton[] commonButtons
The common action buttons.


mainPanel

protected TablePanel mainPanel
Main GUI panel.


clearGraphics

protected Action clearGraphics
Clear graphics action.


toggleGraphics

protected Action toggleGraphics
Toggle graphics action.


toggleConsole

protected Action toggleConsole
Toggle graphics action.


exitFramework

protected Action exitFramework
Application closing action.

Constructor Detail

JPFApplication

public JPFApplication(JPF initializer,
                      String title)
Constructs the GUI. This class must be constructed using JPF.

Parameters:
initializer - JPF framework initializing this application
title - title for the application frame
Method Detail

getGraphicsWindow

public BufferedPanel getGraphicsWindow()
Returns the graphics window.


getFrameTitle

public String getFrameTitle()
Returns the title for the framework window.


setFrameTitle

public void setFrameTitle(String title)
Sets the title for the framework window to the given title.

Parameters:
title - title text for the window

normalConsole

public void normalConsole()
Sets the state of an activated console window to normal.


iconifyConsole

public void iconifyConsole()
Sets the state of an activated console window to iconified.


toggleConsole

public void toggleConsole()
Toggles the state of an activated console window between normal and iconified.


clearGraphics

public void clearGraphics()
Clears the graphics window.


isGraphicsVisible

public boolean isGraphicsVisible()
Returns whether or not the graphics window is visible.


setGraphicsVisible

public void setGraphicsVisible(boolean visible)

Sets the visibility of the graphics window.

Does nothing if visibility will not change.

Parameters:
visible - the desired visibility setting

toggleGraphics

public void toggleGraphics()
Toggles the visibility of the graphics window.


exitFramework

protected void exitFramework()
Exits the framework by closing the Java Virtual Machine.


buildButtons

protected void buildButtons()
Builds the buttons.


addOneButton

protected JButton addOneButton(ActionsPanel panel,
                               Action action,
                               String tooltip)
Adds one button with the given action and tool tip to the panel and then returns the button.


getMethodToolTip

protected String getMethodToolTip(Method method)
Returns a tool tip appropriate for this method.


getParameterNames

protected String getParameterNames(Method method)
Returns a String representing the parameters of the method.


buildGUI

protected void buildGUI()
Builds the main panel.


showConsole

protected void showConsole()
Shows the console using color text.


setMethodButtonsEnabled

protected void setMethodButtonsEnabled(boolean enable)
Enable or disable the method buttons.

Parameters:
enable - whether or not to enable.

getMethodList

protected Method[] getMethodList()
Returns a list of the "proper" methods, that is, methods for which we can instantiate buttons in the main GUI. This list may contain nulls.


removeDuplicateVirtualMethods

protected void removeDuplicateVirtualMethods(Method[] methods)
Removes duplicate virtual methods defined in several classes.


isDuplicate

protected boolean isDuplicate(Method method1,
                              Method method2)
Returns true if the two methods have the same signature.


isDuplicateParameterList

protected boolean isDuplicateParameterList(Method method1,
                                           Method method2)
Returns true if the two methods have the same parameter list.


makeActionFromMethod

protected Action makeActionFromMethod(Method method)
Makes a ThreadedAction from the given method.


performAction

protected void performAction(Method method)
Performs the given method and assures that the method calls are synchronized.


handleMethodException

protected void handleMethodException(Throwable exception,
                                     String name)
Handles exception produced by Method invocation.


printExceptionTrace

protected void printExceptionTrace(Throwable exception,
                                   String name)
Prints the exception trace minus references to Java reflection.


performActionUsingGUI

public void performActionUsingGUI(Method method)
Performs the given method using an automatice GUI and assures that the method calls are synchronized.


isSimpleMethod

protected boolean isSimpleMethod(Method method)
Returns true if the method should be converted to a simple button.


isGUIMethod

protected boolean isGUIMethod(Method method)
Returns true if the method should be converted to a button with GUI.


isAcceptableTypeForParameter

protected boolean isAcceptableTypeForParameter(Class c)
Returns true if the type is acceptable for a method parameter.


isAcceptableTypeForReturn

protected boolean isAcceptableTypeForReturn(Class c)
Returns true if the type is acceptable for a method return.


isAcceptableMethodForGUI

protected boolean isAcceptableMethodForGUI(Method method)
Returns true if the parameter types and return type are acceptable for the automatic MethodGUI and if the method is either non-void or has parameters.


getExtraMethods

protected Method[] getExtraMethods(Class c,
                                   Class d)
Gets the methods in Class c that do not come from Class d.


joinMethodArrays

protected Method[] joinMethodArrays(Method[] listA,
                                    Method[] listB)
Joins two Method arrays into one.


isStatic

protected boolean isStatic(Method method)

className

protected static String className(Class c)
Returns the unqualified name of the given Class