开发者

Adding colours to custom edges

开发者 https://www.devze.com 2023-03-31 18:02 出处:网络
I want to add colours to the edges of the graph which I created using the JUNG library. I have edges which are in the type of custom edges where I set the labels and weights to the edges.

I want to add colours to the edges of the graph which I created using the JUNG library. I have edges which are in the type of custom edges where I set the labels and weights to the edges.

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<= 开发者_StackOverflow中文版10) {
                return palette[0];
            }
            if (value> 10 && value<=20 ) {
                return palette[1];
            }
            else {
                return palette[2];
            }
        }
    };  

The following line returns an error message saying that the type of the edgesPaint should be (string,Paint):

visualizationViewer.getRenderContext().setEdgeFillPaintTransformer(edgesPaint);

Please help me with this.


Offhand I'd guess that your VisualizationViewer was declared to have edge type "String" (i.e., VisualizationViewer. But without more context it's hard to be sure.

Please print the exact error message and stack trace. Showing the declaration of the VisualizationViewer would also probably be helpful.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号