RADi Runtime Library v1.2.1

de.muntjak.radiloader
Class RadiPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by de.muntjak.radiloader.RadiPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable, SwingConstants

public class RadiPanel
extends JPanel
implements Scrollable, SwingConstants

RadiPanel is RADi's implementation of a JPanel. It can display a background image and it implements Scrollable by means of a ScrollableDefinition (not documented).

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int REPEAT_BOTH
          Scale mode constant: Tile a background image if it doesn't fill the panel's display area
static int REPEAT_HORIZONTAL
          Scale mode constant: Tile a background image horizontally if it doesn't fill the panel's display width
static int REPEAT_VERTICAL
          Scale mode constant: Tile a background image vertically if it doesn't fill the panel's display height
static int SCALE_BOTH
          Scale mode constant: Scale a background image both horizontal and vertical
static int SCALE_HORIZONTAL
          Scale mode constant: Scale a background image in the horizontal direction only
static int SCALE_NONE
          Scale mode constant: Do not scale a background image
static int SCALE_TO_FILL
          Scale mode constant: Scale a background image to fill the panel's display area
static int SCALE_TO_FIT
          Scale mode constant: Scale a background image to fit inside the panel's display area
static int SCALE_VERTICAL
          Scale mode constant: Scale a background image in the vertical direction only
 
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 javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
RadiPanel()
          Creates a new RadiPanel with no background image and no scrollable definition.
RadiPanel(boolean isDoubleBuffered)
          Creates a new RadiPanel with no background image, no scrollable definition and the specified buffering strategy.
 
Method Summary
 ImageIcon getBgImage()
          Get this panel's background image.
 int getBgImageHorizontalAlignment()
          Get the horizontal alignment of the background image.
 int getBgImageScaleMode()
          Get the scale mode of the background image.
 int getBgImageVerticalAlignment()
          Get the vertical alignment of the background image.
 Dimension getPreferredScrollableViewportSize()
          Returns the preferred scrollable viewport size as defined by the ScrollableDefinition or the panel's preferred size if the ScrollableDefinition is null.
 int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
          Returns the scrollable block increment as defined by the ScrollableDefinition or height respective width of argument visibleRect if the ScrollableDefinition is null.
 boolean getScrollableTracksViewportHeight()
          Returns true if either the ScrollableDefinition is null or the ScrollableDefinition was specified to fill the viewport vertically and the preferred height of this panel is less than the height of the viewport, false otherwise.
 boolean getScrollableTracksViewportWidth()
          Returns true if either the ScrollableDefinition is null or the ScrollableDefinition was specified to fill the viewport horizontally and the preferred width of this panel is less than the width of the viewport, false otherwise.
 int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
          Returns the scrollable unit increment as defined by the ScrollableDefinition or 1 if the ScrollableDefinition is null.
 boolean isBgImageDoubleBuffered()
          Returns whether the background image should be painted using a double buffer.
 void paintComponent(Graphics g)
          Overrides JComponent.paintComponent to paint the background image (if one was specified) below any children.
 void setBackground(Color bg)
          Overrides JComponent.setBackground because the image buffer must be invalidated if the background color changes.
 void setBgImage(ImageIcon icon)
          Sets the new background image and repaints the component.
 void setBgImageDoubleBuffered(boolean b)
          Sets if the background image should be painted using a double buffer or not.
 void setBgImageHorizontalAlignment(int alignment)
          Sets the horizontal alignment of the background image.
 void setBgImageScaleMode(int scaleMode)
          Sets the scale mode of the background image.
 void setBgImageVerticalAlignment(int alignment)
          Sets the vertical alignment of the background image.
 void setOpaque(boolean b)
          Overrides JComponent.setOpaque because the panel must immediately be repainted if the opaque property changes.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
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, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SCALE_NONE

public static final int SCALE_NONE
Scale mode constant: Do not scale a background image

See Also:
Constant Field Values

SCALE_HORIZONTAL

public static final int SCALE_HORIZONTAL
Scale mode constant: Scale a background image in the horizontal direction only

See Also:
Constant Field Values

SCALE_VERTICAL

public static final int SCALE_VERTICAL
Scale mode constant: Scale a background image in the vertical direction only

See Also:
Constant Field Values

SCALE_BOTH

public static final int SCALE_BOTH
Scale mode constant: Scale a background image both horizontal and vertical

See Also:
Constant Field Values

SCALE_TO_FIT

public static final int SCALE_TO_FIT
Scale mode constant: Scale a background image to fit inside the panel's display area

See Also:
Constant Field Values

SCALE_TO_FILL

public static final int SCALE_TO_FILL
Scale mode constant: Scale a background image to fill the panel's display area

See Also:
Constant Field Values

REPEAT_HORIZONTAL

public static final int REPEAT_HORIZONTAL
Scale mode constant: Tile a background image horizontally if it doesn't fill the panel's display width

See Also:
Constant Field Values

REPEAT_VERTICAL

public static final int REPEAT_VERTICAL
Scale mode constant: Tile a background image vertically if it doesn't fill the panel's display height

See Also:
Constant Field Values

REPEAT_BOTH

public static final int REPEAT_BOTH
Scale mode constant: Tile a background image if it doesn't fill the panel's display area

See Also:
Constant Field Values
Constructor Detail

RadiPanel

public RadiPanel()
Creates a new RadiPanel with no background image and no scrollable definition.


RadiPanel

public RadiPanel(boolean isDoubleBuffered)
Creates a new RadiPanel with no background image, no scrollable definition and the specified buffering strategy. If isDoubleBuffered is true, the JPanel will use a double buffer.

Parameters:
isDoubleBuffered - a boolean, true for double-buffering, which uses additional memory space to achieve fast, flicker-free updates
Method Detail

getBgImage

public ImageIcon getBgImage()
Get this panel's background image.

Returns:
the background image which may be null

getBgImageHorizontalAlignment

public int getBgImageHorizontalAlignment()
Get the horizontal alignment of the background image.

Returns:
the horizontal alignment of the background image which is one of SwingConstants.LEFT, SwingConstants.CENTER or SwingConstants.RIGHT

getBgImageScaleMode

public int getBgImageScaleMode()
Get the scale mode of the background image.

Returns:
the scale mode of the background image, one of SCALE_NONE, SCALE_HORIZONTAL, SCALE_VERTICAL, SCALE_BOTH, SCALE_TO_FIT, SCALE_TO_FILL or REPEAT

getBgImageVerticalAlignment

public int getBgImageVerticalAlignment()
Get the vertical alignment of the background image.

Returns:
the vertical alignment of the background image which is one of SwingConstants.TOP, SwingConstants.CENTER or SwingConstants.BOTTOM

getPreferredScrollableViewportSize

public Dimension getPreferredScrollableViewportSize()
Returns the preferred scrollable viewport size as defined by the ScrollableDefinition or the panel's preferred size if the ScrollableDefinition is null.

Specified by:
getPreferredScrollableViewportSize in interface Scrollable
Returns:
the preferred scrollable viewport size as defined by the ScrollableDefinition or the panel's preferred size if the ScrollableDefinition is null

getScrollableBlockIncrement

public int getScrollableBlockIncrement(Rectangle visibleRect,
                                       int orientation,
                                       int direction)
Returns the scrollable block increment as defined by the ScrollableDefinition or height respective width of argument visibleRect if the ScrollableDefinition is null.

Specified by:
getScrollableBlockIncrement in interface Scrollable
Returns:
the scrollable block increment as defined by the ScrollableDefinition or height respective width of visibleRect if the ScrollableDefinition is null

getScrollableTracksViewportHeight

public boolean getScrollableTracksViewportHeight()
Returns true if either the ScrollableDefinition is null or the ScrollableDefinition was specified to fill the viewport vertically and the preferred height of this panel is less than the height of the viewport, false otherwise.

Specified by:
getScrollableTracksViewportHeight in interface Scrollable
Returns:
true if either the ScrollableDefinition is null or the ScrollableDefinition was specified to fill the viewport vertically and the preferred height of this panel is less than the height of the viewport, false otherwise

getScrollableTracksViewportWidth

public boolean getScrollableTracksViewportWidth()
Returns true if either the ScrollableDefinition is null or the ScrollableDefinition was specified to fill the viewport horizontally and the preferred width of this panel is less than the width of the viewport, false otherwise.

Specified by:
getScrollableTracksViewportWidth in interface Scrollable
Returns:
true if either the ScrollableDefinition is null or the ScrollableDefinition was specified to fill the viewport horizontally and the preferred width of this panel is less than the width of the viewport, false otherwise

getScrollableUnitIncrement

public int getScrollableUnitIncrement(Rectangle visibleRect,
                                      int orientation,
                                      int direction)
Returns the scrollable unit increment as defined by the ScrollableDefinition or 1 if the ScrollableDefinition is null.

Specified by:
getScrollableUnitIncrement in interface Scrollable
Returns:
the scrollable unit increment as defined by the ScrollableDefinition or 1 if the ScrollableDefinition is null

isBgImageDoubleBuffered

public boolean isBgImageDoubleBuffered()
Returns whether the background image should be painted using a double buffer.

Returns:
true if the background image is double buffered, false otherwise.

paintComponent

public void paintComponent(Graphics g)
Overrides JComponent.paintComponent to paint the background image (if one was specified) below any children.

Overrides:
paintComponent in class JComponent

setBackground

public void setBackground(Color bg)
Overrides JComponent.setBackground because the image buffer must be invalidated if the background color changes.

Overrides:
setBackground in class JComponent

setBgImage

public void setBgImage(ImageIcon icon)
Sets the new background image and repaints the component.

Parameters:
icon - the new background image which may be null

setBgImageDoubleBuffered

public void setBgImageDoubleBuffered(boolean b)
Sets if the background image should be painted using a double buffer or not. Using a double buffer increases painting speed but also increases the required memory size used by this component. By default a background image is painted using a double buffer.

Parameters:
b - true if if the background image should be painted using a double buffer, false otherwise

setBgImageHorizontalAlignment

public void setBgImageHorizontalAlignment(int alignment)
Sets the horizontal alignment of the background image. The default is SwingConstants.CENTER.

Parameters:
alignment - the new horizontal alignment of the background image, one of SwingConstants.LEFT, SwingConstants.CENTER or SwingConstants.RIGHT
Throws:
IllegalArgumentException - if argument is not one of SwingConstants.LEFT, SwingConstants.CENTER or SwingConstants.RIGHT

setBgImageScaleMode

public void setBgImageScaleMode(int scaleMode)
Sets the scale mode of the background image. The default is SCALE_NONE.

Parameters:
scaleMode - the new scale mode of the background image, one of
  • SCALE_NONE
  • SCALE_HORIZONTAL
  • SCALE_VERTICAL
  • SCALE_BOTH
  • SCALE_TO_FIT
  • SCALE_TO_FILL
  • REPEAT_HORIZONTAL
  • REPEAT_VERTICAL
  • REPEAT_BOTH
Throws:
IllegalArgumentException - if argument is outside the expected range

setBgImageVerticalAlignment

public void setBgImageVerticalAlignment(int alignment)
Sets the vertical alignment of the background image. The default is SwingConstants.CENTER.

Parameters:
alignment - the new vertical alignment of the background image, one of SwingConstants.TOP, SwingConstants.CENTER or SwingConstants.BOTTOM
Throws:
IllegalArgumentException - if argument is not one of SwingConstants.TOP, SwingConstants.CENTER or SwingConstants.BOTTOM

setOpaque

public void setOpaque(boolean b)
Overrides JComponent.setOpaque because the panel must immediately be repainted if the opaque property changes.

Overrides:
setOpaque in class JComponent

RADi Runtime Library v1.2.1