1 |
pjm2 |
1.1 |
import java.io.*; |
2 |
|
|
import java.awt.*; |
3 |
|
|
import java.awt.image.*; |
4 |
|
|
import Acme.JPM.Encoders.*; |
5 |
|
|
|
6 |
|
|
|
7 |
|
|
public class IscreamChartWriter { |
8 |
|
|
|
9 |
|
|
public IscreamChartWriter() { |
10 |
|
|
|
11 |
|
|
} |
12 |
|
|
|
13 |
|
|
public static void writeChart(BufferedImage img, String filename) { |
14 |
|
|
try { |
15 |
|
|
FileOutputStream fos = new FileOutputStream(new File(filename)); |
16 |
|
|
GifEncoder encoder = new GifEncoder(img, fos); |
17 |
|
|
|
18 |
|
|
encoder.encode(); |
19 |
|
|
|
20 |
|
|
fos.flush(); |
21 |
|
|
fos.close(); |
22 |
|
|
} |
23 |
|
|
catch(Exception e){ |
24 |
|
|
System.out.println("Could not write the .gif file: " + e); |
25 |
|
|
} |
26 |
|
|
|
27 |
|
|
System.out.println("Wrote " + filename + " successfully."); |
28 |
|
|
} |
29 |
|
|
} |