ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/reports/DBReporter/GraphMaker.java
Revision: 1.2
Committed: Thu Dec 14 17:17:29 2000 UTC (25 years ago) by pjm2
Branch: MAIN
Changes since 1.1: +3 -3 lines
Log Message:
Made the heirarchical printing of the current progress include the name of
the report.

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.2 * @version $Id: GraphMaker.java,v 1.1 2000/12/11 16:31:58 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.2 public final String REVISION = "$Revision: 1.1 $";
29 pjm2 1.1
30     private final int _fg = 0; // black
31     private final int _bg = 16777215; // white
32     private final int _gradeColour = 13421823; // i-scream blue ;)
33    
34     //---STATIC METHODS---
35    
36     //---CONSTRUCTORS---
37    
38     public GraphMaker(PlotData pd){
39     _pd = pd;
40     }
41    
42    
43     //---PUBLIC METHODS---
44    
45     public void writeGraph(String filename, int width, int height, int grade){
46    
47     //Uncomment this to find out the integer values for certain colours.
48     //int rgb = 0*256*256 + 0*256 + 0;
49     //System.out.println ((rgb & 0xff00ff00) | ((rgb & 0xff0000) >> 16) | ((rgb & 0xff) << 16));
50    
51     BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
52    
53     _pd.drawGraph(img, width, height, grade, _fg, _bg, _gradeColour);
54    
55     try {
56     FileOutputStream fos = new FileOutputStream(new File(filename));
57     GifEncoder encoder = new GifEncoder(img, fos);
58    
59     encoder.encode();
60    
61     fos.flush();
62     fos.close();
63    
64 pjm2 1.2 System.out.println(" - Written "+width+"x"+height+" graph file");
65 pjm2 1.1 }
66     catch(Exception e){
67     System.out.println("Could not write the .gif file.");
68     }
69    
70     //g.dispose();
71     //frame.dispose();
72    
73     }
74    
75     /**
76     * Overrides the {@link java.lang.Object#toString() Object.toString()}
77     * method to provide clean logging (every class should have this).
78     *
79     * @return the name of this class and its CVS revision
80     */
81     public String toString() {
82     return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")";
83     }
84    
85     //---PRIVATE METHODS---
86    
87     //---ACCESSOR/MUTATOR METHODS---
88    
89     //---ATTRIBUTES---
90    
91     private PlotData _pd;
92    
93     //---STATIC ATTRIBUTES---
94    
95     }