Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 468703

Summary: IllegalArgumentException when using logarithmical scale and words only have a single occurrence.
Product: [Tools] GEF Reporter: Alexander Nyßen <nyssen>
Component: GEF CloudioAssignee: gef-inbox <gef-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: P3    
Version: 0.1.0   
Target Milestone: 3.10.0 (Mars) RC3   
Hardware: All   
OS: All   
Whiteboard:

Description Alexander Nyßen CLA 2015-05-28 15:08:53 EDT
When logarithmical scale is selected and words only have a single occurrence, the following IAE is thrown and the word cloud is not rendered:

java.lang.IllegalStateException: Need an underlying widget to be able to set the input.(Has the widget been disposed?)
	at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:279)
	at org.eclipse.gef4.cloudio.ui.TagCloudViewer.setInput(TagCloudViewer.java:362)
	at org.eclipse.gef4.cloudio.internal.ui.actions.LoadFileAction.run(LoadFileAction.java:47)
	at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:253)
	at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:237)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:511)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:420)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4199)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1467)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1490)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1475)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1279)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4042)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3669)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)

The reason is that the TypeLabelProvider returns NaN as weight in these cases because of a division by zero:

case LOGARITHMIC: {
  double count = Math.log(((Type) element).getOccurrences() - minOccurrences + 1);
  count /= (Math.log(maxOccurrences));
return count;
Comment 1 Alexander Nyßen CLA 2015-05-28 15:23:14 EDT
Added a check to prevent division by zero in case a word only has a single occurrence.

Pushed changes to origin/master. Resolving as fixed in 3.10.0 RC3.