edu.rit.numeric.plot
Class DisplayablePanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
edu.rit.numeric.plot.DisplayablePanel
- All Implemented Interfaces:
- ImageObserver, MenuContainer, Serializable, Accessible
public class DisplayablePanel
- extends JPanel
Class DisplayablePanel is a Swing JPanel that displays a Displayable object. The displayable panel can then be made part
of a Swing GUI.
The displayable object is specified when the displayable panel is
constructed. A different displayable object can be specified later using the
display() method. The displayable panel's preferred size and the
displayable panel's bounds are set to the size of the displayable object when
the displayable panel is constructed and when the display() method
is called. If the same displayable panel will be displaying different
displayable objects, consider embedding the displayable panel in a
JScrollPane so the whole displayable object can be scrolled into view if the
displayable object becomes larger.
If the autofitting flag is true (see setAutofitting()), the
displayable panel will display a scaled version of the displayable object,
such that the displayable object is completely visible within the displayable
panel's current size.
Right-clicking on the displayable panel displays a popup menu for saving the
displayable object as a PNG file or a PostScript file.
- See Also:
- Serialized Form
|
Method Summary |
Displayable |
display()
Obtain this displayable panel's displayable object. |
void |
display(Displayable theDisplayable)
Tell this displayable panel to display the given displayable object. |
void |
doSaveAsPng()
Save this displayable panel's displayable object in a PNG file. |
void |
doSaveAsPostScript()
Save this displayable panel's displayable object in a PostScript file. |
boolean |
isAutofitting()
Determine whether this displayable panel is autofitting. |
protected void |
paintComponent(Graphics g)
Paint this displayable panel into the given graphics context. |
void |
setAutofitting(boolean autofit)
Set this displayable panel's autofitting flag to the given value. |
| Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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 |
DisplayablePanel
public DisplayablePanel(Displayable theDisplayable)
- Construct a new displayable panel. The displayable panel's preferred size
and bounds are set to the size of theDisplayable. The
displayable panel will use its own internal file chooser to select files
to save.
- Parameters:
theDisplayable - Displayable object.
- Throws:
NullPointerException - (unchecked exception) Thrown if theDisplayable is null.
DisplayablePanel
public DisplayablePanel(Displayable theDisplayable,
FileSaveChooser theChooser)
- Construct a new displayable panel. The displayable panel's preferred size
and bounds are set to the size of theDisplayable. The
displayable panel will use theChooser to select files to save.
- Parameters:
theDisplayable - Displayable object.theChooser - File save chooser.
- Throws:
NullPointerException - (unchecked exception) Thrown if theDisplayable is null or
theChooser is null.
display
public Displayable display()
- Obtain this displayable panel's displayable object.
- Returns:
- Displayable object this displayable panel is displaying.
display
public void display(Displayable theDisplayable)
- Tell this displayable panel to display the given displayable object.
- Parameters:
theDisplayable - Displayable object.
- Throws:
NullPointerException - (unchecked exception) Thrown if theDisplayable is null.
isAutofitting
public boolean isAutofitting()
- Determine whether this displayable panel is autofitting.
- Returns:
- True if this displayable panel is autofitting, false otherwise.
setAutofitting
public void setAutofitting(boolean autofit)
- Set this displayable panel's autofitting flag to the given value. If the
autofitting flag is true, the displayable panel will display a scaled
version of the displayable object, such that the displayable object is
completely visible within the displayable panel's current size.
- Parameters:
autofit - True to autofit, false otherwise.
doSaveAsPng
public void doSaveAsPng()
- Save this displayable panel's displayable object in a PNG file. A
JFileChooser dialog is displayed to prompt the user to choose the file to
save.
doSaveAsPostScript
public void doSaveAsPostScript()
- Save this displayable panel's displayable object in a PostScript file. A
JFileChooser dialog is displayed to prompt the user to choose the file to
save.
paintComponent
protected void paintComponent(Graphics g)
- Paint this displayable panel into the given graphics context.
- Overrides:
paintComponent in class JComponent
- Parameters:
g - Graphics context.
Copyright © 2005 by Alan Kaminsky. All rights reserved. Send comments to ark@cs.rit.edu.