1 38 39 package org.jfree.chart.demo; 40 41 import org.jfree.chart.ChartPanel; 42 import org.jfree.chart.JFreeChart; 43 import org.jfree.chart.axis.NumberAxis; 44 import org.jfree.chart.plot.FastScatterPlot; 45 import org.jfree.ui.ApplicationFrame; 46 import org.jfree.ui.RefineryUtilities; 47 48 53 public class FastScatterPlotDemo extends ApplicationFrame { 54 55 56 private static final int COUNT = 500000; 57 58 59 private float[][] data = new float[2][COUNT]; 60 61 66 public FastScatterPlotDemo(String title) { 67 68 super(title); 69 populateData(); 70 NumberAxis domainAxis = new NumberAxis("X"); 71 domainAxis.setAutoRangeIncludesZero(false); 72 NumberAxis rangeAxis = new NumberAxis("Y"); 73 rangeAxis.setAutoRangeIncludesZero(false); 74 FastScatterPlot plot = new FastScatterPlot(data, domainAxis, rangeAxis); 75 JFreeChart chart = new JFreeChart("Fast Scatter Plot", plot); 76 chart.setLegend(null); 77 chart.setAntiAlias(false); 78 ChartPanel panel = new ChartPanel(chart, true); 79 panel.setPreferredSize(new java.awt.Dimension (500, 270)); 80 panel.setHorizontalZoom(true); 81 panel.setVerticalZoom(true); 82 panel.setMinimumDrawHeight(10); 83 panel.setMaximumDrawHeight(2000); 84 panel.setMinimumDrawWidth(20); 85 panel.setMaximumDrawWidth(2000); 86 87 setContentPane(panel); 88 89 } 90 91 102 105 private void populateData() { 106 107 for (int i = 0; i < data[0].length; i++) { 108 float x = (float) i + 100000; 109 data[0][i] = x; 110 data[1][i] = 100000 + (float) Math.random() * COUNT; 111 } 112 113 } 114 115 120 public static void main(String [] args) { 121 122 FastScatterPlotDemo demo = new FastScatterPlotDemo("Fast Scatter Plot Demo"); 123 demo.pack(); 124 RefineryUtilities.centerFrameOnScreen(demo); 125 demo.setVisible(true); 126 127 } 128 129 } 130 | Popular Tags |