|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
edu.neu.ccs.gui.DisplayPanel
edu.neu.ccs.gui.BasePane
edu.neu.ccs.gui.FunctionsPlotter
Class FunctionsPlotter is an end-user tool for
plotting functions of one parameter. The tool provides two panes:
JPTParser.
This function definition pane is implemented using a
SimpleFunctionBuilder object.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.
| 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 javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected int SMALLGAP
protected int LARGEGAP
protected int EXTRAGAP
protected int BORDER
protected int VALUEWIDTH
protected int NAMESWIDTH
protected int PLOTSIZE
protected int PLOTINSET
protected int WINDOWSIZE
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.
protected int MAXWIDTH
protected TextFieldView functionNames
protected TextFieldView xMinimum
protected TextFieldView xMaximum
protected TextFieldView xSpacing
protected TextFieldView yMinimum
protected TextFieldView yMaximum
protected TextFieldView ySpacing
protected Annotation functionNamesLabel
protected Annotation xMinimumLabel
protected Annotation xMaximumLabel
protected Annotation xSpacingLabel
protected Annotation yMinimumLabel
protected Annotation yMaximumLabel
protected Annotation ySpacingLabel
protected SimpleAction yScalingAction
protected BooleanView yScalingCheckBox
protected SimpleAction xSpacingAction
protected BooleanView xSpacingCheckBox
protected SimpleAction ySpacingAction
protected BooleanView ySpacingCheckBox
protected Object[][] xStuff
protected TablePanel xPanel
protected Object[][] yStuff
protected TablePanel yPanel
protected Object[] xSpacingStuff
protected HTable xSpacingPanel
protected Object[] ySpacingStuff
protected HTable ySpacingPanel
protected Object[] parameterStuff
protected VTable parameterPanel
protected Color[] colors
MultiColorView
that determines the plot colors for functions.
protected String[] labels
MultiColorView
that determines the plot colors for functions.
protected MultiColorView multiColorView
MultiColorView
that determines the plot colors for functions.
protected SimpleAction plotAction
The action for the button “Plot Functions”.
protected JButton plotButton
The button “Plot Functions”.
protected SimpleAction dataAction
The action for the button “Show Plot Data Table”.
protected JButton dataButton
The button “Show Plot Data Table”.
protected SimpleAction clearCoordinatesAction
The action for the button “Clear Coordinates in Plot Pane”.
protected JButton clearCoordinatesButton
The button “Show Plot Data Table”.
protected Object[] controlStuff
protected VTable controlPanel
protected BufferedPanel window
BufferedPanel for the function plot
window.
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.
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.
protected MouseAction exitedAction
protected TextFieldView xMouse
protected TextFieldView yMouse
protected Annotation xMouseLabel
protected Annotation yMouseLabel
protected Object[] coordinatesStuff
protected HTable coordinatesPanel
protected Object[] graphicsStuff
protected VTable graphicsPanel
protected Object[] plotPaneStuff
protected HTable plotPanePanel
protected SimpleFunctionBuilder builder
SimpleFunctionBuilder for the
functions definition pane.
protected JTabbedPane tabbedPane
JTabbedPane that combines
the plot pane and the functions definition pane.
protected BaseParser parser
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.
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.
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.
protected PlotTool plottool
PlotTool object for doing the plots.
protected Rectangle2D world
protected Rectangle2D image
protected Stroke stroke
protected Point2D[][] data
protected String names
The string with the function names to be plotted.
Extracted from the GUI.
protected double xmin
The minimum x-coordinate for function plots.
Extracted from the GUI.
protected double xmax
The maximum x-coordinate for function plots.
Extracted from the GUI.
protected double ymin
The minimum y-coordinate for function plots.
Auto-computed or extracted from the GUI.
protected double ymax
The maximum y-coordinate for function plots.
Auto-computed or extracted from the GUI.
protected double xgrid
The size of the x grid spacing for function plots.
Auto-computed or extracted from the GUI.
protected double ygrid
The size of the y grid spacing for function plots.
Auto-computed or extracted from the GUI.
| Constructor Detail |
public FunctionsPlotter()
The FunctionsPlotter constructor creates the tabbed pane
that contains the plot pane and the functions definition pane.
| Method Detail |
protected void initializeFunctionsPlotter()
protected void yScalingMethod()
protected void xSpacingMethod()
protected void ySpacingMethod()
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.
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.
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.
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.
protected void setDecimalFormats()
protected String makeFormatString(double pixel)
pixel - the pixel thickness in world coordinates
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".
z - the double to formatzFormat - the format stringprotected void PlotLimitError(char c)
c - either 'x' or 'y'protected void GridSpacingError(char c)
c - either 'x' or 'y'protected void FunctionError(String message)
message - the error messageprotected 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.
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.
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.
protected void clearCoordinates()
public static void main(String[] args)
FunctionsPlotter
in its own frame.
args - ignored
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||