Mapping ChartEntities to domain entities.

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Göran

Mapping ChartEntities to domain entities.

Post by Göran » Wed Jul 03, 2002 3:08 pm

Hi,

As I tried to do a rubberband selection on a scatterplot I ran into a couple of problems:

1. The only method in EntityCollection that returns a ChartEntity is getEntity(x,y), but since I want to find all entities in a Rectangle I can't use this method.

2. The XYItemEntity doesn't have methods so that I can obtain the series and item mapped to the entity.

I managed to solve problem 1 by subclassing StandardEntityCollection and adding a getEntities() method returning a Collection of all the entities. The subclassed EntityCollection I then passed to the constructor of the ChartRenderingInfo class.

Problem number 2 I haven't manage to solve yet and I would be delighted to get some help on that one or if there is a better overall solution to the problem, please let me know.

Thanks,
Göran

David Gilbert

Re: Mapping ChartEntities to domain entities.

Post by David Gilbert » Thu Jul 04, 2002 6:35 am

Hi Göran,

1) Sounds a useful extension...if you want to post some code I will look at incorporating it into a future release.

2) XYItemEntity has getSeries() and getItem() methods that should tell you which data item the entity represents.

Regards,

DG.

Göran

Re: Mapping ChartEntities to domain entities.

Post by Göran » Thu Jul 04, 2002 7:54 am

Thanks for the quick response. Now I noticed my mistake, I used the JFreeChart JavaDoc on the web which is obviously outdated.

I read through the source now instead and saw that you have already added an iterator() method to EntityCollection which solves my problem #1. And looking through XYItemEntity I found thoose methods you pointed out which solves problem #2.

"Use the source Luke..."

Thanks a lot for the help,

Göran

Locked