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:FaceRatios.java

@SuppressWarnings("serial")
public static void main(String[] args) {
    int r = FSDK.ActivateLibrary(FACE_SDK_LICENSE);
    if (r == FSDK.FSDKE_OK) {
        FSDK.Initialize();/*  w w  w .j  a v  a  2  s. c  o m*/
        FSDK.SetFaceDetectionParameters(true, true, 384);

        Map<String, Map<String, ArrayList<Double>>> faceProperties = new HashMap<>();

        for (String directory : new File(FACE_DIRECTORY).list()) {
            if (new File(FACE_DIRECTORY + directory).isDirectory()) {
                Map<String, ArrayList<Double>> properties = new HashMap<String, ArrayList<Double>>() {
                    {
                        for (String property : propertyNames)
                            put(property, new ArrayList<Double>());
                    }
                };

                File[] files = new File(FACE_DIRECTORY + directory).listFiles();
                System.out.println("Analyzing " + directory + " with " + files.length + " files\n");
                for (File file : files) {
                    if (file.isFile()) {
                        HImage imageHandle = new HImage();
                        FSDK.LoadImageFromFileW(imageHandle, file.getAbsolutePath());

                        FSDK.TFacePosition.ByReference facePosition = new FSDK.TFacePosition.ByReference();
                        if (FSDK.DetectFace(imageHandle, facePosition) == FSDK.FSDKE_OK) {
                            FSDK_Features.ByReference facialFeatures = new FSDK_Features.ByReference();
                            FSDK.DetectFacialFeaturesInRegion(imageHandle, (FSDK.TFacePosition) facePosition,
                                    facialFeatures);

                            Point[] featurePoints = new Point[FSDK.FSDK_FACIAL_FEATURE_COUNT];
                            for (int i = 0; i < FSDK.FSDK_FACIAL_FEATURE_COUNT; i++) {
                                featurePoints[i] = new Point(0, 0);
                                featurePoints[i].x = facialFeatures.features[i].x;
                                featurePoints[i].y = facialFeatures.features[i].y;
                            }

                            double eyeDistance = featureDistance(featurePoints, FeatureID.LEFT_EYE,
                                    FeatureID.RIGHT_EYE);
                            double rightEyeSize = featureDistance(featurePoints,
                                    FeatureID.RIGHT_EYE_INNER_CORNER, FeatureID.RIGHT_EYE_OUTER_CORNER);
                            double leftEyeSize = featureDistance(featurePoints, FeatureID.LEFT_EYE_INNER_CORNER,
                                    FeatureID.LEFT_EYE_OUTER_CORNER);
                            double averageEyeSize = (rightEyeSize + leftEyeSize) / 2;

                            double mouthLength = featureDistance(featurePoints, FeatureID.MOUTH_RIGHT_CORNER,
                                    FeatureID.MOUTH_LEFT_CORNER);
                            double mouthHeight = featureDistance(featurePoints, FeatureID.MOUTH_BOTTOM,
                                    FeatureID.MOUTH_TOP);
                            double noseHeight = featureDistance(featurePoints, FeatureID.NOSE_BOTTOM,
                                    FeatureID.NOSE_BRIDGE);
                            double chinHeight = featureDistance(featurePoints, FeatureID.CHIN_BOTTOM,
                                    FeatureID.MOUTH_BOTTOM);

                            double chinToBridgeHeight = featureDistance(featurePoints, FeatureID.CHIN_BOTTOM,
                                    FeatureID.NOSE_BRIDGE);

                            double faceContourLeft = (featurePoints[FeatureID.CHIN_BOTTOM.getIndex()].getY()
                                    - featurePoints[FeatureID.FACE_CONTOUR2.getIndex()].getY())
                                    / (featurePoints[FeatureID.CHIN_BOTTOM.getIndex()].getX()
                                            - featurePoints[FeatureID.FACE_CONTOUR2.getIndex()].getX());
                            double faceContourRight = (featurePoints[FeatureID.CHIN_BOTTOM.getIndex()].getY()
                                    - featurePoints[FeatureID.FACE_CONTOUR12.getIndex()].getY())
                                    / (featurePoints[FeatureID.CHIN_BOTTOM.getIndex()].getX()
                                            - featurePoints[FeatureID.FACE_CONTOUR12.getIndex()].getX());

                            double bridgeLeftEyeDistance = featureDistance(featurePoints,
                                    FeatureID.LEFT_EYE_INNER_CORNER, FeatureID.NOSE_BRIDGE);
                            double bridgeRightEyeDistance = featureDistance(featurePoints,
                                    FeatureID.RIGHT_EYE_INNER_CORNER, FeatureID.NOSE_BRIDGE);

                            properties.get("eyeSize/eyeDistance").add(averageEyeSize / eyeDistance);
                            properties.get("eyeSizeDisparity")
                                    .add(Math.abs(leftEyeSize - rightEyeSize) / averageEyeSize);
                            properties.get("bridgeToEyeDisparity")
                                    .add(Math.abs(bridgeLeftEyeDistance - bridgeRightEyeDistance)
                                            / ((bridgeLeftEyeDistance + bridgeRightEyeDistance) / 2));
                            properties.get("eyeDistance/mouthLength").add(eyeDistance / mouthLength);
                            properties.get("eyeDistance/noseHeight").add(eyeDistance / noseHeight);
                            properties.get("eyeSize/mouthLength").add(eyeDistance / mouthLength);
                            properties.get("eyeSize/noseHeight").add(eyeDistance / noseHeight);
                            properties.get("mouthLength/mouthHeight").add(mouthLength / mouthHeight);
                            properties.get("chinHeight/noseHeight").add(chinHeight / noseHeight);
                            properties.get("chinHeight/chinToBridgeHeight")
                                    .add(chinHeight / chinToBridgeHeight);
                            properties.get("noseHeight/chinToBridgeHeight")
                                    .add(noseHeight / chinToBridgeHeight);
                            properties.get("mouthHeight/chinToBridgeHeight")
                                    .add(mouthHeight / chinToBridgeHeight);
                            properties.get("faceCountourAngle")
                                    .add(Math.toDegrees(Math.atan((faceContourLeft - faceContourRight)
                                            / (1 + faceContourLeft * faceContourRight))));
                        }

                        FSDK.FreeImage(imageHandle);
                    }
                }

                System.out.format("%32s\t%8s\t%8s\t%3s%n", "Property", "", "", "c");
                System.out.println(new String(new char[76]).replace("\0", "-"));

                ArrayList<Entry<String, ArrayList<Double>>> propertyList = new ArrayList<>(
                        properties.entrySet());
                Collections.sort(propertyList, new Comparator<Entry<String, ArrayList<Double>>>() {
                    @Override
                    public int compare(Entry<String, ArrayList<Double>> arg0,
                            Entry<String, ArrayList<Double>> arg1) {
                        DescriptiveStatistics dStats0 = new DescriptiveStatistics(listToArray(arg0.getValue()));
                        DescriptiveStatistics dStats1 = new DescriptiveStatistics(listToArray(arg1.getValue()));
                        return new Double(dStats0.getStandardDeviation() / dStats0.getMean())
                                .compareTo(dStats1.getStandardDeviation() / dStats1.getMean());
                    }
                });

                for (Entry<String, ArrayList<Double>> property : propertyList) {
                    DescriptiveStatistics dStats = new DescriptiveStatistics(listToArray(property.getValue()));
                    System.out.format("%32s\t%4f\t%4f\t%3s%n", property.getKey(), dStats.getMean(),
                            dStats.getStandardDeviation(),
                            Math.round(dStats.getStandardDeviation() / dStats.getMean() * 100) + "%");
                }

                System.out.println("\n");
                faceProperties.put(directory, properties);
            }
        }

        for (String propertyName : propertyNames) {
            DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
            for (Entry<String, Map<String, ArrayList<Double>>> face : faceProperties.entrySet()) {
                dataset.add(face.getValue().get(propertyName), "Default Series", face.getKey());
            }

            PropertyBoxWhisker plot = new PropertyBoxWhisker(propertyName, dataset);
            plot.pack();
            plot.setVisible(true);
        }
    }
}

From source file:org.jfree.chart.demo.BoxAndWhiskerChartDemo1.java

private static BoxAndWhiskerCategoryDataset createDataset() {
    byte byte0 = 3;
    byte byte1 = 5;
    byte byte2 = 20;
    DefaultBoxAndWhiskerCategoryDataset defaultboxandwhiskercategorydataset = new DefaultBoxAndWhiskerCategoryDataset();
    for (int i = 0; i < byte0; i++) {
        for (int j = 0; j < byte1; j++) {
            @SuppressWarnings("rawtypes")
            List list = createValueList(0.0D, 20D, byte2);
            defaultboxandwhiskercategorydataset.add(list, "Series " + i, "Category " + j);
        }/*from w ww . j a v a2s .  c o  m*/

    }

    return defaultboxandwhiskercategorydataset;
}

From source file:edu.msu.cme.rdp.classifier.train.validation.distance.BoxPlotUtils.java

public static void readData(String inFile, File outdir, String xAxisLabel, String yAxisLabel)
        throws IOException {
    XYSeriesCollection dataset = new XYSeriesCollection();
    DefaultBoxAndWhiskerCategoryDataset scatterDataset = new DefaultBoxAndWhiskerCategoryDataset();

    BufferedReader reader = new BufferedReader(new FileReader(inFile));
    String line = reader.readLine();

    while ((line = reader.readLine()) != null) {
        String[] values = line.split("\\t");
        XYSeries series = new XYSeries(values[2]);
        dataset.addSeries(series);/*from  ww  w .  ja v a 2  s  .  c o m*/

        double average = Double.parseDouble(values[4]);
        int Q1 = Integer.parseInt(values[6]);
        ;
        int median = Integer.parseInt(values[7]);
        int Q3 = Integer.parseInt(values[8]);
        int pct_98 = Integer.parseInt(values[9]);
        int pct_2 = Integer.parseInt(values[10]);
        int minOutlier = 0; // we don't care about the outliers
        int maxOutlier = 0; //

        BoxAndWhiskerItem item = new BoxAndWhiskerItem(average, median, Q1, Q3, pct_2, pct_98, minOutlier,
                maxOutlier, new ArrayList());
        scatterDataset.add(item, values[2], "");
    }

    String title = new File(inFile).getName();
    int index = title.indexOf(".");
    if (index != -1) {
        title = title.substring(0, index);
    }

    Font lableFont = new Font("Helvetica", Font.BOLD, 28);
    createBoxplot(scatterDataset, new PrintStream(new File(outdir, title + ".boxchart.png")), title, xAxisLabel,
            yAxisLabel, lableFont);

}

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

public static JFreeChart createDumyChart() {
    final BoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

    final CategoryAxis xAxis = new CategoryAxis("Type");
    final NumberAxis yAxis = new NumberAxis("Value");
    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(true);/*  ww  w. j a  va  2  s  .c  o m*/
    renderer.setMeanVisible(false);
    renderer.setMedianVisible(false);
    // renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    return new JFreeChart(plot);
}

From source file:org.fhcrc.cpl.toolbox.gui.chart.PanelWithBoxAndWhiskerChart.java

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

    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);/*from   ww  w. ja v  a  2s.co  m*/
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryAxis xAxis = new CategoryAxis("Type");
    final NumberAxis yAxis = new NumberAxis("Value");
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    final JFreeChart chart = new JFreeChart(getName(), new Font("SansSerif", Font.BOLD, 14), plot, true);

    init(chart.getPlot());
}

From source file:playground.anhorni.PLOC.analysis.RunsEnsembleBoxPlot.java

public RunsEnsembleBoxPlot(final String chartTitle) {
    dataset = new DefaultBoxAndWhiskerCategoryDataset();
    this.chartTitle = chartTitle;
}

From source file:playground.anhorni.PLOC.analysis.MultipleEnsemblesBoxPlot.java

public MultipleEnsemblesBoxPlot(final String chartTitle) {
    dataset = new DefaultBoxAndWhiskerCategoryDataset();
    this.chartTitle = chartTitle;
}

From source file:umontreal.iro.lecuyer.charts.BoxSeriesCollection.java

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

From source file:org.jgrasstools.gears.utils.chart.CategoryBoxplot.java

private void createDataset() {
    dataset = new DefaultBoxAndWhiskerCategoryDataset();

    for (int i = 0; i < categories.length; i++) {
        final List<Double> list = new ArrayList<Double>();
        double[] catValues = values.get(i);
        for (int j = 0; j < catValues.length; j++) {
            list.add(catValues[j]);//from   w  w w .j  av  a 2s .  c  o  m
        }
        dataset.add(list, "", categories[i]);
    }

}

From source file:playground.wrashid.tryouts.mess.Boxplot.java

private static BoxAndWhiskerCategoryDataset createSampleDataset() {

    final int seriesCount = 3;
    final int categoryCount = 4;
    final int entityCount = 22;

    final DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    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));
            }/* ww  w .  j a v a2s.c  om*/
            dataset.add(list, "Series " + i, " Type " + j);
        }

    }

    return dataset;
}