/** * 创建连接线的相关属性 * * @return */ public Map createEdgeAttributes() { Map map = new Hashtable(); // Add a Line End Attribute GraphConstants.setLineEnd(map, GraphConstants.ARROW_TECHNICAL); // Add a label along edge attribute GraphConstants.setLabelAlongEdge(map, false); GraphConstants.setEndFill(map, true); GraphConstants.setLineWidth(map, 1.0f); GraphConstants.setLineColor(map, Color.black); GraphConstants.setEditable(map, false); return map; }
/** * 往流程图编辑器中增加一个元素 * * @param ele */ public DefaultGraphCell insertFlowElement(FlowElementObject ele) { if (this.graph == null) return null; if (ele.getId() == 0) { int id = (new IDService()).getProcessID(); ele.setId(id); } DefaultGraphCell cell = new DefaultGraphCell(); cell.setUserObject(ele); if (ele.getImageResource() != null) { GraphConstants.setIcon(cell.getAttributes(), UIUtil.loadImageIcon(ele.getImageResource())); } // 自动设置大小 // GraphConstants.setAutoSize(cell.getAttributes(), true); GraphConstants.setOpaque(cell.getAttributes(), true); // GraphConstants.setBackground(cell.getAttributes(), Color.YELLOW); GraphConstants.setLineColor(cell.getAttributes(), Color.RED); GraphConstants.setLineWidth(cell.getAttributes(), 1.5f); GraphConstants.setLineStyle(cell.getAttributes(), GraphConstants.STYLE_SPLINE); // GraphConstants.setSizeable(cell.getAttributes(),false); GraphConstants.setBorder( cell.getAttributes(), BorderFactory.createLineBorder(Color.BLACK)); // 外框颜色 // GraphConstants.setBounds(cell.getAttributes(), new // Rectangle2D.Double( // 10, 10, 80, 40)); GraphConstants.setBounds( cell.getAttributes(), new Rectangle2D.Double( ele.getLeft().doubleValue(), ele.getTop().doubleValue(), ele.getWidth().doubleValue(), ele.getHeight().doubleValue())); GraphConstants.setEditable(cell.getAttributes(), false); cell.addPort(); this.graph.getGraphLayoutCache().insert(cell); // 向图形编辑器写入处理后的图片. return cell; }