FreeHEP API
Version v1.2.2

org.freehep.graphics2d
Class BufferedPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--org.freehep.graphics2d.BufferedPanel
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
PSPanel

public class BufferedPanel
extends JPanel
implements Serializable

This class extends JPanel by adding double buffering. This is intended to be used in situations in which redrawing the contents of the panel is expensive.

Version:
$Id: BufferedPanel.java,v 1.2 2003/11/22 08:03:36 duns Exp $
Author:
Mark Donszelmann
See Also:
Serialized Form

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.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
BufferedPanel(boolean opaque)
          Creates a new BufferedPanel with a width and height set to zero.
 
Method Summary
 Graphics getGraphics()
          Returns a pointer to the graphics (VectorGraphics) context of the buffer.
 void invalidate()
          Triggers a full repaint, since the component is not valid anymore (size change, iconized, ...)
 boolean isDisplaying()
          Returns true if the drawing is made for a PixelGraphics context, the display.
 boolean isExporting()
          Returns true if the drawing is made for a VectorGraphics context.
 boolean isPrinting()
          Returns true if the drawing is made for a PrinterGraphics context.
 void paintComponent(Graphics g)
          Paint this panel by calling paintComponent(VectorGraphics) if necessary and flushing the buffered image to the screen.
 void paintComponent(VectorGraphics vg)
          Allows for custom graphics to be painted.
 void repaint()
          Triggers a full "user" repaint.
 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, paintBorder, paintChildren, 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, 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, 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
 

Constructor Detail

BufferedPanel

public BufferedPanel(boolean opaque)
Creates a new BufferedPanel with a width and height set to zero.

Parameters:
opaque - transparent panel
Method Detail

repaint

public void repaint()
Triggers a full "user" repaint. If the "system" wants to repaint it will call the paint(Graphics) method directly, rather than scheduling a paint(Graphics) through a repaint().

Overrides:
repaint in class Component

invalidate

public void invalidate()
Triggers a full repaint, since the component is not valid anymore (size change, iconized, ...)

Overrides:
invalidate in class Container

paintComponent

public void paintComponent(Graphics g)
Paint this panel by calling paintComponent(VectorGraphics) if necessary and flushing the buffered image to the screen. This method also handles printing and exporting separately.

Overrides:
paintComponent in class JComponent
Parameters:
g - Graphics object

getGraphics

public Graphics getGraphics()
Returns a pointer to the graphics (VectorGraphics) context of the buffer.

Overrides:
getGraphics in class JComponent

paintComponent

public void paintComponent(VectorGraphics vg)
Allows for custom graphics to be painted. Subclasses should implement real drawing here. They can ask isPrinting(), isExporting() or isDisplaying() to see where the output goes. If painting is done to a display it is done to a buffer which is kept and copied afterwards. Note that the parameter here is of class VectorGraphics rather than Graphics.


setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)
Resize and move a component.

Overrides:
setBounds in class Component

isPrinting

public boolean isPrinting()
Returns true if the drawing is made for a PrinterGraphics context.


isExporting

public boolean isExporting()
Returns true if the drawing is made for a VectorGraphics context.


isDisplaying

public boolean isDisplaying()
Returns true if the drawing is made for a PixelGraphics context, the display. True if not Printing and not Exporting.


FreeHEP API
Version v1.2.2

Copyright © 2000-2003 FreeHEP, All Rights Reserved.