org.opensourcephysics.display
Class DrawableBuffer

java.lang.Object
  extended by org.opensourcephysics.display.DrawableBuffer
All Implemented Interfaces:
Drawable, Measurable

public class DrawableBuffer
extends java.lang.Object
implements Drawable, Measurable

A DrawableBuffer contains an image of drawable objects. This image is displayed on a drawing panel whenever when the draw method is invoked. A drawble buffer should be used to render complex drawable objects that change infrequently. Use the updateImage method to generate a new image when the properties of the drawable objects change.

Version:
1.0
Author:
Wolfgang Christian

Constructor Summary
DrawableBuffer()
          Constructor DrawableBuffer
DrawableBuffer(Drawable drawable)
          Constructor DrawableBuffer
 
Method Summary
 void addDrawable(Drawable drawable)
          Adds a drawable object to the drawing buffer.
 void clear()
          Remove all drawable objects from the drawing buffer.
 void draw(DrawingPanel drawingPanel, java.awt.Graphics g)
          Method draw
 double getXMax()
          Method getXMax
 double getXMin()
          Method getXMin
 double getYMax()
          Method getYMax
 double getYMin()
          Method getYMin
 void invalidateImage()
          Invalidates the image so that it is redrawn during the next repaint operation.
 boolean isMeasured()
          Tests to see if the buffer has an object with a valid measure.
 boolean isVisible()
          Reads the visible flag.
 void setBackground(java.awt.Color color)
          Method setBackground
 void setVisible(boolean vis)
          Sets the bufferrer's visible flag.
 void updateImage(DrawingPanel drawingPanel)
          Updates the image using the given drawing panel to set the dimension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DrawableBuffer

public DrawableBuffer()
Constructor DrawableBuffer


DrawableBuffer

public DrawableBuffer(Drawable drawable)
Constructor DrawableBuffer

Parameters:
drawable -
Method Detail

addDrawable

public void addDrawable(Drawable drawable)
Adds a drawable object to the drawing buffer.

Parameters:
drawable -

setBackground

public void setBackground(java.awt.Color color)
Method setBackground

Parameters:
color -

setVisible

public void setVisible(boolean vis)
Sets the bufferrer's visible flag.

Parameters:
vis - boolean

isVisible

public boolean isVisible()
Reads the visible flag.

Returns:
boolean

clear

public void clear()
Remove all drawable objects from the drawing buffer.


invalidateImage

public void invalidateImage()
Invalidates the image so that it is redrawn during the next repaint operation.


updateImage

public void updateImage(DrawingPanel drawingPanel)
Updates the image using the given drawing panel to set the dimension.

Parameters:
drawingPanel -

draw

public void draw(DrawingPanel drawingPanel,
                 java.awt.Graphics g)
Method draw

Specified by:
draw in interface Drawable
Parameters:
drawingPanel -
g -

getXMin

public double getXMin()
Method getXMin

Specified by:
getXMin in interface Measurable
Returns:
x min

getXMax

public double getXMax()
Method getXMax

Specified by:
getXMax in interface Measurable
Returns:
x max

getYMin

public double getYMin()
Method getYMin

Specified by:
getYMin in interface Measurable
Returns:
ymin

getYMax

public double getYMax()
Method getYMax

Specified by:
getYMax in interface Measurable
Returns:
ymax

isMeasured

public boolean isMeasured()
Tests to see if the buffer has an object with a valid measure.

Specified by:
isMeasured in interface Measurable
Returns:
true if any object in the drawable list is measured