我将 JMathPlot 与 Clojure 一起使用,如下代码所示:
(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)))
但是出现“No Matching method”的错误:
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 中,因为我在没有这种方法的情况下运行代码并且它工作正常!