Hello,
If a chart is scaled the thickness of the lines (and grid and axis) are also
scaled.
It would be nice to have an option to not scale the thickness of the lines.
This problem is not so hard to solve. (I already programmed it !)
If you look at the method drawItem() in StandardXYItemRenderer.java
the following construction is seen (I left out most of the code) :
g2.draw(line);
If we don't want to scale the thickness of lines the following has to be done :
1. Don't modify the scaling of the Graphics2D object.
2. Transform the line itself with the method createTransformedShape()
3. Draw the outline of the Shape of 2.
So that gives me the following code :
1. AffineTransform t = g2.getTransform() // save the orginal transformations.
2. g2.scale((1/t.getScaleX()), (1/t.getScaleY())); // undo the scaling
3. g2.draw(t.createTransformedShap(line)); // Draw the transformed shape
4. g2.setTransform(t); // Restore the original transformation.
This construction could also be used to draw the axis, grid etc.
I hope this feature will be implemented.
Kees.
line thickness when scaling.
Re: line thickness when scaling.
Hi Kees,
In the ChartPanel class, the maximum width for the chart is 680 and the maximum height is 420, by default. For larger sizes, a scaling transform is now used, which increases the thickness of all the elements in the chart (lines, fonts, everything). I meant to add methods to set these maximum values, so that if you don't want the scaling you could set the maximum height and width to 10000 or something.
The default values are in the ChartPanelConstants interface if you want to modify your source...I'll add the setXXX methods for 0.9.2.
Regards,
DG.
In the ChartPanel class, the maximum width for the chart is 680 and the maximum height is 420, by default. For larger sizes, a scaling transform is now used, which increases the thickness of all the elements in the chart (lines, fonts, everything). I meant to add methods to set these maximum values, so that if you don't want the scaling you could set the maximum height and width to 10000 or something.
The default values are in the ChartPanelConstants interface if you want to modify your source...I'll add the setXXX methods for 0.9.2.
Regards,
DG.
Re: line thickness when scaling.
Hello,
I don't think that I mad my point clear.
I do want to scale the chart.
I do want to scale the lines.
But I do not want the lines getting thicker because of the scaling.
The code I showed scales the lines but do not make the lines thicker.
Kees.
I don't think that I mad my point clear.
I do want to scale the chart.
I do want to scale the lines.
But I do not want the lines getting thicker because of the scaling.
The code I showed scales the lines but do not make the lines thicker.
Kees.