Example usage for org.jfree.data.statistics DefaultBoxAndWhiskerCategoryDataset DefaultBoxAndWhiskerCategoryDataset

List of usage examples for org.jfree.data.statistics DefaultBoxAndWhiskerCategoryDataset DefaultBoxAndWhiskerCategoryDataset

Introduction

In this page you can find the example usage for org.jfree.data.statistics DefaultBoxAndWhiskerCategoryDataset DefaultBoxAndWhiskerCategoryDataset.

Prototype

public DefaultBoxAndWhiskerCategoryDataset() 

Source Link

Document

Creates a new dataset.

Usage

From source file:edu.ucla.stat.SOCR.chart.demo.BoxAndWhiskerChartDemo2.java

protected BoxAndWhiskerCategoryDataset createDataset(boolean isDemo) {

    if (isDemo) {
        SERIES_COUNT = 1;/*  w  w  w. j av  a  2 s.c  o m*/
        CATEGORY_COUNT = 1;
        VALUE_COUNT = 10;
        values_storage = new String[SERIES_COUNT][CATEGORY_COUNT];

        DefaultBoxAndWhiskerCategoryDataset result = new DefaultBoxAndWhiskerCategoryDataset();

        List values = createValueList(0, 20.0, VALUE_COUNT);
        values_storage[0][0] = vs;
        result.add(values, "", "Data");

        raw_y = new String[VALUE_COUNT];
        StringTokenizer st = new StringTokenizer(vs, DELIMITERS);
        data_count = st.countTokens();

        for (int i = 0; i < data_count; i++) {
            raw_y[i] = st.nextToken();
        }
        return result;
    }

    else {

        setArrayFromTable();

        int row_count = xyLength;
        //System.out.println("row_count="+row_count);
        raw_y = new String[row_count];

        data_count = 0;
        String v_list = new String();
        independentVarLength = 1;

        for (int index = 0; index < independentVarLength; index++)
            for (int i = 0; i < xyLength; i++) {
                raw_y[i] = indepValues[i][index];
                try {
                    Double.parseDouble(raw_y[i]);
                    data_count++;
                    v_list += raw_y[i] + ",";
                } catch (Exception e) {
                    System.out.println("Skipping " + raw_y[i]);
                }

            }

        // create the dataset... 
        DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
        SERIES_COUNT = 1;
        CATEGORY_COUNT = 1;
        values_storage = new String[SERIES_COUNT][CATEGORY_COUNT];

        dataset.add(createValueList(v_list), "", independentHeaders[0]);
        values_storage[0][0] = vs;

        return dataset;
    }
}

From source file:wsattacker.plugin.intelligentdos.ui.helper.ChartHelper.java

/**
 * @return/*from   www  . j  a  v a2  s .c  o  m*/
 */
private static BoxAndWhiskerCategoryDataset createDataset(SuccessfulAttack sa) {
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

    add(dataset, RequestType.UNTAMPERED, sa.getUntamperedMetrics());
    add(dataset, RequestType.TAMPERED, sa.getTamperedMetrics());
    add(dataset, RequestType.TESTPROBES, sa.getTestProbeMetrics());

    return dataset;
}

From source file:br.upe.ecomp.dosa.controller.chart.FileBoxplotChartManager.java

private BoxAndWhiskerCategoryDataset createSampleDataset(double[][] values, int step) {

    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    ArrayList<Double> list = null;
    for (int i = 0; i < values.length; i++) {
        list = new ArrayList<Double>();
        for (int j = 0; j < values[i].length; j++) {
            list.add(values[i][j]);/*from  w  ww.j a  va2s  . com*/
        }
        Collections.sort(list);
        // dataset.add(list, "Series", " Iteration " + i);
        dataset.add(BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(list), "Boxplot Evolution chart",
                i * step);
    }
    return dataset;
}

From source file:edu.ucla.stat.SOCR.analyses.gui.Chart.java

public JFreeChart getBoxAndWhiskerChart(String title, String xLabel, String yLabel, int sCount, int cCount,
        int xyLength, String[][] input) {

    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    for (int s = 0; s < sCount; s++)
        for (int c = 0; c < cCount; c++) {
            String v = "";
            for (int i = 0; i < xyLength; i++)
                if (input[i][s] != null && input[i][s].length() != 0)
                    v = v + input[i][s] + ",";

            //values_storage[s][c]= v;
            dataset.add(createValueList(v), "Series " + s, "Category " + c);

        }/*from  w ww. j  av  a2 s  .  c  om*/

    JFreeChart chart = createBoxAndWhiskerChart(title, xLabel, yLabel, dataset);
    return chart;

}

From source file:edu.gmu.cs.sim.util.media.chart.BoxPlotGenerator.java

protected void buildChart() {
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

    // we build the chart manually rather than using ChartFactory
    // because we need to customize the getDataRange method below

    CategoryAxis categoryAxis = new CategoryAxis("");
    NumberAxis valueAxis = new NumberAxis("Untitled Y Axis");
    valueAxis.setAutoRangeIncludesZero(false);
    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer) {
        // Customizing this method in order to provide a bit of
        // vertical buffer.  Otherwise the bar chart box gets drawn
        // slightly off-chart, which looks really bad.

        public Range getDataRange(ValueAxis axis) {
            Range range = super.getDataRange(axis);
            if (range == null) {
                return null;
            }//from  w ww.  ja v a  2 s .c o m
            final double EXTRA_PERCENTAGE = 0.02;
            return Range.expand(range, EXTRA_PERCENTAGE, EXTRA_PERCENTAGE);
        }
    };

    chart = new JFreeChart("Untitled Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    ChartFactory.getChartTheme().apply(chart);

    chart.setAntiAlias(true);
    chartPanel = buildChartPanel(chart);
    setChartPanel(chartPanel);

    // this must come last because the chart must exist for us to set its dataset
    setSeriesDataset(dataset);
}

From source file:adapters.BoxSeriesCollectionAdapter.java

/**
 * Creates a new <TT>BoxSeriesCollection</TT> instance with an empty dataset.
 *
 *///from  w  w  w. j  a va  2  s . c  o  m
public BoxSeriesCollectionAdapter() {
    renderer = new BoxAndWhiskerRenderer();
    seriesCollection = new DefaultBoxAndWhiskerCategoryDataset();
    ((BoxAndWhiskerRenderer) renderer).setMaximumBarWidth(BARWIDTH);
}

From source file:unalcol.termites.boxplots.ECALinfoCollected.java

/**
 * Creates a sample dataset.//from   w  ww .  j  a va2s  . c  o  m
 *
 * @return A sample dataset.
 */
private BoxAndWhiskerCategoryDataset createSampleDataset(ArrayList<Double> Pf) {

    final int seriesCount = 5;
    final int categoryCount = 4;
    final int entityCount = 22;
    String sDirectorio = ".\\experiments\\ECAL CR";
    File f = new File(sDirectorio);
    String extension;
    File[] files = f.listFiles();
    Hashtable<String, String> Pop = new Hashtable<>();
    PrintWriter escribir;
    Scanner sc = null;
    ArrayList<Integer> aPops = new ArrayList<>();
    ArrayList<Double> aPf = new ArrayList<>();
    ArrayList<String> aTech = new ArrayList<>();

    final DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

    for (File file : files) {
        extension = "";
        int i = file.getName().lastIndexOf('.');
        int p = Math.max(file.getName().lastIndexOf('/'), file.getName().lastIndexOf('\\'));
        if (i > p) {
            extension = file.getName().substring(i + 1);
        }

        // System.out.println(file.getName() + "extension" + extension);
        if (file.isFile() && extension.equals("csv") && file.getName().startsWith("experiment")) {
            System.out.println(file.getName());
            System.out.println("get: " + file.getName());
            String[] filenamep = file.getName().split(Pattern.quote("+"));

            System.out.println("file" + filenamep[8]);

            int popsize = Integer.valueOf(filenamep[2]);
            double pf = Double.valueOf(filenamep[4]);
            String mode = filenamep[6];

            int maxIter = -1;
            //if (!filenamep[8].isEmpty()) {
            maxIter = Integer.valueOf(filenamep[8]);
            //}

            System.out.println("psize:" + popsize);
            System.out.println("pf:" + pf);
            System.out.println("mode:" + mode);
            System.out.println("maxIter:" + maxIter);

            String[] aMode = { "random", "levywalk", "sandc" };

            if (/*Pf == pf && */isInMode(aMode, mode)) {
                final List list = new ArrayList();
                try {
                    sc = new Scanner(file);

                } catch (FileNotFoundException ex) {
                    Logger.getLogger(DataCollectedLatexConsolidatorSASOMessagesSend1.class.getName())
                            .log(Level.SEVERE, null, ex);
                }
                int agentsCorrect = 0;
                int worldSize = 0;
                double averageExplored = 0.0;
                int bestRoundNumber = 0;
                double avgSend = 0;
                double avgRecv = 0;
                double avgdataExplInd = 0;
                ArrayList<Double> acSt = new ArrayList<>();
                ArrayList<Double> avgExp = new ArrayList<>();
                ArrayList<Double> bestR = new ArrayList<>();
                ArrayList<Double> avSnd = new ArrayList<>();
                ArrayList<Double> avRecv = new ArrayList<>();
                ArrayList<Double> avIndExpl = new ArrayList<>();

                String[] data = null;
                while (sc.hasNext()) {
                    String line = sc.nextLine();
                    //System.out.println("line:" + line);
                    data = line.split(",");
                    agentsCorrect = Integer.valueOf(data[0]);
                    //agentsIncorrect = Integer.valueOf(data[1]); // not used
                    worldSize = Integer.valueOf(data[3]);
                    averageExplored = Double.valueOf(data[4]);
                    // data[3] stdavgExplored - not used
                    bestRoundNumber = Integer.valueOf(data[6]);
                    avgSend = Double.valueOf(data[7]);
                    avgRecv = Double.valueOf(data[8]);
                    avgdataExplInd = Double.valueOf(data[11]);

                    //Add Data and generate statistics 
                    acSt.add((double) agentsCorrect);
                    avgExp.add(averageExplored);

                    avSnd.add(avgSend);
                    avRecv.add(avgRecv);
                    avIndExpl.add(avgdataExplInd);

                    list.add(new Double(averageExplored / (double) worldSize * 100));
                }
                LOGGER.debug("Adding series " + i);
                LOGGER.debug(list.toString());
                if (Pf.contains(pf)) {
                    /*pf == 1.0E-4 || pf == 3.0E-4*/
                    if (Pf.size() == 1) {
                        dataset.add(list, popsize, getTechniqueName(mode));
                    } else {
                        dataset.add(list, String.valueOf(popsize) + "-" + pf, getTechniqueName(mode));
                    }
                }
            }
        }

    }

    /*for (int i = 0; i < seriesCount; i++) {
     for (int j = 0; j < categoryCount; j++) {
     final List list = new ArrayList();
     // add some values...
     for (int k = 0; k < entityCount; k++) {
     final double value1 = 10.0 + Math.random() * 3;
     list.add(new Double(value1));
     final double value2 = 11.25 + Math.random(); // concentrate values in the middle
     list.add(new Double(value2));
     }
     LOGGER.debug("Adding series " + i);
     LOGGER.debug(list.toString());
     dataset.add(list, "Series " + i, " Type " + j);
     }
            
     }*/
    return dataset;
}

From source file:unalcol.termites.boxplots.HybridRoundNumberReport.java

/**
 * Creates a sample dataset./*from  w  w w.  java2 s  . c  om*/
 *
 * @return A sample dataset.
 */
private BoxAndWhiskerCategoryDataset createSampleDataset(ArrayList<Double> Pf) {

    final int seriesCount = 5;
    final int categoryCount = 4;
    final int entityCount = 22;
    String sDirectorio = ".\\experiments\\2015-10-07-Hybrid\\hybridres";

    File f = new File(sDirectorio);
    String extension;
    File[] files = f.listFiles();
    Hashtable<String, String> Pop = new Hashtable<>();
    PrintWriter escribir;
    Scanner sc = null;
    ArrayList<Integer> aPops = new ArrayList<>();
    ArrayList<Double> aPf = new ArrayList<>();
    ArrayList<String> aTech = new ArrayList<>();

    final DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

    for (File file : files) {
        extension = "";
        int i = file.getName().lastIndexOf('.');
        int p = Math.max(file.getName().lastIndexOf('/'), file.getName().lastIndexOf('\\'));
        if (i > p) {
            extension = file.getName().substring(i + 1);
        }

        // System.out.println(file.getName() + "extension" + extension);
        if (file.isFile() && extension.equals("csv") && file.getName().startsWith("experiment")) {
            System.out.println(file.getName());
            System.out.println("get: " + file.getName());
            String[] filenamep = file.getName().split(Pattern.quote("+"));

            System.out.println("file" + filenamep[8]);

            int popsize = Integer.valueOf(filenamep[2]);
            double pf = Double.valueOf(filenamep[4]);
            String mode = filenamep[6];

            int maxIter = -1;
            //if (!filenamep[8].isEmpty()) {
            maxIter = Integer.valueOf(filenamep[8]);
            //}
            int n = 0;
            int rho = 0;
            double evapRate = 0.0;
            //14, 16, 16
            if (mode.equals("hybrid")) {
                n = Integer.valueOf(filenamep[14]);
                rho = Integer.valueOf(filenamep[16]);
                String[] tmp = filenamep[18].split(Pattern.quote("."));

                System.out.println("history size:" + n);
                System.out.println("rho:" + rho);
                String sEvap = tmp[0] + "." + tmp[1];
                evapRate = Double.valueOf(sEvap);
            }

            System.out.println("psize:" + popsize);
            System.out.println("pf:" + pf);
            System.out.println("mode:" + mode);
            System.out.println("maxIter:" + maxIter);
            System.out.println("evap:" + evapRate);
            String[] aMode = { "hybrid", "lwphevap" };

            if (isInMode(aMode, mode)) {
                final List list = new ArrayList();
                try {
                    sc = new Scanner(file);

                } catch (FileNotFoundException ex) {
                    Logger.getLogger(DataCollectedLatexConsolidatorSASOMessagesSend1.class.getName())
                            .log(Level.SEVERE, null, ex);
                }
                int agentsCorrect = 0;
                int worldSize = 0;
                double averageExplored = 0.0;
                int bestRoundNumber = 0;
                double avgSend = 0;
                double avgRecv = 0;
                double avgdataExplInd = 0;
                ArrayList<Double> acSt = new ArrayList<>();
                ArrayList<Double> avgExp = new ArrayList<>();
                ArrayList<Double> bestR = new ArrayList<>();
                ArrayList<Double> avSnd = new ArrayList<>();
                ArrayList<Double> avRecv = new ArrayList<>();
                ArrayList<Double> avIndExpl = new ArrayList<>();

                String[] data = null;
                while (sc.hasNext()) {
                    String line = sc.nextLine();
                    //System.out.println("line:" + line);
                    data = line.split(",");
                    agentsCorrect = Integer.valueOf(data[0]);
                    //agentsIncorrect = Integer.valueOf(data[1]); // not used
                    worldSize = Integer.valueOf(data[3]);
                    averageExplored = Double.valueOf(data[4]);
                    // data[3] stdavgExplored - not used
                    bestRoundNumber = Integer.valueOf(data[6]);
                    avgSend = Double.valueOf(data[7]);
                    avgRecv = Double.valueOf(data[8]);
                    avgdataExplInd = Double.valueOf(data[11]);

                    //Add Data and generate statistics 
                    acSt.add((double) agentsCorrect);
                    avgExp.add(averageExplored);

                    avSnd.add(avgSend);
                    avRecv.add(avgRecv);
                    avIndExpl.add(avgdataExplInd);
                    if (bestRoundNumber != 0 && bestRoundNumber != -1) {
                        list.add(new Double(bestRoundNumber));
                    }
                }
                LOGGER.debug("Adding series " + i);
                LOGGER.debug(list.toString());
                if (Pf.contains(pf)) {
                    /*pf == 1.0E-4 || pf == 3.0E-4*/
                    if (Pf.size() == 1) {
                        if (mode.equals("hybrid")) {
                            dataset.add(list, popsize,
                                    /*getTechniqueName(mode) + */ rho + "-" + evapRate + "-" + n);
                        } else {
                            dataset.add(list, popsize, getTechniqueName(mode));
                        }
                    } else {
                        if (mode.equals("hybrid")) {
                            dataset.add(list, String.valueOf(popsize) + "-" + pf,
                                    /*getTechniqueName(mode) +*/ rho + "-" + evapRate + "-" + n);
                        } else {
                            dataset.add(list, String.valueOf(popsize) + "-" + pf, getTechniqueName(mode));
                        }
                    }
                }
            }
        }

    }

    /*for (int i = 0; i < seriesCount; i++) {
     for (int j = 0; j < categoryCount; j++) {
     final List list = new ArrayList();
     // add some values...
     for (int k = 0; k < entityCount; k++) {
     final double value1 = 10.0 + Math.random() * 3;
     list.add(new Double(value1));
     final double value2 = 11.25 + Math.random(); // concentrate values in the middle
     list.add(new Double(value2));
     }
     LOGGER.debug("Adding series " + i);
     LOGGER.debug(list.toString());
     dataset.add(list, "Series " + i, " Type " + j);
     }
            
     }*/
    return dataset;
}

From source file:de.thorstenberger.taskmodel.view.statistics.graph.BoxScoresDatasetProducer.java

public Object produceDataset(Map params) throws DatasetProduceException {
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    dataset.add(mc, "MC", "MC");
    dataset.add(cloze, "Lckentext", "Lckentext");
    dataset.add(mapping, "Zuordnung", "Zuordnung");
    dataset.add(text, "Freitext", "Freitext");
    return dataset;

}

From source file:unalcol.termites.boxplots.RoundNumber1.java

/**
 * Creates a sample dataset./*www.j a  va2  s.  c o  m*/
 *
 * @return A sample dataset.
 */
private BoxAndWhiskerCategoryDataset createSampleDataset(ArrayList<Double> Pf) {

    String sDirectorio = experimentsDir;
    File f = new File(sDirectorio);
    String extension;
    File[] files = f.listFiles();
    Hashtable<String, String> Pop = new Hashtable<>();
    PrintWriter escribir;
    Scanner sc = null;
    ArrayList<Integer> aPops = new ArrayList<>();
    ArrayList<Double> aPf = new ArrayList<>();
    ArrayList<String> aTech = new ArrayList<>();

    final DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

    for (File file : files) {
        extension = "";
        int i = file.getName().lastIndexOf('.');
        int p = Math.max(file.getName().lastIndexOf('/'), file.getName().lastIndexOf('\\'));
        if (i > p) {
            extension = file.getName().substring(i + 1);
        }

        // System.out.println(file.getName() + "extension" + extension);
        if (file.isFile() && extension.equals("csv") && file.getName().startsWith("experiment")
                && file.getName().contains(mazeMode)) {
            System.out.println(file.getName());
            System.out.println("get: " + file.getName());
            String[] filenamep = file.getName().split(Pattern.quote("+"));

            System.out.println("file" + filenamep[8]);

            int popsize = Integer.valueOf(filenamep[2]);
            double pf = Double.valueOf(filenamep[4]);
            String mode = filenamep[6];

            int maxIter = -1;
            //if (!filenamep[8].isEmpty()) {
            maxIter = Integer.valueOf(filenamep[8]);
            //}

            System.out.println("psize:" + popsize);
            System.out.println("pf:" + pf);
            System.out.println("mode:" + mode);
            System.out.println("maxIter:" + maxIter);

            //String[] aMode = {"random", "levywalk", "sandc", "sandclw"};
            //String[] aMode = {"levywalk", "lwphevap", "hybrid", "hybrid3", "hybrid4", "sequential"};
            if (/*Pf == pf && */isInMode(aMode, mode)) {
                final List list = new ArrayList();
                try {
                    sc = new Scanner(file);

                } catch (FileNotFoundException ex) {
                    Logger.getLogger(DataCollectedLatexConsolidatorSASOMessagesSend1.class.getName())
                            .log(Level.SEVERE, null, ex);
                }
                int agentsCorrect = 0;
                int worldSize = 0;
                double averageExplored = 0.0;
                int bestRoundNumber = 0;
                double avgSend = 0;
                double avgRecv = 0;
                double avgdataExplInd = 0;
                ArrayList<Double> acSt = new ArrayList<>();
                ArrayList<Double> avgExp = new ArrayList<>();
                ArrayList<Double> bestR = new ArrayList<>();
                ArrayList<Double> avSnd = new ArrayList<>();
                ArrayList<Double> avRecv = new ArrayList<>();
                ArrayList<Double> avIndExpl = new ArrayList<>();

                String[] data = null;
                while (sc.hasNext()) {
                    String line = sc.nextLine();
                    //System.out.println("line:" + line);
                    data = line.split(",");
                    agentsCorrect = Integer.valueOf(data[0]);
                    //agentsIncorrect = Integer.valueOf(data[1]); // not used
                    worldSize = Integer.valueOf(data[3]);
                    averageExplored = Double.valueOf(data[4]);
                    // data[3] stdavgExplored - not used
                    bestRoundNumber = Integer.valueOf(data[6]);
                    avgSend = Double.valueOf(data[7]);
                    avgRecv = Double.valueOf(data[8]);
                    avgdataExplInd = Double.valueOf(data[11]);

                    //Add Data and generate statistics 
                    acSt.add((double) agentsCorrect);
                    avgExp.add(averageExplored);

                    avSnd.add(avgSend);
                    avRecv.add(avgRecv);
                    avIndExpl.add(avgdataExplInd);
                    if (bestRoundNumber != 0 && bestRoundNumber != -1) {
                        list.add(new Double(bestRoundNumber));
                    }
                }
                LOGGER.debug("Adding series " + i);
                LOGGER.debug(list.toString());
                if (Pf.contains(pf)) {
                    /*pf == 1.0E-4 || pf == 3.0E-4*/
                    if (Pf.size() == 1) {
                        dataset.add(list, popsize, getTechniqueName(mode));
                    } else {
                        dataset.add(list, String.valueOf(popsize) + "-" + pf, getTechniqueName(mode));
                    }
                }
            }
        }

    }

    /*for (int i = 0; i < seriesCount; i++) {
     for (int j = 0; j < categoryCount; j++) {
     final List list = new ArrayList();
     // add some values...
     for (int k = 0; k < entityCount; k++) {
     final double value1 = 10.0 + Math.random() * 3;
     list.add(new Double(value1));
     final double value2 = 11.25 + Math.random(); // concentrate values in the middle
     list.add(new Double(value2));
     }
     LOGGER.debug("Adding series " + i);
     LOGGER.debug(list.toString());
     dataset.add(list, "Series " + i, " Type " + j);
     }
            
     }*/
    return dataset;
}