List of usage examples for org.jfree.chart.renderer.xy XYErrorRenderer setURLGenerator
@Override public void setURLGenerator(XYURLGenerator urlGenerator)
From source file:graph.jfreecharts.GraphFunction.java
/** * A custom xyerror renderer because jfreecharts does not * have it supported in the api.//from www . j av a 2 s .co 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:org.gumtree.vis.plot1d.Plot1D.java
/** * Creates a line chart (based on an {@link XYDataset}) with default * settings.//from w w w .j a v a 2s . c om * * @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 createXYLineChart(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); LogarithmizableAxis xAxis = new LogarithmizableAxis(xAxisLabel); xAxis.setLogarithmic(false); xAxis.setAutoRangeIncludesZero(false); xAxis.setAllowNegativesFlag(true); xAxis.setLowerMargin(0.02); xAxis.setUpperMargin(0.02); // NumberAxis yAxis = new NumberAxis(yAxisLabel); LogarithmizableAxis yAxis = new LogarithmizableAxis(yAxisLabel); yAxis.setAllowNegativesFlag(true); yAxis.setAutoRangeNextLogFlag(false); yAxis.setLowerMargin(0.02); yAxis.setUpperMargin(0.02); yAxis.setLogarithmic(false); XYErrorRenderer renderer = new XYErrorRenderer(); renderer.setBaseLinesVisible(true); renderer.setBaseShapesVisible(false); renderer.setDrawYError(true); // XYItemRenderer renderer = new XYLineAndShapeRenderer(true, 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); chartTheme.apply(chart); return chart; }
From source file:org.gumtree.vis.awt.PlotFactory.java
/** * Creates a line chart (based on an {@link XYDataset}) with default * settings.// w ww . java 2 s.c o m * * @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. */ protected static JFreeChart createXYLineChart(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); LogarithmizableAxis xAxis = new LogarithmizableAxis(xAxisLabel); boolean isLogX = false; try { isLogX = Boolean.valueOf(System.getProperty(LOGX_PROPERTY)); } catch (Exception e) { } xAxis.setLogarithmic(isLogX); // xAxis.setAutoRangeIncludesZero(false); xAxis.setAllowNegativesFlag(true); xAxis.setLowerMargin(0.02); xAxis.setUpperMargin(0.02); // NumberAxis yAxis = new NumberAxis(yAxisLabel); LogarithmizableAxis yAxis = new LogarithmizableAxis(yAxisLabel); boolean isLogY = false; try { isLogY = Boolean.valueOf(System.getProperty(LOGY_PROPERTY)); } catch (Exception e) { } yAxis.setLogarithmic(isLogY); yAxis.setAllowNegativesFlag(true); yAxis.setAutoRangeNextLogFlag(false); yAxis.setLowerMargin(0.02); yAxis.setUpperMargin(0.02); XYErrorRenderer renderer = new XYErrorRenderer(); renderer.setBaseLinesVisible(true); renderer.setBaseShapesVisible(false); renderer.setDrawYError(true); // XYItemRenderer renderer = new XYLineAndShapeRenderer(true, 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); chartTheme.apply(chart); return chart; }