Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/349.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为自定义边添加颜色_Java_Graph_Jung - Fatal编程技术网

Java 为自定义边添加颜色

Java 为自定义边添加颜色,java,graph,jung,Java,Graph,Jung,我想给我用JUNG库创建的图的边缘添加颜色。我有自定义边类型中的边,在自定义边类型中,我将标签和权重设置为边 Transformer<CustomEdge, Paint> edgesPaint = new Transformer<CustomEdge, Paint>() { private final Color[] palette = {Color.GREEN, Color.YELLOW, Color.RED};

我想给我用JUNG库创建的图的边缘添加颜色。我有自定义边类型中的边,在自定义边类型中,我将标签和权重设置为边

Transformer<CustomEdge, Paint> edgesPaint = new Transformer<CustomEdge, Paint>() {

        private final Color[] palette = {Color.GREEN,
            Color.YELLOW, Color.RED};

        public Paint transform(CustomEdge edgeValue) {
            String stringvalue=edgeValue.toString();
            stringvalue=stringvalue.replaceAll("%","");
            int value=Integer.valueOf(stringvalue);
            if (value<= 10) {
                return palette[0];
            }
            if (value> 10 && value<=20 ) {
                return palette[1];
            }
            else {
                return palette[2];
            }
        }
    };  

请帮我解决这个问题。

我猜您的VisualizationViewer被声明为边缘类型为“字符串”(即VisualizationViewer)。但是如果没有更多上下文,很难确定


请打印准确的错误消息和堆栈跟踪。显示VisualizationViewer的声明可能也会有所帮助。

我想您的VisualizationViewer被声明为具有边缘类型“字符串”(即VisualizationViewer)。但如果没有更多上下文,则很难确定

请打印准确的错误消息和堆栈跟踪。显示VisualizationViewer的声明可能也会有所帮助

visualizationViewer.getRenderContext().setEdgeFillPaintTransformer(edgesPaint);