Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#245 FastXYShapeRenderer

open
nobody
None
5
2012-11-27
2009-04-27
Peter Kolb
No

Inspired by the SamplingXYLineRenderer in 1.0.13, I wanted to create an efficient renderer that is doing the rendering in form of shapes. That renderer should be useful for datasets with a large (> 100K) number of items.
Various approaches how these datasets could be renderer have been discussed in the forum.
One of these ideas is the basis for the present renderer: if several identical shapes are drawn at the same pixel, only one shape will be visible. The others do not need to be rendered.
Previous approaches have used the old way of rendering one item at a time and skipped shapes that would be rendered on top of another.
However, in order to get a chart that is as close to a normal XYShapeRenderer as possible, the shapes in the background, that correspond to an item with a low itemIndex, would need to be omitted!
In order to achieve that, the present renderer first goes through the items in reverse order. For each item, the position is calculated, and if that position is already occupied, the item is not rendered.
This requires that the old drawing item by item convention was bypassed, and that all items of an entire series are analyzed and rendered in a single pass, i. e. the series is rendered at the first opportunity, and subsequent calls to drawItem return immediately.
The name of the renderer might be misleading: it does not XYShapeRenderer and cannot handle XYZDatasets.

Discussion

  • Peter Kolb
    Peter Kolb
    2009-04-27

     
  • Peter Kolb
    Peter Kolb
    2009-06-07

    New renderer with extended possibilities. The new renderer combines the features of the FastXYShapeRenderer and the SamplingXYLineRenderer. It also uses the useFillPaint, useOutlinePaint and drawOutlines flags of the XYLineAndShapeRenderer and should thus produce an output that is indistinguishable from that of an XYLineAndShapeRenderer.
    The new renderer draws entire series in a single pass, regardless of whether shapes or lines or both are drawn.
    The code for drawing the series lines uses the basic idea of the SamplingXYLineRenderer with a few modifications (and including the most recent bugfixes):
    - the variables to track the lowY, highY, closeY and lastX values have been moved from the state to the renderer
    - the SamplingXYLineRenderer first transform the data values into java2D values and then decides what to do (modify the intervalPath, the seriesPath, or just track some values). The new renderer decides what to do based on the data values, and transforms the data values to java2D values only if this is required.
    - the new renderer does not only care about the "goodness" of a point but also about the visibility, and will not draw a line that connects two points that are outside the axes ranges.

     
  • Peter Kolb
    Peter Kolb
    2009-06-21

    Renderer renamed (SamplingXYLineAndShapeRenderer) and extended. It is now possible to set a flag sampleDataset that will not only skip data items that would be covered by data items from the same series but also those items that would be covered by data items from another series in the dataset.
    The code to check for overlapping items has been moved from the renderer to the state object.

     
  • Peter Kolb
    Peter Kolb
    2009-06-21

    Bug fix. The renderer works fine for large dataset that are shown in total, but dies if a large zoom factor is applied. Apparently, the renderer spends a lot of time in drawing the series path far outside the visible screen.
    The current version makes use of the RendererUtilities.findLIveItems(...) method in the constructor of the state object to avoid this.

     
  • Peter Kolb
    Peter Kolb
    2009-07-22

    Bug fix to render the last data item.

     
  • Peter Kolb
    Peter Kolb
    2010-07-03

    New version with efficient tool tip and url generation

     
  • Peter Kolb
    Peter Kolb
    2010-07-03

    New version whcih supports tool tip and URl generation in a memory-saving manner. As suggested in the forum (http://www.jfree.org/phpBB2/viewtopic.php?f=3&t=18592&start=45), the tool tips and URLs are not precomputed but dynamically generated upon request. This achievev by a special subclass of XYItemEntity which keeps a reference to the XYToolTipGenerator and XYURLGenerator.

     
  • Peter Kolb
    Peter Kolb
    2011-11-03

    New version which fixes a bugs which could present some intervals from being drawn.

     

  • Anonymous
    2012-02-01

    Hi, thanks for your code :)
    I have one problem: when I "switch" from NumberAxis axes to a logarithmic axes, some points are missing (with normal axes they are overlapped so they are omitted, when I changes axes, they should be visible if they are not anymore overlapped).
    Am i doing something wrong? Should I "force" a redraw (How?)?