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 prop
| 24 | * @version 1.0 |
| 25 | */ |
| 26 | public class DrawableBuffer implements Drawable, Measurable { |
| 27 | Image image; |
| 28 | boolean invalid = true; |
| 29 | ArrayList<Drawable> drawableList = new ArrayList<Drawable>(); // list of Drawable objects |
| 30 | Color background = Color.white; |
| 31 | boolean measured = false; |
| 32 | double xmin, xmax, ymin, ymax; |
| 33 | boolean visible = true; |
| 34 | |
| 35 | /** |
| 36 | * Constructor DrawableBuffer |
| 37 | * |
| 38 | */ |
| 39 | public DrawableBuffer() {} |
| 40 | |
| 41 | /** |
| 42 | * Constructor DrawableBuffer |
| 43 | * |
| 44 | * @param drawable |
| 45 | */ |
| 46 | public DrawableBuffer(Drawable drawable) { |
| 47 | addDrawable(drawable); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Adds a drawable object to the drawing buffer. |
| 52 | * @param drawable |
| 53 | */ |
| 54 | public synchronized void addDrawable(Drawable drawable) { |
| 55 | if(!drawableList.contains(drawable)) { |
| 56 | drawableList.add(drawable); |
| 57 | } |
| 58 | invalidateImage(); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Method setBackground |
| 63 | * |
| 64 | * @param color |
| 65 | */ |
| 66 | public void setBackground(Color color) { |
| 67 | background = color; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Sets the bufferrer's visible flag. |
| 72 | * @param vis boolean |
| 73 | */ |
| 74 | public void setVisible(boolean vis) { |
| 75 | visible = vis; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Reads the visible flag. |
| 80 | * @return boolean |
| 81 | */ |
| 82 | public boolean isVisible() { |
| 83 | return visible; |
nothing calls this directly
no outgoing calls
no test coverage detected