decoupling of draw()

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Jan Bösenberg

decoupling of draw()

Post by Jan Bösenberg » Tue Nov 07, 2000 10:31 pm

I had a brief look at the code of HorizontalBarPlot and found that you could make it much more flexible by taking the drawing procedure for the bars out of HorizontalBarPlot and put them into Bar by adding a draw(Graphis2D g2) method. By doing and adding some plug method for subclasses of bars to BarPlot it would become very simple to make a chart, lat's say with triangular bars or bars that consist of piled up circles and so on. Also it might make sense to also add a field 'angle' to the class Bar and to other classes that would enable rotating these components (i.e. for radar charts and others). Currently you certainly would only use 0 and 90 degrees (horizontal and vertical bars).

I have not looked at the background yet but also the drawing of the background should happen in a separate class. This would make it easy to draw images on the background or do other fancy stuff by simply subclassing the background class.

By doing these two or three relatively simple things I could imagine easily creating bar charts with triangular, semi-transparent bars on with a nice photograph as the background.

If I find some time I will try to contribute some thing to your project, which in my opinion looks quite nice and very useful.

David Gilbert

RE: decoupling of draw()

Post by David Gilbert » Fri Nov 10, 2000 11:03 pm

Hi Jan,

Thanks for the suggestions. I think you are right about giving the Bar class its own draw() method...it makes sense now, don't know why I didn't see it before.

I've been meaning to add image backgrounds to all the plots for some time now, but never seem to find the time to study the image classes to work out a good implementation. If you feel like sending in some code ;-) that would be great!

Regards,

DG.

Locked