Example usage for org.jfree.data.xy DefaultXYZDataset DefaultXYZDataset

List of usage examples for org.jfree.data.xy DefaultXYZDataset DefaultXYZDataset

Introduction

In this page you can find the example usage for org.jfree.data.xy DefaultXYZDataset DefaultXYZDataset.

Prototype

public DefaultXYZDataset() 

Source Link

Document

Creates a new DefaultXYZDataset instance, initially containing no data.

Usage

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

public static XYZDataset createDataset() {
    DefaultXYZDataset defaultxyzdataset = new DefaultXYZDataset();
    double ad[] = { 2.1000000000000001D, 2.2999999999999998D, 2.2999999999999998D, 2.2000000000000002D,
            2.2000000000000002D, 1.8D, 1.8D, 1.8999999999999999D, 2.2999999999999998D, 3.7999999999999998D };
    double ad1[] = { 14.1D, 11.1D, 10D, 8.8000000000000007D, 8.6999999999999993D, 8.4000000000000004D,
            5.4000000000000004D, 4.0999999999999996D, 4.0999999999999996D, 25D };
    double ad2[] = { 2.3999999999999999D, 2.7000000000000002D, 2.7000000000000002D, 2.2000000000000002D,
            2.2000000000000002D, 2.2000000000000002D, 2.1000000000000001D, 2.2000000000000002D,
            1.6000000000000001D, 4D };/*from   ww w .jav  a 2s.  c  o m*/
    double ad3[][] = { ad, ad1, ad2 };
    defaultxyzdataset.addSeries("Series 1", ad3);
    return defaultxyzdataset;
}

From source file:cv.mikusher.freechart.BubbleChart.java

public static XYZDataset createDataset() {
    DefaultXYZDataset defaultxyzdataset = new DefaultXYZDataset();

    double ad[] = { 30, 40, 50, 60, 70, 80 };
    double ad1[] = { 10, 20, 30, 40, 50, 60 };
    double ad2[] = { 4, 5, 10, 8, 9, 6 };
    double ad3[][] = { ad, ad1, ad2 };
    defaultxyzdataset.addSeries("Series 1", ad3);

    return defaultxyzdataset;
}

From source file:edu.gmu.cs.sim.util.media.chart.BubbleChartGenerator.java

protected void buildChart() {
    DefaultXYZDataset dataset = new DefaultXYZDataset();
    chart = ChartFactory.createBubbleChart("Untitled Chart", "Untitled X Axis", "Untitled Y Axis", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    chart.setAntiAlias(true);//from www .jav a  2s. co  m
    chartPanel = buildChartPanel(chart);
    setChartPanel(chartPanel);

    // most irritating: you can't change the scale type once you've
    // constructed the renderer.  :-(
    chart.getXYPlot().setRenderer(new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_DOMAIN_AXIS));

    // this must come last because the chart must exist for us to set its dataset
    setSeriesDataset(dataset);
}

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

public static XYZDataset createDataset() {
    DefaultXYZDataset defaultxyzdataset = new DefaultXYZDataset();
    double ad[] = { 2.1000000000000001D, 2.2999999999999998D, 2.2999999999999998D, 2.2000000000000002D,
            2.2000000000000002D, 1.8D, 1.8D, 1.8999999999999999D, 2.2999999999999998D, 2.7999999999999998D };
    double ad1[] = { 14.1D, 17.100000000000001D, 10D, 8.8000000000000007D, 8.6999999999999993D,
            8.4000000000000004D, 5.4000000000000004D, 4.0999999999999996D, 4.0999999999999996D, 25D };
    double ad2[] = { 2.3999999999999999D, 2.7000000000000002D, 1.7D, 2.2000000000000002D, 1.3D,
            2.2000000000000002D, 2.1000000000000001D, 3.2000000000000002D, 1.6000000000000001D,
            3.3999999999999999D };//w w  w .  j a v  a  2  s  .  co m
    double ad3[][] = { ad, ad1, ad2 };
    defaultxyzdataset.addSeries("Series 1", ad3);
    return defaultxyzdataset;
}

From source file:edu.gmu.cs.sim.util.media.chart.BubbleChartGenerator.java

protected void update() {
    // we'll rebuild the plot from scratch

    SeriesAttributes[] sa = getSeriesAttributes();
    //XYPlot xyplot = (XYPlot)(chart.getPlot());
    DefaultXYZDataset dataset = new DefaultXYZDataset();

    for (int i = 0; i < sa.length; i++) {
        BubbleChartSeriesAttributes attributes = (BubbleChartSeriesAttributes) (sa[i]);
        double scale = attributes.getScale();

        // copy over values, and square-root the z-value.
        // A bug in JFreeChart means that z-values are not shown by
        // area but rather by (ugh) diameter.
        // Also we'll take advantage of this situation to allow
        // for user-defined scaling of the bubbles on a per-series basis.

        double[][] values = attributes.getValues();
        double[][] v2 = new double[values.length][values[0].length];
        for (int k = 0; k < v2.length; k++) {
            for (int j = 0; j < v2[k].length; j++) {
                v2[k][j] = values[k][j];
            }//  w  w w .  j  av a  2 s. c om
        }
        for (int j = 0; j < v2[2].length; j++) {
            v2[2][j] = Math.sqrt(scale * v2[2][j]);
        }

        dataset.addSeries(new UniqueString(attributes.getSeriesName()), v2);
    }

    setSeriesDataset(dataset);
}

From source file:playground.yu.utils.charts.BubbleChart.java

/**
 * @param title// www.  j  a  v  a  2s  .  c o m
 * @param xAxisLabel
 * @param yAxisLabel
 */
public BubbleChart(String title, String xAxisLabel, String yAxisLabel) {
    super(title, xAxisLabel, yAxisLabel);
    dataset = new DefaultXYZDataset();
    chart = createChart(title, xAxisLabel, yAxisLabel, dataset);
    addDefaultFormatting();
}

From source file:sim.util.media.chart.BubbleChartGenerator.java

protected void update() {
    // we'll rebuild the plot from scratch

    SeriesAttributes[] sa = getSeriesAttributes();
    //XYPlot xyplot = (XYPlot)(chart.getPlot());
    DefaultXYZDataset dataset = new DefaultXYZDataset();

    for (int i = 0; i < sa.length; i++) {
        BubbleChartSeriesAttributes attributes = (BubbleChartSeriesAttributes) (sa[i]);
        double scale = attributes.getScale();

        // copy over values, and square-root the z-value.
        // A bug in JFreeChart means that z-values are not shown by
        // area but rather by (ugh) diameter.
        // Also we'll take advantage of this situation to allow
        // for user-defined scaling of the bubbles on a per-series basis.

        double[][] values = attributes.getValues();
        double[][] v2 = new double[values.length][values[0].length];
        for (int k = 0; k < v2.length; k++)
            for (int j = 0; j < v2[k].length; j++)
                v2[k][j] = values[k][j];
        for (int j = 0; j < v2[2].length; j++)
            v2[2][j] = Math.sqrt(scale * v2[2][j]);

        dataset.addSeries(new UniqueString(attributes.getSeriesName()), v2);
    }/*from   w w w  .  j  av a  2 s  .  co m*/

    setSeriesDataset(dataset);
}

From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV1_5.SimpleScatterPlot.java

public SimpleScatterPlot(double[] xValues, double[] yValues, double[] colors, String xLabel, String yLabel) {
    super(null, true);

    setBackground(Color.white);//  ww  w.  ja  v  a 2 s .  com
    setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));

    xAxis = new NumberAxis(xLabel);
    xAxis.setAutoRangeIncludesZero(false);
    xAxis.setUpperMargin(0);
    xAxis.setLowerMargin(0);

    yAxis = new NumberAxis(yLabel);
    yAxis.setAutoRangeIncludesZero(false);
    yAxis.setUpperMargin(0);
    yAxis.setLowerMargin(0);

    xyDataset = new DefaultXYZDataset();
    int length = Math.min(xValues.length, yValues.length);
    double[][] data = new double[3][length];
    System.arraycopy(xValues, 0, data[0], 0, length);
    System.arraycopy(yValues, 0, data[1], 0, length);
    System.arraycopy(colors, 0, data[2], 0, length);
    xyDataset.addSeries(SERIES_ID, data);

    XYDotRenderer renderer = new XYDotRenderer() {
        @Override
        public Paint getItemPaint(int row, int col) {
            double c = xyDataset.getZ(row, col).doubleValue();
            return Color.getHSBColor((float) c, 1.0f, 1.0f);
        }
    };

    renderer.setDotHeight(3);
    renderer.setDotWidth(3);

    plot = new XYPlot(xyDataset, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinesVisible(true);

    chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 12), plot, false);
    chart.setBackgroundPaint(Color.white);

    super.setChart(chart);
}

From source file:org.jfree.data.xy.DefaultXYZDatasetTest.java

/**
 * Confirm that the equals method can distinguish all the required fields.
 */// w  w w  . java 2  s  . c  om
@Test
public void testEquals() {

    DefaultXYZDataset d1 = new DefaultXYZDataset();
    DefaultXYZDataset d2 = new DefaultXYZDataset();
    assertTrue(d1.equals(d2));
    assertTrue(d2.equals(d1));

    double[] x1 = new double[] { 1.0, 2.0, 3.0 };
    double[] y1 = new double[] { 4.0, 5.0, 6.0 };
    double[] z1 = new double[] { 7.0, 8.0, 9.0 };
    double[][] data1 = new double[][] { x1, y1, z1 };
    double[] x2 = new double[] { 1.0, 2.0, 3.0 };
    double[] y2 = new double[] { 4.0, 5.0, 6.0 };
    double[] z2 = new double[] { 7.0, 8.0, 9.0 };
    double[][] data2 = new double[][] { x2, y2, z2 };
    d1.addSeries("S1", data1);
    assertFalse(d1.equals(d2));
    d2.addSeries("S1", data2);
    assertTrue(d1.equals(d2));
}

From source file:BubbleChartDemo.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, java.io.IOException {

    Connection conn = null;// w w w  . j a v a  2 s  .  c o  m
    Statement stmt = null;
    ResultSet rs = null;
    ResultSetMetaData rsm = null;

    OutputStream out = response.getOutputStream();
    try {

        DefaultXYZDataset dataset = new DefaultXYZDataset();
        double[] x = { 2.1, 2.3, 2.3, 2.2, 2.2, 1.8, 1.8, 1.9, 2.3, 3.8 };
        double[] y = { 14.1, 11.1, 10.0, 8.8, 8.7, 8.4, 5.4, 4.1, 4.1, 25 };
        double[] z = { 2.4, 2.7, 2.7, 2.2, 2.2, 2.2, 2.1, 2.2, 1.6, 4 };
        double[][] series = new double[][] { x, y, z };
        dataset.addSeries("Series 1", series);

        JFreeChart chart = ChartFactory.createBubbleChart("Bubble Chart Demo 1", "X", "Y", dataset,
                PlotOrientation.HORIZONTAL, true, true, true);
        XYPlot plot = (XYPlot) chart.getPlot();
        plot.setForegroundAlpha(0.65f);

        XYItemRenderer renderer = plot.getRenderer();
        renderer.setSeriesPaint(0, Color.blue);

        // increase the margins to account for the fact that the auto-range
        // doesn't take into account the bubble size...
        NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
        domainAxis.setLowerMargin(0.15);
        domainAxis.setUpperMargin(0.15);
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setLowerMargin(0.15);
        rangeAxis.setUpperMargin(0.15);

        response.setContentType("image/png");
        int width = 800;
        int height = 600;
        ChartUtilities.writeChartAsPNG(out, chart, width, height);

    } catch (Exception e) {
        throw new ServletException(e);
    }

}