|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--javax.swing.JPanel
|
+--edu.neu.ccs.gui.DisplayPanel
|
+--edu.neu.ccs.gui.BufferedPanel
A panel that maintains a persistent graphics state
by repainting itself from a stored
object.BufferedImage
This behavior differs from the double-buffering
provided in
in that its intention is not necessarily to provide
flicker-free repaints. Its goal is to retain the effects of
method calls on its buffer graphics context regardless of
whether or not those calls are in a JComponentpaint method.
To ensure proper performance, the user should paint
to the buffer graphics context,
which is available through the
method, rather than to a component graphics context
provided as an argument to the
getBufferGraphics method
or returned by the
paint method.getGraphics
| Nested Class Summary | |
protected static class |
BufferedPanel.Painter
Panel that paints the internal BufferedImage
that maintains the persistent graphics state
of a BufferedPanel. |
| Field Summary | |
protected BufferedImage |
buffer
The buffered image that maintains the persistent graphics state. |
protected Paint |
bufferBackground
The background paint for this buffered panel. |
static Color |
DEFAULT_BUFFER_BACKGROUND
Default background color for a buffered panel. |
protected KeyActionAdapter |
keyActions
The key action adapter for this buffered panel. |
protected MouseActionAdapter |
mouseActions
The mouse action adapter for this buffered panel. |
protected BufferedPanel.Painter |
painter
The internal painter panel. |
| Fields inherited from class edu.neu.ccs.gui.DisplayPanel |
background, codec, CODEC |
| 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 edu.neu.ccs.gui.Displayable |
DEFAULT_VIEW_STATE, VIEW_STATE |
| Fields inherited from interface edu.neu.ccs.util.JPTConstants |
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT |
| 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 | |
BufferedPanel(Dimension dimension)
Constructs a BufferedPanel containing a buffered image with the given Dimension,
and a white background. |
|
BufferedPanel(Dimension dimension,
Paint background)
Constructs a BufferedPanel containing a buffered image with the given Dimension,
and the given background color or Paint
for the image. |
|
BufferedPanel(int width,
int height)
Constructs a BufferedPanel containing a buffered image with the given width and height, and a white background. |
|
BufferedPanel(int width,
int height,
Paint background)
Constructs a BufferedPanel containing a buffered image with the given width and height, and the given background color or Paint
for the image. |
|
| Method Summary | |
void |
clearPanel()
Fills this buffered panel with its background color or Paint. |
void |
fillPanel(Paint fill)
Fills this buffered panel with the given color or Paint. |
BufferedImage |
getBuffer()
Returns the internal buffered image for this panel. |
Paint |
getBufferBackground()
Returns the background color or Paint
for this buffered panel. |
Graphics2D |
getBufferGraphics()
Returns a Graphics2D object that permits
painting to the internal buffered image for this panel. |
int |
getBufferHeight()
Returns the height of the buffered image. |
int |
getBufferWidth()
Returns the width of the buffered image. |
DisplayPanel |
getInnerPanel()
Returns the internal panel for this buffered panel, that is, the panel that paints the buffered image and handles the mouse and key adapters. |
KeyActionAdapter |
getKeyActionAdapter()
Returns the key action adapter for the buffer. |
MouseActionAdapter |
getMouseActionAdapter()
Returns the mouse action adapter for the buffer. |
void |
paintOver(Graphics2D g2)
Override this paintOver method to add additional
painting actions after the default buffer repaint is done during
a repaint() call. |
void |
quickRepaint()
Repaints the buffered panel directly without a call to the generic repaint method in Component. |
void |
setBackground(Color background)
Sets the background color for the panel that wraps the buffer to the given color. |
void |
setBufferBackground(Paint background)
Sets the background color or Paint
to the given color or Paint. |
void |
setBufferSize(Dimension size)
Sets the size of the buffered image to the given Dimension. |
void |
setBufferSize(int width,
int height)
Sets the size of the buffered image to the given height and width. |
void |
setKeyActionAdapter(KeyActionAdapter adapter)
Sets the key action adapter for the buffer to the given adapter. |
void |
setMouseActionAdapter(MouseActionAdapter adapter)
Sets the mouse action adapter for the buffer to the given adapter. |
| Methods inherited from class edu.neu.ccs.gui.DisplayPanel |
add, add, add, add, add, addObject, addObject, addObject, addObject, dataMalformed, endAlert, frame, frame, frame, frame, frame, frame, generalDialog, generalDialog, generalDialog, generalDialog, getCodec, getDefaultViewState, getViewState, makeComponent, OKCancelDialog, OKCancelDialog, OKDialog, OKDialog, refreshComponent, remove, remove, removeAll, reset, setCodec, setDefaultViewState, setEnabled, setViewState, startAlert, uniformizeHeight, uniformizeSize, uniformizeWidth, YesNoCancelDialog, YesNoCancelDialog |
| Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final Color DEFAULT_BUFFER_BACKGROUND
protected BufferedImage buffer
protected BufferedPanel.Painter painter
protected Paint bufferBackground
protected MouseActionAdapter mouseActions
protected KeyActionAdapter keyActions
| Constructor Detail |
public BufferedPanel(int width,
int height)
Constructs a BufferedPanel containing a buffered image with the given width and height, and a white background.
If the given width or height is less than 1 pixel, that value is set to 1 pixel.
Though the component itself may grow arbitrarily large,
the buffered image painted to the buffer will
remain the size specified in this constructor
unless the size is reset using the
setBufferSize method.
width - the width of the buffered imageheight - the height of the buffered imageBufferedPanel(Dimension),
BufferedPanel(int, int, Paint),
BufferedPanel(Dimension, Paint),
setBufferSize(int, int),
setBufferSize(Dimension)public BufferedPanel(Dimension dimension)
Constructs a BufferedPanel containing a buffered image
with the given Dimension,
and a white background.
If the given Dimension is null,
then the buffer width and height are both set to 1 pixel.
If the width or height of the given Dimension
is less than 1 pixel, that value is set to 1 pixel.
Though the component itself may grow arbitrarily large,
the buffered image painted to the buffer will
remain the size specified in this constructor
unless the size is reset using the
setBufferSize method.
dimension - the dimension of the buffered imageBufferedPanel(int, int),
BufferedPanel(int, int, Paint),
BufferedPanel(Dimension, Paint),
setBufferSize(int, int),
setBufferSize(Dimension)
public BufferedPanel(int width,
int height,
Paint background)
Constructs a BufferedPanel containing a buffered image
with the given width and height,
and the given background color or Paint
for the image.
If the given width or height is less than 1 pixel, that value is set to 1 pixel.
Though the component itself may grow arbitrarily large,
the buffered image painted to the buffer will
remain the size specified in this constructor
unless the size is reset using the
setBufferSize method.
width - the width of the buffered imageheight - the height of the buffered imagebackground - the background color or Paint
for the buffered imageBufferedPanel(int, int),
BufferedPanel(Dimension),
BufferedPanel(Dimension, Paint),
setBufferSize(int, int),
setBufferSize(Dimension)
public BufferedPanel(Dimension dimension,
Paint background)
Constructs a BufferedPanel containing a buffered image
with the given Dimension,
and the given background color or Paint
for the image.
If the given Dimension is null,
then the buffer width and height are both set to 1 pixel.
If the width or height of the given Dimension
is less than 1 pixel, that value is set to 1 pixel.
Though the component itself may grow arbitrarily large,
the buffered image painted to the buffer will
remain the size specified in this constructor
unless the size is reset using the
setBufferSize method.
dimension - the dimension of the buffered imagebackground - the background color or Paint
for the buffered imageBufferedPanel(int, int),
BufferedPanel(Dimension),
BufferedPanel(int, int, Paint),
setBufferSize(int, int),
setBufferSize(Dimension)| Method Detail |
public Graphics2D getBufferGraphics()
Returns a Graphics2D object that permits
painting to the internal buffered image for this panel.
The user should always use this object to paint to the buffer and thus indirectly modify this buffered panel.
To make painting changes to the buffer visible, the
repaint() method must explicitly be called.
This allows a number of painting operations to be done
prior to screen repaint.
getBuffer(),
getInnerPanel()public BufferedImage getBuffer()
Returns the internal buffered image for this panel.
getBufferGraphics(),
getInnerPanel()public DisplayPanel getInnerPanel()
Returns the internal panel for this buffered panel, that is, the panel that paints the buffered image and handles the mouse and key adapters.
This panel may be used when access to the panel on which the graphics is drawn is needed.
Do not set a border on this internal panel. Set a
border on the outer BufferedPanel object.
getBufferGraphics(),
getBuffer()public void quickRepaint()
Repaints the buffered panel directly without a call to the generic
repaint method in Component.
Instead, this method directly asks the inner panel to paint itself which is done by repainting the screen from the buffer.
This method is supplied for performance reasons to support the use of animation in a buffered panel.
This method does nothing if the buffered panel is not installed in a window or dialog box.
public void setBufferBackground(Paint background)
Sets the background color or Paint
to the given color or Paint.
If the given color or Paint is null,
the current background is not changed.
background - the new background color or PaintgetBufferBackground()public Paint getBufferBackground()
Returns the background color or Paint
for this buffered panel.
PaintsetBufferBackground(Paint)public void clearPanel()
Fills this buffered panel
with its background color or Paint.
fillPanel(Paint)public void fillPanel(Paint fill)
Fills this buffered panel
with the given color or Paint.
If the given color or Paint is null,
the buffered panel is not changed.
fill - the color or Paint used to fillclearPanel()public void setBackground(Color background)
Sets the background color for the panel that wraps the buffer to the given color.
setBackground in class JComponentbackground - the new background colorpublic void setBufferSize(Dimension size)
Sets the size of the buffered image
to the given Dimension.
If the given Dimension is null,
the current image size is not changed.
If the width or height of the given Dimension
is less than 1 pixel, it is set to 1 pixel.
Any image area gained by an size increase in either direction will be painted with the current background color.
Any image area lost by a size decrease in either direction will be clipped on the right and/or bottom of the image.
For a short time both the image of the previous size and an image of the new size are maintained in memory.
size - the new size for the imagesetBufferSize(int, int)
public void setBufferSize(int width,
int height)
Sets the size of the buffered image to the given height and width.
If the given width or height is less than 1 pixel, it is set to 1 pixel.
Any image area gained by an size increase in either direction will be painted with the current background color.
Any image area lost by a size decrease in either direction will be clipped on the right and/or bottom of the image.
For a short time both the image of the previous size and an image of the new size are maintained in memory.
width - the new width for the imageheight - the new height for the imagesetBufferSize(Dimension)public int getBufferWidth()
public int getBufferHeight()
public void setMouseActionAdapter(MouseActionAdapter adapter)
Sets the mouse action adapter for the buffer to the given adapter.
If null, the current adapter
is not changed.
adapter - the new mouse action adaptergetMouseActionAdapter()public MouseActionAdapter getMouseActionAdapter()
setMouseActionAdapter(MouseActionAdapter)public void setKeyActionAdapter(KeyActionAdapter adapter)
Sets the key action adapter for the buffer to the given adapter.
If null, the current adapter
is not changed.
adapter - the new key action adaptergetKeyActionAdapter()public KeyActionAdapter getKeyActionAdapter()
setKeyActionAdapter(KeyActionAdapter)public void paintOver(Graphics2D g2)
Override this paintOver method to add additional
painting actions after the default buffer repaint is done during
a repaint() call.
The intention of this facility is to enable algorithmic
painting to be done via the paintOver method on
top of the default painting of the buffer image on the panel.
This makes the buffer appear to be the background and what is
painted via the paintOver method to be painted in
the foreground.
The default implementation of the paintOver
method is to do nothing. This enables overrides as desired.
g2 - the Graphics2D context for the buffer
repaint operationBufferedPanel.Painter.paint(Graphics)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||