gpt4 book ai didi

java - Clojure JUNG setVertexFillPaintTransformer

转载 作者:行者123 更新时间:2023-12-02 13:19:06 26 4
gpt4 key购买 nike

我有一个用 JUNG 构建的图表。现在我想改变特定顶点的颜色。在 Java 中,这将是这样的:

    Transformer<V, Paint> vertexPaintRed = new Transformer<V, Paint>() {
public Paint transform(V input) {
return Color.red;
}
};

vv.getRenderContext().setVertexFillPaintTransformer(vertexColor);

当我将其翻译为 Clojure 时

(def vertex-paint (proxy [Transformer] [] (transform [i] java.awt.Color/GREEN)))
(.setVertexFillPaintTransformer vertex-paint)

抛出以下异常: Exception in thread "JavaFX Application Thread" java.lang.ClassCastException: Cannot cast tableau.tableau.proxy$java.lang.Object$Transformer$4341005c to com.google.common.base.Function

谢谢!

最佳答案

我明白了:我将 [com.google.guava/guava "21.0"] 添加到我的 Leiningen 依赖项中在特定命名空间中导入 com.google.common.base.Function并改变了

(def vertex-paint (proxy [Transformer] [] (transform [i] java.awt.Color/GREEN)))

(def vertex-paint (proxy [Function] [] (apply [i] java.awt.Color/GREEN)))

Function 和 apply 来自 com.google.commom.base.Function。

关于java - Clojure JUNG setVertexFillPaintTransformer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43643707/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com