ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/reports/DBReporter/GraphMaker.java
Revision: 1.11
Committed: Sun Jan 7 19:13:14 2001 UTC (24 years, 11 months ago) by pjm2
Branch: MAIN
Changes since 1.10: +0 -0 lines
Log Message:
All generated pages are now stored as metadata in ReportPages.  This will
allow the index pages to be created more easily.

File Contents

# User Rev Content
1 pjm2 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: pjm2 $
19 pjm2 1.4 * @version $Id: GraphMaker.java,v 1.3 2000/12/15 09:39:17 pjm2 Exp $
20 pjm2 1.1 */
21     public class GraphMaker {
22    
23     //---FINAL ATTRIBUTES---
24    
25     /**
26     * The current CVS revision of this class
27     */
28 pjm2 1.4 public final String REVISION = "$Revision: 1.3 $";
29    
30 pjm2 1.1
31     //---STATIC METHODS---
32    
33     //---CONSTRUCTORS---
34    
35     public GraphMaker(PlotData pd){
36     _pd = pd;
37     }
38    
39    
40     //---PUBLIC METHODS---
41    
42 pjm2 1.3 public void writeGraph(String filename, int width, int height, int gradeX, int gradeY){
43 pjm2 1.1
44     BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
45    
46 pjm2 1.4 _pd.drawGraph(img, width, height, gradeX, gradeY);
47 pjm2 1.1
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 pjm2 1.2 System.out.println(" - Written "+width+"x"+height+" graph file");
58 pjm2 1.1 }
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    
88     }