FreeHEP API
Version v1.2.2

org.freehep.swing.graphics
Class StackedPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JLayeredPane
                          |
                          +--org.freehep.swing.graphics.StackedPanel
All Implemented Interfaces:
Accessible, EventListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable

public class StackedPanel
extends JLayeredPane
implements Serializable, PropertyChangeListener

StackedPanel defines an extension to JLayeredPane which allows a set of equally-sized, overlayed panels to form a single 2D surface on which to draw.

Version:
$Id: StackedPanel.java,v 1.19 2002/11/12 00:14:51 duns Exp $
Author:
Charles Loomis
See Also:
Serialized Form

Nested Class Summary
protected  class StackedPanel.PanelArray
          A protected class which simply wraps the set of Panels which form the sublayers of a particular layer.
 
Field Summary
static Integer INTERACTION_LAYER
          Layer intended for interaction with the user.
static Integer MAXIMUM_LAYER
          One larger than the maximum allowed layer for components.
static Integer MINIMUM_LAYER
          The lowest allowed value for components.
static String NEED_GRAPHICAL_SELECTION_PANEL
          An error message indicating that the class passed into addGraphicalSelectionPanelOfClass method was not a type of GraphicalSelectionPanel.
 
Fields inherited from class javax.swing.JLayeredPane
DEFAULT_LAYER, DRAG_LAYER, FRAME_CONTENT_LAYER, LAYER_PROPERTY, MODAL_LAYER, PALETTE_LAYER, POPUP_LAYER
 
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
StackedPanel()
          This constructor makes a new stacked panel which has no PanelArtist associated with it.
StackedPanel(AbstractPanelArtist panelArtist)
          The constructor allocates all of the panels for drawing.
 
Method Summary
 void activateGraphicalSelectionPanel(GraphicalSelectionPanel panel)
          Make a given GraphicalSelectionPanel active.
 void activateGraphicalSelectionPanelOfClass(Class c)
          Make the GraphicalSelectionPanel of the given class active.
 void addGraphicalSelectionPanel(GraphicalSelectionPanel panel)
          Add an interaction component.
 void addLayer(String layerName, int sublayers, boolean opaque)
          A routine which adds a new layer to this StackedPanel.
 void addLayer(String layerName, JComponent panel)
          adds a Panel as layer to this StackedPanel
 void addLayer(String layerName, JComponent[] panels)
          adds a set of Panels as layer and sublayers to this StackedPanel
 void clearAllLayers()
          This provides a method for PanelArtists to clear all layers.
 void clearLayer(String layerName)
          This provides a method for PanelArtists to clear a layer.
 void deactivateGraphicalSelectionPanels()
          Make all GraphicalSelectionPanels inactive.
 void drawComplete()
          This callback routine is intended to be used by the controlling PanelArtist after it has returned false from the drawPanel() method, indicating that the redraw of the panel has not yet completed.
 void getGraphics(String layerName, Graphics[] g)
          This provides an additional getGraphics method which returns the graphics object associated with the image of the given layer.
 AbstractPanelArtist getPanelArtist()
          Return the PanelArtist which controls the graphics content of this panel.
 long getUpdatePeriod()
          Get the delay for the periodic update of the display.
 boolean isRedrawNeeded()
          Return a boolean indicating whether or not this panel will be completely redrawn at the next repaint.
 void paint(Graphics g)
           
 void paintChildren(Graphics g)
           
 void paintComponent(Graphics g)
          Override of the paintComponent() method ensures that the drawPanel() method will be called if a complete redraw is needed.
 void printBorder(Graphics g)
          Print the border of this component.
 void printChildren(Graphics g)
          Do NOT print the children because the printing is handled directly by the PanelArtist.
 void printComponent(Graphics g)
          This prints this StackedPanel.
 void propertyChange(PropertyChangeEvent evt)
          Look for changes in property values.
 void removeGraphicalSelectionPanel(GraphicalSelectionPanel panel)
          Remove an interaction component.
 void removeLayer(String layerName)
          Remove a layer from the stacked panel.
 void reorderLayers()
          Reorder the layers.
 void setAntialias(String layerName, boolean antialias)
          This sets the anti-aliasing on or off for the given layer.
 void setBorder(Border border)
          Set the border of this component.
 void setBounds(int x, int y, int w, int h)
          Intercept a resize event so that the redraw flag can be set.
 void setPanelArtist(AbstractPanelArtist panelArtist)
          Set which PanelArtist will control the graphics content of this panel.
 void setRedrawNeeded(boolean redrawNeeded)
          Set the redraw flag.
 void setUpdatePeriod(int period)
          Set the delay for the periodic update of the display.
 void setVisible(String layerName, boolean[] visible)
          Tell the component whether or not a given layer is visible.
protected  void startPeriodicUpdate()
          Start a periodic update of this panel.
protected  void stopPeriodicUpdate()
          Stop the periodic update of this panel.
 
Methods inherited from class javax.swing.JLayeredPane
addImpl, getAccessibleContext, getComponentCountInLayer, getComponentsInLayer, getComponentToLayer, getIndexOf, getLayer, getLayer, getLayeredPaneAbove, getObjectForLayer, getPosition, highestLayer, insertIndexForLayer, isOptimizedDrawingEnabled, lowestLayer, moveToBack, moveToFront, paramString, putLayer, remove, setLayer, setLayer, setPosition
 
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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, 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, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, 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

NEED_GRAPHICAL_SELECTION_PANEL

public static final String NEED_GRAPHICAL_SELECTION_PANEL
An error message indicating that the class passed into addGraphicalSelectionPanelOfClass method was not a type of GraphicalSelectionPanel.

See Also:
Constant Field Values

INTERACTION_LAYER

public static final Integer INTERACTION_LAYER
Layer intended for interaction with the user. (e.g. zooming, picking, etc.) Positioned just behind the palette layer.


MINIMUM_LAYER

public static final Integer MINIMUM_LAYER
The lowest allowed value for components.


MAXIMUM_LAYER

public static final Integer MAXIMUM_LAYER
One larger than the maximum allowed layer for components.

Constructor Detail

StackedPanel

public StackedPanel()
This constructor makes a new stacked panel which has no PanelArtist associated with it.


StackedPanel

public StackedPanel(AbstractPanelArtist panelArtist)
The constructor allocates all of the panels for drawing.

Method Detail

addLayer

public void addLayer(String layerName,
                     int sublayers,
                     boolean opaque)
A routine which adds a new layer to this StackedPanel. By default, the layer is added above all others. Each layer will contain the given number of sublayers. If the number of sublayers is larger than one and the layer should be opaque, only the lowest sublayer will be opaque, all others will be transparent. When retrieving the graphics context for the sublayers, the topmost layer is listed first. If the number of sublayers is non-positive, then an IllegalArgumentException will be thrown.


addLayer

public void addLayer(String layerName,
                     JComponent panel)
adds a Panel as layer to this StackedPanel


addLayer

public void addLayer(String layerName,
                     JComponent[] panels)
adds a set of Panels as layer and sublayers to this StackedPanel


removeLayer

public void removeLayer(String layerName)
Remove a layer from the stacked panel.


reorderLayers

public void reorderLayers()
Reorder the layers.


addGraphicalSelectionPanel

public void addGraphicalSelectionPanel(GraphicalSelectionPanel panel)
Add an interaction component. Initially the component is inactive (invisible).


removeGraphicalSelectionPanel

public void removeGraphicalSelectionPanel(GraphicalSelectionPanel panel)
Remove an interaction component.


activateGraphicalSelectionPanelOfClass

public void activateGraphicalSelectionPanelOfClass(Class c)
                                            throws InstantiationException,
                                                   IllegalAccessException
Make the GraphicalSelectionPanel of the given class active.

InstantiationException
IllegalAccessException

activateGraphicalSelectionPanel

public void activateGraphicalSelectionPanel(GraphicalSelectionPanel panel)
Make a given GraphicalSelectionPanel active.


deactivateGraphicalSelectionPanels

public void deactivateGraphicalSelectionPanels()
Make all GraphicalSelectionPanels inactive.


setVisible

public void setVisible(String layerName,
                       boolean[] visible)
Tell the component whether or not a given layer is visible.

Parameters:
layerName - String describing a particular layer
visible - true if layer should be visible, false otherwise

setPanelArtist

public void setPanelArtist(AbstractPanelArtist panelArtist)
Set which PanelArtist will control the graphics content of this panel. If the PanelArtist is not yet available, then null can be passed in here.

Parameters:
panelArtist - PanelArtist which provides the graphics content

getPanelArtist

public AbstractPanelArtist getPanelArtist()
Return the PanelArtist which controls the graphics content of this panel. Note this can return null if no PanelArtist has been set.

Returns:
the PanelArtist which control the graphics content

isRedrawNeeded

public boolean isRedrawNeeded()
Return a boolean indicating whether or not this panel will be completely redrawn at the next repaint.


setRedrawNeeded

public void setRedrawNeeded(boolean redrawNeeded)
Set the redraw flag. If set to true, the entire panel will be redrawn at the next repaint. (The paintComponent method will call drawPanel() rather than flushing the saved image to the screen.


getGraphics

public void getGraphics(String layerName,
                        Graphics[] g)
This provides an additional getGraphics method which returns the graphics object associated with the image of the given layer. This will return the graphics object associated with a given layer even if that layer is hidden.


clearAllLayers

public void clearAllLayers()
This provides a method for PanelArtists to clear all layers.


clearLayer

public void clearLayer(String layerName)
This provides a method for PanelArtists to clear a layer. This conditionally clears a particular layer depending on whether or not the images are being printed.


setAntialias

public void setAntialias(String layerName,
                         boolean antialias)
This sets the anti-aliasing on or off for the given layer.


paint

public void paint(Graphics g)
Overrides:
paint in class JLayeredPane

paintChildren

public void paintChildren(Graphics g)
Overrides:
paintChildren in class JComponent

paintComponent

public void paintComponent(Graphics g)
Override of the paintComponent() method ensures that the drawPanel() method will be called if a complete redraw is needed.

Overrides:
paintComponent in class JComponent

printComponent

public void printComponent(Graphics g)
This prints this StackedPanel.

Overrides:
printComponent in class JComponent

drawComplete

public void drawComplete()
This callback routine is intended to be used by the controlling PanelArtist after it has returned false from the drawPanel() method, indicating that the redraw of the panel has not yet completed. This signals that the redraw is now complete.


setUpdatePeriod

public void setUpdatePeriod(int period)
Set the delay for the periodic update of the display.


getUpdatePeriod

public long getUpdatePeriod()
Get the delay for the periodic update of the display.


startPeriodicUpdate

protected void startPeriodicUpdate()
Start a periodic update of this panel. This is called internally when the controlling PanelArtist is drawing into the images from another, background thread.


stopPeriodicUpdate

protected void stopPeriodicUpdate()
Stop the periodic update of this panel.


setBorder

public void setBorder(Border border)
Set the border of this component. This is intercepted so that if the size of the border changes, the redraw flag can be set.

Overrides:
setBorder in class JComponent

setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)
Intercept a resize event so that the redraw flag can be set. (Swing internally calls reshape() which is then forwarded to setBounds().)

Overrides:
setBounds in class Component

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Look for changes in property values. If a property is set on a component which has a key "InhibitRepaint" and a value of true, repainting of the component will be inhibited.

Specified by:
propertyChange in interface PropertyChangeListener

printBorder

public void printBorder(Graphics g)
Print the border of this component.

Overrides:
printBorder in class JComponent

printChildren

public void printChildren(Graphics g)
Do NOT print the children because the printing is handled directly by the PanelArtist.

Overrides:
printChildren in class JComponent

FreeHEP API
Version v1.2.2

Copyright © 2000-2003 FreeHEP, All Rights Reserved.