KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > monitorenter > gui > chart > demos > StaticChartDiscs


1 /*
2  *
3  * StaticChartDiscs.java, rendering demo of jchart2d.
4  * Copyright (C) Achim Westermann, created on 10.12.2004, 13:48:55
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  *
20  * If you modify or optimize the code in a useful way please let me know.
21  * Achim.Westermann@gmx.de
22  *
23  */

24 package info.monitorenter.gui.chart.demos;
25
26 import info.monitorenter.gui.chart.Chart2D;
27 import info.monitorenter.gui.chart.ITrace2D;
28 import info.monitorenter.gui.chart.layout.ChartPanel;
29 import info.monitorenter.gui.chart.traces.Trace2DSimple;
30 import info.monitorenter.gui.chart.traces.painters.TracePainterDisc;
31
32 import java.awt.Color JavaDoc;
33 import java.awt.event.WindowAdapter JavaDoc;
34 import java.awt.event.WindowEvent JavaDoc;
35
36 import javax.swing.JFrame JavaDoc;
37
38 /**
39  * A demo chart that uses a
40  * {@link info.monitorenter.gui.chart.traces.painters.TracePainterDisc}.
41  * <p>
42  *
43  * @author <a HREF="mailto:Achim.Westermann@gmx.de">Achim Westermann </a>
44  *
45  * @version $Revision: 1.1 $
46  *
47  */

48 public final class StaticChartDiscs {
49
50   /**
51    * Main entry.
52    * <p>
53    *
54    * @param args
55    * ignored.
56    */

57   public static void main(final String JavaDoc[] args) {
58     // Create a chart:
59
Chart2D chart = new Chart2D();
60
61     // Create an ITrace:
62
ITrace2D trace = new Trace2DSimple();
63     trace.setTracePainter(new TracePainterDisc());
64     trace.setColor(Color.DARK_GRAY);
65     // Add all points, as it is static:
66
double count = 0;
67     double value;
68     double place = 0;
69     for (int i = 120; i >= 0; i--) {
70       count += 1.0;
71       place += 1.0;
72       value = Math.random() * count * 10;
73       trace.addPoint(place, value);
74     }
75     // Add the trace to the chart:
76
chart.addTrace(trace);
77
78     // Make it visible:
79
// Create a frame.
80
JFrame JavaDoc frame = new JFrame JavaDoc("StaticChartDiscs");
81     // add the chart to the frame:
82
frame.getContentPane().add(new ChartPanel(chart));
83     frame.setSize(400, 300);
84     // Enable the termination button [cross on the upper right edge]:
85
frame.addWindowListener(new WindowAdapter JavaDoc() {
86       public void windowClosing(final WindowEvent JavaDoc e) {
87         System.exit(0);
88       }
89     });
90     frame.setVisible(true);
91   }
92
93   /**
94    * Defcon.
95    * <p>
96    */

97   private StaticChartDiscs() {
98     // nop
99
}
100 }
101
Popular Tags