• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
import java.awt.RenderingHints;import org.jfree.chart.ChartPanel;import org.jfree.chart.JFreeChart;import org.jfree.chart.axis.NumberAxis;import org.jfree.chart.plot.FastScatterPlot;import org.jfree.ui.ApplicationFrame;import org.jfree.ui.RefineryUtilities;/*** A demo of the fast scatter plot.**/public class FastScatterPlotDemo extends ApplicationFrame {/** A constant for the number of items in the sample dataset. */private static final int COUNT = 500000;/** The data. */private float[][] data = new float[2][COUNT];/*** Creates a new fast scatter plot demo.** @param title the frame title.*/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);}//****************************************************************************
 
// * JFREECHART DEVELOPER GUIDE*// * The JFreeChart Developer Guide, written by David Gilbert, is available*// * to purchase from Object Refinery Limited:*// **// * http://www.object-refinery.com/jfreechart/guide.html*// **// * Sales are used to provide funding for the JFreeChart project - please*// * support us so that we can continue developing free software.*//**************************************************************************** /*** Populates the data array with random values.*/private void populateData() {for (int i = 0; i < this.data[0].length; i++) {final float x = (float) i + 100000;this.data[0][i] = x;this.data[1][i] = 100000 + (float) Math.random() * COUNT;}}/*** Starting point for the demonstration application.** @param args ignored.*/public static void main(final String[] args) {final FastScatterPlotDemo demo = new FastScatterPlotDemo("Fast ScatterPlot Demo");demo.pack();RefineryUtilities.centerFrameOnScreen(demo);demo.setVisible(true);}}
 
import java.awt.Dimension;import javax.swing.JPanel;import org.jfree.chart.*;import org.jfree.chart.axis.NumberAxis;import org.jfree.chart.plot.PlotOrientation;import org.jfree.chart.plot.XYPlot;import org.jfree.chart.renderer.xy.XYDotRenderer;import org.jfree.data.xy.XYDataset;import org.jfree.ui.ApplicationFrame;import org.jfree.ui.RefineryUtilities;// Referenced classes of package demo:// SampleXYDataset2public class ScatterPlotDemo2 extends ApplicationFrame{public ScatterPlotDemo2(String s){super(s);JPanel jpanel = createDemoPanel();jpanel.setPreferredSize(new Dimension(500, 270));setContentPane(jpanel);}private static JFreeChart createChart(XYDataset xydataset){JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter Plot Demo2", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false);XYPlot xyplot = (XYPlot)jfreechart.getPlot();XYDotRenderer xydotrenderer = new XYDotRenderer();xydotrenderer.setDotWidth(2);xydotrenderer.setDotHeight(2);xyplot.setRenderer(xydotrenderer);NumberAxis numberaxis = (NumberAxis)xyplot.getDomainAxis();numberaxis.setAutoRangeIncludesZero(false);return jfreechart;}public static JPanel createDemoPanel(){JFreeChart jfreechart = createChart(new SampleXYDataset2());ChartPanel chartpanel = new ChartPanel(jfreechart);chartpanel.setVerticalAxisTrace(true);chartpanel.setHorizontalAxisTrace(true);chartpanel.setPopupMenu(null);chartpanel.setDomainZoomable(true);chartpanel.setRangeZoomable(true);return chartpanel;}public static void main(String args[]){ScatterPlotDemo2 scatterplotdemo2 = new ScatterPlotDemo2("Scatter Plot
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...