I`ve been trying to get the chart dimensions as described here:
http://www.jfree.org/phpBB2/viewtopic.php?f=3&t=28208
Basically I have a chartPanel inside a JFrame, using a CandlestickRenderer.
I used Componentlistener to execute code each time I resize the window, to give me the Chart Dimensions:
Code: Select all
@Override
public void componentResized(ComponentEvent arg0) {
// TODO Auto-generated method stub
System.out.println("WINDOW RESIZED!");
System.out.println( chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea());
System.out.println( chartPanel.getChartRenderingInfo().getPlotInfo().getPlotArea() );
}
I suspect that after a certain width the chart only gets stretched, therefore there is no update on the dimensions? How can I stop stretching it and make it render over the whole range?
I actually need the dimensions (especially the width) to calculate how many data items should be displayed with domainAxis.setRange(), but this does not work if there is an artificial limit to the width feedback.
Thanks in advance for your feedback!
EDIT:
I suspected that it is maybe the default width and height for chartPanel that is causing this, overriding its gePreferredSize to set width and height to 2000, but the dimensions max out at width=932,height=720 when calling chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea(). dimensions seem to max out at(even though the chart gets streched more):
java.awt.Rectangle[x=84,y=6,width=932,height=720]
java.awt.geom.Rectangle2D$Double[x=8.0,y=6.0,w=1008.0,h=758.0]