我用java做了一個(gè)圖表,我想自定義它的風(fēng)格。有什么簡(jiǎn)單的方法嗎?通過(guò)為它們添加樣式?以下是我使用的代碼的一部分:它從json文件中獲取一些數(shù)據(jù),這些數(shù)據(jù)被填充到一些哈希圖中。public mxGraphComponent createGlobalOverview(String Filename) { mxGraph graph = new mxGraph(); Object parent = graph.getDefaultParent(); graph.getModel().beginUpdate(); try { Object vRoot = graph.insertVertex(parent, null, Filename, 0, 0, 100, 50); int fmsCounter = 0; for (Object i : blueprint.keySet()) { getDependencies(i.toString()); if (blueprint.get(i).equals("FMS")) { if (dependsList.get(fmsCounter).equals("null")) { Object rootFMS = graph.insertVertex(parent, null, getTitle(i.toString()), 0, 0, 200, 50); graph.insertEdge(parent, null, "rootFMS", vRoot, rootFMS); System.out.println(blueprint.size()); createGraph(graph, parent, rootFMS, i, blueprint.size()); } } } graph.setCellsEditable(false); graph.setCellsMovable(false); graph.setCellsResizable(false); graph.setCellsSelectable(false); graph.setEnabled(false); mxIGraphLayout layout = new mxHierarchicalLayout(graph); layout.execute(parent); } finally { graph.getModel().endUpdate(); } graph.getView().setScale(0.9); mxGraphComponent graphComponent = new mxGraphComponent(graph); graphComponent.setConnectable(false); return graphComponent; }
1 回答

搖曳的薔薇
TA貢獻(xiàn)1793條經(jīng)驗(yàn) 獲得超6個(gè)贊
您可以使用 API 文檔mxStyleChange()
mxStyleChange(mxGraphModel graph, java.lang.Object cell, java.lang.String style)
要了解有關(guān)布局的更多信息,請(qǐng)?jiān)诖颂幉榭?/a>,這將幫助您定義樣式。這些形狀也可能很有用:
API文檔很廣泛,您應(yīng)該始終查看那里。希望這對(duì)您有所幫助
添加回答
舉報(bào)
0/150
提交
取消