1

私は gv_java を使用しようとしています - Graphviz で Java を使用したグラフ操作。必要に応じて、java.Installed graphviz に SWIG Type ファイルを含む Java パッケージをダウンロードしました。

よりクリーンなソリューションとして、graphviz が提供する JNI を使用してみました。これが私のテスト コードです。

public class TestGraphvizLibrary {

    public final static native long graph__SWIG_0(String jarg1);
    public final static native long digraph(String jarg1);
    public final static native long strictgraph(String jarg1);
    public final static native long strictdigraph(String jarg1);
    public final static native long readstring(String jarg1);
    public final static native long read__SWIG_0(String jarg1);
    public final static native long read__SWIG_1(long jarg1);
    public final static native long graph__SWIG_1(long jarg1, String jarg2);
    public final static native long node(long jarg1, String jarg2);
    public final static native long edge__SWIG_0(long jarg1, long jarg2);
    public final static native long edge__SWIG_1(long jarg1, String jarg2);
    public final static native long edge__SWIG_2(String jarg1, long jarg2);
    public final static native long edge__SWIG_3(long jarg1, String jarg2, String jarg3);
    public final static native String setv__SWIG_0(long jarg1, String jarg2, String jarg3);
    public final static native String setv__SWIG_1(long jarg1, String jarg2, String jarg3);
    public final static native String setv__SWIG_2(long jarg1, String jarg2, String jarg3);
    public final static native String setv__SWIG_3(long jarg1, long jarg2, String jarg3);
    public final static native String setv__SWIG_4(long jarg1, long jarg2, String jarg3);
    public final static native String setv__SWIG_5(long jarg1, long jarg2, String jarg3);
    public final static native String getv__SWIG_0(long jarg1, String jarg2);
    public final static native String getv__SWIG_1(long jarg1, String jarg2);
    public final static native String getv__SWIG_2(long jarg1, String jarg2);
    public final static native String getv__SWIG_3(long jarg1, long jarg2);
    public final static native String getv__SWIG_4(long jarg1, long jarg2);
    public final static native String getv__SWIG_5(long jarg1, long jarg2);
    public final static native String nameof__SWIG_0(long jarg1);
    public final static native String nameof__SWIG_1(long jarg1);
    public final static native String nameof__SWIG_2(long jarg1);
    public final static native long findsubg(long jarg1, String jarg2);
    public final static native long findnode(long jarg1, String jarg2);
    public final static native long findedge(long jarg1, long jarg2);
    public final static native long findattr__SWIG_0(long jarg1, String jarg2);
    public final static native long findattr__SWIG_1(long jarg1, String jarg2);
    public final static native long findattr__SWIG_2(long jarg1, String jarg2);
    public final static native long headof(long jarg1);
    public final static native long tailof(long jarg1);
    public final static native long graphof__SWIG_0(long jarg1);
    public final static native long graphof__SWIG_1(long jarg1);
    public final static native long graphof__SWIG_2(long jarg1);
    public final static native long rootof(long jarg1);
    public final static native long protonode(long jarg1);
    public final static native long protoedge(long jarg1);
    public final static native boolean ok__SWIG_0(long jarg1);
    public final static native boolean ok__SWIG_1(long jarg1);
    public final static native boolean ok__SWIG_2(long jarg1);
    public final static native boolean ok__SWIG_3(long jarg1);
    public final static native long firstsubg(long jarg1);
    public final static native long nextsubg(long jarg1, long jarg2);
    public final static native long firstsupg(long jarg1);
    public final static native long nextsupg(long jarg1, long jarg2);
    public final static native long firstedge__SWIG_0(long jarg1);
    public final static native long nextedge__SWIG_0(long jarg1, long jarg2);
    public final static native long firstout__SWIG_0(long jarg1);
    public final static native long nextout__SWIG_0(long jarg1, long jarg2);
    public final static native long firstedge__SWIG_1(long jarg1);
    public final static native long nextedge__SWIG_1(long jarg1, long jarg2);
    public final static native long firstout__SWIG_1(long jarg1);
    public final static native long nextout__SWIG_1(long jarg1, long jarg2);
    public final static native long firsthead(long jarg1);
    public final static native long nexthead(long jarg1, long jarg2);
    public final static native long firstin__SWIG_0(long jarg1);
    public final static native long nextin__SWIG_0(long jarg1, long jarg2);
    public final static native long firstin__SWIG_1(long jarg1);
    public final static native long nextin__SWIG_1(long jarg1, long jarg2);
    public final static native long firsttail(long jarg1);
    public final static native long nexttail(long jarg1, long jarg2);
    public final static native long firstnode__SWIG_0(long jarg1);
    public final static native long nextnode__SWIG_0(long jarg1, long jarg2);
    public final static native long firstnode__SWIG_1(long jarg1);
    public final static native long nextnode__SWIG_1(long jarg1, long jarg2);
    public final static native long firstattr__SWIG_0(long jarg1);
    public final static native long nextattr__SWIG_0(long jarg1, long jarg2);
    public final static native long firstattr__SWIG_1(long jarg1);
    public final static native long nextattr__SWIG_1(long jarg1, long jarg2);
    public final static native long firstattr__SWIG_2(long jarg1);
    public final static native long nextattr__SWIG_2(long jarg1, long jarg2);
    public final static native boolean rm__SWIG_0(long jarg1);
    public final static native boolean rm__SWIG_1(long jarg1);
    public final static native boolean rm__SWIG_2(long jarg1);
    public final static native boolean layout(long jarg1, String jarg2);
    public final static native boolean render__SWIG_0(long jarg1);
    public final static native boolean render__SWIG_1(long jarg1, String jarg2);
    public final static native boolean render__SWIG_2(long jarg1, String jarg2, long jarg3);
    public final static native boolean render__SWIG_3(long jarg1, String jarg2, String jarg3);
    public final static native boolean renderchannel(long jarg1, String jarg2, String jarg3);
    public final static native void renderresult(long jarg1, String jarg2, String jarg3);
    public final static native String renderdata(long jarg1, String jarg2);
    public final static native boolean write__SWIG_0(long jarg1, String jarg2);
    public final static native boolean write__SWIG_1(long jarg1, long jarg2);


    public static SWIGTYPE_p_Agraph_t graph(String name) {
        long cPtr = gvJNI.graph__SWIG_0(name);
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agraph_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agraph_t digraphh(String name) {
        long cPtr = digraph(name);
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agraph_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agraph_t strictgraphh(String name) {
        long cPtr = gvJNI.strictgraph(name);
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agraph_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agraph_t strictdigraphh(String name) {
        long cPtr = gvJNI.strictdigraph(name);
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agraph_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agraph_t readstringg(String string) {
        long cPtr = gvJNI.readstring(string);
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agraph_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agraph_t read(String filename) {
        long cPtr = gvJNI.read__SWIG_0(filename);
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agraph_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agraph_t read(SWIGTYPE_p_FILE f) {
        long cPtr = gvJNI.read__SWIG_1(SWIGTYPE_p_FILE.getCPtr(f));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agraph_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agraph_t graph(SWIGTYPE_p_Agraph_t g, String name) {
        long cPtr = gvJNI.graph__SWIG_1(SWIGTYPE_p_Agraph_t.getCPtr(g), name);
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agraph_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agnode_t node(SWIGTYPE_p_Agraph_t g, String name) {
        long cPtr = gvJNI.node(SWIGTYPE_p_Agraph_t.getCPtr(g), name);
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agnode_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agedge_t edge(SWIGTYPE_p_Agnode_t t, SWIGTYPE_p_Agnode_t h) {
        long cPtr = gvJNI.edge__SWIG_0(SWIGTYPE_p_Agnode_t.getCPtr(t), SWIGTYPE_p_Agnode_t.getCPtr(h));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agedge_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agedge_t edge(SWIGTYPE_p_Agnode_t t, String hname) {
        long cPtr = gvJNI.edge__SWIG_1(SWIGTYPE_p_Agnode_t.getCPtr(t), hname);
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agedge_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agedge_t edge(String tname, SWIGTYPE_p_Agnode_t h) {
        long cPtr = gvJNI.edge__SWIG_2(tname, SWIGTYPE_p_Agnode_t.getCPtr(h));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agedge_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agedge_t edge(SWIGTYPE_p_Agraph_t g, String tname, String hname) {
        long cPtr = gvJNI.edge__SWIG_3(SWIGTYPE_p_Agraph_t.getCPtr(g), tname, hname);
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agedge_t(cPtr, false);
      }

      public static String setv(SWIGTYPE_p_Agraph_t g, String attr, String val) {
        return gvJNI.setv__SWIG_0(SWIGTYPE_p_Agraph_t.getCPtr(g), attr, val);
      }

      public static String setv(SWIGTYPE_p_Agnode_t n, String attr, String val) {
        return gvJNI.setv__SWIG_1(SWIGTYPE_p_Agnode_t.getCPtr(n), attr, val);
      }

      public static String setv(SWIGTYPE_p_Agedge_t e, String attr, String val) {
        return gvJNI.setv__SWIG_2(SWIGTYPE_p_Agedge_t.getCPtr(e), attr, val);
      }

      public static String setv(SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_Agsym_t a, String val) {
        return gvJNI.setv__SWIG_3(SWIGTYPE_p_Agraph_t.getCPtr(g), SWIGTYPE_p_Agsym_t.getCPtr(a), val);
      }

      public static String setv(SWIGTYPE_p_Agnode_t n, SWIGTYPE_p_Agsym_t a, String val) {
        return gvJNI.setv__SWIG_4(SWIGTYPE_p_Agnode_t.getCPtr(n), SWIGTYPE_p_Agsym_t.getCPtr(a), val);
      }

      public static String setv(SWIGTYPE_p_Agedge_t e, SWIGTYPE_p_Agsym_t a, String val) {
        return gvJNI.setv__SWIG_5(SWIGTYPE_p_Agedge_t.getCPtr(e), SWIGTYPE_p_Agsym_t.getCPtr(a), val);
      }

      public static String getv(SWIGTYPE_p_Agraph_t g, String attr) {
        return gvJNI.getv__SWIG_0(SWIGTYPE_p_Agraph_t.getCPtr(g), attr);
      }

      public static String getv(SWIGTYPE_p_Agnode_t n, String attr) {
        return gvJNI.getv__SWIG_1(SWIGTYPE_p_Agnode_t.getCPtr(n), attr);
      }

      public static String getv(SWIGTYPE_p_Agedge_t e, String attr) {
        return gvJNI.getv__SWIG_2(SWIGTYPE_p_Agedge_t.getCPtr(e), attr);
      }

      public static String getv(SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_Agsym_t a) {
        return gvJNI.getv__SWIG_3(SWIGTYPE_p_Agraph_t.getCPtr(g), SWIGTYPE_p_Agsym_t.getCPtr(a));
      }

      public static String getv(SWIGTYPE_p_Agnode_t n, SWIGTYPE_p_Agsym_t a) {
        return gvJNI.getv__SWIG_4(SWIGTYPE_p_Agnode_t.getCPtr(n), SWIGTYPE_p_Agsym_t.getCPtr(a));
      }

      public static String getv(SWIGTYPE_p_Agedge_t e, SWIGTYPE_p_Agsym_t a) {
        return gvJNI.getv__SWIG_5(SWIGTYPE_p_Agedge_t.getCPtr(e), SWIGTYPE_p_Agsym_t.getCPtr(a));
      }

      public static String nameof(SWIGTYPE_p_Agraph_t g) {
        return gvJNI.nameof__SWIG_0(SWIGTYPE_p_Agraph_t.getCPtr(g));
      }

      public static String nameof(SWIGTYPE_p_Agnode_t n) {
        return gvJNI.nameof__SWIG_1(SWIGTYPE_p_Agnode_t.getCPtr(n));
      }

      public static String nameof(SWIGTYPE_p_Agsym_t a) {
        return gvJNI.nameof__SWIG_2(SWIGTYPE_p_Agsym_t.getCPtr(a));
      }

      public static SWIGTYPE_p_Agraph_t findsubg(SWIGTYPE_p_Agraph_t g, String name) {
        long cPtr = gvJNI.findsubg(SWIGTYPE_p_Agraph_t.getCPtr(g), name);
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agraph_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agnode_t findnode(SWIGTYPE_p_Agraph_t g, String name) {
        long cPtr = gvJNI.findnode(SWIGTYPE_p_Agraph_t.getCPtr(g), name);
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agnode_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agedge_t findedge(SWIGTYPE_p_Agnode_t t, SWIGTYPE_p_Agnode_t h) {
        long cPtr = gvJNI.findedge(SWIGTYPE_p_Agnode_t.getCPtr(t), SWIGTYPE_p_Agnode_t.getCPtr(h));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agedge_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agsym_t findattr(SWIGTYPE_p_Agraph_t g, String name) {
        long cPtr = gvJNI.findattr__SWIG_0(SWIGTYPE_p_Agraph_t.getCPtr(g), name);
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agsym_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agsym_t findattr(SWIGTYPE_p_Agnode_t n, String name) {
        long cPtr = gvJNI.findattr__SWIG_1(SWIGTYPE_p_Agnode_t.getCPtr(n), name);
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agsym_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agsym_t findattr(SWIGTYPE_p_Agedge_t e, String name) {
        long cPtr = gvJNI.findattr__SWIG_2(SWIGTYPE_p_Agedge_t.getCPtr(e), name);
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agsym_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agnode_t headof(SWIGTYPE_p_Agedge_t e) {
        long cPtr = gvJNI.headof(SWIGTYPE_p_Agedge_t.getCPtr(e));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agnode_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agnode_t tailof(SWIGTYPE_p_Agedge_t e) {
        long cPtr = gvJNI.tailof(SWIGTYPE_p_Agedge_t.getCPtr(e));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agnode_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agraph_t graphof(SWIGTYPE_p_Agraph_t g) {
        long cPtr = gvJNI.graphof__SWIG_0(SWIGTYPE_p_Agraph_t.getCPtr(g));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agraph_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agraph_t graphof(SWIGTYPE_p_Agedge_t e) {
        long cPtr = gvJNI.graphof__SWIG_1(SWIGTYPE_p_Agedge_t.getCPtr(e));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agraph_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agraph_t graphof(SWIGTYPE_p_Agnode_t n) {
        long cPtr = gvJNI.graphof__SWIG_2(SWIGTYPE_p_Agnode_t.getCPtr(n));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agraph_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agraph_t rootof(SWIGTYPE_p_Agraph_t g) {
        long cPtr = gvJNI.rootof(SWIGTYPE_p_Agraph_t.getCPtr(g));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agraph_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agnode_t protonode(SWIGTYPE_p_Agraph_t g) {
        long cPtr = gvJNI.protonode(SWIGTYPE_p_Agraph_t.getCPtr(g));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agnode_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agedge_t protoedge(SWIGTYPE_p_Agraph_t g) {
        long cPtr = gvJNI.protoedge(SWIGTYPE_p_Agraph_t.getCPtr(g));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agedge_t(cPtr, false);
      }

      public static boolean ok(SWIGTYPE_p_Agraph_t g) {
        return gvJNI.ok__SWIG_0(SWIGTYPE_p_Agraph_t.getCPtr(g));
      }

      public static boolean ok(SWIGTYPE_p_Agnode_t n) {
        return gvJNI.ok__SWIG_1(SWIGTYPE_p_Agnode_t.getCPtr(n));
      }

      public static boolean ok(SWIGTYPE_p_Agedge_t e) {
        return gvJNI.ok__SWIG_2(SWIGTYPE_p_Agedge_t.getCPtr(e));
      }

      public static boolean ok(SWIGTYPE_p_Agsym_t a) {
        return gvJNI.ok__SWIG_3(SWIGTYPE_p_Agsym_t.getCPtr(a));
      }

      public static SWIGTYPE_p_Agraph_t firstsubg(SWIGTYPE_p_Agraph_t g) {
        long cPtr = gvJNI.firstsubg(SWIGTYPE_p_Agraph_t.getCPtr(g));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agraph_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agraph_t nextsubg(SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_Agraph_t sg) {
        long cPtr = gvJNI.nextsubg(SWIGTYPE_p_Agraph_t.getCPtr(g), SWIGTYPE_p_Agraph_t.getCPtr(sg));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agraph_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agraph_t firstsupg(SWIGTYPE_p_Agraph_t g) {
        long cPtr = gvJNI.firstsupg(SWIGTYPE_p_Agraph_t.getCPtr(g));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agraph_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agraph_t nextsupg(SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_Agraph_t sg) {
        long cPtr = gvJNI.nextsupg(SWIGTYPE_p_Agraph_t.getCPtr(g), SWIGTYPE_p_Agraph_t.getCPtr(sg));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agraph_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agedge_t firstedge(SWIGTYPE_p_Agraph_t g) {
        long cPtr = gvJNI.firstedge__SWIG_0(SWIGTYPE_p_Agraph_t.getCPtr(g));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agedge_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agedge_t nextedge(SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_Agedge_t e) {
        long cPtr = gvJNI.nextedge__SWIG_0(SWIGTYPE_p_Agraph_t.getCPtr(g), SWIGTYPE_p_Agedge_t.getCPtr(e));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agedge_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agedge_t firstout(SWIGTYPE_p_Agraph_t g) {
        long cPtr = gvJNI.firstout__SWIG_0(SWIGTYPE_p_Agraph_t.getCPtr(g));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agedge_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agedge_t nextout(SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_Agedge_t e) {
        long cPtr = gvJNI.nextout__SWIG_0(SWIGTYPE_p_Agraph_t.getCPtr(g), SWIGTYPE_p_Agedge_t.getCPtr(e));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agedge_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agedge_t firstedge(SWIGTYPE_p_Agnode_t n) {
        long cPtr = gvJNI.firstedge__SWIG_1(SWIGTYPE_p_Agnode_t.getCPtr(n));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agedge_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agedge_t nextedge(SWIGTYPE_p_Agnode_t n, SWIGTYPE_p_Agedge_t e) {
        long cPtr = gvJNI.nextedge__SWIG_1(SWIGTYPE_p_Agnode_t.getCPtr(n), SWIGTYPE_p_Agedge_t.getCPtr(e));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agedge_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agedge_t firstout(SWIGTYPE_p_Agnode_t n) {
        long cPtr = gvJNI.firstout__SWIG_1(SWIGTYPE_p_Agnode_t.getCPtr(n));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agedge_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agedge_t nextout(SWIGTYPE_p_Agnode_t n, SWIGTYPE_p_Agedge_t e) {
        long cPtr = gvJNI.nextout__SWIG_1(SWIGTYPE_p_Agnode_t.getCPtr(n), SWIGTYPE_p_Agedge_t.getCPtr(e));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agedge_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agnode_t firsthead(SWIGTYPE_p_Agnode_t n) {
        long cPtr = gvJNI.firsthead(SWIGTYPE_p_Agnode_t.getCPtr(n));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agnode_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agnode_t nexthead(SWIGTYPE_p_Agnode_t n, SWIGTYPE_p_Agnode_t h) {
        long cPtr = gvJNI.nexthead(SWIGTYPE_p_Agnode_t.getCPtr(n), SWIGTYPE_p_Agnode_t.getCPtr(h));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agnode_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agedge_t firstin(SWIGTYPE_p_Agraph_t g) {
        long cPtr = gvJNI.firstin__SWIG_0(SWIGTYPE_p_Agraph_t.getCPtr(g));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agedge_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agedge_t nextin(SWIGTYPE_p_Agnode_t n, SWIGTYPE_p_Agedge_t e) {
        long cPtr = gvJNI.nextin__SWIG_0(SWIGTYPE_p_Agnode_t.getCPtr(n), SWIGTYPE_p_Agedge_t.getCPtr(e));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agedge_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agedge_t firstin(SWIGTYPE_p_Agnode_t n) {
        long cPtr = gvJNI.firstin__SWIG_1(SWIGTYPE_p_Agnode_t.getCPtr(n));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agedge_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agedge_t nextin(SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_Agedge_t e) {
        long cPtr = gvJNI.nextin__SWIG_1(SWIGTYPE_p_Agraph_t.getCPtr(g), SWIGTYPE_p_Agedge_t.getCPtr(e));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agedge_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agnode_t firsttail(SWIGTYPE_p_Agnode_t n) {
        long cPtr = gvJNI.firsttail(SWIGTYPE_p_Agnode_t.getCPtr(n));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agnode_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agnode_t nexttail(SWIGTYPE_p_Agnode_t n, SWIGTYPE_p_Agnode_t t) {
        long cPtr = gvJNI.nexttail(SWIGTYPE_p_Agnode_t.getCPtr(n), SWIGTYPE_p_Agnode_t.getCPtr(t));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agnode_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agnode_t firstnode(SWIGTYPE_p_Agraph_t g) {
        long cPtr = gvJNI.firstnode__SWIG_0(SWIGTYPE_p_Agraph_t.getCPtr(g));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agnode_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agnode_t nextnode(SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_Agnode_t n) {
        long cPtr = gvJNI.nextnode__SWIG_0(SWIGTYPE_p_Agraph_t.getCPtr(g), SWIGTYPE_p_Agnode_t.getCPtr(n));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agnode_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agnode_t firstnode(SWIGTYPE_p_Agedge_t e) {
        long cPtr = gvJNI.firstnode__SWIG_1(SWIGTYPE_p_Agedge_t.getCPtr(e));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agnode_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agnode_t nextnode(SWIGTYPE_p_Agedge_t e, SWIGTYPE_p_Agnode_t n) {
        long cPtr = gvJNI.nextnode__SWIG_1(SWIGTYPE_p_Agedge_t.getCPtr(e), SWIGTYPE_p_Agnode_t.getCPtr(n));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agnode_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agsym_t firstattr(SWIGTYPE_p_Agraph_t g) {
        long cPtr = gvJNI.firstattr__SWIG_0(SWIGTYPE_p_Agraph_t.getCPtr(g));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agsym_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agsym_t nextattr(SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_Agsym_t a) {
        long cPtr = gvJNI.nextattr__SWIG_0(SWIGTYPE_p_Agraph_t.getCPtr(g), SWIGTYPE_p_Agsym_t.getCPtr(a));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agsym_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agsym_t firstattr(SWIGTYPE_p_Agedge_t e) {
        long cPtr = gvJNI.firstattr__SWIG_1(SWIGTYPE_p_Agedge_t.getCPtr(e));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agsym_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agsym_t nextattr(SWIGTYPE_p_Agedge_t e, SWIGTYPE_p_Agsym_t a) {
        long cPtr = gvJNI.nextattr__SWIG_1(SWIGTYPE_p_Agedge_t.getCPtr(e), SWIGTYPE_p_Agsym_t.getCPtr(a));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agsym_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agsym_t firstattr(SWIGTYPE_p_Agnode_t n) {
        long cPtr = gvJNI.firstattr__SWIG_2(SWIGTYPE_p_Agnode_t.getCPtr(n));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agsym_t(cPtr, false);
      }

      public static SWIGTYPE_p_Agsym_t nextattr(SWIGTYPE_p_Agnode_t n, SWIGTYPE_p_Agsym_t a) {
        long cPtr = gvJNI.nextattr__SWIG_2(SWIGTYPE_p_Agnode_t.getCPtr(n), SWIGTYPE_p_Agsym_t.getCPtr(a));
        return (cPtr == 0) ? null : new SWIGTYPE_p_Agsym_t(cPtr, false);
      }

      public static boolean rm(SWIGTYPE_p_Agraph_t g) {
        return gvJNI.rm__SWIG_0(SWIGTYPE_p_Agraph_t.getCPtr(g));
      }

      public static boolean rm(SWIGTYPE_p_Agnode_t n) {
        return gvJNI.rm__SWIG_1(SWIGTYPE_p_Agnode_t.getCPtr(n));
      }

      public static boolean rm(SWIGTYPE_p_Agedge_t e) {
        return gvJNI.rm__SWIG_2(SWIGTYPE_p_Agedge_t.getCPtr(e));
      }

      public static boolean layout(SWIGTYPE_p_Agraph_t g, String engine) {
        return gvJNI.layout(SWIGTYPE_p_Agraph_t.getCPtr(g), engine);
      }

      public static boolean render(SWIGTYPE_p_Agraph_t g) {
        return gvJNI.render__SWIG_0(SWIGTYPE_p_Agraph_t.getCPtr(g));
      }

      public static boolean render(SWIGTYPE_p_Agraph_t g, String format) {
        return gvJNI.render__SWIG_1(SWIGTYPE_p_Agraph_t.getCPtr(g), format);
      }

      public static boolean render(SWIGTYPE_p_Agraph_t g, String format, SWIGTYPE_p_FILE fout) {
        return gvJNI.render__SWIG_2(SWIGTYPE_p_Agraph_t.getCPtr(g), format, SWIGTYPE_p_FILE.getCPtr(fout));
      }

      public static boolean render(SWIGTYPE_p_Agraph_t g, String format, String filename) {
        return gvJNI.render__SWIG_3(SWIGTYPE_p_Agraph_t.getCPtr(g), format, filename);
      }

      public static boolean renderchannel(SWIGTYPE_p_Agraph_t g, String format, String channelname) {
        return gvJNI.renderchannel(SWIGTYPE_p_Agraph_t.getCPtr(g), format, channelname);
      }

      public static void renderresult(SWIGTYPE_p_Agraph_t g, String format, String outdata) {
        gvJNI.renderresult(SWIGTYPE_p_Agraph_t.getCPtr(g), format, outdata);
      }

      public static String renderdata(SWIGTYPE_p_Agraph_t g, String format) {
        return gvJNI.renderdata(SWIGTYPE_p_Agraph_t.getCPtr(g), format);
      }

      public static boolean write(SWIGTYPE_p_Agraph_t g, String filename) {
        return gvJNI.write__SWIG_0(SWIGTYPE_p_Agraph_t.getCPtr(g), filename);
      }

      public static boolean write(SWIGTYPE_p_Agraph_t g, SWIGTYPE_p_FILE f) {
        return gvJNI.write__SWIG_1(SWIGTYPE_p_Agraph_t.getCPtr(g), SWIGTYPE_p_FILE.getCPtr(f));
      }

    /**
     * @param args
     */
    public static void main(String[] args) {
        TestGraphvizLibrary gvt = new TestGraphvizLibrary();
        //create a new graph    
        SWIGTYPE_p_Agraph_t newGraph = TestGraphvizLibrary.graph("hello");
        SWIGTYPE_p_Agnode_t headNode =    TestGraphvizLibrary.node(newGraph, "First Node");
        SWIGTYPE_p_Agnode_t tailNode = TestGraphvizLibrary.node(newGraph, "second Node"); 

        //SWIGTYPE_p_Agedge_t firstEdge = gv.edge(tailNode, headNode);
        boolean file =gv.write(newGraph, "graph");
        System.out.println("file is success "+ file);
    }

    static {
        System.out.println("Loading library...");
        System.load("/usr/lib64/graphviz/java/libgv_java.so");
        System.out.println("Loaded library.");
    }


}

システムはライブラリをロードできますが、ネイティブ メソッドを呼び出すと、メッセージなしでメソッド呼び出しの行に UnsatisfiedLinkError が表示されます。

私は何か間違ったことをしていますか.Linuxマシンにgraphvizをインストールしました.ライブラリとすべてのクラスが適切に配置されています.

4

1 に答える 1

1

インストールを確認し、すべてが適切であるため、Javaファイルに問題があると判断しました。

JNIメソッドを使用している間、命名規則に関するさまざまな投稿を読みました。GraphvizすべてのJavaメソッド名はSWIG、次にチェックしたのはパッケージ構造によって生成されるためです。

上記の私のコードでは、最初は(提供されているように)GraphVizではなく、自分のパッケージ名にすべてのネイティブメソッドが含まれていました。org.graphviz

私はそれらをそれぞれのパッケージに移動しました、そしてそれは魅力のように働きました!

于 2013-02-04T20:59:51.790 に答える