0
我編寫了這個java代碼來顯示使用Graphviz和GEF4框架的簡單圖形。什麼是重要的,我也在Eclipse中使用Window Builder。我創建了SWT/JFace Java項目,然後將其轉換爲插件項目。Graphviz,GEF4並在Java中構建路徑
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.SWT;
import org.eclipse.gef4.dot.DotImport;
import org.eclipse.gef4.graph.*;
import org.eclipse.gef4.zest.fx.*;
import org.eclipse.gef4.layout.*;
import org.eclipse.gef4.layout.algorithms.*;
public class Code1 {
public static void main(String[] args) {
Display display = Display.getDefault();
Shell shell = new Shell();
shell.setSize(450, 300);
shell.setText("SWT Application");
shell.setLayout(null);
Graph.Builder graph2 = new Graph.Builder().attr(ZestProperties.GRAPH_LAYOUT, new SpringLayoutAlgorithm());
new DotImport("digraph{1->2}").into(graph2);
new DotImport("node[label=zested]; 2->3; 2->4").into(graph2);
new DotImport("edge[style=dashed]; 3->5; 4->6").into(graph2);
//SpringLayoutAlgorithm SLA= new SpringLayoutAlgorithm();
graph2.build();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
}
我有errrors:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/emf/ecore/resource/ResourceSet
at org.eclipse.gef4.dot.DotImport.load(DotImport.java:81)
at org.eclipse.gef4.dot.DotImport.loadFrom(DotImport.java:63)
at org.eclipse.gef4.dot.DotImport.init(DotImport.java:55)
at org.eclipse.gef4.dot.DotImport.<init>(DotImport.java:46)
at program2.Code2.main(Code2.java:24)
Caused by: java.lang.ClassNotFoundException: org.eclipse.emf.ecore.resource.ResourceSet
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 5 more
我發現我需要在構建路徑添加構建路徑(jar文件所需要的庫)。所以我補充說。我也添加了所有的依賴關係。但它仍然不起作用。你有什麼想法,我可能會錯過什麼?謝謝你的任何想法!
我會很感激任何想法,任何提示!謝謝! – sourire09