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:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.SingleCellAnalysisController.java

/**
 * Generate the dataset for the box plot with the track directionality
 * values./*from   w w  w.j  a v  a2s  .  c o m*/
 *
 * @return a DefaultBoxAndWhiskerCategoryDataset
 */
private DefaultBoxAndWhiskerCategoryDataset getDirecBoxPlotDataset() {
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    singleCellMainController.getFilteringMap().keySet().stream().forEach((singleCellConditionDataHolder) -> {
        dataset.add(Arrays.asList(singleCellConditionDataHolder.getEndPointDirectionalityRatios()),
                singleCellConditionDataHolder.getPlateCondition().toString(), "");
    });
    return dataset;
}

From source file:org.locationtech.udig.processingtoolbox.tools.BoxPlotDialog.java

private BoxAndWhiskerCategoryDataset getDataset(SimpleFeatureCollection features, String[] fields) {
    minMaxVisitor.reset();/* w  ww  .  j a  v a 2 s  .  c  om*/

    Expression[] expression = new Expression[fields.length];
    Map<String, List<Double>> listMap = new TreeMap<String, List<Double>>();
    for (int index = 0; index < expression.length; index++) {
        expression[index] = ff.property(fields[index]);
        listMap.put(fields[index], new ArrayList<Double>());
    }

    SimpleFeatureIterator featureIter = features.features();
    try {
        while (featureIter.hasNext()) {
            SimpleFeature feature = featureIter.next();
            for (int index = 0; index < expression.length; index++) {
                Double val = expression[index].evaluate(feature, Double.class);
                if (val == null || val.isNaN() || val.isInfinite()) {
                    continue;
                }
                minMaxVisitor.visit(val, val);
                listMap.get(fields[index]).add(val);
            }
        }
    } finally {
        featureIter.close();
    }

    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    for (int index = 0; index < fields.length; index++) {
        dataset.add(listMap.get(fields[index]), "Series1", fields[index]); //$NON-NLS-1$
    }
    return dataset;
}

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

private BoxAndWhiskerCategoryDataset addDataSet(Hashtable<String, List> info) {
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    for (String key : info.keySet()) {
        System.out.println(key + ":" + info.get(key).size());
        String[] keyData = key.split(Pattern.quote("+"));
        dataset.add(info.get(key), keyData[1], getTechniqueName(keyData[0]));
    }//from  w w  w.ja  v  a 2 s  . co m
    //System.out.println("dataset" + dataset);
    return dataset;
}

From source file:com.diversityarrays.kdxplore.boxplot.BoxPlotPanel.java

private BoxAndWhiskerCategoryDataset createSampleDataSet(Bag<String> missingOrBad, Bag<String> suppressed,
        Double[] minMax) {/* w ww  .  j av  a  2  s  . c  o m*/
    final DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    seriesCountByTraitName.clear();

    minMax[0] = null;
    minMax[1] = null;
    int count = 0;
    for (TraitInstance instance : traitInstances) {

        TraitInstanceValueRetriever<?> y_tivr = tivrByTi.get(instance);
        String instanceName = traitNameStyle.makeTraitInstanceName(instance);

        List<Double> data = new ArrayList<Double>();

        for (PlotOrSpecimen pos : plotSpecimens) {
            Plot plot = plotInfoProvider.getPlotByPlotId(pos.getPlotId());
            if (plot == null || !plot.isActivated()) {
                continue;
            }

            TraitValue yTraitValue = y_tivr.getAttributeValue(plotInfoProvider, plot, null);
            if (yTraitValue == null || !(yTraitValue.comparable instanceof Number)) {
                missingOrBad.add(instanceName);
                continue;
            } else if (yTraitValue.suppressed) {
                // TODO count suppressed
                suppressed.add(instanceName);
                continue;
            }
            double y = ((Number) yTraitValue.comparable).doubleValue();
            data.add(y);

            if (minMax[0] == null) {
                minMax[0] = y;
                minMax[1] = y;
            } else {
                minMax[0] = Math.min(minMax[0], y);
                minMax[1] = Math.max(minMax[1], y);
            }
        }

        seriesCountByTraitName.put(instanceName, count);

        String columnKey = ""; // TODO use something better? //$NON-NLS-1$
        dataset.add(data, instanceName, columnKey);
        count++;
    }

    return dataset;
}

From source file:msi.gama.outputs.layers.ChartLayerStatement.java

/**
 * create dataset for box_whisker chart// w w  w  . jav a2  s.co  m
 * @return A sample dataset.
 */
private BoxAndWhiskerCategoryDataset createWhisker(final IScope scope) {

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    // final int seriesCount = 1;
    final int categoryCount = 3;
    final int entityCount = 2;

    final DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    for (int i = 0; i < datas.size(); i++) {
        // ChartData e = datas.get(i);
        for (int j = 0; j < categoryCount; j++) {
            final List list = new ArrayList();
            // add some values...
            for (int k = 0; k < entityCount; k++) {
                // list.add(new Double(k*2));
                // list.add(new Double(k*3));
                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));
            }
            dataset.add(list, "Series " + i, " Type " + j);

            history.append("Series " + i);
            history.append(',');
        }
    }
    history.deleteCharAt(history.length() - 1);
    history.append(Strings.LN);
    plot.setDataset(dataset);
    chart.removeLegend();
    final CategoryAxis axis = plot.getDomainAxis();
    axis.setTickLabelFont(getTickFont());
    axis.setLabelFont(getLabelFont());
    // ((BarRenderer3D) plot.getRenderer()).setItemMargin(0.1);
    axis.setCategoryMargin(0.1);
    axis.setUpperMargin(0.05);
    axis.setLowerMargin(0.05);
    return dataset;
}

From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java

public JFreeChart getChartForPlate(PlateImpl plate) {
    IntensityMatrixImpl intensityMatrix = dataManager.getIntensityMatrix();
    List<Injection> injections = intensityMatrix.getInjectionsByPlate().get(plate);

    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    for (Injection one : injections) {
        dataset.add(Arrays.asList(intensityMatrix.getColumn(one)).stream().map((o) -> ((Double) o))
                .collect(Collectors.toList()), "Intensity", one.toString());
    }// w w w.  j a  va 2s .  co  m
    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(plate.toString(), "Injection", "Intensity",
            dataset, true);
    chart.getCategoryPlot().getDomainAxis()
            .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2));
    return chart;
}

From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java

public JFreeChart getChartForGlobalQC() {
    IntensityMatrixImpl intensityMatrix = dataManager.getIntensityMatrix();
    if (intensityMatrix == null)
        return null;
    List<Sample> globalQCList = intensityMatrix.getGlobalQCSamples();
    log.info("global QC {}", globalQCList.size());
    if (globalQCList.size() == 0)
        return null;
    List<Injection> injections = intensityMatrix.getInjectionsBySample(globalQCList.get(0));

    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    for (Injection one : injections) {
        dataset.add(Arrays.asList(intensityMatrix.getColumn(one)).stream().map((o) -> ((Double) o))
                .collect(Collectors.toList()), "Intensity", one.toString());
    }//from   w w  w.  j a v a 2s  .  c o m

    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart("Global QC " + globalQCList.get(0).toString(),
            "Injection", "Intensity", dataset, true);
    chart.getCategoryPlot().getDomainAxis()
            .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2));
    return chart;
}

From source file:playground.christoph.evacuation.analysis.EvacuationTimePictureWriter.java

private JFreeChart createBoxplotChart(List<Double> travelTimes) {

    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    dataset.add(travelTimes, "Series", "");

    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(null, null, "evacuation travel time", dataset,
            false);/* w w  w .j  a v a  2  s  . co  m*/
    chart.getCategoryPlot().setForegroundAlpha(0.75f);
    return chart;
}

From source file:org.moeaframework.analysis.plot.Plot.java

/**
 * Displays the statistical results from an {@link AnalyzerResults} as a
 * box-and-whisker plot.//from   w  w w  .j a v a2  s. co m
 * 
 * @param result the {@code AnalyzerResults} instance
 * @return a reference to this {@code Plot} instance
 */
public Plot add(AnalyzerResults result) {
    createCategoryPlot();

    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

    for (String algorithm : result.getAlgorithms()) {
        for (String indicator : result.get(algorithm).getIndicators()) {
            List<Double> values = new ArrayList<Double>();

            for (double value : result.get(algorithm).get(indicator).getValues()) {
                values.add(value);
            }

            dataset.add(values, algorithm, indicator);
        }
    }

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setDataset(dataset);

    return this;
}

From source file:org.sakaiproject.sitestats.impl.ServerWideReportManagerImpl.java

private BoxAndWhiskerCategoryDataset getHourlyUsageDataSet() {
    // log.info("Generating activityWeekBarDataSet");
    List<ServerWideStatsRecord> hourlyUsagePattern = getHourlyUsagePattern();
    if (hourlyUsagePattern == null) {
        return null;
    }// ww  w  .j  a v  a2 s  .com

    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

    List[] hourList = new ArrayList[24];
    for (int ii = 0; ii < 24; ii++) {
        hourList[ii] = new ArrayList();
    }

    int totalDays = 0;
    Date prevDate = null;
    for (ServerWideStatsRecord regularUsers : hourlyUsagePattern) {
        Date currDate = (Date) regularUsers.get(0);
        if (!currDate.equals(prevDate)) {
            prevDate = currDate;
            totalDays++;
        }
        hourList[(Integer) regularUsers.get(1)].add((Long) regularUsers.get(2));
    }

    for (int ii = 0; ii < 24; ii++) {
        // add zero counts, when no data for the day
        for (int jj = hourList[ii].size(); jj < totalDays; jj++) {
            hourList[ii].add(Long.valueOf(0));
        }

        dataset.add(hourList[ii], "Last 30 days", "" + ii);
    }

    return dataset;
}