How to plot a graph with Nebula XYGraph

Nebula is an Eclipse Project that allows you to use hundreds of cool widgets to make your application really awesome.

XYGraph is one of them and you can use it to plot a graph with plenty of options. Let’s see how to do that.

In Eclipse menu select Help, Install New Software…, put the following Update Site in the Work with field

 

http://download.eclipse.org/nebula/snapshot

 

then expand Nebula Release Individual Widgets node
and select Nebula Visualization Widgets, finish the installation and let Eclipse restart.

Now you can create a new application with File, New, Project, Plug-in Development, Plug-in Project, Next.

Give the project a name, e.g. it.rcpvision.nebula.xygraph, Next, select

  • Generate an activator, …
  • This plug-in will make contributions to the UI
  • Would you like to create a rich client application: Yes

Next, then select Eclipse 4 RCP application template, Next, select Create sample content …, Finish
(confirm opening Plug-in Development perspective is just a matter of taste, let’s say yes).

 

Now navigate and open /it.rcpvision.nebula.xygraph/src/it/rcpvision/nebula/xygraph/parts/SamplePart.java

remove the following parts

Press Ctrl-Shift-O to remove unused imports, Save and you’ll get an empty Part.

You can test it by selecting it.rcpvision.nebula.xygraph.product, right click, Run As, Eclipse Application: your empty application will pop-up. Now close it.

 

Ok, time to add the right dependencies: open (double-click) MANIFEST.MF, Dependencies tab, Add

  • org.eclipse.draw2d
  • org.eclipse.nebula.visualization.xygraph

in the Required Plug-ins, Save.

Then open it.rcpvision.nebula.xygraph.product, Contents tab, Add the same two plug-ins, Save

Then go again in SamplePart.java and, after line

in createComposite() method, add the following lines

In the end we are ready to relaunch our application (right-click it.rcpvision.nebula.xygraph.productRun As, Eclipse Application) and see (and play with) our new graph.

 

2018-08-09T14:33:43+00:00 By |

Leave A Comment