您的位置:首页 > Web前端 > CSS

mxGraph 设置默认Edge样式

2014-04-20 17:22 253 查看
在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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  swing mxgraph edge