문제

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<= 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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top