I have posted this in the bug tracking system at sourceforge but it didn't format the code too well so I am re-posting it here. Please feel free to delete one or the other.
There appears to be a bug either in ChartPanel or CombinedDomainXYPlot when trying to zoom in/out on the range axis.
ChartPanel
Code: Select all
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);
}
}
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: Select all
//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)));
}
}
};
My suggestion for a fix would be in CombinedDomainXYPlot to override the method
Code: Select all
public void zoomRangeAxes(double factor, PlotRenderingInfo info,
Point2D source, boolean useAnchor);
Code: Select all
public void zoomRangeAxes(double factor, PlotRenderingInfo info,
Point2D source);
}
I think the same may be true of CombinedRangeXYPlot but I have not tested thet.[/code]