com.arsdigita.toolbox.rebop
Class GenericComponent

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended bycom.arsdigita.toolbox.rebop.GenericComponent
All Implemented Interfaces:
EventListener, GenericDrawable, ImageObserver, MenuContainer, MouseListener, Serializable
Direct Known Subclasses:
GenericButton, GenericImage, GenericLabel, GenericList

public class GenericComponent
extends Container
implements MouseListener, GenericDrawable

Root of all rebop components. Takes care of double-buffering. Typically, only the "root" component need have its double-buffer flag set to true, as all sub-components will automatically be double-buffered.

Author:
Gavin Doughtie
See Also:
Serialized Form

Nested Class Summary
 
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
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface com.arsdigita.toolbox.rebop.GenericDrawable
versionId
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GenericComponent()
           
 
Method Summary
 void addNotify()
          Called when the native peer is available, Double-buffer image is automatically created if required.
 void componentReshape(int x, int y, int width, int height)
           
protected  void draw(Graphics g)
          Draw this component to a Graphics context.
 void draw(Graphics g, int x, int y, int width, int height)
          Implementation of the GenericDrawable interface.
protected  void drawDebug(Graphics g)
          Draws the outer edge of the component's rectangle in red, and the component's preferred size in blue.
 void forceInvalid()
           
static boolean getDebugPaint()
           
 boolean getDoubleBuffered()
           
 GenericDrawable getDrawable()
           
 int getXOffset()
           
 int getYOffset()
           
 void mouseClicked(MouseEvent e)
          Invoked when the mouse has been clicked on a component.
 void mouseEntered(MouseEvent e)
          Invoked when the mouse enters a component.
 void mouseExited(MouseEvent e)
          Invoked when the mouse exits a component.
 void mousePressed(MouseEvent e)
          Invoked when a mouse button has been pressed on a component.
 void mouseReleased(MouseEvent e)
          Invoked when a mouse button has been released on a component.
 void paint(Graphics g)
          paints the component by calling the draw method.
 void reshape(int x, int y, int width, int height)
          Called whenever a component is resized.
 void setBounds(int x, int y, int width, int height)
          Called whenever a component is resized.
static void setDebugPaint(boolean debug)
          Toggles debug component painting for ALL components
 void setDoubleBuffered(boolean db)
          if db is set to true, then this component will paint using standard double-buffered techniques
 void setDrawable(GenericDrawable drawable)
          Sets the object that will draw this component.
 void setXOffset(int xOffset)
          The X and Y offsets are used to offset a drawable from the location where it is told to draw.
 void setYOffset(int yOffset)
           
protected  void validateTree()
           
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, 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

GenericComponent

public GenericComponent()
Method Detail

setDrawable

public void setDrawable(GenericDrawable drawable)
Sets the object that will draw this component. while some components will want to do their own painting, it is recommended that you create re-useable objects that implement the GenericDrawable interface instead.

Parameters:
drawable - Object that will be drawn in this component's paint() method

getDrawable

public GenericDrawable getDrawable()

setDoubleBuffered

public void setDoubleBuffered(boolean db)
if db is set to true, then this component will paint using standard double-buffered techniques

Parameters:
db - double buffer flag

getDoubleBuffered

public boolean getDoubleBuffered()

addNotify

public void addNotify()
Called when the native peer is available, Double-buffer image is automatically created if required.


setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Called whenever a component is resized. Recreate the back buffer if necessary.

Parameters:
x - new x coordinate
y - new y coordinate
width - new width
height - new height

reshape

public void reshape(int x,
                    int y,
                    int width,
                    int height)
Called whenever a component is resized. Recreate the back buffer if necessary. This is a deprecated method, but it is the "root" method of all the awt component methods that change the size of a component (at least up through the JDK 1.3.1x) and overriding this method prevents having to override many others. Whenever this changes, this method can be removed as setBounds() will take care of things.

Parameters:
x - new x coordinate
y - new y coordinate
width - new width
height - new height

componentReshape

public void componentReshape(int x,
                             int y,
                             int width,
                             int height)

paint

public void paint(Graphics g)
paints the component by calling the draw method. Handles double-buffer and debug drawing logic. Subclasses should override draw if they wish to perform custom painting.

Parameters:
g - Graphics to draw in

validateTree

protected void validateTree()

forceInvalid

public void forceInvalid()

draw

protected void draw(Graphics g)
Draw this component to a Graphics context. Subclasses should override this method rather than paint() for custom drawing.

Parameters:
g - Graphics to draw in

draw

public void draw(Graphics g,
                 int x,
                 int y,
                 int width,
                 int height)
Implementation of the GenericDrawable interface. Allows you to "compose" a complex drawable from simpler sub-components (for example, a GenericComponent with a BevelBox as its drawable, and with a GenericImage as a subcomponent. for this to work, you MUST add any components you wish to use as drawables someplace in the AWT component hierarchy of your applet. You can set them to be not visible, however.

Specified by:
draw in interface GenericDrawable
Parameters:
g - Graphics to draw on
x - horizontal location to begin drawing
y - vertical location to begin drawing
width - width of area to draw in
height - height of area to draw in

setXOffset

public void setXOffset(int xOffset)
Description copied from interface: GenericDrawable
The X and Y offsets are used to offset a drawable from the location where it is told to draw. Offsets are typically used for drawables that are inside components that form the contents of a push-down button.

Specified by:
setXOffset in interface GenericDrawable
Parameters:
xOffset - number of horizontal pixels to offset this drawable before drawing it.

getXOffset

public int getXOffset()
Specified by:
getXOffset in interface GenericDrawable

getYOffset

public int getYOffset()
Specified by:
getYOffset in interface GenericDrawable

setYOffset

public void setYOffset(int yOffset)
Specified by:
setYOffset in interface GenericDrawable
Parameters:
yOffset - number of vertical pixels to offset this
See Also:
GenericDrawable.setXOffset(int)

drawDebug

protected void drawDebug(Graphics g)
Draws the outer edge of the component's rectangle in red, and the component's preferred size in blue. Subclasses can override to provide additional debugging graphics, which will not appear unless GenericComponent.setDebugPaint(true) has been called.

Parameters:
g - Graphics to draw in

setDebugPaint

public static void setDebugPaint(boolean debug)
Toggles debug component painting for ALL components

Parameters:
debug - if true, then drawDebug will be called from the draw method.

getDebugPaint

public static boolean getDebugPaint()

mouseClicked

public void mouseClicked(MouseEvent e)
Invoked when the mouse has been clicked on a component.

Specified by:
mouseClicked in interface MouseListener

mousePressed

public void mousePressed(MouseEvent e)
Invoked when a mouse button has been pressed on a component.

Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent e)
Invoked when a mouse button has been released on a component.

Specified by:
mouseReleased in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
Invoked when the mouse enters a component.

Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Invoked when the mouse exits a component.

Specified by:
mouseExited in interface MouseListener


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC