添加颜色到自定义边缘
我想向使用 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];
}
}
};
以下行返回一条错误消息,指出 edgesPaint
的类型应为 (string,Paint)
:
visualizationViewer.getRenderContext().setEdgeFillPaintTransformer(edgesPaint);
请帮我解决这个问题。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜测您的 VisualizationViewer 被声明为具有边缘类型“String”(即 VisualizationViewer)。但是如果没有更多上下文,很难确定。
请打印确切的错误消息和堆栈跟踪。显示 VisualizationViewer 的声明也将可能会有帮助。
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.