Example usage for org.jfree.ui ApplicationFrame pack

List of usage examples for org.jfree.ui ApplicationFrame pack

Introduction

In this page you can find the example usage for org.jfree.ui ApplicationFrame pack.

Prototype

@SuppressWarnings("deprecation")
public void pack() 

Source Link

Document

Causes this Window to be sized to fit the preferred size and layouts of its subcomponents.

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;//  w w  w .  jav a 2 s .  co 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:edu.psu.citeseerx.misc.charts.CiteChartBuilderJFree.java

public static void main(String[] args) throws Exception {

    DataSource csxDataSource = DBCPFactory.createDataSource("citeseerx");
    DataSource cgDataSource = DBCPFactory.createDataSource("citegraph");

    CSXDAO csxdao = new CSXDAO();
    csxdao.setDataSource(csxDataSource);

    CiteClusterDAO citedao = new CiteClusterDAOImpl();
    citedao.setDataSource(cgDataSource);

    CiteChartBuilderJFree builder = new CiteChartBuilderJFree();
    builder.setCiteClusterDAO(citedao);/*w  w  w  .j a v  a2 s .  c om*/

    Document doc = csxdao.getDocumentFromDB("10.1.1.1.3288", false, false);
    JFreeChart chart = builder.buildChart(doc);

    ApplicationFrame frame = new ApplicationFrame("Chart Test");
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(500, 500));
    frame.setContentPane(chartPanel);
    frame.pack();
    RefineryUtilities.centerFrameOnScreen(frame);
    frame.setVisible(true);

}

From source file:org.mili.jmibs.jfree.examples.Example5.java

/**
 * @param args//w w w . java 2s .co  m
 */
public static void main(String[] args) {
    /* list with iterations. */
    List<Integer> il = new ArrayList<Integer>() {
        {
            add(100);
            add(1000);
            add(10000);
        }
    };

    /* list with object loadings. */
    List<Integer> ol = new ArrayList<Integer>() {
        {
            add(1000);
            add(10000);
        }
    };

    /* create the suite. */
    BenchmarkSuite bs = DefaultIterationObjectLoadBenchmarkSuite.create(il, ol);

    /* add some benches. */
    bs.addBenchmark(new ReplaceStringBenchmark());
    bs.addBenchmark(new ReplaceStringAppendBenchmark());
    bs.addBenchmark(new ReplaceStringAppendSingleBenchmark());

    /* execute the suite. */
    IterationObjectLoadBenchmarkSuiteResult bsr = (IterationObjectLoadBenchmarkSuiteResult) bs.execute();

    /* create a renderer. */
    BenchmarkSuiteResultRenderer<JFreeChart> bsrr = JFreeChartBarIterationObjectLoadBenchmarkSuiteResultRenderer
            .create();

    /* display the results. */
    ApplicationFrame af = new ApplicationFrame(bsr.getBenchmarkSuite().getName());
    ChartPanel chartPanel = new ChartPanel(bsrr.render(bsr));
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseZoomable(true);
    chartPanel.setPreferredSize(new Dimension(640, 480));
    af.setContentPane(chartPanel);
    af.pack();
    RefineryUtilities.centerFrameOnScreen(af);
    af.setVisible(true);
}

From source file:org.mili.jmibs.jfree.examples.Example4.java

/**
 * @param args/*from   w  ww  .java2s .  c o m*/
 */
public static void main(String[] args) {
    /* list with iterations. */
    List<Integer> il = new ArrayList<Integer>() {
        {
            add(100);
            add(1000);
            add(10000);
        }
    };

    /* list with object loadings. */
    List<Integer> ol = new ArrayList<Integer>() {
        {
            add(1000);
            add(10000);
        }
    };

    /* create the suite. */
    BenchmarkSuite bs = DefaultIterationObjectLoadBenchmarkSuite.create(il, ol);

    /* add some benches. */
    bs.addBenchmark(new AppendStringBufferBenchmark());
    bs.addBenchmark(new AppendStringBuilderBenchmark());
    bs.addBenchmark(new AppendStringConcatBenchmark());
    bs.addBenchmark(new AppendStringPlusBenchmark());

    /* execute the suite. */
    IterationObjectLoadBenchmarkSuiteResult bsr = (IterationObjectLoadBenchmarkSuiteResult) bs.execute();

    /* create a renderer. */
    BenchmarkSuiteResultRenderer<JFreeChart> bsrr = JFreeChartBarIterationObjectLoadBenchmarkSuiteResultRenderer
            .create();

    /* display the results. */
    ApplicationFrame af = new ApplicationFrame(bsr.getBenchmarkSuite().getName());
    ChartPanel chartPanel = new ChartPanel(bsrr.render(bsr));
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseZoomable(true);
    chartPanel.setPreferredSize(new Dimension(640, 480));
    af.setContentPane(chartPanel);
    af.pack();
    RefineryUtilities.centerFrameOnScreen(af);
    af.setVisible(true);
}

From source file:org.mili.jmibs.jfree.examples.Example3.java

/**
 * @param args/*from  w ww.  j av  a  2  s.  c o m*/
 */
public static void main(String[] args) {
    /* list with iterations. */
    List<Integer> il = new ArrayList<Integer>() {
        {
            add(100);
            add(1000);
            add(10000);
        }
    };

    /* list with object loadings. */
    List<Integer> ol = new ArrayList<Integer>() {
        {
            add(1000);
            add(10000);
        }
    };

    /* create the suite. */
    BenchmarkSuite bs = DefaultIterationObjectLoadBenchmarkSuite.create(il, ol);

    /* add some benches. */
    bs.addBenchmark(new TraverseForEachArrayListStringBenchmark());
    bs.addBenchmark(new TraverseHighSpeedIdiomArrayListStringBenchmark());
    bs.addBenchmark(new TraverseForEachVectorStringBenchmark());
    bs.addBenchmark(new TraverseHighSpeedIdiomVectorStringVariableOutsideBenchmark());
    bs.addBenchmark(new TraverseHighSpeedIdiomVectorStringBenchmark());

    /* execute the suite. */
    IterationObjectLoadBenchmarkSuiteResult bsr = (IterationObjectLoadBenchmarkSuiteResult) bs.execute();

    /* create a renderer. */
    BenchmarkSuiteResultRenderer<JFreeChart> bsrr = JFreeChartBarIterationObjectLoadBenchmarkSuiteResultRenderer
            .create();

    /* display the results. */
    ApplicationFrame af = new ApplicationFrame(bsr.getBenchmarkSuite().getName());
    ChartPanel chartPanel = new ChartPanel(bsrr.render(bsr));
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseZoomable(true);
    chartPanel.setPreferredSize(new Dimension(640, 480));
    af.setContentPane(chartPanel);
    af.pack();
    RefineryUtilities.centerFrameOnScreen(af);
    af.setVisible(true);
}

From source file:org.mili.jmibs.jfree.examples.Example6.java

/**
 * @param args/*from w w  w .  ja  v  a 2 s  .  co m*/
 */
public static void main(String[] args) {
    /* list with iterations. */
    List<Integer> il = new ArrayList<Integer>() {
        {
            add(100);
            add(1000);
            add(10000);
        }
    };

    /* list with object loadings. */
    List<Integer> ol = new ArrayList<Integer>() {
        {
            add(10);
            add(20);
            add(30);
            add(40);
            add(50);
        }
    };

    /* create the suite. */
    BenchmarkSuite bs = DefaultIterationObjectLoadBenchmarkSuite.create(il, ol);

    /* add some benches. */
    // really slow ...
    //bs.addBenchmarkClass(FibonacciRecursiveBenchmark.class);
    bs.addBenchmark(new FibonacciEndRecursiveBenchmark());
    bs.addBenchmark(new FibonacciNonRecursiveBenchmark());
    bs.addBenchmark(new FibonacciExplicitBenchmark());

    /* execute the suite. */
    IterationObjectLoadBenchmarkSuiteResult bsr = (IterationObjectLoadBenchmarkSuiteResult) bs.execute();

    /* create a renderer. */
    BenchmarkSuiteResultRenderer<JFreeChart> bsrr = JFreeChartBarIterationObjectLoadBenchmarkSuiteResultRenderer
            .create();

    /* display the results. */
    ApplicationFrame af = new ApplicationFrame(bsr.getBenchmarkSuite().getName());
    ChartPanel chartPanel = new ChartPanel(bsrr.render(bsr));
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseZoomable(true);
    chartPanel.setPreferredSize(new Dimension(640, 480));
    af.setContentPane(chartPanel);
    af.pack();
    RefineryUtilities.centerFrameOnScreen(af);
    af.setVisible(true);
}

From source file:org.mili.jmibs.jfree.examples.Example2.java

/**
 * @param args//from  w  w w .  ja v  a  2s  .c  o m
 */
public static void main(String[] args) {
    /* list with iterations. */
    List<Integer> il = new ArrayList<Integer>() {
        {
            add(100);
            add(1000);
            add(10000);
        }
    };

    /* list with object loadings. */
    List<Integer> ol = new ArrayList<Integer>() {
        {
            add(100);
            add(1000);
            add(10000);
        }
    };

    /* create the suite. */
    BenchmarkSuite bs = DefaultIterationObjectLoadBenchmarkSuite.create(il, ol);

    /* add some benches. */
    bs.addBenchmark(new TraverseForEachArrayListStringBenchmark());
    bs.addBenchmark(new TraverseHighSpeedIdiomArrayListStringBenchmark());

    /* execute the suite. */
    IterationObjectLoadBenchmarkSuiteResult bsr = (IterationObjectLoadBenchmarkSuiteResult) bs.execute();

    /* create a renderer. */
    /*
     * @doc jMibs/II/Getting Started Guide/1. Object load/4. How report my results with jFree?{
     * To create a JFreeChart for an object load suite result, use class
     * &quot;JFreeChartBarIterationObjectLoadBenchmarkSuiteResultRenderer&quot;. It produces
     * a simple chart from your results. The application is as the string renderer. It
     * renders to an JFreeChart object. Simply switch the renderer like following:}
     * @doc jMibs/II/Getting Started Guide/1. Object load/4. How report my results with jFree?(Pre){
     * BenchmarkSuiteResultRenderer<JFreeChart> bsrr = JFreeChartBarIterationObjectLoadBenchmarkSuiteResultRenderer.create(); }
     */
    BenchmarkSuiteResultRenderer<JFreeChart> bsrr = JFreeChartBarIterationObjectLoadBenchmarkSuiteResultRenderer
            .create();

    /* display the results. */
    /*
     * @doc jMibs/II/Getting Started Guide/1. Object load/4. How report my results with jFree?{
     * This chart you can pack into a chart panel and application frame, like this:}
     * @doc jMibs/II/Getting Started Guide/1. Object load/4. How report my results with jFree?(Pre){
     * ApplicationFrame af = new ApplicationFrame(bsr.getBenchmarkSuite().getName());
     * ChartPanel chartPanel = new ChartPanel(bsrr.render(bsr));
     * chartPanel.setFillZoomRectangle(true);
     * chartPanel.setMouseZoomable(true);
     * chartPanel.setPreferredSize(new Dimension(640, 480));
     * af.setContentPane(chartPanel);
     * af.pack(); RefineryUtilities.centerFrameOnScreen(af);
     * af.setVisible(true); }
     */
    ApplicationFrame af = new ApplicationFrame(bsr.getBenchmarkSuite().getName());
    ChartPanel chartPanel = new ChartPanel(bsrr.render(bsr));
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseZoomable(true);
    chartPanel.setPreferredSize(new Dimension(640, 480));
    af.setContentPane(chartPanel);
    af.pack();
    RefineryUtilities.centerFrameOnScreen(af);
    af.setVisible(true);
}

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  ww w .  j  a  va 2 s .c o  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:pisco.batch.visu.BatchingChartFactory.java

/**
 * Starting point for the demonstration application.
 *
 * @param args  ignored.//  w  w w .  ja v  a 2s. com
 */
public static void main(String[] args) {
    //data
    final BJob[] inst1 = new BJob[] { new BJob(1, 5, 2, 1, 7), new BJob(2, 6, 3, 1, 8),
            new BJob(3, 7, 4, 1, 12), new BJob(4, 4, 1, 1, 9), new BJob(5, 3, 2, 1, 15) };
    Batch[] batches = new Batch[3];
    batches[0] = new Batch(0);
    batches[0].parallelMerge(inst1[0]);
    batches[0].parallelMerge(inst1[1]);
    batches[1] = new Batch(1);
    batches[1].parallelMerge(inst1[2]);
    batches[1].parallelMerge(inst1[3]);
    batches[2] = new Batch(2);
    batches[2].parallelMerge(inst1[4]);
    //PDRScheduler.schedule1Lmax(batches);
    PDR1Scheduler.schedule1WFlow(batches);
    //frame
    ApplicationFrame demo = new ApplicationFrame("Batch Processing Demo");
    //ChartPanel chartPanel = new ChartPanel( createLmaxChart(batches, "test", 10));
    ChartPanel chartPanel = new ChartPanel(createWFlowChart(batches, "test", -1));
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
    demo.setContentPane(chartPanel);
    demo.pack();
    RefineryUtilities.centerFrameOnScreen(demo);
    demo.setVisible(true);

}

From source file:javatest.IndicatorsToChart.java

/**
 * Displays a chart in a frame.//  ww  w .  j av a 2  s  .c  o m
 * @param chart the chart to be displayed
 */
private static void displayChart(JFreeChart chart) {
    // Chart panel
    ChartPanel panel = new ChartPanel(chart);
    panel.setFillZoomRectangle(true);
    panel.setMouseWheelEnabled(true);
    panel.setPreferredSize(new java.awt.Dimension(1000, 540));
    // Application frame
    ApplicationFrame frame = new ApplicationFrame("neli - Indicators to chart");
    frame.setContentPane(panel);
    frame.pack();
    RefineryUtilities.centerFrameOnScreen(frame);
    frame.setVisible(true);
}