JGraphX - change edge rooting style

2019-08-12 23:28发布

I am using eclipse as editor and jgraphx v1.1. I am trying to change the edge style to sidetoside. For some reason I keep getting errors in setStyle. I have also tried edgeStyle[mxConstants.STYLE_EDGE] = mxEdgeStyle.SideToSide but still nothing. Any ideas what I do wrong?

Thanks in advance

public Design() {


        super("Path Followed");

        AAA aaa = new AAA() ;

        mxGraph graph = new mxGraph();
        Object parent = graph.getDefaultParent();

        Object edgeStyle = graph.getStylesheet().getDefaultEdgeStyle() ;
            graph.setStyle(edgeStyle=mxEdgeStyle.SideToSide, parent) ;

        graph.getModel().beginUpdate();

        int k = 0 ;

        while(ontoq.path[k][0] != null) {

        try
        {


            Object v1 = graph.insertVertex(parent, null, aaa.path[k][0], 20, 20, 80, 30);
            Object v2 = graph.insertVertex(parent, null, aaa.path[k+1][0], 20, 20, 80, 30);
            graph.insertEdge(parent, null, " ", v1, v2);
            graph.insertEdge(parent, null, " ", v1, v1);

            k++ ;
        }
        finally
        {
            graph.getModel().endUpdate();
        }
    }



        mxGraphComponent graphComponent = new mxGraphComponent(graph);
        add(graphComponent);


    }


    public static void main(String[] args)
    {
        Design frame = new Design();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 320);
        frame.setVisible(true);
    }

}

1条回答
乱世女痞
2楼-- · 2019-08-13 00:07

Try this:

Map<String, Object> style = graph.getStylesheet().getDefaultEdgeStyle();
style.put(mxConstants.STYLE_EDGE, mxEdgeStyle.SideToSide);
查看更多
登录 后发表回答