如何使用JUNG着色&形状顶点和边
我在使用 JUNG 时遇到问题。我想绘制一个网络图,其中顶点将具有不同的形状和颜色,边缘将是不同颜色的虚线或实线。
由于我是Java新手,我无法理解jung的实际架构。当我使用 setVertexFillPaintTransformer 时,它用相同的颜色为所有顶点着色。顶点存储在整数数组中。过去一周我一直在敲头。 如果有人可以帮助我或有一些反问题,请问我
I am facing a problem in using JUNG. I want to draw a network diagram where the vertices will be having different shapes and colors and edges will be dashed or full line in different colors.
Since I am a newbie in Java, I am unable to understand the actual architecture of jung. When I use setVertexFillPaintTransformer, it colors all the vertices with the same color. The vertices are stored in an integer array. I am banging my head for past one week now.
Plz if someone can help me or has some counter questions, do ask me
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
setVertexFillPaintTransformer 方法接受一个将顶点转换为颜色的转换器。因此,要为不同的顶点设置不同的颜色,您需要让它检查顶点。 public Paint transform(Integer i) 方法中的参数 i 是顶点,因此您可以提供基于顶点的颜色(或i)。例如,如果我有一个顶点是整数的图表,我可以通过向setVertexFillPaintTransformer提供以下转换器来循环为顶点分配三种不同的颜色/强>:
The method setVertexFillPaintTransformer takes in a transformer that converts a vertice into a colour. So to have different colours for different vertices, you need to make it inspect the vertex. The parameter, i in the method public Paint transform(Integer i) is the vertex, so you can provide a colour that is based on the vertices (or i). For example, if I had a graph where the vertices were an Integer, I could cycle assign three different colours to the vertices by supplying the following transformer to setVertexFillPaintTransformer: