Example usage for org.jfree.chart.plot SpiderWebPlot setDataset

List of usage examples for org.jfree.chart.plot SpiderWebPlot setDataset

Introduction

In this page you can find the example usage for org.jfree.chart.plot SpiderWebPlot setDataset.

Prototype

public void setDataset(CategoryDataset dataset) 

Source Link

Document

Sets the dataset used by the plot and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:org.qsos.radar.GenerateRadar.java

/**
 * This class creates a composite in which the radar char will be
 * implemented/* w  ww .ja  va2s .  c o  m*/
 * 
 * @param parent
 *             Composite where the chart will be seen
 * @param Categories
 *             String[] that contains the name of the elements [4 min and 7 max] the user has chosen to visualize
 * @param Scores
 *             Double[] that contains the average score of each category
 * @return Control
 * 
 */
public static Control createChart(Composite parent, String[] Categories, double[] Scores) {

    Composite Charcomposite = new Composite(parent, SWT.EMBEDDED);
    Charcomposite.setLayout(new FillLayout());
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    //
    for (int i = 0; i < CatNumber; i++) {
        dataset.addValue(Scores[i], getTitle(), Categories[i]);
    }

    String BackGroundMire = null;

    //Configuration of the spiderwebplot
    SpiderWebPlot plot = new SpiderWebPlot();
    plot.setDataset(dataset);
    plot.setMaxValue(JQConst.RADAR_MAX_VALUE);
    plot.setSeriesPaint(JQConst.RADAR_SERIES_PAINT);
    plot.setAxisLabelGap(JQConst.RADAR_AXIS_LABEL_GAP);
    plot.setHeadPercent(JQConst.RADAR_HEAD_PERCENT);
    plot.setInteriorGap(JQConst.RADAR_INTERIOR_GAP);
    plot.setWebFilled(true);

    //The backgroundpicture used as a spiderweb is chosen according to the 
    //number of categories selected
    switch (CatNumber) {
    case 4:
        BackGroundMire = JQConst.RADAR_SPIDERWEB_4;
        break;
    case 5:
        BackGroundMire = JQConst.RADAR_SPIDERWEB_5;
        break;
    case 6:
        BackGroundMire = JQConst.RADAR_SPIDERWEB_6;
        break;
    case 7:
        BackGroundMire = JQConst.RADAR_SPIDERWEB_7;
        break;
    }
    javax.swing.ImageIcon icon = new javax.swing.ImageIcon(BackGroundMire);
    plot.setBackgroundImage(icon.getImage());

    //chart creation
    JFreeChart chart = new JFreeChart(plot);

    //Here the background color from the shell is taken in order to match AWT and SWT backgrounds
    Color backgroundColor = parent.getBackground();

    //JFreechart doesn't support SWT so we create an AWT Frame that will depend on Charcomposite
    java.awt.Frame chartPanel = SWT_AWT.new_Frame(Charcomposite);
    chartPanel.setLayout(new java.awt.GridLayout());
    ChartPanel jfreeChartPanel = new ChartPanel(chart);

    chartPanel.setBackground(new java.awt.Color(backgroundColor.getRed(), backgroundColor.getGreen(),
            backgroundColor.getBlue()));

    chartPanel.add(jfreeChartPanel);
    chartPanel.pack();

    return parent;

}

From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputRadar.java

@Override
protected void createNewSerie(final IScope scope, final String serieid) {
    // final ChartDataSeries dataserie = chartdataset.getDataSeries(scope,
    // serieid);/*  w  w w  .  ja  va2s . c o  m*/
    // final XYIntervalSeries serie = new
    // XYIntervalSeries(dataserie.getSerieLegend(scope), false, true);
    final SpiderWebPlot plot = (SpiderWebPlot) this.chart.getPlot();

    final DefaultCategoryDataset firstdataset = (DefaultCategoryDataset) plot.getDataset();

    if (nbseries == 0) {
        plot.setDataset(firstdataset);

    } else {

        // DefaultCategoryDataset newdataset=new DefaultCategoryDataset();
        // jfreedataset.add(newdataset);
        // plot.setDataset(jfreedataset.size()-1, newdataset);
        // plot.setDataset(nbseries, firstdataset);

    }
    nbseries++;
    // plot.setRenderer(nbseries-1,
    // (CategoryItemRenderer)getOrCreateRenderer(scope,serieid));
    IdPosition.put(serieid, nbseries - 1);

    // DEBUG.LOG("new serie"+serieid+" at
    // "+IdPosition.get(serieid)+" fdsize "+plot.getCategories().size()+"
    // jfds "+jfreedataset.size()+" datasc "+plot.getDatasetCount()+" nbse
    // "+nbseries);
    // TODO Auto-generated method stub
}

From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputRadar.java

@Override
protected void clearDataSet(final IScope scope) {
    // TODO Auto-generated method stub
    super.clearDataSet(scope);
    final SpiderWebPlot plot = (SpiderWebPlot) this.chart.getPlot();
    for (int i = plot.getDataset().getRowCount() - 1; i >= 1; i--) {
        // plot.setDataset(i, null);
        // plot.setRenderer(i, null);
    }/*ww  w.j  av a2 s  .c  o m*/
    if (jfreedataset.size() > 0)
        ((DefaultCategoryDataset) jfreedataset.get(0)).clear();
    jfreedataset.clear();
    jfreedataset.add(0, new DefaultCategoryDataset());
    plot.setDataset((DefaultCategoryDataset) jfreedataset.get(0));
    IdPosition.clear();
    nbseries = 0;
}