Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top