mdh.hephaestus2.gamelib
Class DoublePanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--mdh.hephaestus2.gamelib.DoublePanel
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
IconList, ImagePanel, Screen, Terminal

public abstract class DoublePanel
extends Panel

A double-buffered panel. Override the draw() method with your drawing code, and DoublePanel handles image creation, resizing, and swapping buffers.

Author:
Copyright © 2002 by Mark Hughes <kamikaze@kuoi.asui.uidaho.edu>
See Also:
Serialized Form

Field Summary
 
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
DoublePanel()
          Creates a new DoublePanel with the default FlowLayout layout manager.
DoublePanel(LayoutManager layout)
          Creates a new DoublePanel with the given layout manager.
 
Method Summary
abstract  void draw(Graphics2D g)
          Override this to do your drawing on the offscreen buffer; you need do nothing else.
 Dimension getMinimumSize()
           
 Dimension getPreferredSize()
           
 boolean isDoubleBuffered()
           
 boolean isFixedSize()
           
 boolean isFocusable()
           
 boolean isFocusTraversable()
          This is deprecated in 1.4, but still necessary for 1.3 compatibility.
 void paint(Graphics g)
          Blits the onscreen buffer to the screen.
 boolean redraw()
          Creates buffers if necessary, forces an immediate call to draw() in the current thread, and switches the onscreen and offscreen buffers.
 void repaintNow()
          Forces an immediate call to paint() in the current thread.
 void setSize(int width, int height)
          Sets the size of the component to fixed values.
 void update(Graphics g)
          Redraws and paints.
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, 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, isEnabled, isFocusOwner, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DoublePanel

public DoublePanel()
Creates a new DoublePanel with the default FlowLayout layout manager.


DoublePanel

public DoublePanel(LayoutManager layout)
Creates a new DoublePanel with the given layout manager.

Method Detail

draw

public abstract void draw(Graphics2D g)
Override this to do your drawing on the offscreen buffer; you need do nothing else.


getMinimumSize

public Dimension getMinimumSize()
Overrides:
getMinimumSize in class Container

getPreferredSize

public Dimension getPreferredSize()
Overrides:
getPreferredSize in class Container

isFixedSize

public boolean isFixedSize()

isDoubleBuffered

public boolean isDoubleBuffered()
Overrides:
isDoubleBuffered in class Component

isFocusable

public boolean isFocusable()
Overrides:
isFocusable in class Component

isFocusTraversable

public boolean isFocusTraversable()
This is deprecated in 1.4, but still necessary for 1.3 compatibility.

Overrides:
isFocusTraversable in class Component

paint

public final void paint(Graphics g)
Blits the onscreen buffer to the screen.

Overrides:
paint in class Container

redraw

public final boolean redraw()
Creates buffers if necessary, forces an immediate call to draw() in the current thread, and switches the onscreen and offscreen buffers. The next time the panel is repainted, it will show the new buffer. If you want an immediate repaint, call repaintNow().

Returns:
true if the drawing process worked, false if the buffers failed to load. In the latter case, repaint(100L) is called to try it again.

repaintNow

public final void repaintNow()
Forces an immediate call to paint() in the current thread. If you want something done, you have to it yourself. The AWT handles repaint() whenever it feels like it, not *RIGHT NOW*.


setSize

public void setSize(int width,
                    int height)
Sets the size of the component to fixed values.

Overrides:
setSize in class Component

update

public final void update(Graphics g)
Redraws and paints.

Overrides:
update in class Container