Hi David,
I have rewritten the DatasetUtilities.java to use getX and getY instead of getXVal and getYVal (called "PrimitivesDatasetUtilities").
I have made a subclass og XYPlot called ExtendedXYPlot
In order to use PrimitivesDatasetUtilities I have to overwrite the method
getDataRange. Instead of copying the code and replacing
DatasetUtilities by PrimitivesDatasetUtilities I also have to
write my own version of
getDatasetsMappedToDomainAxis
getDatasetsMappedToRangeAxis
since
those methods are private.
How do you choose which methods that should be protected and which ones should be private? (This question also applies for class variables). Would it be wrong to make most of the class variables and methods protected??
By the way,
I have also rewritten renderers and tooltip generators so that they use primitives instead of Number (getXValue methods in dataset).
Would it be more useful to use a singleton class (a new version of the DatasetUtilities class) implementing an interface (here called DatasetUtilityInterface) that contain all the "static" methods in DatasetUtilities?
If you also provide a method
public void setDatasetUtility(DatasetUtilityInterface utility)
it would be easier to overwrite the old DatasetUtilities.
I am checking for Double.isNan(double value) where (Number value == null) was previously used.
Best regards,
Elisabeth
optimization issues: public vs protected methods jfreech.
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: optimization issues: public vs protected methods jfreec
DatasetUtilities.java should be changed to use the getX() and getY() methods where possible. If you make the changes directly and submit a patch I'll try to incorporate it into a future release.havfrue wrote:I have rewritten the DatasetUtilities.java to use getX and getY instead of getXVal and getYVal (called "PrimitivesDatasetUtilities").
I have made a subclass og XYPlot called ExtendedXYPlot
In order to use PrimitivesDatasetUtilities I have to overwrite the method
getDataRange. Instead of copying the code and replacing
DatasetUtilities by PrimitivesDatasetUtilities I also have to
write my own version of
getDatasetsMappedToDomainAxis
getDatasetsMappedToRangeAxis
since
those methods are private.
Most things private by default, except where a good case has been made for a different access level. That means there are some things that are private that should be protected, but I prefer to deal with them on a case by case basis. If you provide a good example of the type of extension you are doing and why it is difficult or impossible, I'll consider changing things.havfrue wrote:How do you choose which methods that should be protected and which ones should be private? (This question also applies for class variables). Would it be wrong to make most of the class variables and methods protected??
Great! Feel free to submit patches for any renderers that you have converted...I'd like to get them all done eventually. I'm less sure about the tooltip generators, since they tend to make use of the NumberFormat class, so they need Number objects...havfrue wrote:By the way,
I have also rewritten renderers and tooltip generators so that they use primitives instead of Number (getXValue methods in dataset).
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

