Logo
Distributed Genetic Programming Framework
print print

File org.jfree.experimental.chart.swt.demo.SWTPieChartDemo1.java

Here you can find all the information about the file org.jfree.experimental.chart.swt.demo.SWTPieChartDemo1.java. You may explore it here or download it onto your local disk.
/* ===========================================================
 * JFreeChart : a free chart library for the Java(tm) platform
 * ===========================================================
 *
 * (C) Copyright 2000-2006, by Object Refinery Limited and Contributors.
 *
 * Project Info:  http://www.jfree.org/jfreechart/index.html
 *
 * This library is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU Lesser General Public License as published by 
 * the Free Software Foundation; either version 2.1 of the License, or 
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
 * USA.  
 *
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
 * in the United States and other countries.]
 *
 * ---------------------
 * SWTPieChartDemo1.java
 * ---------------------
 * (C) Copyright 2006, by Object Refinery Limited and Contributors.
 *
 * Original Author:  David Gilbert (for Object Refinery Limited);
 * Contributor(s):
 *
 * Changes
 * -------
 * 23-Aug-2006 : New class (DG);
 * 
 */


package org.jfree.experimental.chart.swt.demo;

import java.awt.Font;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
import org.jfree.experimental.chart.swt.ChartComposite;

/**
 * This demo shows a time series chart that has multiple range axes.
 */

public class SWTPieChartDemo1 {
    
    /**
     * Creates a sample dataset.
     * 
     * @return A sample dataset.
     */

    private static PieDataset createDataset() {
        DefaultPieDataset dataset = new DefaultPieDataset();
        dataset.setValue("One"new Double(43.2));
        dataset.setValue("Two"new Double(10.0));
        dataset.setValue("Three"new Double(27.5));
        dataset.setValue("Four"new Double(17.5));
        dataset.setValue("Five"new Double(11.0));
        dataset.setValue("Six"new Double(19.4));
        return dataset;        
    }
    
    /**
     * Creates a chart.
     * 
     * @param dataset  the dataset.
     * 
     * @return A chart.
     */

    private static JFreeChart createChart(PieDataset dataset) {
        
        JFreeChart chart = ChartFactory.createPieChart(
            "Pie Chart Demo 1",  // chart title
            dataset,             // data
            true,               // include legend
            true,
            false
        );

        PiePlot plot = (PiePlot) chart.getPlot();
        plot.setSectionOutlinesVisible(false);
        plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
        plot.setNoDataMessage("No data available");
        plot.setCircular(false);
        plot.setLabelGap(0.02);
        return chart;
        
    }
    
    /**
     * Starting point for the demonstration application.
     *
     * @param args  ignored.
     */

    public static void main( String[] args ) 
    {
        JFreeChart chart = createChart(createDataset());
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setSize(600, 300);
        shell.setLayout(new FillLayout());
        shell.setText("Test for jfreechart running with SWT");
        final ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart,
                false);
        frame.pack();
        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
    }

}

File Information:

file name:SWTPieChartDemo1.java
package:org.jfree.experimental.chart.swt.demo
qualified name:org.jfree.experimental.chart.swt.demo.SWTPieChartDemo1.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/jfree/experimental/chart/swt/demo/SWTPieChartDemo1.java
size:4.157 KB (4257 B)
uploaded: 2018-01-07 12:03:36 GMT+0000
last update: 2006-08-25 12:16:46 GMT+0000
last access: 2018-04-25 23:57:40 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2018-01-07 12:03:34 GMT+0000 served at 2018-04-25 23:57:40 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo