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:org.jax.pubarray.server.restful.GraphingResource.java

/**
 * Create a graph for the given configuration
 * @param graphConfiguration//from  w ww  .j  a  va2  s  .com
 *          the key
 * @return
 *          the graph
 */
@SuppressWarnings("unchecked")
private JFreeChart createProbeIntensityGraph(ProbeIntensityGraphConfiguration graphConfiguration) {
    try {
        Connection connection = this.getConnection();

        String[] probeIds = graphConfiguration.getProbeIds();
        double[][] probeDataRows = new double[probeIds.length][];
        for (int i = 0; i < probeIds.length; i++) {
            probeDataRows[i] = this.persistenceManager.getDataRowForProbeID(connection, probeIds[i]);
        }

        TableColumnMetadata orderBy = graphConfiguration.getOrderProbesBy();
        final List<Comparable> orderByItems;
        if (orderBy != null) {
            LOG.info("We are ordering by: " + orderBy);
            orderByItems = this.persistenceManager.getDesignDataColumn(connection, orderBy);
        } else {
            orderByItems = null;
        }

        TableMetadata metadata = this.persistenceManager.getDataTableMetadata(connection);
        final CategoryDataset categoryDataset;
        if (graphConfiguration.getGroupReplicates()) {
            switch (graphConfiguration.getGroupedGraphType()) {
            case BOX_PLOT: {
                categoryDataset = new DefaultBoxAndWhiskerCategoryDataset();
            }
                break;

            case SCATTER_PLOT: {
                categoryDataset = new DefaultMultiValueCategoryDataset();
            }
                break;

            default:
                throw new IllegalArgumentException(
                        "don't know how to deal with plot type: " + graphConfiguration.getGroupedGraphType());
            }
        } else {
            categoryDataset = new DefaultCategoryDataset();
        }

        // iterate through all of the selected probesets
        List<QualifiedColumnMetadata> termsOfInterest = Arrays.asList(graphConfiguration.getTermsOfInterest());
        for (int rowIndex = 0; rowIndex < probeDataRows.length; rowIndex++) {
            double[] currRow = probeDataRows[rowIndex];
            assert currRow.length == metadata.getColumnMetadata().length - 1;

            // should we log2 transform the data?
            if (graphConfiguration.getLog2TransformData()) {
                for (int i = 0; i < currRow.length; i++) {
                    currRow[i] = Math.log(currRow[i]) / LOG2_FACTOR;
                }
            }

            // iterate through the columns in the data table (each column
            // represents a different array)
            List<ComparableContainer<Double, Comparable>> rowElemList = new ArrayList<ComparableContainer<Double, Comparable>>();
            for (int colIndex = 0; colIndex < currRow.length; colIndex++) {
                // we use +1 indexing here because we want to skip over
                // the probesetId metadata and get right to the
                // array intensity metadata
                TableColumnMetadata colMeta = metadata.getColumnMetadata()[colIndex + 1];

                // check to see if we need to skip this data
                if (!graphConfiguration.getIncludeDataFromAllArrays()) {
                    // if it's one of the "terms of interest" we will keep
                    // it. we're using a brute force search here
                    boolean keepThisOne = false;
                    for (QualifiedColumnMetadata termOfInterest : termsOfInterest) {
                        if (termOfInterest.getTableName().equals(metadata.getTableName())
                                && termOfInterest.getName().equals(colMeta.getName())) {
                            keepThisOne = true;
                            break;
                        }
                    }

                    if (!keepThisOne) {
                        continue;
                    }
                }

                final String columnName = colMeta.getName();
                final Comparable columnKey;
                if (orderByItems == null) {
                    columnKey = columnName;
                } else {
                    // the ordering will be done on the selected
                    // "order by" design criteria
                    columnKey = new ComparableContainer<String, Comparable>(columnName,
                            orderByItems.get(colIndex), !graphConfiguration.getGroupReplicates());

                    // TODO remove me!!!!
                    System.out.println("For array " + columnName + " the order by " + "value is: "
                            + orderByItems.get(colIndex));
                    // end of remove me
                }

                rowElemList
                        .add(new ComparableContainer<Double, Comparable>(currRow[colIndex], columnKey, false));
            }

            Collections.sort(rowElemList);

            if (graphConfiguration.getGroupReplicates()) {
                switch (graphConfiguration.getGroupedGraphType()) {
                case BOX_PLOT: {
                    DefaultBoxAndWhiskerCategoryDataset dataset = (DefaultBoxAndWhiskerCategoryDataset) categoryDataset;
                    for (int i = 0; i < rowElemList.size(); i++) {
                        List<Double> groupList = new ArrayList<Double>();
                        groupList.add(rowElemList.get(i).getElement());
                        Comparable colKey = rowElemList.get(i).getComparable();

                        i++;
                        for (; i < rowElemList.size()
                                && rowElemList.get(i).getComparable().equals(colKey); i++) {
                            groupList.add(rowElemList.get(i).getElement());
                        }
                        i--;

                        dataset.add(groupList, probeIds[rowIndex], colKey);
                    }
                }
                    break;

                case SCATTER_PLOT: {
                    DefaultMultiValueCategoryDataset dataset = (DefaultMultiValueCategoryDataset) categoryDataset;
                    for (int i = 0; i < rowElemList.size(); i++) {
                        List<Double> groupList = new ArrayList<Double>();
                        groupList.add(rowElemList.get(i).getElement());
                        Comparable colKey = rowElemList.get(i).getComparable();

                        i++;
                        for (; i < rowElemList.size()
                                && rowElemList.get(i).getComparable().equals(colKey); i++) {
                            groupList.add(rowElemList.get(i).getElement());
                        }
                        i--;

                        dataset.add(groupList, probeIds[rowIndex], colKey);
                    }
                }
                    break;
                }
            } else {
                DefaultCategoryDataset dataset = (DefaultCategoryDataset) categoryDataset;
                for (ComparableContainer<Double, Comparable> rowElem : rowElemList) {
                    dataset.addValue(rowElem.getElement(), probeIds[rowIndex], rowElem.getComparable());
                }
            }
        }

        CategoryAxis xAxis = new CategoryAxis();
        if (graphConfiguration.getGroupReplicates() && orderBy != null) {
            xAxis.setLabel(orderBy.getName());
        } else {
            if (orderBy != null) {
                xAxis.setLabel("Arrays (Ordered By " + orderBy.getName() + ")");
            } else {
                xAxis.setLabel("Arrays");
            }
        }
        xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);

        final NumberAxis yAxis;
        if (graphConfiguration.getLog2TransformData()) {
            yAxis = new NumberAxis("log2(Intensity)");
        } else {
            yAxis = new NumberAxis("Intensity");
        }
        yAxis.setAutoRange(true);
        yAxis.setAutoRangeIncludesZero(false);

        // TODO: this is a HACK to deal with auto-range bug in JFreeChart
        //       which occurs when doing the grouped scatter plot
        if (graphConfiguration.getGroupReplicates()
                && graphConfiguration.getGroupedGraphType() == GroupedGraphType.SCATTER_PLOT) {
            double minVal = Double.POSITIVE_INFINITY;
            double maxVal = Double.NEGATIVE_INFINITY;
            for (double[] dataRow : probeDataRows) {
                for (double datum : dataRow) {
                    if (datum > maxVal) {
                        maxVal = datum;
                    }

                    if (datum < minVal) {
                        minVal = datum;
                    }
                }

                if (minVal != Double.POSITIVE_INFINITY && maxVal != Double.NEGATIVE_INFINITY
                        && minVal != maxVal) {
                    yAxis.setAutoRange(false);

                    double margin = (maxVal - minVal) * 0.02;
                    Range yRange = new Range(minVal - margin, maxVal + margin);
                    yAxis.setRange(yRange);
                }
            }
        }
        // END HACK

        final CategoryItemRenderer renderer;
        if (graphConfiguration.getGroupReplicates()) {
            switch (graphConfiguration.getGroupedGraphType()) {
            case BOX_PLOT: {
                BoxAndWhiskerRenderer boxRenderer = new BoxAndWhiskerRenderer();
                boxRenderer.setMaximumBarWidth(0.03);
                renderer = boxRenderer;
            }
                break;

            case SCATTER_PLOT: {
                renderer = new ScatterRenderer();
            }
                break;

            default:
                throw new IllegalArgumentException(
                        "don't know how to deal with plot type: " + graphConfiguration.getGroupedGraphType());
            }
        } else {
            renderer = new LineAndShapeRenderer();
        }
        Plot plot = new CategoryPlot(categoryDataset, xAxis, yAxis, renderer);

        return new JFreeChart("Intensity Values", plot);
    } catch (SQLException ex) {
        LOG.log(Level.SEVERE, "failed to generate image", ex);
        return null;
    }
}

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

/**
 * Creates a sample dataset./*from   w  w  w . j a v a2  s  .  c  o  m*/
 *
 * @return A sample dataset.
 */
private BoxAndWhiskerCategoryDataset createSampleDataset(ArrayList<Double> Pf) {
    String sDirectorio = experimentsDir;
    System.out.println("experiments dir" + sDirectorio);
    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);

                    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.MessagesSent1.java

/**
 * Creates a sample dataset./*from w w w.  j a v a 2  s.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 = 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"};
            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(avgSend));

                }
                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:org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDatasetTest.java

/**
 * Some checks for the add() method./*from   w  w w .  j a  v  a2  s  .  c  o  m*/
 */
@Test
public void testAddUpdatesCachedRange() {
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    BoxAndWhiskerItem item1 = new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList());
    dataset.add(item1, "R1", "C1");

    // now overwrite this item with another
    BoxAndWhiskerItem item2 = new BoxAndWhiskerItem(1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, new ArrayList());
    dataset.add(item2, "R1", "C1");

    assertEquals(2.5, dataset.getValue("R1", "C1").doubleValue(), EPSILON);
    assertEquals(1.5, dataset.getMeanValue("R1", "C1").doubleValue(), EPSILON);
    assertEquals(2.5, dataset.getMedianValue("R1", "C1").doubleValue(), EPSILON);
    assertEquals(3.5, dataset.getQ1Value("R1", "C1").doubleValue(), EPSILON);
    assertEquals(4.5, dataset.getQ3Value("R1", "C1").doubleValue(), EPSILON);
    assertEquals(5.5, dataset.getMinRegularValue("R1", "C1").doubleValue(), EPSILON);
    assertEquals(6.5, dataset.getMaxRegularValue("R1", "C1").doubleValue(), EPSILON);
    assertEquals(7.5, dataset.getMinOutlier("R1", "C1").doubleValue(), EPSILON);
    assertEquals(8.5, dataset.getMaxOutlier("R1", "C1").doubleValue(), EPSILON);
    assertEquals(new Range(7.5, 8.5), dataset.getRangeBounds(false));
}

From source file:edu.ucla.stat.SOCR.chart.SuperDotChart.java

protected BoxAndWhiskerCategoryDataset createDataset2(boolean isDemo) {
    if (isDemo) {
        updateStatus("isDemo==true in " + this.getClass().getName()
                + " class! return null Dataset, check the code!");
        return null;
    } else {/* w w w .j a  v a 2  s  .  co  m*/

        setArrayFromTable();

        String vs = "";
        row_count = xyLength;
        //System.out.println("row_count="+row_count);
        raw_x = new String[row_count];
        int data_count = 0;
        double[] tmp_xvalue = new double[row_count];

        for (int index = 0; index < independentVarLength; index++)
            for (int i = 0; i < xyLength; i++) {
                raw_x[i] = indepValues[i][index];
                //   System.out.println("raw_x="+raw_x[i]);
                try {

                    // per Ivo request, don't use 0.0 to fill the empty cells 4/16/09
                    if (raw_x[i] == null || raw_x[i].length() == 0) {
                        //   tmp_xvalue[data_count]=0.0;
                        //   vs+="0.0"+",";
                    } else {
                        tmp_xvalue[data_count] = Double.parseDouble(raw_x[i]);
                        vs += raw_x[i] + ",";
                    }
                    data_count++;

                } catch (Exception e) {
                    System.out.println("skipping wrong data " + raw_x[i] + " at " + i);
                }
            }

        //System.out.println("vs="+vs);
        DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
        dataset.add(createValueList(vs), "", "");
        values_storage[0][0] = vs;
        return dataset;
    }
}

From source file:at.ac.tuwien.inso.subcat.ui.widgets.DistributionChart.java

private void initCharts() {
    boxDataSet = new DefaultBoxAndWhiskerCategoryDataset();
    sizeDataSet = new DefaultCategoryDataset();

    // Box:/*from   w w w  . j a v  a  2 s  .  c o m*/
    NumberAxis yAxis = new NumberAxis("Values");
    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());

    boxPlot = new CategoryPlot(boxDataSet, null, yAxis, renderer);
    drawingSupplier = boxPlot.getDrawingSupplier();

    // Bar.
    NumberAxis rangeAxis2 = new NumberAxis("Values");
    rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer renderer2 = new BarRenderer();
    renderer2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    sizePlot = new CategoryPlot(sizeDataSet, null, rangeAxis2, renderer2);
    sizePlot.setDomainGridlinesVisible(true);
}

From source file:gov.nih.nci.ispy.ui.graphing.chart.plot.ISPYCategoricalCorrelationPlot.java

private DefaultBoxAndWhiskerCategoryDataset createChartData() {

    DefaultBoxAndWhiskerCategoryDataset dataSet = new DefaultBoxAndWhiskerCategoryDataset();

    int i = 0;//from  w w w .j  a  v  a  2s.com
    ReporterInfo ri;
    String sequenceName = "";
    for (DataPointVector vec : categoryData) {
        if ((reporterInfoList != null) && (!reporterInfoList.isEmpty())) {
            ri = reporterInfoList.get(i);
            if (ri != null) {
                sequenceName = ri.getGeneSymbol() + " " + ri.getReporterName();
            }
        }
        //only using the X component of the vector to hold the data y and z are not used.
        List<Double> values = removeNaNandNulls(vec.getXValues());
        String categoryName = vec.getName() + " N=" + values.size();
        dataSet.add(values, sequenceName, categoryName);

    }
    return dataSet;
}

From source file:gov.nih.nci.cma.web.graphing.GEPlot.java

public String generateBWLog2IntensityChart(String xAxisLabel, String yAxisLabel, HttpSession session,
        PrintWriter pw, boolean isCoinPlot) {
    String bwFilename = "";

    //PlotSize ps = PlotSize.MEDIUM;

    JFreeChart bwChart = null;/* www .j  a v  a 2  s .c om*/
    try {
        //IMAGE Size Control

        CategoryAxis xAxis = new CategoryAxis(xAxisLabel);
        xAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
        NumberAxis yAxis = new NumberAxis(yAxisLabel);
        yAxis.setAutoRangeIncludesZero(true);
        BoxAndWhiskerCoinPlotRenderer bwRenderer = null;
        CategoryPlot bwPlot = null;

        if (isCoinPlot) {
            Map<String, List<Double>> groupMap = rawDataMap.get(reporterName);
            DefaultBoxAndWhiskerCategoryDataset smallBwdataset = new DefaultBoxAndWhiskerCategoryDataset();
            int row = 0;
            int column = 0;
            HashMap<String, List> caIntegatorCoinList = new HashMap<String, List>();
            for (String group : groupList) {
                smallBwdataset.add(groupMap.get(group), reporterName, group);
                caIntegatorCoinList.put(row + "_" + column++, groupMap.get(group));
            }
            bwRenderer = new BoxAndWhiskerCoinPlotRenderer(caIntegatorCoinList);
            bwRenderer.setDisplayAllOutliers(true);
            bwRenderer.setDisplayCoinCloud(true);
            bwRenderer.setDisplayMean(false);
            bwRenderer.setFillBox(false);
            bwRenderer.setPlotColor(null);
            bwPlot = new CategoryPlot(smallBwdataset, xAxis, yAxis, bwRenderer);

            if (groupList.size() < 6)
                imgW = 200;

        } else {
            bwRenderer = new BoxAndWhiskerCoinPlotRenderer();
            bwRenderer.setDisplayAllOutliers(true);
            bwRenderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {
                public String generateToolTip(CategoryDataset dataset, int series, int item) {
                    String tt = "";
                    NumberFormat formatter = new DecimalFormat(".####");
                    String key = "";
                    //String s = formatter.format(-1234.567);  // -001235
                    if (dataset instanceof DefaultBoxAndWhiskerCategoryDataset) {
                        DefaultBoxAndWhiskerCategoryDataset ds = (DefaultBoxAndWhiskerCategoryDataset) dataset;
                        try {
                            String med = formatter.format(ds.getMedianValue(series, item));
                            tt += "Median: " + med + "<br/>";
                            tt += "Mean: " + formatter.format(ds.getMeanValue(series, item)) + "<br/>";
                            tt += "Q1: " + formatter.format(ds.getQ1Value(series, item)) + "<br/>";
                            tt += "Q3: " + formatter.format(ds.getQ3Value(series, item)) + "<br/>";
                            tt += "Max: " + formatter.format(
                                    FaroutOutlierBoxAndWhiskerCalculator.getMaxFaroutOutlier(ds, series, item))
                                    + "<br/>";
                            tt += "Min: " + formatter.format(
                                    FaroutOutlierBoxAndWhiskerCalculator.getMinFaroutOutlier(ds, series, item))
                                    + "<br/>";
                            tt += "<br/><br/>Please click on the box and whisker to view a plot for this reporter.<br/>";
                            key = ds.getRowKeys().get(series).toString();
                        } catch (Exception e) {
                        }
                    }
                    String returnString = "onclick=\"popCoin('" + geneSymbol + "','" + key + "');\" | ";

                    return returnString + tt;
                }
            });
            bwRenderer.setFillBox(false);
            bwPlot = new CategoryPlot(bwdataset, xAxis, yAxis, bwRenderer);
        }

        bwChart = new JFreeChart(bwPlot);

        bwChart.setBackgroundPaint(java.awt.Color.white);
        LegendTitle title = bwChart.getLegend();
        LegendItemSource[] sources = title.getSources();

        legendItemCollection = sources[0].getLegendItems();
        bwChart.removeLegend();

        // Write the chart image to the temporary directory
        ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());

        // BW
        if (bwChart != null) {
            //int bwwidth = new BigDecimal(1.5).multiply(new BigDecimal(imgW)).intValue();
            bwFilename = ServletUtilities.saveChartAsPNG(bwChart, imgW, 400, info, session);
            CustomOverlibToolTipTagFragmentGenerator ttip = new CustomOverlibToolTipTagFragmentGenerator();
            ttip.setExtra(" href='javascript:void(0);' "); //must have href for area tags to have cursor:pointer
            ChartUtilities.writeImageMap(pw, bwFilename, info, ttip, new StandardURLTagFragmentGenerator());
            info.clear(); // lose the first one
            info = new ChartRenderingInfo(new StandardEntityCollection());
        }
        //END  BW

        pw.flush();

    } catch (Exception e) {
        System.out.println("Exception - " + e.toString());
        e.printStackTrace(System.out);
    }
    // return filename;
    //charts.put("errorBars", log2Filename);
    //charts.put("noErrorBars", rawFilename);
    //charts.put("bwFilename", bwFilename);
    //charts.put("legend", legendHtml);
    //charts.put("size", ps.toString());

    return bwFilename;
}

From source file:org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDatasetTest.java

/**
 * Some basic checks for the constructor.
 *//*from  w w  w  .j a v a2  s  .co  m*/
@Test
public void testConstructor() {
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    assertEquals(0, dataset.getColumnCount());
    assertEquals(0, dataset.getRowCount());
    assertTrue(Double.isNaN(dataset.getRangeLowerBound(false)));
    assertTrue(Double.isNaN(dataset.getRangeUpperBound(false)));
}

From source file:org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDatasetTest.java

/**
 * Some checks for the getRangeBounds() method.
 *//*from www  .  j ava  2 s . c o  m*/
@Test
public void testGetRangeBounds() {
    DefaultBoxAndWhiskerCategoryDataset d1 = new DefaultBoxAndWhiskerCategoryDataset();
    d1.add(new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList()), "R1", "C1");
    assertEquals(new Range(7.0, 8.0), d1.getRangeBounds(false));
    assertEquals(new Range(7.0, 8.0), d1.getRangeBounds(true));

    d1.add(new BoxAndWhiskerItem(1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, new ArrayList()), "R1", "C1");
    assertEquals(new Range(7.5, 8.5), d1.getRangeBounds(false));
    assertEquals(new Range(7.5, 8.5), d1.getRangeBounds(true));

    d1.add(new BoxAndWhiskerItem(2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, new ArrayList()), "R2", "C1");
    assertEquals(new Range(7.5, 9.5), d1.getRangeBounds(false));
    assertEquals(new Range(7.5, 9.5), d1.getRangeBounds(true));

    // this replaces the entry with the current minimum value, but the new
    // minimum value is now in a different item
    d1.add(new BoxAndWhiskerItem(1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 8.6, 9.6, new ArrayList()), "R1", "C1");
    assertEquals(new Range(8.5, 9.6), d1.getRangeBounds(false));
    assertEquals(new Range(8.5, 9.6), d1.getRangeBounds(true));
}