Hi,
would be glad if someone could give a hand with the example from
https://github.com/yannrichet/jmathplot.
jmathplot.jar is in https://github.com/yannrichet/jmathplot/tree/master/dist
Got lost in the calling syntax.
Thx
1 Like
The Java library is not in a great state. First you have to acquire the main jar and it’s two dependencies. You also need to download the icons and put them in a folder “org\math\plot\icons”.
julia> cd("Documents\\Julia\\jmathplot")
julia> readdir()
4-element Vector{String}:
"jmatharray.jar"
"jmathio.jar"
"jmathplot.jar"
"org"
julia> using JavaCall
julia> JavaCall.addClassPath("./*.jar")
julia> JavaCall.addClassPath(pwd())
julia> JavaCall.init()
julia> Plot2DPanel = @jimport org.math.plot.Plot2DPanel
JavaObject{Symbol("org.math.plot.Plot2DPanel")}
julia> plot = Plot2DPanel()
JavaObject{Symbol("org.math.plot.Plot2DPanel")}(JavaLocalRef(Ptr{Nothing} @0x0000000060bcfd60))
julia> x = Float64[1, 2, 3]
3-element Vector{Float64}:
1.0
2.0
3.0
julia> y = Float64[4, 5, 6]
3-element Vector{Float64}:
4.0
5.0
6.0
julia> jcall(plot, "addLinePlot", jint, (JString, Vector{Float64}, Vector{Float64}), "my plot", x, y)
0
julia> JFrame = @jimport javax.swing.JFrame
JavaObject{Symbol("javax.swing.JFrame")}
julia> frame = JFrame((JString,), "a plot panel")
JavaObject{Symbol("javax.swing.JFrame")}(JavaLocalRef(Ptr{Nothing} @0x0000000060bcfda0))
julia> jcall(frame, "setContentPane", jvoid, (@jimport(java.awt.Container),), plot)
julia> listmethods(frame, "pack")
1-element Vector{JMethod}:
void pack()
julia> jcall(frame, "pack", jvoid)
julia> jcall(frame, "setVisible", jvoid, (jboolean,), true)
I got a small Window from this that I then I had to manually expand.
1 Like
Icons: https://github.com/yannrichet/jmathplot/tree/master/src/main/resources/org/math/plot/icons
jmathplot.jar: https://github.com/yannrichet/jmathplot/blob/master/dist/jmathplot.jar
jmathio.jar: https://github.com/yannrichet/jmathio/blob/master/dist/jmathio.jar
jmatharray.jar: https://github.com/yannrichet/jmatharray/blob/master/dist/jmatharray.jar
Put the icons in “org/math/plot/icons” and add the root directory to the classpath as I demonstrated above.
1 Like
Awesome, thank you!