JUNG 将节点的颜色从绿色变为白色

问题描述 投票:0回答:0

此刻,我正在尝试将集群节点的颜色从深绿色更改为浅绿色或白色。但我没有办法,或者我正在寻找一种方法。

` public WebSearchInterface() { setLayout(new BorderLayout());

  graph = GraphHandler.createForestTestempty();

 
    vv =
            VisualizationViewer.builder(graph)
                    .layoutAlgorithm(new StaticLayoutAlgorithm<>())
                    .layoutSize(layoutSize)
                    .viewSize(viewSize)
                    .graphMouse(graphMouse)
                    .build();

    vv.addPreRenderPaintable(
            new LayoutPaintable.LayoutBounds(
                    vv.getVisualizationModel(), vv.getRenderContext().getMultiLayerTransformer()));     
    
    
    Box controls = Box.createHorizontalBox();
    controls.add(
            GraphControlHelpers.getCenteredContainer(
                    "Layout Controls", GraphLayoutSelector.builder(vv).initialSelection(1).build()));
    //controls.add(GraphControlHelpers.getCenteredContainer("Search",GraphLayoutSelector.InputtextF),BorderLayout.CENTER);
    controls.add(GraphControlHelpers.getCenteredContainer("Zoom",GraphControlHelpers.getZoom(vv)));
    controls.add(GraphControlHelpers.getCenteredContainer("Node properties",GraphLayoutSelector.GraphPropList));

    add(controls, BorderLayout.SOUTH);

    panel = new VisualizationScrollPane(vv);

    add(panel);
    

}`

我的集群

enter image description here

我知道我可以使用以下功能。我不知道如何将颜色从深绿色调到非常浅的绿色或白色。也许有人有想法。我还创建了这个绿色的列表。但是我正在寻找一种方法来将颜色从深绿色更改为非常浅的绿色或白色。

`

public static Color[] clusterColor = {new Color(0, 102, 0), new Color(0, 153, 0), new Color(0, 204, 0), new Color(0, 255, 51), new颜色(102, 255, 102)};

   vv.getRenderContext().setVertexFillPaintFunction(v->{ // set vertex color

      else if(v.equals(Center)&&(!Center.isEmpty()))
      {
        return Color.yellow;
      }
      else if((!v.equals(Center)) // first cluster  v is an string 
      {
          cnt_Vertex = cnt_Vertex +1;
          System.out.println(cnt_Vertex);
          System.out.println(v);
              return clusterColor[2];
      }
      return Color.blue;
    });

`

java graph colors graphics jung
© www.soinside.com 2019 - 2024. All rights reserved.