簡體   English   中英

自定義JGraphX

[英]Customizing JGraphX

我一直在使用JGraphX來顯示一些數據(簡單的離散圖),我想知道如何用JGraphX庫做以下事情:

  • 使所有邊不可移動但仍允許用戶在兩​​個頂點之間創建邊
  • 使所有頂點和邊不可編輯(它們無法編輯顯示在它們上面的內容)
  • 如何在任何給定時間獲得選定的頂點或邊?
  • 使所有頂點框對用戶不可調整
  • 如何修改每個頂點框的顏色?

謝謝,ExtremeCoder

這是一個例子:

mxGraph graph = new mxGraph()
{
  // Make all edges unmovable
  public boolean isCellMovable(Object cell)
  {
    return !getModel().isEdge(cell);
  }

  // Make all vertex boxes unresizable
  public boolean isCellResizable(Object cell)
  {
     return !getModel().isVertex(cell);
  }
};

// Make all vertices and edges uneditable
graph.setCellsEditable(false);

// Make all edges unbendable
graph.setCellsBendable(false);

// Get the selected vertex or edge
System.out.println(graph.getSelectionCell());

// To insert a vertex with a given color:
Object v1 = graph.insertVertex(parent, null, "Hello",
            20, 20, 80, 30, "fillColor=#FF0000;");

// To modify the color of a vertex:
graph.setCellStyles(mxConstants.STYLE_FILLCOLOR, "#00FF00", new Object[]{v1});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM