MVT API

mvt.tools
Class GraphicsPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--mvt.tools.ToolPanel
                                |
                                +--mvt.tools.GraphicsPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable
Direct Known Subclasses:
Graphics2DPanel, Graphics3DPanel

public abstract class GraphicsPanel
extends ToolPanel
implements java.awt.print.Printable

GraphicsPanel is an abstract class that takes much of the similarities of Graphics2DPanel and Graphics3DPanel an puts them in one place. It holds onto the "only" copies of input and plot panels, holds the listeners for plot and clear buttons, as well as takes * care of saving GIF images and printing.

Since:
JDK1.2
Author:
Darin Gillis
, for the Mathematical Visualization Project for the Department of Applied Mathematics, University of Colorado at Boulder
See Also:
Serialized Form

Nested Class Summary
 class GraphicsPanel.ImageFilter
          This class that gets the *.gif option to pop up in the JFileChooser Dialog.
 class GraphicsPanel.PrintHandler
           
 class GraphicsPanel.PrintPreviewHandler
           
 class GraphicsPanel.SaveHandler
           
 
Nested classes inherited from class mvt.tools.ToolPanel
ToolPanel.CloseListener, ToolPanel.HelpListener, ToolPanel.MenuChangeListener, ToolPanel.OptionsListener
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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 java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GraphicsPanel(java.lang.String toolTitle, PlotPanel plotPanel, InputPanel inputPanel, OptionsPanel optionsPanel)
          Constructor for this graphics panel, the superclass of any 3D or 2D plotting tool.
 
Method Summary
 void buildMenu(javax.swing.JInternalFrame owner)
          Overriding this method will give the that object control over the layout of the menu bar.
 void calculatePlotBounds(java.util.Map data)
          This function is called after the GraphicsComponents has been constructed; in order to set the correct default range.
 java.util.Map collectInput()
           
abstract  GraphicsComponent createGraphicsComponent()
          Predcondition: verifyInput() has been called before this function gets called.
 InputPanel getInputPanel()
          Get the InputPanel for this tool.
 PlotPanel getPlotPanel()
          Get the PlotPanel for this tool.
 VariableSet getStatedVariables()
          This function retrieves the variables from the variable name boxes in either the InputPanel or OptionsPanel.
 int print(java.awt.Graphics pg, java.awt.print.PageFormat pageFormat, int pageIndex)
          Called by Java internally to print the graphics context
 void printPlot()
          Called when the user requests a print
 void savePicture()
          Performs the following: creates a gif image attempts to save the gif to a file
 void setVariables(VariableSet vars)
          This function updates all the labels in each panel, reflecting a change in the variable name.
 void updatePlot()
          Adds the tool's generated object to the PlotPanel, as long as there were no difficulties in creating the GraphicsComponent.
abstract  java.util.Map verifyInput()
          This function parses all of the data collected from the input panel, checks the validity of the input, and then stores the data in this tool's private attributes.
 
Methods inherited from class mvt.tools.ToolPanel
errorMessage, getActiveToolPanel, getOptionsPanel, getTitle, pack
 
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, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, 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, remove, remove, removeAll, 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
 

Constructor Detail

GraphicsPanel

public GraphicsPanel(java.lang.String toolTitle,
                     PlotPanel plotPanel,
                     InputPanel inputPanel,
                     OptionsPanel optionsPanel)
Constructor for this graphics panel, the superclass of any 3D or 2D plotting tool. If there is one plotpanel, inputpanel and options panel, use this constructor.

Method Detail

buildMenu

public void buildMenu(javax.swing.JInternalFrame owner)
Overriding this method will give the that object control over the layout of the menu bar. If you would like to add an option, override buildMenu(), call super.buildMenu() and then access the menubar with frame.getJMenuBar().

Overrides:
buildMenu in class ToolPanel

getPlotPanel

public PlotPanel getPlotPanel()
Get the PlotPanel for this tool.


getInputPanel

public InputPanel getInputPanel()
Get the InputPanel for this tool.


collectInput

public java.util.Map collectInput()
                           throws SyntaxException
SyntaxException

createGraphicsComponent

public abstract GraphicsComponent createGraphicsComponent()
Predcondition: verifyInput() has been called before this function gets called. This gives the tool the most current information from the InputPanel & OptionsPanel to work from. This function will create a GraphicsComponent from the data in the tool's private attributes; the attributes are filled in by the verifyInput() method.


verifyInput

public abstract java.util.Map verifyInput()
                                   throws java.lang.Exception
This function parses all of the data collected from the input panel, checks the validity of the input, and then stores the data in this tool's private attributes. The createGraphicsObject() method uses the data stored in the private attributes.

java.lang.Exception

calculatePlotBounds

public void calculatePlotBounds(java.util.Map data)
This function is called after the GraphicsComponents has been constructed; in order to set the correct default range. If and explicit range has been set, then it is used. By default, it takes care of setting the one-to-one ratio found in many 2D tools. (3D tools have no such option)


getStatedVariables

public VariableSet getStatedVariables()
This function retrieves the variables from the variable name boxes in either the InputPanel or OptionsPanel. This will return null if there is a bad variable in one of the boxes. On success, it will return a list of the variables used by the tool.


setVariables

public void setVariables(VariableSet vars)
This function updates all the labels in each panel, reflecting a change in the variable name.


updatePlot

public void updatePlot()
Adds the tool's generated object to the PlotPanel, as long as there were no difficulties in creating the GraphicsComponent. Primarily this code originates from a Plot Button Click.


printPlot

public void printPlot()
Called when the user requests a print


print

public int print(java.awt.Graphics pg,
                 java.awt.print.PageFormat pageFormat,
                 int pageIndex)
          throws java.awt.print.PrinterException
Called by Java internally to print the graphics context

Specified by:
print in interface java.awt.print.Printable
java.awt.print.PrinterException

savePicture

public void savePicture()
Performs the following:
  • creates a gif image
  • attempts to save the gif to a file


  • MVT API

    mvt.icons