Removing Chart Properties Options.

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
artipton
Posts: 16
Joined: Thu Jul 03, 2008 6:59 pm

Removing Chart Properties Options.

Post by artipton » Mon Mar 02, 2009 10:03 pm

Afternoon All,

If I understand correctly, the options under the "Other" tab on the chart properties are not all currently implemented. Is there a way to remove the "Series" options from this tab?

Thank you,
Andy

MitchBuell
Posts: 47
Joined: Thu Dec 11, 2008 7:59 pm

Re: Removing Chart Properties Options.

Post by MitchBuell » Tue Mar 03, 2009 9:34 pm

JFreeChart has a built in chart editor that comes up when you right click on a chart and select Properties. The current chart editor is very basic, but you can replace it with your own. See my post here on how to create your own chart editor: http://www.jfree.org/phpBB2/viewtopic.php?p=74702#74702

In your case, all you need to do is edit DefaultChartEditor.java, which contains the stuff on the Other tab.

artipton
Posts: 16
Joined: Thu Jul 03, 2008 6:59 pm

Re: Removing Chart Properties Options.

Post by artipton » Tue Mar 03, 2009 11:03 pm

I downloaded the source, modified it, and re-compiled it. Thank you. I didn't want to have to do that becuase it causes more maintenance with staying up-to-date, but it solved my problem. Any idea with those might be implemented?

Thank you again for you help,
Andy

MitchBuell
Posts: 47
Joined: Thu Dec 11, 2008 7:59 pm

Re: Removing Chart Properties Options.

Post by MitchBuell » Wed Mar 04, 2009 10:27 pm

Having your own copy of a ChartEditor that is independent of updates to the built in ChartEditor is the only downside to my approach (that I know of). However, now that the basic framework is down, you can get clever and start replacing the My stuff back to Default stuff. The only file you needed to change was DefaultChartEditor.java because it contains the Other tab. Everything else can now revert back to the built in Default stuff.

For example, to get back the built in DefaultTitleEditor and DefaultPlotEditor, simply revert these lines in DefaultChartEditor:

Code: Select all

this.titleEditor = new DefaultTitleEditor(title);

this.plotEditor = new DefaultPlotEditor(plot);
Or, if you're feeling lucky, you can continue to use the DefaultChartEditor and then dynamically edit the panel inside your ChartEditorFactory. For example:

Code: Select all

package my.java.app.myeditor;

import org.jfree.chart.*;
import org.jfree.chart.editor.*;

/**
* My implementation of the ChartEditorFactory interface.
*/
public class MyChartEditorFactory implements ChartEditorFactory
{
    /**
     * Creates a new instance.
     */
    public MyChartEditorFactory()
    {
    }

    /**
     * Returns a new instance of a ChartEditor.
     *
     * @param chart  the chart.
     *
     * @return A chart editor for the given chart.
     */
    public ChartEditor createEditor(JFreeChart chart)
    {
        ChartEditor chartEditor = new DefaultChartEditor(chart);
        
        // chartEditor extends JPanel, so utilize JPanel methods to manipulate the UI before it is shown
        chartEditor.getComponent...
        
        return chartEditor;
    }
}
That's all I can think of so far. Hopefully someone more clever than I can come up with something better. But atleast you have access to the JPanel you want to edit, just need to add in the logic to remove the stuff.

Locked