| Total Lines | 15 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package org.gannacademy.cdf.turtlelogo.docs; |
||
| 11 | public class SavableTerrarium extends Terrarium { |
||
| 12 | public void drawTo(String path) { |
||
| 13 | drawTo(path, "PNG"); |
||
| 14 | } |
||
| 15 | |||
| 16 | public void drawTo(String path, String format) { |
||
| 17 | try { |
||
| 18 | BufferedImage image = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB); |
||
| 19 | Graphics2D context = image.createGraphics(); |
||
| 20 | context.setPaint(getBackground()); |
||
| 21 | context.fillRect(0, 0, image.getWidth(), image.getHeight()); |
||
| 22 | draw(context); |
||
| 23 | ImageIO.write(image, format, new File(path)); |
||
| 24 | } catch (IOException e) { |
||
| 25 | e.printStackTrace(); |
||
|
|
|||
| 26 | } |
||
| 29 |