#860 ChartPanel.zoomRangeAxis broken for CombinedDomainXYPlot

closed-fixed
None
5
2008-04-28
2008-04-23
Anonymous
No

Hi,
This appears to be a bug either in ChartPanel or CombinedDomainXYPlot when trying to zoom in/out on the range axis.

from ChartPanel
[code]
public void zoomOutRange(double x, double y) {
Plot p = this.chart.getPlot();
if (p instanceof Zoomable) {
Zoomable z = (Zoomable) p;
z.zoomRangeAxes(this.zoomOutFactor, this.info.getPlotInfo(),
translateScreenToJava2D(new Point((int) x, (int) y)),
this.zoomAroundAnchor);
}
}
[/code]
This calls zoomRangeAxis() in XYPlot and not in CombinedDomainXYPlot. The other 2 zoomRangeAxis() methods are overridden in CombinedDomainXYPlot and correctly identify the sub plot to zoom.

Because ChartPanel.zoomOutRange calls the one that is not overridden it tries to use the Range of the MainPlot and not the SubPlot. The Range is null so no zoom occurs. I have managed to get around this by overriding the methods in ChartPanel
[code]
//Create the actual chart
final JFreeChart chart = new JFreeChart(null, null, mainPlot, false);
//Create the visible chart panel
chartPanel = new ChartPanel(chart)
{
public void zoomInRange(double x, double y)
{
Plot p = chart.getPlot();
if (p instanceof Zoomable) {
Zoomable z = (Zoomable) p;
z.zoomRangeAxes(getZoomInFactor(), getChartRenderingInfo().getPlotInfo(),
translateScreenToJava2D(new Point((int) x, (int) y)));
}
}
public void zoomOutRange(double x, double y) {
Plot p = chart.getPlot();
if (p instanceof Zoomable) {
Zoomable z = (Zoomable) p;
z.zoomRangeAxes(getZoomOutFactor(), getChartRenderingInfo().getPlotInfo(),
translateScreenToJava2D(new Point((int) x, (int) y)));
}
}
};
[/code]
(They call the methods without the this.zoomAroundAnchor so the overridden method gets called)

My suggestion for a fix would be in CombinedDomainXYPlot to override the method
[code]
public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor);
[/code]
and not
[code]
public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source);
}
[/code]
as it does currently.

I think the same may be true of CombinedRangeXYPlot but I have not tested that.

Discussion

  • David Gilbert

    David Gilbert - 2008-04-28

    Logged In: YES
    user_id=112975
    Originator: NO

    Thanks for the report. This bug does indeed affect CombinedRangeXYPlot as well, and also CombinedDomainCategoryPlot. I'm fixing it now for the 1.0.10 release.

    Regards,

    Dave Gilbert
    JFreeChart Project Leader

     
  • David Gilbert

    David Gilbert - 2008-04-28
    • assigned_to: nobody --> mungady
     
  • David Gilbert

    David Gilbert - 2008-04-28

    Logged In: YES
    user_id=112975
    Originator: NO

    The fix is committed to Subversion for inclusion in the 1.0.10 release.

    Regards,

    Dave

     
  • David Gilbert

    David Gilbert - 2008-04-28
    • status: open --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks