Example usage for org.jfree.chart.renderer.xy XYItemRenderer setURLGenerator

List of usage examples for org.jfree.chart.renderer.xy XYItemRenderer setURLGenerator

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYItemRenderer setURLGenerator.

Prototype

public void setURLGenerator(XYURLGenerator urlGenerator);

Source Link

Document

Sets the URL generator for HTML image maps.

Usage

From source file:com.itemanalysis.jmetrik.graph.histogram.HistogramChart.java

public static JFreeChart createHistogram(String title, String xAxisLabel, String yAxisLabel,
        IntervalXYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips,
        boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }/*w  w  w .ja  v a2 s  .co  m*/
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    ValueAxis yAxis = new NumberAxis(yAxisLabel);

    XYItemRenderer renderer = new XYBarRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;
}

From source file:org.hxzon.demo.jfreechart.XYDatasetDemo2.java

private static JFreeChart createScatterChart(XYDataset dataset) {

    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);

    XYToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = new StandardXYToolTipGenerator();
    }//ww  w. j  av a2  s.c om

    XYURLGenerator urlGenerator = null;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }
    XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true);
    renderer.setBaseToolTipGenerator(toolTipGenerator);
    renderer.setURLGenerator(urlGenerator);
    plot.setRenderer(renderer);
    plot.setOrientation(orientation);

    JFreeChart chart = new JFreeChart("Scatter Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    yAxis.setNumberFormatOverride(MyNumberFormat.getMyNumberFormat());

    return chart;

}

From source file:org.hxzon.demo.jfreechart.XYDatasetDemo2.java

private static JFreeChart createHistogramChart(XYDataset dataset) {
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    ValueAxis yAxis = new NumberAxis(yAxisLabel);

    XYItemRenderer renderer = new XYBarRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    }//from   w  ww  .  ja  v  a  2 s  .co m
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);
    plot.setDomainZeroBaselineVisible(true);
    plot.setRangeZeroBaselineVisible(true);
    JFreeChart chart = new JFreeChart("Histogram Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    return chart;
}

From source file:org.hxzon.demo.jfreechart.OtherDatasetDemo.java

private static JFreeChart createBubbleChart(XYZDataset dataset) {
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
    //        A renderer that draws a circle at each data point with a diameter that is
    //        determined by the z-value in the dataset (the renderer requires the dataset
    //        to be an instance of {@link XYZDataset}.
    XYItemRenderer renderer = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator());
    }/*from  w  ww  .  j a v a 2 s. c  om*/
    if (urls) {
        renderer.setURLGenerator(new StandardXYZURLGenerator());
    }
    plot.setRenderer(renderer);
    plot.setOrientation(orientation);

    JFreeChart chart = new JFreeChart("Bubble Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    return chart;
}

From source file:org.hxzon.demo.jfreechart.XYDatasetDemo2.java

private static JFreeChart createXYLineChart(XYDataset dataset) {

    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);// w  ww .  ja  v  a 2s  .co m
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    JFreeChart chart = new JFreeChart("XYLine Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    yAxis.setNumberFormatOverride(MyNumberFormat.getMyNumberFormat());

    return chart;
}

From source file:org.openfaces.component.chart.impl.configuration.UrlsConfigurator.java

private void setupUrls(final GridChartView chartView, XYItemRenderer renderer) {
    if (chartView.getUrl() != null) {
        renderer.setURLGenerator(new XYURLGenerator() {
            public String generateURL(XYDataset xyDataset, int i, int i1) {
                return chartView.getUrl();
            }//from   w w w .ja v  a  2 s .c om
        });
    } else if (chartView.getDynamicUrl() != null) {
        renderer.setURLGenerator(new DynamicXYGenerator(chartView, chartView.getDynamicUrl()));
    }
}

From source file:bicat.gui.GraphicPane.java

/**
 * Creates a line chart with//from   w  w w .j a  v a2s .co m
 * default settings.
 *
 * @param title       the chart title (<code>null</code> permitted).
 * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
 * @param dataset     the dataset for the chart (<code>null</code> permitted).
 * @param orientation the plot orientation (horizontal or vertical) (
 *                    <code>null</code> NOT permitted).
 * @param legend      a flag specifying whether or not a legend is required.
 * @param tooltips    configure chart to generate tool tips?
 * @param urls        configure chart to generate URLs?
 * @return The chart.
 */
public static JFreeChart myCreateXYLineChart(String title, String xAxisLabel, String yAxisLabel,
        org.jfree.data.xy.XYDataset dataset, double marker, org.jfree.chart.plot.PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    ValueMarker vm = new ValueMarker(marker);
    vm.setPaint(Color.GRAY);
    // plot.addRangeMarker(vm, Layer.FOREGROUND); //.setPaint(Color.PINK));
    plot.addDomainMarker(vm, Layer.FOREGROUND);

    plot.setOrientation(orientation);
    if (tooltips) {
        renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

}

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

private JFreeChart createChart(final String title, final String categoryAxisLabel, final String valueAxisLabel,
        final XYSeriesCollection dataset) {
    // return ChartFactory.createScatterPlot(title, categoryAxisLabel,
    // valueAxisLabel, dataset, PlotOrientation.VERTICAL, true, // legend?
    // false, // tooltips?
    // false // URLs?
    // );//from w  w  w . ja va2  s  .c o m
    NumberAxis xAxis = new NumberAxis(categoryAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    xAxis.setRange(0, 24);
    NumberAxis yAxis = new NumberAxis(valueAxisLabel);
    yAxis.setAutoRangeIncludesZero(true);
    yAxis.setRange(0, 100);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);

    XYItemRenderer renderer = new XYLineAndShapeRenderer(true, true);
    renderer.setBaseToolTipGenerator(null/* XYToolTipGenerator */);
    renderer.setURLGenerator(null/* urlGenerator */);
    plot.setRenderer(renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true/* legend */);
    return chart;
}

From source file:bicat.gui.GraphicPane.java

public static JFreeChart myCreateXYLineChart(String title, String xAxisLabel, String yAxisLabel,
        org.jfree.data.xy.XYDataset dataset, double[] marker, org.jfree.chart.plot.PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }/*w w w .  j a va 2 s  .c o m*/
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);
    XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    for (int i = 0; i < marker.length; i++) {
        ValueMarker vm = new ValueMarker(marker[i]);
        vm.setPaint(Color.GRAY.brighter());
        // plot.addRangeMarker(vm, Layer.FOREGROUND);
        // //.setPaint(Color.PINK));
        plot.addDomainMarker(vm, Layer.FOREGROUND);
    }

    plot.setOrientation(orientation);
    if (tooltips) {
        renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

}

From source file:bicat.gui.GraphicPane.java

public static JFreeChart myCreateSimpleXYLineChart(String title, String xAxisLabel, String yAxisLabel,
        org.jfree.data.xy.XYDataset dataset, double[] marker, org.jfree.chart.plot.PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }/* w  w w  .ja  va 2 s . c o  m*/
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    // xAxis.setAxisLineVisible(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);
    // yAxis.setAxisLineVisible(false); // new?

    // xAxis.setAxisLineVisible(false);
    // yAxis.setAxisLineVisible(false);

    XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    /*
     * for(int i = 0; i < marker.length; i++) { ValueMarker vm = new
     * ValueMarker(marker[i]); vm.setPaint(Color.GRAY.brighter());
     * //plot.addRangeMarker(vm, Layer.FOREGROUND);
     * //.setPaint(Color.PINK)); plot.addDomainMarker(vm, Layer.FOREGROUND);
     * }
     */

    plot.setOrientation(orientation);
    if (tooltips) {
        renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);

}