mxGraph 设置默认Edge样式

来源:互联网 发布:cf淘宝开保箱 编辑:程序博客网 时间:2024/05/29 11:33

在mxgraph Swing 操作中,单击某个cell连接其他cell的节点线是,默认样式是直线连接,没有节点弯曲的设置。可以修改mxgraph的jar包中的mxStylesheet.java 对应的createDefaultEdgeStyle方法,在其中添加:style.put("edgeStyle", mxEdgeStyle.ElbowConnector); 即可。

/** * Creates and returns the default edge style. *  * @return Returns the default edge style. */protected Map<String, Object> createDefaultEdgeStyle(){Map<String, Object> style = new Hashtable<String, Object>();style.put(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_CONNECTOR);style.put(mxConstants.STYLE_ENDARROW, mxConstants.ARROW_CLASSIC);style.put(mxConstants.STYLE_VERTICAL_ALIGN, mxConstants.ALIGN_MIDDLE);style.put(mxConstants.STYLE_ALIGN, mxConstants.ALIGN_CENTER);style.put(mxConstants.STYLE_STROKECOLOR, "#6482B9");style.put(mxConstants.STYLE_FONTCOLOR, "#446299");style.put("edgeStyle", mxEdgeStyle.ElbowConnector);   //新添加的样式return style;}

这个文件里面也可以修改 Cell样式,方法是:

/** * Creates and returns the default vertex style. *  * @return Returns the default vertex style. */protected Map<String, Object> createDefaultVertexStyle(){Map<String, Object> style = new Hashtable<String, Object>();style.put(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_RECTANGLE);style.put(mxConstants.STYLE_PERIMETER, mxPerimeter.RectanglePerimeter);style.put(mxConstants.STYLE_VERTICAL_ALIGN, mxConstants.ALIGN_MIDDLE);style.put(mxConstants.STYLE_ALIGN, mxConstants.ALIGN_CENTER);style.put(mxConstants.STYLE_FILLCOLOR, "#C3D9FF");style.put(mxConstants.STYLE_STROKECOLOR, "#6482B9");style.put(mxConstants.STYLE_FONTCOLOR, "#774400");return style;}

===================华丽丽的分割线==================

2014-04-20

0 0
原创粉丝点击