gpt4 book ai didi

colors - JUNG:未选取的顶点标签颜色

转载 作者:行者123 更新时间:2023-12-04 05:36:36 24 4
gpt4 key购买 nike

我可以做已选 顶点标签红色使用 vertexLabelRenderer 声明如下:

DefaultVertexLabelRenderer vertexLabelRenderer=new DefaultVertexLabelRenderer(Color.RED);

如何更改 的颜色未挑选 顶点标签。构造函数(见下文)只允许定义 未挑选 顶点标签。方法 setForeground() 也不会影响字体颜色。

这是 JUNG 2.0.1 API 文档:
http://jung.sourceforge.net/site/apidocs/edu/uci/ics/jung/visualization/renderers/DefaultVertexLabelRenderer.html

最佳答案

对于任何仍在挠头的人,这里有两个简单的类,它们可以更改未选择的顶点/边缘标签颜色。

public class MyDefaultVertexLaberRenderer extends DefaultVertexLabelRenderer
{
protected Color unpickedVertexLabelColor = Color.BLACK;

public MyDefaultVertexLaberRenderer(Color unpickedVertexLabelColor, Color pickedVertexLabelColor)
{
super(pickedVertexLabelColor);
this.unpickedVertexLabelColor = unpickedVertexLabelColor;
}

public <V> Component getVertexLabelRendererComponent(JComponent vv, Object value, Font font, boolean isSelected, V vertex)
{
super.setForeground(unpickedVertexLabelColor);
if (isSelected) setForeground(pickedVertexLabelColor);
super.setBackground(vv.getBackground());
if (font != null)
{
setFont(font);
}
else
{
setFont(vv.getFont());
}
setIcon(null);
setBorder(noFocusBorder);
setValue(value);
return this;
}
}

public class MyDefaultEdgeLaberRenderer extends DefaultEdgeLabelRenderer
{
protected Color unpickedEdgeLabelColor = Color.BLACK;

public MyDefaultEdgeLaberRenderer(Color unpickedEdgeLabelColor, Color pickedEdgeLabelColor)
{
super(pickedEdgeLabelColor);
this.unpickedEdgeLabelColor = unpickedEdgeLabelColor;
}

public <E> Component getEdgeLabelRendererComponent(JComponent vv, Object value, Font font, boolean isSelected, E edge)
{
super.setForeground(unpickedEdgeLabelColor);
if (isSelected) setForeground(pickedEdgeLabelColor);
super.setBackground(vv.getBackground());

if (font != null)
{
setFont(font);
}
else
{
setFont(vv.getFont());
}
setIcon(null);
setBorder(noFocusBorder);
setValue(value);
return this;
}
}

关于colors - JUNG:未选取的顶点标签颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11845842/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com