【问题标题】:Graphviz, GEF4 and build paths in JavaGraphviz、GEF4 和 Java 中的构建路径
【发布时间】:2016-07-05 03:54:33
【问题描述】:

我使用 Graphviz 和 GEF4 框架编写了这个 java 代码来显示一个简单的图形。重要的是,我也在 E​​clipse 中使用 Window Builder。我创建了 SWT/JFace Java 项目,然后将其转换为 Plug-in 项目。

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();
        }
    }
  }
}

我有错误:

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

我发现我需要在 Build Path 中添加构建路径(带有所需库的 jar 文件)。所以我加了。我还添加了所有依赖项。但它仍然不起作用。你有什么想法,我会错过什么吗?谢谢你的任何想法!

【问题讨论】:

  • 我会非常感谢任何想法,任何提示!谢谢!

标签: java graphviz dot zest


【解决方案1】:

您应该找到 org.eclipse.emf.ecore.resource.ResourceSet lib 并将文件 jar 添加到 elipse。

【讨论】:

    猜你喜欢
    • 2012-06-19
    • 1970-01-01
    • 2011-09-20
    • 2021-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多