ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/reports/DBReporter/GraphMaker.java
(Generate patch)

Comparing projects/cms/source/reports/DBReporter/GraphMaker.java (file contents):
Revision 1.12 by pjm2, Sun Jan 7 19:54:03 2001 UTC vs.
Revision 1.13 by pjm2, Thu Jan 11 19:03:04 2001 UTC

# Line 1 | Line 1
1 < //---PACKAGE DECLARATION---
2 <
3 < //---IMPORTS---
4 <
5 < import java.io.*;
6 < import java.awt.*;
7 < import java.awt.image.*;
8 <
9 < import Acme.JPM.Encoders.*;
10 <
11 < /**
12 < * GraphMaker - Used to create and ultimately output a gif image.
13 < * This class accepts a PlotData object in the constructor, yet has
14 < * the filename, size, etc. passed in a separate method - this is so
15 < * that the same PlotData can easily be used to create several graphs
16 < * of differing filenames, sizes, etc...
17 < *
18 < * @author  $Author$
19 < * @version $Id$
20 < */
21 < public class GraphMaker {
22 <
23 < //---FINAL ATTRIBUTES---
24 <
25 <    /**
26 <     * The current CVS revision of this class
27 <     */
28 <    public final String REVISION = "$Revision$";
29 <    
30 <
31 < //---STATIC METHODS---
32 <
33 < //---CONSTRUCTORS---
34 <
35 <    public GraphMaker(PlotData pd){
36 <        _pd = pd;
37 <    }
38 <
39 <
40 < //---PUBLIC METHODS---
41 <
42 <    public void writeGraph(String filename, int width, int height, int gradeX, int gradeY){
43 <        
44 <        BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
45 <
46 <        _pd.drawGraph(img, width, height, gradeX, gradeY);
47 <  
48 <        try {
49 <            FileOutputStream fos = new FileOutputStream(new File(filename));
50 <            GifEncoder encoder = new GifEncoder(img, fos);
51 <            
52 <            encoder.encode();
53 <
54 <            fos.flush();
55 <            fos.close();
56 <            
57 <            System.out.println("            - Written "+width+"x"+height+" graph file");
58 <        }
59 <        catch(Exception e){
60 <            System.out.println("Could not write the .gif file.");
61 <        }
62 <
63 <        //g.dispose();
64 <        //frame.dispose();
65 <        
66 <    }
67 <    
68 <    /**
69 <     * Overrides the {@link java.lang.Object#toString() Object.toString()}
70 <     * method to provide clean logging (every class should have this).
71 <     *
72 <     * @return the name of this class and its CVS revision
73 <     */
74 <    public String toString() {
75 <        return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")";
76 <    }
77 <    
78 < //---PRIVATE METHODS---
79 <
80 < //---ACCESSOR/MUTATOR METHODS---
81 <
82 < //---ATTRIBUTES---
83 <
84 <    private PlotData _pd;
85 <
86 < //---STATIC ATTRIBUTES---
87 <    
1 > //---PACKAGE DECLARATION---
2  
3 +
4  
5 + //---IMPORTS---
6  
7 +
8  
9 + import java.io.*;
10  
11 + import java.awt.*;
12  
13 + import java.awt.image.*;
14  
15 +
16  
17 + import Acme.JPM.Encoders.*;
18  
19 +
20  
21 + /**
22  
23 + * GraphMaker - Used to create and ultimately output a gif image.
24  
25 + * This class accepts a PlotData object in the constructor, yet has
26  
27 + * the filename, size, etc. passed in a separate method - this is so
28  
29 + * that the same PlotData can easily be used to create several graphs
30  
31 + * of differing filenames, sizes, etc...
32  
33 + *
34  
35 + * @author  $Author$
36  
37 + * @version $Id$
38  
39 + */
40  
41 + public class GraphMaker {
42  
43 +
44  
45 + //---FINAL ATTRIBUTES---
46  
47 +
48  
49 +    /**
50  
51 +     * The current CVS revision of this class
52  
53 +     */
54  
55 +    public final String REVISION = "$Revision$";
56  
57 +    
58  
59 +
60  
61 + //---STATIC METHODS---
62  
63 +
64  
65 + //---CONSTRUCTORS---
66  
67 +
68  
69 +    public GraphMaker(PlotData pd){
70  
71 +        _pd = pd;
72  
73 +    }
74  
75 +
76  
77 +
78  
79 + //---PUBLIC METHODS---
80  
81 +
82  
83 +    public void writeGraph(String filename, int width, int height, int gradeX, int gradeY){
84  
85 +        
86  
87 +        BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
88  
89 +
90  
91 +        _pd.drawGraph(img, width, height, gradeX, gradeY);
92  
93 +  
94  
95 +        try {
96  
97 +            FileOutputStream fos = new FileOutputStream(new File(filename));
98  
99 +            GifEncoder encoder = new GifEncoder(img, fos);
100  
101 +            
102  
103 +            encoder.encode();
104  
105 +
106  
107 +            fos.flush();
108  
109 +            fos.close();
110  
111 +            
112  
113 +            System.out.println("            - Written "+width+"x"+height+" graph file");
114  
115 +        }
116  
117 +        catch(Exception e){
118  
119 +            System.out.println("Could not write the .gif file.");
120  
121 +        }
122  
123 +
124  
125 +        //g.dispose();
126  
127 +        //frame.dispose();
128  
129 +        
130  
131 +    }
132  
133 +    
134  
135 +    /**
136  
137 +     * Overrides the {@link java.lang.Object#toString() Object.toString()}
138  
139 +     * method to provide clean logging (every class should have this).
140  
141 +     *
142  
143 +     * @return the name of this class and its CVS revision
144  
145 +     */
146  
147 +    public String toString() {
148  
149 +        return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")";
150  
151 +    }
152  
153 +    
154  
155 + //---PRIVATE METHODS---
156  
157 +
158  
159 + //---ACCESSOR/MUTATOR METHODS---
160  
161 +
162  
163 + //---ATTRIBUTES---
164  
165 +
166  
167 +    private PlotData _pd;
168  
169 +
170  
171 + //---STATIC ATTRIBUTES---
172  
173 +    
174  
175   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines