JGraphX - 改变边缘生根风格

时间:2013-09-02 14:51:10

标签: java eclipse user-interface edge jgraphx

我使用eclipse作为编辑器和jgraphx v1.1。我正在尝试将边缘样式更改为sidetoside。出于某种原因,我一直在setStyle中遇到错误。我也试过edgeStyle [mxConstants.STYLE_EDGE] = mxEdgeStyle.SideToSide但仍然没有。 我有什么想法吗?

提前致谢

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 个答案:

答案 0 :(得分:2)

试试这个:

Map<String, Object> style = graph.getStylesheet().getDefaultEdgeStyle();
style.put(mxConstants.STYLE_EDGE, mxEdgeStyle.SideToSide);