FreeHEP API
Version current

org.freehep.swing.graphics
Class BackedPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byorg.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

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  BufferedImage backingImage
          The backing image itself.
protected  Rectangle clip
          Rectangle to hold the clipping bounds.
 
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.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
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.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, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

backingImage

protected BufferedImage backingImage
The backing image itself.


clip

protected Rectangle clip
Rectangle to hold the clipping bounds.

Constructor Detail

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
Method Detail

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.


FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.