1

でカスタムシェイプを描画しようとしていjgraphxます。私はほとんど持っていませmxPointscustomcell

長方形や楕円を描くだけでなく、ランダムなn点の多角形も描きたいと思っています。

これは可能ですか?

ここに私が使用するコードがありますが、動作しません。ラインでクラッシュする

currentCustomCell.getGeometry().getPoints().add(point1);

このエラーでException in thread AWT-EventQueue-0 java.lang.NullPointerException

すべての助けに感謝します。私はJavaとjgraphxの初心者です

mxGraph graph = new mxGraph();
Object parent = graph.getDefaultParent();
currentCustomCell = new mxCell();
currentCustomCell.setVertex(true);
currentCustomCell.setConnectable(false);
try {
    mxPoint point1 = new mxPoint(20.0,20.0);
    currentCustomCell.getGeometry().getPoints().add(point1);
    mxPoint point2 = new mxPoint(20.0,40.0);
    currentCustomCell.getGeometry().getPoints().add(point2);
    mxPoint point3 = new mxPoint(40.0,40.0);
    currentCustomCell.getGeometry().getPoints().add(point3);
    mxPoint point4 = new mxPoint(40.0,20.0);
    currentCustomCell.getGeometry().getPoints().add(point4);
    mxPoint point5 = new mxPoint(50.0,30.0);
    currentCustomCell.getGeometry().getPoints().add(point5);
    graph.addCell(currentCustomCell, parent);
}finally {
    graph.getModel().endUpdate();
}
mxGraphComponent graphComponent = new mxGraphComponent(graph);
graphComponent.refresh();
4

0 に答える 0