edu.neu.ccs.gui
Class FunctionsPlotter

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.gui.BasePane
                          extended byedu.neu.ccs.gui.FunctionsPlotter
All Implemented Interfaces:
Accessible, AlertListener, Displayable, EventListener, ImageObserver, JPTConstants, MalformedDataListener, MenuContainer, Serializable, SwingConstants

public class FunctionsPlotter
extends BasePane

Class FunctionsPlotter is an end-user tool for plotting functions of one parameter. The tool provides two panes:

Functions are plotted in different colors and a MultiColorView object shows which colors are assigned to which functions. Using this view, the user can change the default color settings.

As the mouse moves over the plot window, the world coordinates of its position are displayed in text views below. This allows a user to obtain approximate values for points of interest in the plot.

If the mouse is pressed in the plot window, then the world coordinates of its position will be displayed as an (x,y) pair. Normally, the midpoint of the baseline will be the point that was pressed but if that would cause the (x,y) pair to display outside of the plot pane then the position will be slightly adjusted.

For more fine-grained access to the plot data, a window that shows all plot data points can be displayed.

In 2.6.0, the only public methods are the constructor that creates the panel and the static main method that launches such a panel in a frame. All internal data and methods are protected, however, so a developer may tweak settings in a derived class.

In future releases, we may expose functionality but that is a question that requires further investigation.

Since:
2.6.0
Version:
2.6.0
See Also:
Serialized Form

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
protected  int BORDER
          The empty border thickness used to create space for titled borders.
protected  SimpleFunctionBuilder builder
          The SimpleFunctionBuilder for the functions definition pane.
protected  SimpleAction clearCoordinatesAction
          The action for the button “Clear Coordinates in Plot Pane”.
protected  JButton clearCoordinatesButton
          The button “Show Plot Data Table”.
protected  Color[] colors
          The default colors for the MultiColorView that determines the plot colors for functions.
protected  VTable controlPanel
          The controls table panel that constitutes the left side of the GUI.
protected  Object[] controlStuff
          The ingredients for the controls table panel that constitutes the left side of the GUI.
protected  HTable coordinatesPanel
          The coordinates table panel.
protected  Object[] coordinatesStuff
          The ingredients for the coordinates table panel.
protected  Point2D[][] data
          The plot data that is computed to draw the function plots and that may later be displayed in a data table.
protected  SimpleAction dataAction
          The action for the button “Show Plot Data Table”.
protected  JButton dataButton
          The button “Show Plot Data Table”.
protected  MouseAction exitedAction
          The action for mouse exit from the function plot window that clears the coordinate text views.
protected  int EXTRAGAP
          The extra wide horizontal gap for a data table.
protected  TextFieldView functionNames
          The text field view for function names.
protected  Annotation functionNamesLabel
          The label for the function names text field view.
protected  VTable graphicsPanel
          The plot window plus coordinates table panel.
protected  Object[] graphicsStuff
          The ingredients for the plot window plus coordinates table panel.
protected  boolean hasPlot
          Whether or not there is a plot in the plot window.
protected  Rectangle2D image
          The rectangle for the image coordinates in the plot window.
protected  String[] labels
          The labels for the MultiColorView that determines the plot colors for functions.
protected  int LARGEGAP
          The large gap for outer table panels.
protected  int MAXWIDTH
          The maximum width of a data table.
protected  MouseAction motionAction
          The action for mouse motion in the plot window that converts pixel coordinates to world coordinates and then displays these coordinates in the text views below the function plot window.
protected  MultiColorView multiColorView
          The MultiColorView that determines the plot colors for functions.
protected  String names
          The string with the function names to be plotted.
protected  int NAMESWIDTH
          The width of the field for function names.
protected  VTable parameterPanel
          The table panel for all plot parameters combined.
protected  Object[] parameterStuff
          The ingredients for the table panel for all plot parameters combined.
protected  BaseParser parser
          The parser that will be used to evaluate functions for the purpose of making plots.
protected  int PIXELGAP
          The horizontal gap between data pixels in the plot.
protected  SimpleAction plotAction
          The action for the button “Plot Functions”.
protected  JButton plotButton
          The button “Plot Functions”.
protected  int PLOTINSET
          The amount of inset on all sides of the plot square.
protected  HTable plotPanePanel
          The entire plot pane table panel.
protected  Object[] plotPaneStuff
          The ingredients for the entire plot pane table panel.
protected  int PLOTSIZE
          The size of the main plot square.
protected  PlotTool plottool
          The PlotTool object for doing the plots.
protected  MouseAction pressedAction
          The action for mouse pressed in the plot window that converts pixel coordinates to world coordinates and then displays these coordinates as a text paintable with string (x,y) at the postion of the mouse press.
protected  int SMALLGAP
          The small gap for inner table panels.
protected  Stroke stroke
          The stroke for function plots.
protected  JTabbedPane tabbedPane
          The JTabbedPane that combines the plot pane and the functions definition pane.
protected  int VALUEWIDTH
          The width of fields for numeric values.
protected  BufferedPanel window
          The BufferedPanel for the function plot window.
protected  int WINDOWSIZE
          The size of the full plot square with insets.
protected  Rectangle2D world
          The rectangle for the world coordinates.
protected  DecimalFormat xFormat
          The decimal format to be used for world x-coordinates in the coordinates panel and in any data table.
protected  double xgrid
          The size of the x grid spacing for function plots.
protected  double xmax
          The maximum x-coordinate for function plots.
protected  TextFieldView xMaximum
          The text field view for the maximum x value.
protected  Annotation xMaximumLabel
          The label for the maximum x text field view.
protected  double xmin
          The minimum x-coordinate for function plots.
protected  TextFieldView xMinimum
          The text field view for the minimum x value.
protected  Annotation xMinimumLabel
          The label for the minimum x text field view.
protected  TextFieldView xMouse
          The text field view for the world x-coordinate corresponding to the mouse position.
protected  Annotation xMouseLabel
          The label for the text field view for the world x-coordinate corresponding to the mouse position.
protected  TablePanel xPanel
          The table panel for the minimum and maximum x.
protected  TextFieldView xSpacing
          The text field view for the x grid spacing value.
protected  SimpleAction xSpacingAction
          The action for the x grid spacing check box which enables or disables the corresponding text field view.
protected  BooleanView xSpacingCheckBox
          The x grid spacing check box.
protected  Annotation xSpacingLabel
          The label for the x grid spacing text field view.
protected  HTable xSpacingPanel
          The table panel for the x grid spacing.
protected  Object[] xSpacingStuff
          The ingredients for the table panel for the x grid spacing.
protected  Object[][] xStuff
          The ingredients for the table panel for the minimum and maximum x.
protected  DecimalFormat yFormat
          The decimal format to be used for world y-coordinates in the coordinates panel and in any data table.
protected  double ygrid
          The size of the y grid spacing for function plots.
protected  double ymax
          The maximum y-coordinate for function plots.
protected  TextFieldView yMaximum
          The text field view for the maximum y value.
protected  Annotation yMaximumLabel
          The label for the maximum y text field view.
protected  double ymin
          The minimum y-coordinate for function plots.
protected  TextFieldView yMinimum
          The text field view for the minimum y value.
protected  Annotation yMinimumLabel
          The label for the minimum y text field view.
protected  TextFieldView yMouse
          The text field view for the world y-coordinate corresponding to the mouse position.
protected  Annotation yMouseLabel
          The label for the text field view for the world y-coordinate corresponding to the mouse position.
protected  TablePanel yPanel
          The table panel for the minimum and maximum y.
protected  SimpleAction yScalingAction
          The action for the y scaling check box which enables or disables the corresponding text field views.
protected  BooleanView yScalingCheckBox
          The y scaling check box.
protected  TextFieldView ySpacing
          The text field view for the y grid spacing value.
protected  SimpleAction ySpacingAction
          The action for the y grid spacing check box which enables or disables the corresponding text field view.
protected  BooleanView ySpacingCheckBox
          The y grid spacing check box.
protected  Annotation ySpacingLabel
          The label for the y grid spacing text field view.
protected  HTable ySpacingPanel
          The table panel for the y grid spacing.
protected  Object[] ySpacingStuff
          The ingredients for the table panel for the y grid spacing.
protected  Object[][] yStuff
          The ingredients for the table panel for the minimum and maximum y.
 
Fields inherited from class edu.neu.ccs.gui.BasePane
baseFontSize, buttonFont, DEFAULT_BASE_FONT_SIZE, fieldFont, fontSize, gap, labelFont, largeFieldWidth, mediumFieldWidth, MINIMUM_FONT_SIZE, monospacedFontName, sansserifFontName, serifFontName, smallFieldWidth
 
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.gui.Displayable
DEFAULT_VIEW_STATE, VIEW_STATE
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
FunctionsPlotter()
          The FunctionsPlotter constructor creates the tabbed pane that contains the plot pane and the functions definition pane.
 
Method Summary
protected  void clearCoordinates()
          Clear the coordinate labels in the plot window.
protected  void clearMouseXY()
          The method for mouse exit from the function plot window that clears the coordinate text views.
protected  String formatDouble(double z, DecimalFormat zFormat)
          Return the formatted double using the given format string.
protected  void FunctionError(String message)
          Show a dialog with an error regarding a plot function.
protected  void GridSpacingError(char c)
          Show a dialog box with an error for x or y grid spacing.
protected  void initializeFunctionsPlotter()
          This helper method handles all initialzations for the constructor that cannot be done inline in the member data declarations.
static void main(String[] args)
          The main method that launches a FunctionsPlotter in its own frame.
protected  PaintableComponent makeDataTable()
          The helper method for the button “Show Plot Data Table”.
protected  String makeFormatString(double pixel)
          Return a fixed point format string that is optimum for distinguishing the given pixel thickness.
protected  void motionMethod(MouseEvent event)
          The method for mouse motion in the plot window that converts pixel coordinates to world coordinates and then displays these coordinates in the text views below the function plot window.
protected  void plotData()
          The helper method for the button “Plot Functions”.
protected  void PlotLimitError(char c)
          Show a dialog box with an error for x or y plot limits.
protected  void plotMethod()
          The method for the button “Plot Functions”.
protected  void pressedMethod(MouseEvent event)
          The method for mouse pressed in the plot window that converts pixel coordinates to world coordinates and then displays these coordinates as a text paintable with string (x,y) at the postion of the mouse press.
protected  void setDecimalFormats()
          Set the x and y decimal format strings at the optimum number of decimal places needed to distinguish pixel positions translated to world coordinates.
protected  void showDataTable()
          The method for the button “Show Plot Data Table”.
protected  void xSpacingMethod()
          The method for the x grid spacing check box which enables or disables the corresponding text field view.
protected  void yScalingMethod()
          The method for the y scaling check box which enables or disables the corresponding text field views.
protected  void ySpacingMethod()
          The method for the y grid spacing check box which enables or disables the corresponding text field view.
 
Methods inherited from class edu.neu.ccs.gui.BasePane
getButtonFont, getFieldFont, getFontSize, getGap, getLabelFont, getLargeFieldWidth, getMediumFieldWidth, getSmallFieldWidth, initializeBasePane
 
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

SMALLGAP

protected int SMALLGAP
The small gap for inner table panels.


LARGEGAP

protected int LARGEGAP
The large gap for outer table panels.


EXTRAGAP

protected int EXTRAGAP
The extra wide horizontal gap for a data table.


BORDER

protected int BORDER
The empty border thickness used to create space for titled borders.


VALUEWIDTH

protected int VALUEWIDTH
The width of fields for numeric values.


NAMESWIDTH

protected int NAMESWIDTH
The width of the field for function names.


PLOTSIZE

protected int PLOTSIZE
The size of the main plot square.


PLOTINSET

protected int PLOTINSET
The amount of inset on all sides of the plot square.


WINDOWSIZE

protected int WINDOWSIZE
The size of the full plot square with insets.


PIXELGAP

protected int PIXELGAP

The horizontal gap between data pixels in the plot.

In 2.6.0, this gap is set to 1, so plots are dense.


MAXWIDTH

protected int MAXWIDTH
The maximum width of a data table.


functionNames

protected TextFieldView functionNames
The text field view for function names.


xMinimum

protected TextFieldView xMinimum
The text field view for the minimum x value.


xMaximum

protected TextFieldView xMaximum
The text field view for the maximum x value.


xSpacing

protected TextFieldView xSpacing
The text field view for the x grid spacing value.


yMinimum

protected TextFieldView yMinimum
The text field view for the minimum y value.


yMaximum

protected TextFieldView yMaximum
The text field view for the maximum y value.


ySpacing

protected TextFieldView ySpacing
The text field view for the y grid spacing value.


functionNamesLabel

protected Annotation functionNamesLabel
The label for the function names text field view.


xMinimumLabel

protected Annotation xMinimumLabel
The label for the minimum x text field view.


xMaximumLabel

protected Annotation xMaximumLabel
The label for the maximum x text field view.


xSpacingLabel

protected Annotation xSpacingLabel
The label for the x grid spacing text field view.


yMinimumLabel

protected Annotation yMinimumLabel
The label for the minimum y text field view.


yMaximumLabel

protected Annotation yMaximumLabel
The label for the maximum y text field view.


ySpacingLabel

protected Annotation ySpacingLabel
The label for the y grid spacing text field view.


yScalingAction

protected SimpleAction yScalingAction
The action for the y scaling check box which enables or disables the corresponding text field views.


yScalingCheckBox

protected BooleanView yScalingCheckBox
The y scaling check box.


xSpacingAction

protected SimpleAction xSpacingAction
The action for the x grid spacing check box which enables or disables the corresponding text field view.


xSpacingCheckBox

protected BooleanView xSpacingCheckBox
The x grid spacing check box.


ySpacingAction

protected SimpleAction ySpacingAction
The action for the y grid spacing check box which enables or disables the corresponding text field view.


ySpacingCheckBox

protected BooleanView ySpacingCheckBox
The y grid spacing check box.


xStuff

protected Object[][] xStuff
The ingredients for the table panel for the minimum and maximum x.


xPanel

protected TablePanel xPanel
The table panel for the minimum and maximum x.


yStuff

protected Object[][] yStuff
The ingredients for the table panel for the minimum and maximum y.


yPanel

protected TablePanel yPanel
The table panel for the minimum and maximum y.


xSpacingStuff

protected Object[] xSpacingStuff
The ingredients for the table panel for the x grid spacing.


xSpacingPanel

protected HTable xSpacingPanel
The table panel for the x grid spacing.


ySpacingStuff

protected Object[] ySpacingStuff
The ingredients for the table panel for the y grid spacing.


ySpacingPanel

protected HTable ySpacingPanel
The table panel for the y grid spacing.


parameterStuff

protected Object[] parameterStuff
The ingredients for the table panel for all plot parameters combined.


parameterPanel

protected VTable parameterPanel
The table panel for all plot parameters combined.


colors

protected Color[] colors
The default colors for the MultiColorView that determines the plot colors for functions.


labels

protected String[] labels
The labels for the MultiColorView that determines the plot colors for functions.


multiColorView

protected MultiColorView multiColorView
The MultiColorView that determines the plot colors for functions.


plotAction

protected SimpleAction plotAction

The action for the button “Plot Functions”.


plotButton

protected JButton plotButton

The button “Plot Functions”.


dataAction

protected SimpleAction dataAction

The action for the button “Show Plot Data Table”.


dataButton

protected JButton dataButton

The button “Show Plot Data Table”.


clearCoordinatesAction

protected SimpleAction clearCoordinatesAction

The action for the button “Clear Coordinates in Plot Pane”.


clearCoordinatesButton

protected JButton clearCoordinatesButton

The button “Show Plot Data Table”.


controlStuff

protected Object[] controlStuff
The ingredients for the controls table panel that constitutes the left side of the GUI.


controlPanel

protected VTable controlPanel
The controls table panel that constitutes the left side of the GUI.


window

protected BufferedPanel window
The BufferedPanel for the function plot window.


motionAction

protected MouseAction motionAction

The action for mouse motion in the plot window that converts pixel coordinates to world coordinates and then displays these coordinates in the text views below the function plot window.

This mouse action will be performed whether or not the mouse button is pressed.

This mouse action does nothing if there is no plot in the function plot pane.


pressedAction

protected MouseAction pressedAction

The action for mouse pressed in the plot window that converts pixel coordinates to world coordinates and then displays these coordinates as a text paintable with string (x,y) at the postion of the mouse press.

This mouse action does nothing if there is no plot in the function plot pane.


exitedAction

protected MouseAction exitedAction
The action for mouse exit from the function plot window that clears the coordinate text views.


xMouse

protected TextFieldView xMouse
The text field view for the world x-coordinate corresponding to the mouse position.


yMouse

protected TextFieldView yMouse
The text field view for the world y-coordinate corresponding to the mouse position.


xMouseLabel

protected Annotation xMouseLabel
The label for the text field view for the world x-coordinate corresponding to the mouse position.


yMouseLabel

protected Annotation yMouseLabel
The label for the text field view for the world y-coordinate corresponding to the mouse position.


coordinatesStuff

protected Object[] coordinatesStuff
The ingredients for the coordinates table panel.


coordinatesPanel

protected HTable coordinatesPanel
The coordinates table panel.


graphicsStuff

protected Object[] graphicsStuff
The ingredients for the plot window plus coordinates table panel.


graphicsPanel

protected VTable graphicsPanel
The plot window plus coordinates table panel.


plotPaneStuff

protected Object[] plotPaneStuff
The ingredients for the entire plot pane table panel.


plotPanePanel

protected HTable plotPanePanel
The entire plot pane table panel.


builder

protected SimpleFunctionBuilder builder
The SimpleFunctionBuilder for the functions definition pane.


tabbedPane

protected JTabbedPane tabbedPane
The JTabbedPane that combines the plot pane and the functions definition pane.


parser

protected BaseParser parser
The parser that will be used to evaluate functions for the purpose of making plots.


xFormat

protected DecimalFormat xFormat

The decimal format to be used for world x-coordinates in the coordinates panel and in any data table.

This format is dynamically constructed based on the actual data being plotted.


yFormat

protected DecimalFormat yFormat

The decimal format to be used for world y-coordinates in the coordinates panel and in any data table.

This format is dynamically constructed based on the actual data being plotted.


hasPlot

protected boolean hasPlot

Whether or not there is a plot in the plot window.

If this boolean is true, then there is data available to display in a data table.


plottool

protected PlotTool plottool
The PlotTool object for doing the plots.


world

protected Rectangle2D world
The rectangle for the world coordinates.


image

protected Rectangle2D image
The rectangle for the image coordinates in the plot window.


stroke

protected Stroke stroke
The stroke for function plots.


data

protected Point2D[][] data
The plot data that is computed to draw the function plots and that may later be displayed in a data table.


names

protected String names

The string with the function names to be plotted.

Extracted from the GUI.


xmin

protected double xmin

The minimum x-coordinate for function plots.

Extracted from the GUI.


xmax

protected double xmax

The maximum x-coordinate for function plots.

Extracted from the GUI.


ymin

protected double ymin

The minimum y-coordinate for function plots.

Auto-computed or extracted from the GUI.


ymax

protected double ymax

The maximum y-coordinate for function plots.

Auto-computed or extracted from the GUI.


xgrid

protected double xgrid

The size of the x grid spacing for function plots.

Auto-computed or extracted from the GUI.


ygrid

protected double ygrid

The size of the y grid spacing for function plots.

Auto-computed or extracted from the GUI.

Constructor Detail

FunctionsPlotter

public FunctionsPlotter()

The FunctionsPlotter constructor creates the tabbed pane that contains the plot pane and the functions definition pane.

Method Detail

initializeFunctionsPlotter

protected void initializeFunctionsPlotter()
This helper method handles all initialzations for the constructor that cannot be done inline in the member data declarations.


yScalingMethod

protected void yScalingMethod()
The method for the y scaling check box which enables or disables the corresponding text field views.


xSpacingMethod

protected void xSpacingMethod()
The method for the x grid spacing check box which enables or disables the corresponding text field view.


ySpacingMethod

protected void ySpacingMethod()
The method for the y grid spacing check box which enables or disables the corresponding text field view.


plotMethod

protected void plotMethod()

The method for the button “Plot Functions”.

Clears any previous plot and its data.

Extracts user input from the GUI including function names, x,y bounds, and x,y grid spacing. If an error is detected, shows a dialog and then returns.

Creates the mathematical data for the plots. This data is saved in case the user wishes to view the data table.

Determines the bounds in world coordinates.

Determines the optimal fixed-point decimal formats separately for x and y data values for use with the coordinates panel and with a data table.

Calls plotData to perform the plot.


plotData

protected void plotData()

The helper method for the button “Plot Functions”.

Utilizes the tools in class PlotTool.

Determines the transform from world to image coordinates.

Plots grids based either on user settings or by automatic means.

Plots axes if visible in the plot region.

Plots the function data using the color choices selected in the GUI to distinguish various functions.


showDataTable

protected void showDataTable()

The method for the button “Show Plot Data Table”.

Calls makeDataTable to place the plot data for the functions into a PaintableComponent.

Inserts the PaintableComponent into a JPTScrollPane.

Inserts the JPTScrollPane into a GeneralDialog which is then displayed.


makeDataTable

protected PaintableComponent makeDataTable()

The helper method for the button “Show Plot Data Table”.

Column 0 has the x-coordinate of a plot point. The remaining columns have the y-coordinates of the function values at the common x-coordinate position.

The top and bottom rows have column labels with “x” in column 0 and the function names in the remaining columns.

Technically, the data table is constructed with a huge PaintableSequence that contains one TextPaintable for each item in the table. This PaintableSequence is then placed in a PaintableComponent which is the component that is returned. The perforance for this design is much, much faster than alternate approaches that we tested.


setDecimalFormats

protected void setDecimalFormats()
Set the x and y decimal format strings at the optimum number of decimal places needed to distinguish pixel positions translated to world coordinates.


makeFormatString

protected String makeFormatString(double pixel)
Return a fixed point format string that is optimum for distinguishing the given pixel thickness.

Parameters:
pixel - the pixel thickness in world coordinates

formatDouble

protected String formatDouble(double z,
                              DecimalFormat zFormat)

Return the formatted double using the given format string.

Nan is returned as "Nan".

POSITIVE_INFINITY is returned as "+Infinity".

NEGATIVE_INFINITY is returned as "-Infinity".

Parameters:
z - the double to format
zFormat - the format string

PlotLimitError

protected void PlotLimitError(char c)
Show a dialog box with an error for x or y plot limits.

Parameters:
c - either 'x' or 'y'

GridSpacingError

protected void GridSpacingError(char c)
Show a dialog box with an error for x or y grid spacing.

Parameters:
c - either 'x' or 'y'

FunctionError

protected void FunctionError(String message)
Show a dialog with an error regarding a plot function.

Parameters:
message - the error message

motionMethod

protected void motionMethod(MouseEvent event)

The method for mouse motion in the plot window that converts pixel coordinates to world coordinates and then displays these coordinates in the text views below the function plot window.

This method displays the data using the x and y format strings.

This method will be performed whether or not the mouse button is pressed.

This method does nothing if there is no plot in the function plot pane.


pressedMethod

protected void pressedMethod(MouseEvent event)

The method for mouse pressed in the plot window that converts pixel coordinates to world coordinates and then displays these coordinates as a text paintable with string (x,y) at the postion of the mouse press.

This method displays the data using the x and y format strings.

This method does nothing if there is no plot in the function plot pane.


clearMouseXY

protected void clearMouseXY()

The method for mouse exit from the function plot window that clears the coordinate text views.

Since this method does not require a MouseEvent parameter, it may also be called directly when needed.


clearCoordinates

protected void clearCoordinates()
Clear the coordinate labels in the plot window.


main

public static void main(String[] args)
The main method that launches a FunctionsPlotter in its own frame.

Parameters:
args - ignored