Hi Eugene! Thanks for your help! Unfortunately, this solves only part of the problem: Of course, there is no nullpointer exception now. But still I don't get the event. The root cause seems to be that the chart entities (which are there) are not retrieved.
I really need to get these events. Exist there any update version? I am really Wondering because the example on the community page works. I'm using: jcommon-1.0.12.jar, jfreechart-1.0.9.jar, jfreechart-extension-client-1.0.jar, jfreechart-extension-server-1.0.jar Thanks and kind regards, Kevin Hirschmann -----Ursprüngliche Nachricht----- Von: Kevin Hirschmann [mailto:[email protected]] Gesendet: Donnerstag, 12. März 2009 09:22 An: Bernhard Schüler Betreff: WG: [ULC-developer] Nullpointer in JFreechart Extension Hi Kevin , Replace the following in UIJFreeChart private UIChartEntity findEntity(int x, int y) { UIChartEntity result = null; for (Iterator iter = fChartEntities.iterator(); iter.hasNext();) { UIChartEntity entity = (UIChartEntity) iter.next(); if (entity.getArea()!=null){ if (entity.getArea().contains(x, y)) { result = entity; } } } return result; } Regards, Eugene Kevin Hirschmann wrote: > > Hi! > > I encountered a problem using JFreeChart Extension II along with > JFreeChart 1.0.9 (and the same for JFreeChart 1.0.0). > > More precisely: jcommon-1.0.12.jar, jfreechart-1.0.9.jar, > jfreechart-extension-client-1.0.jar, jfreechart-extension-server-1.0.jar > > There is a nullpointer exception when a mouse event occurs and an > IChartEventListener has been registered. > > This appears to be the same problem which has previously been posted > on [ULC-developer] > > (by Eugene Coelho, Wed, 19 Jul 2006 01:20:54 -0700). > > Unfortunately, no answer has been posted. > > To produce this error I added an ULCJFreeChart to the template created by > > New ULC Project Wizard > Simple dialog ULC application template in > Eclipse. > > Please see below for the code and the stack trace. > > Thanks and kind regards, > > Kevin Hirschmann > > Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException > > at > com.canoo.ulc.community.jfreechart.client.UIJFreeChart$MouseEventHandler.fin dEntity(UIJFreeChart.java:184) > > at > com.canoo.ulc.community.jfreechart.client.UIJFreeChart$MouseEventHandler.mou seClicked(UIJFreeChart.java:162) > > at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:212) > > at java.awt.Component.processMouseEvent(Component.java:5520) > > at javax.swing.JComponent.processMouseEvent(JComponent.java:3135) > > at > com.ulcjava.base.client.UILabel$BasicLabel.processMouseEvent(UILabel.java:38 ) > > at java.awt.Component.processEvent(Component.java:5282) > > at java.awt.Container.processEvent(Container.java:1966) > > at java.awt.Component.dispatchEventImpl(Component.java:3984) > > at java.awt.Container.dispatchEventImpl(Container.java:2024) > > at java.awt.Component.dispatchEvent(Component.java:3819) > > at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212) > > at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3901) > > at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822) > > at java.awt.Container.dispatchEventImpl(Container.java:2010) > > at java.awt.Window.dispatchEventImpl(Window.java:1791) > > at java.awt.Component.dispatchEvent(Component.java:3819) > > at java.awt.EventQueue.dispatchEvent(EventQueue.java:463) > > at > com.ulcjava.base.client.FilteringEventQueue.dispatchEvent(FilteringEventQueu e.java:61) > > at > java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.ja va:242) > > at > java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java :163) > > at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157) > > at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149) > > at java.awt.EventDispatchThread.run(EventDispatchThread.java:110) > > public class TestChartEventsBoxPane extends ULCBoxPane { > > // The structure of the class enables its visualization with ULC > Visual Editor Plugin > > private ULCButton ulcButton = null; > > private ULCLabel ulcLabel = null; > > private ULCJFreeChart chartComponent = null; > > public TestChartEventsBoxPane() { > > initialize(); > > } > > private void initialize() { > > setHorizontalGap(5); > > set(0, 1, 1, 1, com.ulcjava.base.shared.IDefaults.BOX_CENTER_CENTER, > getUlcButton()); > > set(0, 0, 1, 1, com.ulcjava.base.shared.IDefaults.BOX_CENTER_CENTER, > getUlcLabel()); > > set(2, 2, 1, 1, com.ulcjava.base.shared.IDefaults.BOX_CENTER_CENTER, > getULCJFreeChart()); > > } > > private ULCButton getUlcButton() { > > if (ulcButton == null) { > > ulcButton = new ULCButton(); > > ulcButton.setText("Say Hello"); > > ulcButton.addActionListener(new IActionListener() { > > public void actionPerformed(ActionEvent e) { > > new ULCAlert("Title","Hello!","OK").show(); > > } > > }); > > } > > return ulcButton; > > } > > private ULCLabel getUlcLabel() { > > if (ulcLabel == null) { > > ulcLabel = new ULCLabel(); > > ulcLabel.setText("Click button for greeting"); > > } > > return ulcLabel; > > } > > private ULCJFreeChart getULCJFreeChart() { > > if (this.chartComponent == null) { > > this.chartComponent = new ULCJFreeChart(); > > double[][] data = new double[][] { { 4257, 4058, 3357 }, { 257, 58, > 357 } }; > > CategoryDataset dataset = DatasetUtilities.createCategoryDataset( > > new String[] { "prognose", "real" }, > > new String[] { "02.09.2008", "03.09.2008", "04.09.2008" }, > > data); > > JFreeChart chart1 = ChartFactory.createBarChart("TEST", "", "", > dataset, PlotOrientation.VERTICAL, false, > > false, false); > > this.chartComponent.setChart(chart1, new Dimension(600, 400)); > > this.chartComponent.addChartComponentListener(new > IChartComponentListener() { > > public void chartResized(UlcChartComponentEvent event) { > > System.out.println("chartResized: latest chart size: " + > event.getChartComponentSize()); > > } > > }); > > this.chartComponent.addChartEventListener(new IChartEventListener() { > > public void chartClicked(UlcChartEvent event) { > > System.out.println("chart clicked"); > > } > > public void chartEntityClicked(UlcChartEvent event) { > > ChartEntity entity = event.getChartEntity(); > > System.out.println("entity coordinates: " + entity.getShapeCoords()); > > } > > public void chartZoomed(UlcChartEvent arg0) { > > ; > > } > > }); > > } > > return chartComponent; > > } > > } > > HUEBINET Informationsmanagement GmbH & Co. KG > > Universitätsstraße 3 > > 56070 Koblenz > > Sitz und Registergericht: Koblenz HRA 5329 > > Persönlich haftender Gesellschafter der KG: > > HUEBINET GmbH; > > Sitz und Registergericht: Koblenz HRB 6857 > > Geschäftsführung: > > Frank Hüttmann; Michael Biemer > > Der Nachrichtenaustausch mit HUEBINET Informationsmanagement GmbH & > Co. KG, Koblenz via E-Mail dient lediglich zu Informationszwecken. > Rechtsgeschäftliche Erklärungen mit verbindlichem Inhalt können über > dieses Medium nicht ausgetauscht werden, da die Manipulation von > E-Mails durch Dritte nicht ausgeschlossen werden kann. > _______________________________________________ ULC-developer mailing list [email protected] http://lists.canoo.com/mailman/listinfo/ulc-developer _______________________________________________ ULC-developer mailing list [email protected] http://lists.canoo.com/mailman/listinfo/ulc-developer
