Example usage for org.jfree.chart.plot FastScatterPlot FastScatterPlot

List of usage examples for org.jfree.chart.plot FastScatterPlot FastScatterPlot

Introduction

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

Prototype

public FastScatterPlot(float[][] data, ValueAxis domainAxis, ValueAxis rangeAxis) 

Source Link

Document

Creates a new fast scatter plot.

Usage

From source file:org.openimaj.demos.sandbox.PlotFlickrGeo.java

public static void main(String[] args) throws IOException {
    File inputcsv = new File("/Users/jsh2/Desktop/world-geo.csv");
    List<float[]> data = new ArrayList<float[]>(10000000);

    //read in images
    BufferedReader br = new BufferedReader(new FileReader(inputcsv));
    String line;/*from   w ww . ja v  a 2 s .c o m*/
    int i = 0;
    while ((line = br.readLine()) != null) {
        String[] parts = line.split(",");

        float longitude = Float.parseFloat(parts[0]);
        float latitude = Float.parseFloat(parts[1]);

        data.add(new float[] { longitude, latitude });

        if (i++ % 10000 == 0)
            System.out.println(i);
    }

    System.out.println("Done reading");

    float[][] dataArr = new float[2][data.size()];
    for (i = 0; i < data.size(); i++) {
        dataArr[0][i] = data.get(i)[0];
        dataArr[1][i] = data.get(i)[1];
    }

    NumberAxis domainAxis = new NumberAxis("X");
    domainAxis.setRange(-180, 180);
    NumberAxis rangeAxis = new NumberAxis("Y");
    rangeAxis.setRange(-90, 90);
    FastScatterPlot plot = new FastScatterPlot(dataArr, domainAxis, rangeAxis);

    JFreeChart chart = new JFreeChart("Fast Scatter Plot", plot);
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    final ApplicationFrame frame = new ApplicationFrame("Title");
    frame.setContentPane(chartPanel);
    frame.pack();
    frame.setVisible(true);
}

From source file:scatterplot1k.JFreeScatter.java

/**
 * Creates a new fast scatter plot demo.
 *
 * @param title      the frame title.//from  ww w  .ja  v a 2s  .  c  om
 * @param sampleSize
 */
public JFreeScatter(final String title, int sampleSize) {
    super(title);
    this.sampleCount = sampleSize;

    data = new float[2][sampleSize];
    populateData();
    final NumberAxis domainAxis = new NumberAxis("X");
    domainAxis.setAutoRangeIncludesZero(false);
    final NumberAxis rangeAxis = new NumberAxis("Y");
    rangeAxis.setAutoRangeIncludesZero(false);
    final FastScatterPlot plot = new FastScatterPlot(this.data, domainAxis, rangeAxis);
    final JFreeChart chart = new JFreeChart("Fast Scatter Plot", plot);
    //        chart.setLegend(null);

    // force aliasing of the rendered content..
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    final ChartPanel panel = new ChartPanel(chart, true);
    panel.setPreferredSize(new java.awt.Dimension(800, 600));
    //      panel.setHorizontalZoom(true);
    //    panel.setVerticalZoom(true);
    panel.setMinimumDrawHeight(10);
    panel.setMaximumDrawHeight(2000);
    panel.setMinimumDrawWidth(20);
    panel.setMaximumDrawWidth(2000);

    setContentPane(panel);

}

From source file:org.openimaj.demos.sandbox.flickr.geo.PlotFlickrGeo.java

public static void main(String[] args) throws IOException {
    final File inputcsv = new File("/Volumes/SSD/training_latlng");
    final List<double[]> data = new ArrayList<double[]>(10000000);

    // read in images
    final BufferedReader br = new BufferedReader(new FileReader(inputcsv));
    String line;//from   w ww . j av a  2 s  .  co  m
    int i = 0;
    br.readLine();
    while ((line = br.readLine()) != null) {
        final String[] parts = line.split(" ");

        final double longitude = Double.parseDouble(parts[2]);
        final double latitude = Double.parseDouble(parts[1]);

        data.add(new double[] { longitude, latitude });

        if (longitude >= -0.1 && longitude < 0 && latitude > 50 && latitude < 54)
            System.out.println(parts[0] + " " + latitude + " " + longitude);

        // if (i++ % 10000 == 0)
        // System.out.println(i);
    }
    br.close();

    System.out.println("Done reading");

    final float[][] dataArr = new float[2][data.size()];
    for (i = 0; i < data.size(); i++) {
        dataArr[0][i] = (float) data.get(i)[0];
        dataArr[1][i] = (float) data.get(i)[1];
    }

    final NumberAxis domainAxis = new NumberAxis("X");
    domainAxis.setRange(-180, 180);
    final NumberAxis rangeAxis = new NumberAxis("Y");
    rangeAxis.setRange(-90, 90);
    final FastScatterPlot plot = new FastScatterPlot(dataArr, domainAxis, rangeAxis);

    final JFreeChart chart = new JFreeChart("Fast Scatter Plot", plot);
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    final ApplicationFrame frame = new ApplicationFrame("Title");
    frame.setContentPane(chartPanel);
    frame.pack();
    frame.setVisible(true);
}

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

/**
 * Runs the test.//from w  w w .  j  ava 2s. c  om
 */
public void run() {

    this.finished = false;

    // create a dataset...
    populateData();

    // create a fast scatter chart...
    final Plot plot = new FastScatterPlot(this.data, new NumberAxis("X"), new NumberAxis("Y"));
    final JFreeChart chart = new JFreeChart("Fast Scatter Plot Timing", JFreeChart.DEFAULT_TITLE_FONT, plot,
            true);

    final BufferedImage image = new BufferedImage(400, 300, BufferedImage.TYPE_INT_RGB);
    final Graphics2D g2 = image.createGraphics();
    final Rectangle2D chartArea = new Rectangle2D.Double(0, 0, 400, 300);

    // set up the timer...
    final Timer timer = new Timer(10000, this);
    timer.setRepeats(false);
    int count = 0;
    timer.start();
    while (!this.finished) {
        chart.draw(g2, chartArea, null, null);
        System.out.println("Charts drawn..." + count);
        if (!this.finished) {
            count++;
        }
    }
    System.out.println("DONE");

}

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

/**
 * Creates a new fast scatter plot demo.
 *
 * @param title  the frame title./* w w w.  ja v a  2  s  .co  m*/
 */
public FastScatterPlotDemo(final String title) {

    super(title);
    populateData();
    final NumberAxis domainAxis = new NumberAxis("X");
    domainAxis.setAutoRangeIncludesZero(false);
    final NumberAxis rangeAxis = new NumberAxis("Y");
    rangeAxis.setAutoRangeIncludesZero(false);
    final FastScatterPlot plot = new FastScatterPlot(this.data, domainAxis, rangeAxis);
    final JFreeChart chart = new JFreeChart("Fast Scatter Plot", plot);
    //        chart.setLegend(null);

    // force aliasing of the rendered content..
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    final ChartPanel panel = new ChartPanel(chart, true);
    panel.setPreferredSize(new java.awt.Dimension(500, 270));
    //      panel.setHorizontalZoom(true);
    //    panel.setVerticalZoom(true);
    panel.setMinimumDrawHeight(10);
    panel.setMaximumDrawHeight(2000);
    panel.setMinimumDrawWidth(20);
    panel.setMaximumDrawWidth(2000);

    setContentPane(panel);

}

From source file:test.FastScatterDemo.java

/**
 * Creates a new fast scatter plot demo.
 *
 * @param title  the frame title.//from  w  w  w .  j a v  a2 s .c o m
 */
public FastScatterDemo(final String title) {

    super(title);
    populateData();
    final NumberAxis domainAxis = new NumberAxis("X");
    domainAxis.setAutoRangeIncludesZero(false);
    final NumberAxis rangeAxis = new NumberAxis("Y");
    rangeAxis.setAutoRangeIncludesZero(false);
    final FastScatterPlot plot = new FastScatterPlot(this.data, domainAxis, rangeAxis);
    final JFreeChart chart = new JFreeChart("Fast Scatter Plot", plot);
    //        chart.setLegend(null);

    // force aliasing of the rendered content..
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    final ChartPanel panel = new ChartPanel(chart, true);
    panel.setPreferredSize(new java.awt.Dimension(500, 270));
    //      panel.setHorizontalZoom(true);
    //    panel.setVerticalZoom(true);
    panel.setMinimumDrawHeight(10);
    panel.setMaximumDrawHeight(2000);
    panel.setMinimumDrawWidth(20);
    panel.setMaximumDrawWidth(2000);

    setContentPane(panel);

}

From source file:lk.ac.mrt.projectx.buildex.complex.FormalVerifier.java

/**
 * Creates a new fast scatter plot demo.
 *
 * @param title the frame title./*from   ww  w . j  a v  a2 s.  c o m*/
 */
public FormalVerifier(final String title, final String lblx, final String lbly) throws IOException {

    super(title);
    populateData();
    final NumberAxis domainAxis = new NumberAxis(lblx);
    domainAxis.setAutoRangeIncludesZero(false);
    final NumberAxis rangeAxis = new NumberAxis(lbly);
    rangeAxis.setAutoRangeIncludesZero(false);
    final FastScatterPlot plot = new FastScatterPlot(this.data, domainAxis, rangeAxis);
    final JFreeChart chart = new JFreeChart(title, plot);
    //        chart.setLegend(null);

    // force aliasing of the rendered content..
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    final ChartPanel panel = new ChartPanel(chart, true);
    panel.setPreferredSize(new java.awt.Dimension(800, 600));
    //      panel.setHorizontalZoom(true);
    //    panel.setVerticalZoom(true);
    panel.setMinimumDrawHeight(10);
    panel.setMaximumDrawHeight(3000);
    panel.setMinimumDrawWidth(20);
    panel.setMaximumDrawWidth(3000);

    setContentPane(panel);
    //TODO : Print

    ChartUtilities.saveChartAsJPEG(
            new File("F:\\FYP2\\FinalP\\graphs\\Twirl" + System.currentTimeMillis() + ".jpg"), chart, 800, 600);

}

From source file:info.debatty.java.datasets.examples.GaussianMixtureBuilder.java

/**
 * Creates a new fast scatter plot demo.
 *
 * @param title  the frame title.//ww  w. j a va2s.co m
 */
FastScatterPlot2D(final String title, final float[][] data) {

    super(title);
    final NumberAxis x_axis = new NumberAxis("X");
    x_axis.setAutoRangeIncludesZero(false);
    final NumberAxis y_axis = new NumberAxis("Y");
    y_axis.setAutoRangeIncludesZero(false);

    final FastScatterPlot plot = new FastScatterPlot(data, x_axis, y_axis);
    final JFreeChart chart = new JFreeChart(title, plot);

    // force aliasing of the rendered content..
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    final ChartPanel panel = new ChartPanel(chart, true);
    panel.setPreferredSize(new java.awt.Dimension(1024, 768));

    setContentPane(panel);
}

From source file:org.fhcrc.cpl.viewer.gui.ProteinMatcherFrame.java

protected void showPredictedHydroTimePlot() {
    //clone because we're sorting
    Feature[] regressionMS2FeatureArray = _regressionMS2Features.getFeatures().clone();
    Arrays.sort(regressionMS2FeatureArray, new Feature.ScanAscComparator());
    int numQualifyingFeatures = 0;
    for (int i = 0; i < regressionMS2FeatureArray.length; i++) {
        if (MS2ExtraInfoDef.getPeptideProphet(regressionMS2FeatureArray[i]) >= minPeptideProphet)
            numQualifyingFeatures++;//from  www.  ja v a2s . c om
    }
    float[][] scatterPlotData = new float[2][numQualifyingFeatures];
    int[] sortedScanArray = new int[numQualifyingFeatures];
    int arrayIndex = 0;
    for (int i = 0; i < regressionMS2FeatureArray.length; i++) {
        if (MS2ExtraInfoDef.getPeptideProphet(regressionMS2FeatureArray[i]) >= minPeptideProphet) {
            Feature ms2Feature = regressionMS2FeatureArray[i];
            scatterPlotData[0][arrayIndex] = (float) AmtUtilities
                    .calculateNormalizedHydrophobicity(MS2ExtraInfoDef.getFirstPeptide(ms2Feature));
            //                scatterPlotData[1][arrayIndex] = ms2Feature.getScan();
            sortedScanArray[arrayIndex] = ms2Feature.getScan();
            arrayIndex++;
        }
    }
    MSRun run = (MSRun) ApplicationContext.getProperty(SharedProperties.MS_RUN);
    double[] timesArrayTemp = AmtUtilities.getTimesForSortedScanArray(run, sortedScanArray);
    float[] timesArray = new float[timesArrayTemp.length];
    for (int i = 0; i < timesArrayTemp.length; i++)
        timesArray[i] = (float) timesArrayTemp[i];
    scatterPlotData[1] = timesArray;

    FastScatterPlot scatterPlot = new FastScatterPlot(scatterPlotData,
            new NumberAxis(TextProvider.getText("CALCULATED_HYDROPHOBICITY")),
            new NumberAxis(TextProvider.getText("TIME")));
    scatterPlot.setPaint(Color.BLUE);
    scatterPlot.setOutlineStroke(new BasicStroke(10));
    ChartDialog chartDialog = new ChartDialog(scatterPlot);
    chartDialog.setLocation(getLocation());
    chartDialog.setVisible(true);
}