Search in sources :

Example 6 with XYURLGenerator

use of org.jfree.chart.urls.XYURLGenerator in project seng438-a3-R41Ryan by seng438-winter-2022.

the class ChartFactory method createXYAreaChart.

/**
 * Creates an area chart using an {@link XYDataset}.
 * <P>
 * The chart object returned by this method uses an {@link XYPlot} instance
 * as the plot, with a {@link NumberAxis} for the domain axis, a
 * {@link NumberAxis} as the range axis, and a {@link XYAreaRenderer} 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 An XY area chart.
 */
public static JFreeChart createXYAreaChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {
    ParamChecks.nullNotPermitted(orientation, "orientation");
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
    plot.setOrientation(orientation);
    plot.setForegroundAlpha(0.5f);
    XYToolTipGenerator tipGenerator = null;
    if (tooltips) {
        tipGenerator = new StandardXYToolTipGenerator();
    }
    XYURLGenerator urlGenerator = null;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }
    plot.setRenderer(new XYAreaRenderer(XYAreaRenderer.AREA, tipGenerator, urlGenerator));
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;
}
Also used : XYAreaRenderer(org.jfree.chart.renderer.xy.XYAreaRenderer) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) StandardXYURLGenerator(org.jfree.chart.urls.StandardXYURLGenerator) XYURLGenerator(org.jfree.chart.urls.XYURLGenerator) StandardXYURLGenerator(org.jfree.chart.urls.StandardXYURLGenerator) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator)

Example 7 with XYURLGenerator

use of org.jfree.chart.urls.XYURLGenerator in project seng438-a3-R41Ryan by seng438-winter-2022.

the class ChartFactory method createXYStepChart.

/**
 * Creates a stepped XY plot with 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 A chart.
 */
public static JFreeChart createXYStepChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {
    ParamChecks.nullNotPermitted(orientation, "orientation");
    DateAxis xAxis = new DateAxis(xAxisLabel);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = new StandardXYToolTipGenerator();
    }
    XYURLGenerator urlGenerator = null;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }
    XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator, urlGenerator);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
    plot.setRenderer(renderer);
    plot.setOrientation(orientation);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) StandardXYURLGenerator(org.jfree.chart.urls.StandardXYURLGenerator) XYURLGenerator(org.jfree.chart.urls.XYURLGenerator) StandardXYURLGenerator(org.jfree.chart.urls.StandardXYURLGenerator) XYStepRenderer(org.jfree.chart.renderer.xy.XYStepRenderer) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer)

Example 8 with XYURLGenerator

use of org.jfree.chart.urls.XYURLGenerator in project seng438-a3-R41Ryan by seng438-winter-2022.

the class ChartFactory method createTimeSeriesChart.

/**
 * Creates and returns a time series chart.  A time series chart is an
 * {@link XYPlot} with a {@link DateAxis} for the x-axis and a
 * {@link NumberAxis} for the y-axis.  The default renderer is an
 * {@link XYLineAndShapeRenderer}.
 * <P>
 * A convenient dataset to use with this chart is a
 * {@link org.jfree.data.time.TimeSeriesCollection}.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code>
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> 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 time series chart.
 */
public static JFreeChart createTimeSeriesChart(String title, String timeAxisLabel, String valueAxisLabel, XYDataset dataset, boolean legend, boolean tooltips, boolean urls) {
    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    // reduce the default margins
    timeAxis.setLowerMargin(0.02);
    timeAxis.setUpperMargin(0.02);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    // override default
    valueAxis.setAutoRangeIncludesZero(false);
    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(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) ValueAxis(org.jfree.chart.axis.ValueAxis) StandardXYURLGenerator(org.jfree.chart.urls.StandardXYURLGenerator) XYURLGenerator(org.jfree.chart.urls.XYURLGenerator) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) StandardXYURLGenerator(org.jfree.chart.urls.StandardXYURLGenerator) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator)

Example 9 with XYURLGenerator

use of org.jfree.chart.urls.XYURLGenerator in project graphcode2vec by graphcode2vec.

the class AbstractXYItemRenderer method addEntity.

/**
 * Adds an entity to the collection.
 *
 * @param entities  the entity collection being populated.
 * @param area  the entity area (if <code>null</code> a default will be
 *              used).
 * @param dataset  the dataset.
 * @param series  the series.
 * @param item  the item.
 * @param selected  is the item selected?
 * @param entityX  the entity's center x-coordinate in user space (only
 *                 used if <code>area</code> is <code>null</code>).
 * @param entityY  the entity's center y-coordinate in user space (only
 *                 used if <code>area</code> is <code>null</code>).
 *
 * @since 1.2.0
 */
protected void addEntity(EntityCollection entities, Shape area, XYDataset dataset, int series, int item, boolean selected, double entityX, double entityY) {
    if (!getItemCreateEntity(series, item, selected)) {
        return;
    }
    Shape hotspot = area;
    if (hotspot == null) {
        double r = getDefaultEntityRadius();
        double w = r * 2;
        if (getPlot().getOrientation() == PlotOrientation.VERTICAL) {
            hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w);
        } else {
            hotspot = new Ellipse2D.Double(entityY - r, entityX - r, w, w);
        }
    }
    String tip = null;
    XYToolTipGenerator generator = getToolTipGenerator(series, item, selected);
    if (generator != null) {
        tip = generator.generateToolTip(dataset, series, item);
    }
    String url = null;
    XYURLGenerator urlster = getURLGenerator(series, item, selected);
    if (urlster != null) {
        url = urlster.generateURL(dataset, series, item);
    }
    XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item, tip, url);
    entities.add(entity);
}
Also used : XYItemEntity(org.jfree.chart.entity.XYItemEntity) Shape(java.awt.Shape) XYURLGenerator(org.jfree.chart.urls.XYURLGenerator) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator) Ellipse2D(java.awt.geom.Ellipse2D)

Example 10 with XYURLGenerator

use of org.jfree.chart.urls.XYURLGenerator in project SIMVA-SoS by SESoS.

the class ChartFactory method createScatterPlot.

/**
 * Creates a scatter plot with default settings.  The chart object
 * returned by this method uses an {@link XYPlot} instance as the plot,
 * with a {@link NumberAxis} for the domain axis, a  {@link NumberAxis}
 * as the range axis, and an {@link XYLineAndShapeRenderer} 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 scatter plot.
 */
public static JFreeChart createScatterPlot(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {
    ParamChecks.nullNotPermitted(orientation, "orientation");
    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();
    }
    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(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;
}
Also used : StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) StandardXYURLGenerator(org.jfree.chart.urls.StandardXYURLGenerator) XYURLGenerator(org.jfree.chart.urls.XYURLGenerator) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) StandardXYURLGenerator(org.jfree.chart.urls.StandardXYURLGenerator) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer)

Aggregations

XYToolTipGenerator (org.jfree.chart.labels.XYToolTipGenerator)23 XYURLGenerator (org.jfree.chart.urls.XYURLGenerator)23 NumberAxis (org.jfree.chart.axis.NumberAxis)18 StandardXYToolTipGenerator (org.jfree.chart.labels.StandardXYToolTipGenerator)18 XYPlot (org.jfree.chart.plot.XYPlot)18 StandardXYURLGenerator (org.jfree.chart.urls.StandardXYURLGenerator)18 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)9 DateAxis (org.jfree.chart.axis.DateAxis)6 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)6 Shape (java.awt.Shape)5 XYItemEntity (org.jfree.chart.entity.XYItemEntity)5 Paint (java.awt.Paint)4 Stroke (java.awt.Stroke)4 Line2D (java.awt.geom.Line2D)4 Rectangle2D (java.awt.geom.Rectangle2D)4 EntityCollection (org.jfree.chart.entity.EntityCollection)4 PlotOrientation (org.jfree.chart.plot.PlotOrientation)4 ValueAxis (org.jfree.chart.axis.ValueAxis)3 StackedXYAreaRenderer2 (org.jfree.chart.renderer.xy.StackedXYAreaRenderer2)3 XYAreaRenderer (org.jfree.chart.renderer.xy.XYAreaRenderer)3