#236 Charts with fixed data area size

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

The patch allows to set a fixed size for the data area. Based on this size, a preferred size for the plot and for the chart are calculated. These "preferred sizes" are recalculated if required. Based on the preferred chart area size, a retangle can be constructed and used as parameter in the JFreeChart.draw(...) methods to get a chart with a data area of the desired, constant size.
Changes have been made to JFreeChart, Plot, XYPlot and ChartPanel. The ChartPanel has a flag to indicate whether the preferred chart size should be honored. If that is the case, changing the size of the chart panel has no effect on the chart itself.
If the ChartPanel is placed in a JScrollPane, things work as expected, i.e. the scroll pane honors the increasing chart panel size if axes/titles are added. Placing the ChartPanel in the content pane of a JFrame is somewhat "unstable", and the JFrame is not always resized as needed.
The ZIP contains a demo program.

Discussion

  • Peter Kolb
    Peter Kolb
    2009-01-18

    ZIP with diff file and source of demo program

     
    Attachments
  • Peter Kolb
    Peter Kolb
    2009-01-18

     
  • Peter Kolb
    Peter Kolb
    2009-01-18

    New DIFF file without paintFixedComponent-method in the ChartPanel class. Zooming did not work for some reason. Now, both cases (old behaviour and adjustement according to the preferred size of the JFreeChart) are treated in a single paintComponent.
    JFreeChart has an additional flag useFixedChartAreaSize.
    File Added: FixedDataAndPlotArea.diff

     
  • Peter Kolb
    Peter Kolb
    2009-03-05

    New patch with fixed ChartPanel.java

     
  • Peter Kolb
    Peter Kolb
    2009-03-05

    The ChartPanel code was broken (paintFixedComponent was still there for some reason, and the preferred size of the chart was never really used).
    File Added: FixedDataAndPlotArea_corr.diff

     
  • Peter Kolb
    Peter Kolb
    2009-03-09

    New demo program. The different flags are set in order to show the desired effect in the chart panel.
    File Added: FixedDataAreaSizeDemo.java

     
  • Peter Kolb
    Peter Kolb
    2009-03-09

    New demo program

     
  • Peter Kolb
    Peter Kolb
    2009-03-09

    New demo program. The different flags are set in order to show the desired effect in the chart panel.
    File Added: FixedDataAreaSizeDemo.java

     
  • Peter Kolb
    Peter Kolb
    2009-03-09

    New demo program

     
  • Peter Kolb
    Peter Kolb
    2009-04-28

    - Patched against 1.0.13
    - Added calculatePreferredPlotAreaSize to the CategoryPlot class.
    - Added a double fixedCategoryWidth and boolean useFixedCategoryWidth to the CategoryPlot class. These parameters can be used to ensure that the width of a category is fixed and that the data area of the plot grows when more categories are added.
    - Added missing initial value for fixedPlotAreaSize in the JFreeChart class (used to be null unless explicitly set)
    - Changed the calculation of the preferredChartAreaSize in the JFreeChart class. If the chart should use a fixedPlotAreaSize, it is now checked whether the plot uses a fixedDataAreaSize. If that is the case, the preferredPlotAreaSize from the plot is obtained, otherwise the fixedPlotAreaSize is used.
    - Changed the ChartPanel class: the preferredChartAreaSize is not only considered in the paintComponent method to set the size of the ChartPanel, but is also checked when the chart is transferred to the clipboard.
    - The archive contains two demo programs, one for the XYPlot class, one for the CategoryPlot class.
    -

     
  • Peter Kolb
    Peter Kolb
    2009-04-28

    zip with diff file, demos, and changed source code

     
    Attachments
  • Peter Kolb
    Peter Kolb
    2009-06-04

    Diff file for 1.0.13

     
    Attachments