org.freehep.swing.graphics
Class BackedPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.freehep.swing.graphics.BackedPanel
- All Implemented Interfaces:
- Accessible, ImageObserver, MenuContainer, Serializable
- Direct Known Subclasses:
- Canvas3D
- public class BackedPanel
- extends JPanel
- implements Serializable
This class extends JPanel by adding a backing store. This is
intended to be used in situations in which redrawing the contents
of the panel is extremely expensive.
To keep things simple, this component does NOT support borders. If
a border is desired, then this component should be embedded within
another container which has one.
Likewise, children components should NOT be added to this
component.
- Version:
- $Id: BackedPanel.java,v 1.7 2004/01/16 23:05:11 duns Exp $
- Author:
- Charles Loomis, Mark Donszelmann
- See Also:
- Serialized Form
- Source Code:
- BackedPanel.java
Constructor Summary |
BackedPanel(boolean opaque)
Creates a new BackedPanel with a width and height set to zero,
and the backing image and graphics object to null. |
Method Summary |
Graphics |
getGraphics()
Return the graphics object for the backing image. |
Object |
getLock()
Get the object which acts as a lock on the backing image.
|
void |
paintBorder(Graphics g)
Since this component does not support borders, override this
method to do nothing. |
void |
paintChildren(Graphics g)
Since this component should not contain children, override this
method to do nothing. |
void |
paintComponent(Graphics g)
Paint this panel by flushing the backing image to the screen. |
void |
printBorder(Graphics g)
Since this component does not support borders, override this
method to do nothing. |
void |
printChildren(Graphics g)
Since this component should not contain children, override this
method to do nothing. |
void |
printComponent(Graphics g)
Printing should be handled directly by the component which
paints into the backing store. |
void |
setBorder(Border border)
This component does not support borders. |
void |
setBounds(int x,
int y,
int w,
int h)
Resize and move a component. |
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, 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, paintImmediately, paintImmediately, print, printAll, 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, 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, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
backingImage
protected BufferedImage backingImage
- The backing image itself.
clip
protected Rectangle clip
- Rectangle to hold the clipping bounds.
BackedPanel
public BackedPanel(boolean opaque)
- Creates a new BackedPanel with a width and height set to zero,
and the backing image and graphics object to null. By default,
the Swing double buffering is turned off (since we're writing
to a backing image anyway). The caller of this constructor
selects whether this is a transparent or opaque panel.
- Parameters:
opaque
- transparent panel
getGraphics
public Graphics getGraphics()
- Return the graphics object for the backing image. All drawing
goes to this image first. Only on a repaint() is the image
flushed to the screen.
- Returns:
- Graphics of backing image
getLock
public Object getLock()
- Get the object which acts as a lock on the backing image.
Drawing to the graphics context supplied by getGraphics() or
the image returned from getBackingImage() should be
synchronized to this object.
- Returns:
- lock for the backing image
paintComponent
public void paintComponent(Graphics g)
- Paint this panel by flushing the backing image to the screen.
- Parameters:
g
- Graphics object to draw backing store into
paintBorder
public void paintBorder(Graphics g)
- Since this component does not support borders, override this
method to do nothing.
- Parameters:
g
- ignored Graphics context
paintChildren
public void paintChildren(Graphics g)
- Since this component should not contain children, override this
method to do nothing.
- Parameters:
g
- ignored Graphics context
printComponent
public void printComponent(Graphics g)
- Printing should be handled directly by the component which
paints into the backing store. Hence, this method does
nothing.
- Parameters:
g
- ignored Graphics context
printBorder
public void printBorder(Graphics g)
- Since this component does not support borders, override this
method to do nothing.
- Parameters:
g
- ignored Graphics context
printChildren
public void printChildren(Graphics g)
- Since this component should not contain children, override this
method to do nothing.
- Parameters:
g
- ignored Graphics context
setBorder
public final void setBorder(Border border)
- This component does not support borders. If this method is
called with any non-null argument, then an
IllegalArgumentException is thrown. If a border is desired,
then this component should be embedded within another container
which has one.
- Parameters:
border
- must be null
setBounds
public void setBounds(int x,
int y,
int w,
int h)
- Resize and move a component.
Copyright © 2000-2004 FreeHEP, All Rights Reserved.