2013-02-04 78 views
1

我正嘗試使用gv_java - 使用java與Graphviz進行圖形操作。 我根據需要下載了包含java.Installed graphviz中的SWIG類型文件的java包。如何在java中使用Graphviz進行圖形操作

對於更清潔的解決方案,我嘗試使用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,庫和所有類都在位。

回答

0

我檢查了安裝,一切正常,所以我決定我的java文件有問題。

我在使用JNI方法時讀取命名約定中的各種帖子,因爲對於Graphviz所有java方法名都是由SWIG生成的,接下來我檢查的是包結構。

在我上面的代碼中,我最初擁有所有GraphViz本地方法,而不是我自己的包名稱,而不是org.graphviz(由它們提供)。

我把它們移到了相應的包中,它的功能就像一個魅力!

+0

嗨,您能否提供一些鏈接或自己描述使用gv_java API的步驟? – Ilya

相關問題