我使用JMathPlot使用Clojure,如下面的代碼:使用JMathPlot使用Clojure,.addLinePlot方法給錯誤
(ns plot.core
(:gen-class)
(:import [org.math.plot Plot2DPanel])
(:import [javax.swing JFrame]))
(let [plot (new Plot2DPanel)
frame (JFrame. "plot")]
(doto plot
(.addLegend "SOUTH")
(.addLinePlot [1 2 3] [22 33 44]))
(doto frame
(.setContentPane plot)
(.setSize 300 300)
(.setVisible true)))
但「無匹配方法」的錯誤:
java.lang.IllegalArgumentException: No matching method found: addLinePlot for class org.math.plot.Plot2DPanel
Reflector.java:80 clojure.lang.Reflector.invokeMatchingMethod
Reflector.java:28 clojure.lang.Reflector.invokeInstanceMethod
jmp.clj:8 plot.core/eval56
Compiler.java:6511 clojure.lang.Compiler.eval
Compiler.java:6952 clojure.lang.Compiler.load
NO_SOURCE_FILE:1 user/eval48
Compiler.java:6511 clojure.lang.Compiler.eval
Compiler.java:6477 clojure.lang.Compiler.eval
core.clj:2797 clojure.core/eval
main.clj:245 clojure.main/repl[fn]
main.clj:266 clojure.main/repl[fn]
main.clj:266 clojure.main/repl
RestFn.java:1096 clojure.lang.RestFn.invoke
interruptible_eval.clj:56 clojure.tools.nrepl.middleware.interruptible-eval/evaluate[fn]
AFn.java:159 clojure.lang.AFn.applyToHelper
AFn.java:151 clojure.lang.AFn.applyTo
core.clj:601 clojure.core/apply
core.clj:1771 clojure.core/with-bindings*
RestFn.java:425 clojure.lang.RestFn.invoke
interruptible_eval.clj:41 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj:171 clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval[fn]
core.clj:2278 clojure.core/comp[fn]
interruptible_eval.clj:138 clojure.tools.nrepl.middleware.interruptible-eval/run-next[fn]
AFn.java:24 clojure.lang.AFn.run
(Unknown Source) java.util.concurrent.ThreadPoolExecutor.runWorker
(Unknown Source) java.util.concurrent.ThreadPoolExecutor$Worker.run
(Unknown Source) java.lang.Thread.run
代碼基於來自JMathPlot網頁的示例,所以我不確定該方法不存在? 問題是在addLinePlot中,因爲我運行的代碼沒有這個方法,它的工作正常!
我對Jython使用了相同的代碼,它的工作完美。與Clojure我可以在JFrame中顯示來自Plot2DPanel的新實例,但不能添加.addLinePlot! – Samir 2013-03-17 21:21:36