API Changes

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

API Changes

Post by david.gilbert » Mon Mar 17, 2003 9:47 am

Until JFreeChart 1.0.0 is released, the library API is subject to change. Up until now, time constraints have meant that I haven't carefully documented each change. However, I understand that this is causing difficulties, especially as JFreeChart becomes more widely used. So I have put together the following notes to assist developers upgrading from older versions. The notes are not complete, but I will update them as questions are asked, or errors and omissions are pointed out.

Regards,

Dave Gilbert
JFreeChart Project Leader

Version 0.9.9
------------
A large number of changes. Please see:

http://www.jfree.org/jfreechart/jdiff/changes.html

Version 0.9.6
-------------
A bug fix release. Some new methods are added to the API, but none removed, so this version should be a "drop-in" replacement for 0.9.5.

Version 0.9.5
-------------

(1) All the axis classes have moved to a new package com.jrefinery.chart.axis.

(2) All the plot classes have moved to a new package com.jrefinery.chart.plot.

(3) The CategoryDataset interface has been changed so that it now treats series and categories (rows and columns) in a symmetrical way.

- the DefaultCategoryDataset class has been rewritten accordingly. The "array constructors" no longer exist, but there are methods in the DatasetUtilities class that will create a CategoryDataset from an array.

(4) The addition of secondary datasets / axes has required a change in the way that series paint/stroke/shape settings are made. Control is transferred to the renderer classes.

(5) The grid line settings are no longer maintained by the axis classes, but have moved to the plot classes. Look for setDomainGridlineXXX(...) methods and setRangeGridlineXXX(...) methods in the CategoryPlot and XYPlot classes.

(6) The JFreeChart class formerly maintained a list of titles, but this proved awkward for users that only wanted to use a single chart title. So now the JFreeChart class maintains a single title, and a list of subtitles. The addTitle(...) method is gone, look for the setTitle(...) and addSubTitle(...) methods.
Last edited by david.gilbert on Tue Jan 06, 2004 11:31 pm, edited 3 times in total.

Hannes

setCategories???

Post by Hannes » Tue Jun 03, 2003 4:12 pm

Hi,

I cannot find the setCategories- and setSeriesNamees-Method?

Regards,

Hannes

mhilpert
Posts: 497
Joined: Wed Apr 02, 2003 1:57 pm
Location: Germany

API changes in 0.9.12

Post by mhilpert » Thu Sep 11, 2003 12:27 pm

In addition to the various deprecated methods and fields from 0.9.11 to 0.9.12 (applause for you, david, that you finally did it :wink:), there still was a 'hard' API change:

old:

Code: Select all

piePlot.setDirection(PiePlot.CLOCKWISE);
new (Rotation class from jcommon.jar):

Code: Select all

piePlot.setDirection(Rotation.CLOCKWISE);
Alas, JFreeChart.setAntiAlias() is deprecated in favour of the support of RenderingHints. Here's a replacement method to get back the good old setAntiAlias() with a boolean parameter:

Code: Select all

    /**
     * Switch on/off anti-aliasing.
     * 
     * @param chart JFreeChart.
     * @param antiAlias True, to switch on anti-aliasing for graphics and text.
     */
    public void setAntiAlias(JFreeChart chart, boolean antiAlias) {
        if (chart != null) {
            Object antiAliasing = RenderingHints.VALUE_ANTIALIAS_DEFAULT;
            Object antiAliasingText = RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT;

            if (antiAlias) { //bug in SVG
                antiAliasing = RenderingHints.VALUE_ANTIALIAS_ON;
                antiAliasingText = RenderingHints.VALUE_TEXT_ANTIALIAS_ON;
            } else {
                antiAliasing = RenderingHints.VALUE_ANTIALIAS_OFF;
                antiAliasingText = RenderingHints.VALUE_TEXT_ANTIALIAS_OFF;
            }
            
            //add/replace rendering hint:
            RenderingHints rh = chart.getRenderingHints();
            if (rh == null) {
                rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, antiAliasing);
            } else {
                rh.put(RenderingHints.KEY_ANTIALIASING, antiAliasing);
            }
            rh.put(RenderingHints.KEY_TEXT_ANTIALIASING, antiAliasingText);

            chart.setRenderingHints(rh);
        }//else: input unavailable
    }//setAntiAlias()
Java 11, JFreeChart 1.0.15, JFreeSVG 4.0

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu Sep 11, 2003 2:48 pm

I used deprecation in a lot of cases, but there are some cases where I was lazy...
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

mhilpert
Posts: 497
Joined: Wed Apr 02, 2003 1:57 pm
Location: Germany

Deprecation

Post by mhilpert » Fri Sep 19, 2003 10:08 am

Deprecation is cool, because it lets the developer enough time to adjust the code and still use a new version (with better performance, more features, etc.). Deprecated objects don't need to stay in the code forever (though Sun does this with Java, so far). So, it would be cool to have a kind of expiry date for deprecated objects (like e.g. 1 year). this will clean up code from time to time and David (i.e. the developers of JFreeChart) has an easy way to remove such deprecated objects (by searching for expiry dates > 1 years).
Java 11, JFreeChart 1.0.15, JFreeSVG 4.0

mhilpert
Posts: 497
Joined: Wed Apr 02, 2003 1:57 pm
Location: Germany

0.9.12 to 0.9.13

Post by mhilpert » Mon Sep 29, 2003 1:34 pm

One undocumented API change is the return value of ValueAxis.getStandardTickUnits(). This change is not easy to implement, see 0.9.13: how to replace ValueAxis.getStandardTickUnits() ?
Java 11, JFreeChart 1.0.15, JFreeSVG 4.0

Locked