KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > chart > demo > ScatterPlotDemo


1 /* ======================================
2  * JFreeChart : a free Java chart library
3  * ======================================
4  *
5  * Project Info: http://www.jfree.org/jfreechart/index.html
6  * Project Lead: David Gilbert (david.gilbert@object-refinery.com);
7  *
8  * (C) Copyright 2000-2003, by Object Refinery Limited and Contributors.
9  *
10  * This library is free software; you can redistribute it and/or modify it under the terms
11  * of the GNU Lesser General Public License as published by the Free Software Foundation;
12  * either version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License along with this
19  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20  * Boston, MA 02111-1307, USA.
21  *
22  * --------------------
23  * ScatterPlotDemo.java
24  * --------------------
25  * (C) Copyright 2002, 2003, by Object Refinery Limited and Contributors.
26  *
27  * Original Author: David Gilbert (for Object Refinery Limited);
28  * Contributor(s): -;
29  *
30  * $Id: ScatterPlotDemo.java,v 1.7 2003/11/28 10:57:36 mungady Exp $
31  *
32  * Changes
33  * -------
34  * 05-Aug-2002 : Version 1 (DG);
35  *
36  */

37
38 package org.jfree.chart.demo;
39
40 import org.jfree.chart.ChartFactory;
41 import org.jfree.chart.ChartPanel;
42 import org.jfree.chart.JFreeChart;
43 import org.jfree.chart.Legend;
44 import org.jfree.chart.StandardLegend;
45 import org.jfree.chart.axis.NumberAxis;
46 import org.jfree.chart.plot.PlotOrientation;
47 import org.jfree.data.XYDataset;
48 import org.jfree.ui.ApplicationFrame;
49 import org.jfree.ui.RefineryUtilities;
50
51 /**
52  * A demo scatter plot.
53  *
54  * @author David Gilbert
55  */

56 public class ScatterPlotDemo extends ApplicationFrame {
57
58     /**
59      * A demonstration application showing a scatter plot.
60      *
61      * @param title the frame title.
62      */

63     public ScatterPlotDemo(String JavaDoc title) {
64
65         super(title);
66         XYDataset data = new SampleXYDataset2();
67         JFreeChart chart = ChartFactory.createScatterPlot(
68             "Scatter Plot Demo",
69             "X", "Y",
70             data,
71             PlotOrientation.VERTICAL,
72             true,
73             true,
74             false
75         );
76         Legend legend = chart.getLegend();
77         if (legend instanceof StandardLegend) {
78             StandardLegend sl = (StandardLegend) legend;
79             sl.setDisplaySeriesShapes(true);
80         }
81         NumberAxis domainAxis = (NumberAxis) chart.getXYPlot().getDomainAxis();
82         domainAxis.setAutoRangeIncludesZero(false);
83         ChartPanel chartPanel = new ChartPanel(chart);
84         chartPanel.setPreferredSize(new java.awt.Dimension JavaDoc(500, 270));
85         chartPanel.setVerticalAxisTrace(true);
86         chartPanel.setHorizontalAxisTrace(true);
87         chartPanel.setVerticalZoom(true);
88         chartPanel.setHorizontalZoom(true);
89         setContentPane(chartPanel);
90
91     }
92
93     // ****************************************************************************
94
// * COMMERCIAL SUPPORT / JFREECHART DEVELOPER GUIDE *
95
// * Please note that commercial support and documentation is available from: *
96
// * *
97
// * http://www.object-refinery.com/jfreechart/support.html *
98
// * *
99
// * This is not only a great service for developers, but is a VERY IMPORTANT *
100
// * source of funding for the JFreeChart project. Please support us so that *
101
// * we can continue developing free software. *
102
// ****************************************************************************
103

104     /**
105      * Starting point for the demonstration application.
106      *
107      * @param args ignored.
108      */

109     public static void main(String JavaDoc[] args) {
110
111         ScatterPlotDemo demo = new ScatterPlotDemo("Scatter Plot Demo");
112         demo.pack();
113         RefineryUtilities.centerFrameOnScreen(demo);
114         demo.setVisible(true);
115
116     }
117
118 }
119
Popular Tags