| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 
 | package gpi.Charts;
import gpi.*;
import org.jCharts.chartData.ChartDataException;
import org.jCharts.chartData.PieChartDataSet;
import org.jCharts.nonAxisChart.PieChart2D;
import org.jCharts.properties.*;
 
import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowEvent;
import java.awt.image.*;
 
public class PieChart extends JFrame
{
	private JPanel panel;
        private String [] labels;
        private double [] data;
        private JButton Fermer;        
	/*******************************************************************************
         *
         ********************************************************************************/
	public PieChart(String [] labels1, double [] data1) throws ChartDataException, PropertyException
	{
            labels   = labels1;
            data     = data1;
            initComponents();
	}
 
 
	/*******************************************************************************
         *
         ********************************************************************************/
	private void initComponents() throws ChartDataException, PropertyException                
	{
		this.setSize( 600, 800 );
		this.panel=new JPanel( true );
		this.panel.setSize( 800, 600 );
                Fermer = new JButton();
                Fermer.setText("  Fermer  ");
                Fermer.setBounds(380,500,140,30);
                this.panel.add(Fermer);         
 
		this.getContentPane().add( this.panel );
		this.setVisible( true ); 
 
                InfosConfig LesInfosConfig = new InfosConfig();
		String title="Etat du Parc ";
		int NbElemens = labels.length;
                Paint[] paints = new Color[NbElemens];                
                for (int i=0; i<NbElemens; i++) {
                    int ValColor = i*500/NbElemens;
                    paints[i] = new Color(ValColor);
                }                 
                this.setBounds(20,20,800,600);                
		PieChart2DProperties pieChart2DProperties=new PieChart2DProperties();
		PieChartDataSet pieChartDataSet=new PieChartDataSet( title, data, labels, paints, pieChart2DProperties );
		PieChart2D pieChart2D=new PieChart2D( pieChartDataSet, new LegendProperties(), new ChartProperties(), 450, 450 );
		pieChart2D.setGraphics2D( (Graphics2D) this.panel.getGraphics() );
		pieChart2D.render();
		addWindowListener( new java.awt.event.WindowAdapter()
		{
			public void windowClosing( WindowEvent windowEvent )
			{
				exitForm( windowEvent );
			}
		}
		);
                Fermer.addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseClicked(java.awt.event.MouseEvent evt) {
                        System.exit( 0 );
                    }
                });
 
                try {
                   synchronized(this) {
                        wait();
                    }
                }
                catch (Exception e) {
                    System.out.println("Message erreur = " + e.getMessage());
                }
 
	}
 
 
	/*********************************************************************************
         * Exit the Application
         *
         * @param windowEvent
         ***********************************************************************************/
	private void exitForm( WindowEvent windowEvent )
	{
		System.exit( 0 );
	}
 
        public void wake() {
                synchronized (this) {
                    this.notify();
                }
 
        }
 
	/*********************************************************************************
         *
         *
         ***********************************************************************************/
	public static void main( String args[] ) throws ChartDataException, PropertyException
	{
                String [] labels0 = {"DELL", "HP", "Sun"};
                double [] data0 = {8, 63,52};
                PieChart UnePieChart = new PieChart(labels0 ,data0 );
	}
 
} | 
Partager