Feb 18
There is a great tutorial on vogella.de describing how to add a pie chart with JFreeChart to an Eclipse RCP application or plug-in. The ChartFactory that is used to create the pie chart does not include a method to create a speedometer (or dial) as shown in the sample section of JFreeChart. The following code fragment creates a view that displays a very basic speedometer using the org.jfree.chart.plot.MeterPlot class:
package com.martinklinke.eclipse.jfreechart.demo.views;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.MeterPlot;
import org.jfree.data.general.DefaultValueDataset;
import org.jfree.experimental.chart.swt.ChartComposite;
/**
* @author martin
*
*/
public class MeterChartView extends ViewPart {
public static final String ID = "com.martinklinke.eclipse.jfreechart.demo.views.MeterChartView";
public void createPartControl(Composite parent) {
JFreeChart chart = createChart();
final ChartComposite frame = new ChartComposite(parent, SWT.NONE, chart, true);
}
public void setFocus() {
}
/**
* Creates the Chart based on a dataset
*/
private JFreeChart createChart() {
DefaultValueDataset data = new DefaultValueDataset(20.0);
MeterPlot plot = new MeterPlot(data);
JFreeChart chart = new JFreeChart("Meter Chart",
JFreeChart.DEFAULT_TITLE_FONT, plot, false);
plot.setNoDataMessage("No data available");
return chart;
}
}
The result should look like the following screenshot:

JFreeChart Speedometer in Eclipse View
Of course, the MeterPlot can be further customized by calling the plot.setXXX(…) methods. However, this exercise is left to the willing reader ;)
Jul 11
Today, I had a strange problem with Eclipse. I have an EJB project with JBoss v4.2 selected in targeted runtimes (project properties) and as such the JBoss v4.2 server runtime classpath variable. I have really no idea what happened, but the effect was that the JBoss classpath entry didn’t show up any longer. My first thought was that maybe the .classpath file got mixed up, but it still contained the required entry. The project properties also contained all the correct information. Just the package explorer didn’t show the entry and it definitely wasn’t there as the build for the project failed because the required classes could not be found.
The <workspace>/.metadata/.log file contained the following error message many times:
!ENTRY org.eclipse.jst.server.core 4 0 2008-07-11 16:24:46.251
!MESSAGE Error calling delegate RuntimeClasspathProviderWrapper[org.eclipse.jst.server.generic.runtimeTarget]: null
So this must have been a bug in resolving the server classpath. I couldn’t find an equivalent problem description, and after playing around with the project settings, adding and removing the library manually, which didn’t help any further, I tried updating the Java Standard Tools. There was indeed a patch available. My previous version of JST was org.eclipse.jst_2.0.2.v200802150100-7B-7_8dDTOvmuz0di_U5vgUfz0em and I installed the patch org.eclipse.jst.web_core.feature.patch_2.0.2.v200803241913-208i8s733I395D6BA7. My Eclipse SDK version used is 3.3.2, Build id M20080221-1800.
After the installation of the patch and a restart of Eclipse, the JBoss v4.2 entry showed up again and the error message didn’t occur any longer in the log file. As I said, I don’t really know what had happened, but the patch might have resolved the issue for me, so maybe this helps someone out there, who runs into the same problem.
Jul 10
Eclipse is a great IDE for developing any kind of Java code, e.g. Rich Client (RCP), Web or standalone applications. However, when a project is built using any IDE (yes, there are others – e.g. Netbeans or IntelliJ IDEA), there may be some dependencies towards the chosen tool when it comes to compiling and packaging the code. This doesn’t matter too much as long as there is no requirement to automate the build process. This will happen, as soon as you decide to set up Continuous Integration for your project.
Continue reading »
Recent Comments