Package org.opensourcephysics.display
Class DrawableBuffer
java.lang.Object
org.opensourcephysics.display.DrawableBuffer
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionConstructor DrawableBufferDrawableBuffer
(Drawable drawable) Constructor DrawableBuffer -
Method Summary
Modifier and TypeMethodDescriptionvoid
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, Graphics g) Method drawdouble
getXMax()
Method getXMaxdouble
getXMin()
Method getXMindouble
getYMax()
Method getYMaxdouble
getYMin()
Method getYMinvoid
Invalidates the image so that it is redrawn during the next repaint operation.boolean
Tests to see if the buffer has an object with a valid measure.boolean
Reads the visible flag.void
setBackground
(Color color) Method setBackgroundvoid
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
Methods inherited from interface org.opensourcephysics.display.Drawable
isInteractive
-
Constructor Details
-
DrawableBuffer
public DrawableBuffer()Constructor DrawableBuffer -
DrawableBuffer
Constructor DrawableBuffer- Parameters:
drawable
-
-
-
Method Details
-
addDrawable
Adds a drawable object to the drawing buffer.- Parameters:
drawable
-
-
setBackground
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
Updates the image using the given drawing panel to set the dimension.- Parameters:
drawingPanel
-
-
draw
Method draw -
getXMin
public double getXMin()Method getXMin- Specified by:
getXMin
in interfaceMeasurable
- Returns:
- x min
-
getXMax
public double getXMax()Method getXMax- Specified by:
getXMax
in interfaceMeasurable
- Returns:
- x max
-
getYMin
public double getYMin()Method getYMin- Specified by:
getYMin
in interfaceMeasurable
- Returns:
- ymin
-
getYMax
public double getYMax()Method getYMax- Specified by:
getYMax
in interfaceMeasurable
- Returns:
- ymax
-
isMeasured
public boolean isMeasured()Tests to see if the buffer has an object with a valid measure.- Specified by:
isMeasured
in interfaceMeasurable
- Returns:
- true if any object in the drawable list is measured
-