antialias off when drawing straight lines

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Kees Kuip

antialias off when drawing straight lines

Post by Kees Kuip » Sun Jun 16, 2002 8:41 pm

Hello,

It would be nice to set antialiasing of when drawing straight lines.
(For performance reasons).

For instance in the method render() of XYPlot.java the methods
drawverticalLines() and drawHorizontalLines() are drawn. There is
no need to antialias here.

So I changed :
drawVerticalLines(g2, dataArea);
drawHorizontalLines(g2, dataArea);

into :
Object hint;
// Save original antialias
hint = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
// No need to antialias here.
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_OFF);

drawVerticalLines(g2, dataArea);
drawHorizontalLines(g2, dataArea);

// Restore antialias
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, hint);

This construction could be implemented at a lot of places to get more
performance (I'm using the dynamic charts !! (on linux!!!!))

It would be better to create a AntialiasUtil.java with static methods
saveAntiAlias(g2), setAntialias(g2, true), restoreAntialias(g2)

Kees.

David Gilbert

Re: antialias off when drawing straight lines

Post by David Gilbert » Mon Jun 17, 2002 10:54 am

Do you have any performance tests that show what sort of difference this makes? I do plan to put together some framework for measuring JFreeChart's performance, because there are areas where big improvements can be made and I want to make changes on the basis of measured data rather than guesswork. I want to do this before version 1.0.0 is released. Any ideas you have would be appreciated.

For the antialiasing, my feeling is that some people will want antialiasing left on for everything, because performance isn't the main concern for them (I fall into this camp). In which case creating your own subclass of StandardXYItemRenderer with the enhancements added is probably a good solution.

Regards,

DG

Locked