Class DrawableBuffer

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

public class DrawableBuffer extends 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 Details

    • DrawableBuffer

      public DrawableBuffer()
      Constructor DrawableBuffer
    • DrawableBuffer

      public DrawableBuffer(Drawable drawable)
      Constructor DrawableBuffer
      Parameters:
      drawable -
  • Method Details

    • addDrawable

      public void addDrawable(Drawable drawable)
      Adds a drawable object to the drawing buffer.
      Parameters:
      drawable -
    • setBackground

      public void setBackground(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, 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