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 TypeMethodDescriptionvoidaddDrawable(Drawable drawable) Adds a drawable object to the drawing buffer.voidclear()Remove all drawable objects from the drawing buffer.voiddraw(DrawingPanel drawingPanel, Graphics g) Method drawdoublegetXMax()Method getXMaxdoublegetXMin()Method getXMindoublegetYMax()Method getYMaxdoublegetYMin()Method getYMinvoidInvalidates the image so that it is redrawn during the next repaint operation.booleanTests to see if the buffer has an object with a valid measure.booleanReads the visible flag.voidsetBackground(Color color) Method setBackgroundvoidsetVisible(boolean vis) Sets the bufferrer's visible flag.voidupdateImage(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, waitMethods 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:
getXMinin interfaceMeasurable- Returns:
- x min
-
getXMax
public double getXMax()Method getXMax- Specified by:
getXMaxin interfaceMeasurable- Returns:
- x max
-
getYMin
public double getYMin()Method getYMin- Specified by:
getYMinin interfaceMeasurable- Returns:
- ymin
-
getYMax
public double getYMax()Method getYMax- Specified by:
getYMaxin interfaceMeasurable- Returns:
- ymax
-
isMeasured
public boolean isMeasured()Tests to see if the buffer has an object with a valid measure.- Specified by:
isMeasuredin interfaceMeasurable- Returns:
- true if any object in the drawable list is measured
-