Class OfflineRenderingChartPanel

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, ChartChangeListener, ChartProgressListener, OverlayChangeListener

    public class OfflineRenderingChartPanel
    extends ChartPanel
    A ChartPanel that applies offline rendering, for better performance when navigating (i.e. panning / zooming) charts with lots of data.

    This chart panel uses a SwingWorker to perform the actual JFreeChart rendering. While rendering, a wait cursor is visible and the current buffered image of the chart will be scaled and drawn to the screen. When - while rendering - another refresh is requested, this will be either postponed until the current rendering is done or ignored when another refresh is requested.

    See Also:
    Serialized Form
    • Constructor Detail

      • OfflineRenderingChartPanel

        public OfflineRenderingChartPanel​(JFreeChart chart)
        Constructs a double buffered JFreeChart panel that displays the specified chart.
        Parameters:
        chart - the chart.
      • OfflineRenderingChartPanel

        public OfflineRenderingChartPanel​(JFreeChart chart,
                                          boolean properties,
                                          boolean save,
                                          boolean print,
                                          boolean zoom,
                                          boolean tooltips)
        Constructs a double buffered JFreeChart panel.
        Parameters:
        chart - the chart.
        properties - a flag indicating whether or not the chart property editor should be available via the popup menu.
        save - a flag indicating whether or not save options should be available via the popup menu.
        print - a flag indicating whether or not the print option should be available via the popup menu.
        zoom - a flag indicating whether or not zoom options should be added to the popup menu.
        tooltips - a flag indicating whether or not tooltips should be enabled for the chart.
      • OfflineRenderingChartPanel

        public OfflineRenderingChartPanel​(JFreeChart chart,
                                          int width,
                                          int height,
                                          int minimumDrawWidth,
                                          int minimumDrawHeight,
                                          int maximumDrawWidth,
                                          int maximumDrawHeight,
                                          boolean properties,
                                          boolean save,
                                          boolean print,
                                          boolean zoom,
                                          boolean tooltips)
        Constructs a double buffered JFreeChart panel.
        Parameters:
        chart - the chart.
        width - the preferred width of the panel.
        height - the preferred height of the panel.
        minimumDrawWidth - the minimum drawing width.
        minimumDrawHeight - the minimum drawing height.
        maximumDrawWidth - the maximum drawing width.
        maximumDrawHeight - the maximum drawing height.
        properties - a flag indicating whether or not the chart property editor should be available via the popup menu.
        save - a flag indicating whether or not save options should be available via the popup menu.
        print - a flag indicating whether or not the print option should be available via the popup menu.
        zoom - a flag indicating whether or not zoom options should be added to the popup menu.
        tooltips - a flag indicating whether or not tooltips should be enabled for the chart.
      • OfflineRenderingChartPanel

        public OfflineRenderingChartPanel​(JFreeChart chart,
                                          int width,
                                          int height,
                                          int minimumDrawWidth,
                                          int minimumDrawHeight,
                                          int maximumDrawWidth,
                                          int maximumDrawHeight,
                                          boolean properties,
                                          boolean copy,
                                          boolean save,
                                          boolean print,
                                          boolean zoom,
                                          boolean tooltips)
        Constructs a double buffered JFreeChart panel.
        Parameters:
        chart - the chart.
        width - the preferred width of the panel.
        height - the preferred height of the panel.
        minimumDrawWidth - the minimum drawing width.
        minimumDrawHeight - the minimum drawing height.
        maximumDrawWidth - the maximum drawing width.
        maximumDrawHeight - the maximum drawing height.
        properties - a flag indicating whether or not the chart property editor should be available via the popup menu.
        copy - a flag indicating whether or not a copy option should be available via the popup menu.
        save - a flag indicating whether or not save options should be available via the popup menu.
        print - a flag indicating whether or not the print option should be available via the popup menu.
        zoom - a flag indicating whether or not zoom options should be added to the popup menu.
        tooltips - a flag indicating whether or not tooltips should be enabled for the chart.
    • Method Detail

      • paintChartToBuffer

        protected java.awt.image.BufferedImage paintChartToBuffer​(java.awt.Graphics2D g2,
                                                                  java.awt.Dimension bufferSize,
                                                                  java.awt.Dimension chartSize,
                                                                  java.awt.geom.Point2D anchor,
                                                                  ChartRenderingInfo info)
        Description copied from class: ChartPanel
        Paints the chart to fill the entire off-screen buffer image.
        Overrides:
        paintChartToBuffer in class ChartPanel
        Parameters:
        g2 - the graphics context to create an off-screen buffer image.
        bufferSize - the required off-screen buffer image size.
        chartSize - the size with which the chart should be drawn (apply scaling if not equal to bufferSize).
        anchor - the anchor point (in Java2D space) for the chart (null permitted).
        info - records info about the drawing (null means collect no info).
        Returns:
        the off-screen buffer image to draw onto the panel.
      • setCursor

        public void setCursor​(java.awt.Cursor cursor)
        Overrides:
        setCursor in class java.awt.Component
      • createChartBuffer

        private static java.awt.image.BufferedImage createChartBuffer​(java.awt.Graphics2D g2,
                                                                      java.awt.Dimension bufferSize)
      • clearChartBuffer

        private static void clearChartBuffer​(java.awt.image.BufferedImage buffer)