Example usage for org.jfree.chart.urls StandardXYURLGenerator StandardXYURLGenerator

List of usage examples for org.jfree.chart.urls StandardXYURLGenerator StandardXYURLGenerator

Introduction

In this page you can find the example usage for org.jfree.chart.urls StandardXYURLGenerator StandardXYURLGenerator.

Prototype

public StandardXYURLGenerator() 

Source Link

Document

Creates a new default generator.

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.");
    }//from www.ja  v  a  2s  . c o 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.pentaho.plugin.jfreereport.reportcharts.XYAreaChartExpression.java

public static JFreeChart createTimeSeriesChart(final String title, final String timeAxisLabel,
        final String valueAxisLabel, final XYDataset dataset, final boolean legend, final boolean tooltips,
        final boolean urls, final boolean stacked) {
    final ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    timeAxis.setLowerMargin(0.02); // reduce the default margins
    timeAxis.setUpperMargin(0.02);//from w  w  w.ja  va  2 s . c  o m
    final NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false); // override default
    final XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);

    XYToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance();
    }

    XYURLGenerator urlGenerator = null;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }

    final XYAreaRenderer2 renderer;
    if (stacked) {
        renderer = new StackedXYAreaRenderer2();
    } else {
        renderer = new XYAreaRenderer2();
    }
    renderer.setBaseToolTipGenerator(toolTipGenerator);
    renderer.setURLGenerator(urlGenerator);
    plot.setRenderer(renderer);

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

From source file:com.itemanalysis.jmetrik.graph.itemmap.ItemMapPanel.java

public void setGraph() {
    HistogramChartDataset personDataset = null;
    HistogramChartDataset itemData = null;

    try {//from w  w  w .  j  ava  2 s.  c  o m
        //get titles
        String chartTitle = command.getFreeOption("title").getString();
        String chartSubtitle = command.getFreeOption("subtitle").getString();
        PlotOrientation itemMapOrientation = PlotOrientation.HORIZONTAL;

        //create common x-axis
        NumberAxis domainAxis = new NumberAxis();
        domainAxis.setLabel("Logits");

        //create histogram
        personDataset = new HistogramChartDataset();
        ValueAxis rangeAxis = new NumberAxis("Person Density");
        if (itemMapOrientation == PlotOrientation.HORIZONTAL)
            rangeAxis.setInverted(true);
        XYBarRenderer renderer = new XYBarRenderer();
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
        renderer.setURLGenerator(new StandardXYURLGenerator());
        renderer.setDrawBarOutline(true);
        renderer.setShadowVisible(false);
        XYPlot personPlot = new XYPlot(personDataset, null, rangeAxis, renderer);
        personPlot.setOrientation(PlotOrientation.HORIZONTAL);

        //create scatterplot of item difficulty
        itemData = new HistogramChartDataset();
        NumberAxis itemRangeAxis = new NumberAxis("Item Frequency");
        if (itemMapOrientation == PlotOrientation.VERTICAL) {
            itemRangeAxis.setInverted(true);
        }

        XYBarRenderer itemRenderer = new XYBarRenderer();
        itemRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
        itemRenderer.setURLGenerator(new StandardXYURLGenerator());
        itemRenderer.setDrawBarOutline(true);
        itemRenderer.setShadowVisible(false);
        XYPlot itemPlot = new XYPlot(itemData, null, itemRangeAxis, itemRenderer);
        itemPlot.setOrientation(PlotOrientation.HORIZONTAL);

        //combine the two charts
        CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(domainAxis);
        cplot.add(personPlot, 3);
        cplot.add(itemPlot, 2);
        cplot.setGap(8.0);
        cplot.setDomainGridlinePaint(Color.white);
        cplot.setDomainGridlinesVisible(true);
        cplot.setOrientation(itemMapOrientation);

        //            //next four lines are temp setting for book
        //            //these four lines will create a histogram with white bars so it appears as just the bar outline
        //            renderer.setBarPainter(new StandardXYBarPainter());
        //            renderer.setSeriesPaint(0, Color.white);
        //            itemRenderer.setBarPainter(new StandardXYBarPainter());
        //            itemRenderer.setSeriesPaint(0, Color.white);

        chart = new JFreeChart(chartTitle, JFreeChart.DEFAULT_TITLE_FONT, cplot, false);
        chart.setBackgroundPaint(Color.white);
        if (chartSubtitle != null && !"".equals(chartSubtitle)) {
            chart.addSubtitle(new TextTitle(chartSubtitle));
        }

        ChartPanel panel = new ChartPanel(chart);
        panel.getPopupMenu().addSeparator();
        this.addJpgMenuItem(this, panel.getPopupMenu());
        panel.setPreferredSize(new Dimension(width, height));

        //            //temp setting for book
        //            this.addLocalEPSMenuItem(this, panel.getPopupMenu(), chart);//remove this line for public release versions

        chart.setPadding(new RectangleInsets(20.0, 5.0, 20.0, 5.0));
        this.setBackground(Color.WHITE);
        this.add(panel);
    } catch (IllegalArgumentException ex) {
        logger.fatal(ex.getMessage(), ex);
        this.firePropertyChange("error", "", "Error - Check log for details.");
    }

}

From source file:graph.jfreecharts.GraphFunction.java

/**
 * A custom xyerror renderer because jfreecharts does not
 * have it supported in the api./* w  w w  .  j  av a 2 s . c  o m*/
 * @param title the graph title
 * @param xAxisLabel the xaxis title
 * @param yAxisLabel the yaxis title
 * @param dataset the xydataset
 * @param orientation the plot orientation
 * @param legend true to turn on legend
 * @param tooltips true to turn on tooltips (the pop up when right click)
 * @param urls // no idea what this is for
 * @return
 */
private static JFreeChart createXYIntervalChart(String title, String xAxisLabel, String yAxisLabel,
        XYDataset dataset, 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);
    XYErrorRenderer renderer = new XYErrorRenderer();

    renderer.setDrawXError(true);
    renderer.setDrawYError(true);

    xAxis.setNumberFormatOverride(new DecimalFormat("0.######E0"));
    yAxis.setNumberFormatOverride(new DecimalFormat("0.######E0"));

    xAxis.setAutoRangeIncludesZero(false);
    yAxis.setAutoRangeIncludesZero(false);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;

}

From source file:de.iteratec.visualizationmodel.jfreechart.ChartFactory.java

public JFreeChart createXYStepChart(XYDataset dataset) {
    XYToolTipGenerator toolTipGenerator = !showTooltips ? null : new StandardXYToolTipGenerator();
    XYURLGenerator urlGenerator = !showUrls ? null : new StandardXYURLGenerator();
    XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator, urlGenerator);

    XYPlot plot = new XYPlot(dataset, (ValueAxis) xAxis, (ValueAxis) yAxis, null);
    plot.setRenderer(renderer);/*from w  ww.j a va  2 s .  co  m*/
    plot.setOrientation(orientation);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.getRenderer().setSeriesStroke(0, new BasicStroke(5.0f));
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend);
    THEME.apply(chart);
    return chart;
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.XYBarChartExpression.java

protected static JFreeChart createTimeSeriesChart(final String title, final String timeAxisLabel,
        final String valueAxisLabel, final XYDataset dataset, final boolean legend, final boolean tooltips,
        final boolean urls, final boolean stacked) {
    final ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    timeAxis.setLowerMargin(0.02); // reduce the default margins
    timeAxis.setUpperMargin(0.02);//ww w  .  ja  v a  2 s.  c o m
    final NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false); // override default
    final XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);

    XYToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance();
    }

    XYURLGenerator urlGenerator = null;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }

    final XYBarRenderer renderer;
    if (stacked) {
        renderer = new StackedXYBarRenderer();
    } else {
        renderer = new XYBarRenderer();
    }
    renderer.setBaseToolTipGenerator(toolTipGenerator);
    renderer.setURLGenerator(urlGenerator);
    plot.setRenderer(renderer);

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

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

private JFreeChart createChart(String title, String timeAxisLabel, String valueAxisLabel,
        final TimeTableXYDataset dataset) {
    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    timeAxis.setLowerMargin(0.02); // reduce the default margins
    timeAxis.setUpperMargin(0.02);/*from  w w  w  .jav a 2s  .  c  om*/
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false); // override default
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);

    XYToolTipGenerator toolTipGenerator = null;
    boolean tooltips = false;
    if (tooltips) {
        toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance();
    }

    XYURLGenerator urlGenerator = null;
    boolean urls = false;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);
    renderer.setBaseToolTipGenerator(toolTipGenerator);
    renderer.setURLGenerator(urlGenerator);
    plot.setRenderer(renderer);

    boolean legend = true;
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    return chart;
    // return ChartFactory.createTimeSeriesChart(title, timeAxisLabel,
    // valueAxisLabel, dataset, true, // legend?
    // false, // tooltips?
    // false // URLs?
    // );
}

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

private JFreeChart createChart(String title, String timeAxisLabel, String valueAxisLabel,
        final TimeTableXYDataset dataset) {
    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    timeAxis.setLowerMargin(0.02); // reduce the default margins
    timeAxis.setUpperMargin(0.02);//from   w ww .  j  a v  a 2s  .c o m
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false); // override default
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);

    XYToolTipGenerator toolTipGenerator = null;
    boolean tooltips = false;
    if (tooltips) {
        toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance();
    }

    XYURLGenerator urlGenerator = null;
    boolean urls = false;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true/* line */, false/* shape */);
    renderer.setBaseToolTipGenerator(toolTipGenerator);
    renderer.setURLGenerator(urlGenerator);
    plot.setRenderer(renderer);

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

From source file:org.pentaho.plugin.jfreereport.reportcharts.XYAreaChartExpression.java

/**
 * Creates a stacked XY area plot.  The chart object returned by this method uses an {@link
 * org.jfree.chart.plot.XYPlot} instance as the plot, with a {@link org.jfree.chart.axis.NumberAxis} for the domain
 * axis, a {@link org.jfree.chart.axis.NumberAxis} as the range axis, and a {@link
 * org.jfree.chart.renderer.xy.StackedXYAreaRenderer2} as the renderer.
 *
 * @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 A stacked XY area chart.//  w  w w . ja va 2 s . c  o  m
 */
protected static JFreeChart createStackedXYAreaChart(final String title, final String xAxisLabel,
        final String yAxisLabel, final XYDataset dataset, final PlotOrientation orientation,
        final boolean legend, final boolean tooltips, final boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    final NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);
    final NumberAxis yAxis = new NumberAxis(yAxisLabel);
    XYToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = new StandardXYToolTipGenerator();
    }

    XYURLGenerator urlGenerator = null;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }
    final StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(toolTipGenerator, urlGenerator);
    renderer.setOutline(true);
    final XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);

    plot.setRangeAxis(yAxis); // forces recalculation of the axis range

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

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

private static JFreeChart createTimeSeriesChart(XYDataset dataset) {

    DateAxis timeAxis = new DateAxis(xAxisLabel);
    timeAxis.setLowerMargin(0.02); // reduce the default margins
    timeAxis.setUpperMargin(0.02);//from  w w w  .j a  va 2 s .  co  m
    NumberAxis valueAxis = new NumberAxis(yAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false); // override default
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);

    XYToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance();
    }

    XYURLGenerator urlGenerator = null;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setBaseToolTipGenerator(toolTipGenerator);
    renderer.setURLGenerator(urlGenerator);
    plot.setRenderer(renderer);

    JFreeChart chart = new JFreeChart("TimeSeries 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);

    //        renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setDrawSeriesLineAsPath(true);

    timeAxis.setDateFormatOverride(new SimpleDateFormat("MM-yyyy"));

    return chart;
}