/** * */ protected TreeNode createNode(Object cell) { TreeNode node = new TreeNode(cell); mxRectangle geo = getVertexBounds(cell); if (geo != null) { if (horizontal) { node.width = geo.getHeight(); node.height = geo.getWidth(); } else { node.width = geo.getWidth(); node.height = geo.getHeight(); } } return node; }
/** * */ protected mxRectangle apply(TreeNode node, mxRectangle bounds) { mxRectangle g = graph.getModel().getGeometry(node.cell); if (node.cell != null && g != null) { if (isVertexMovable(node.cell)) { g = setVertexLocation(node.cell, node.x, node.y); } if (bounds == null) { bounds = new mxRectangle(g.getX(), g.getY(), g.getWidth(), g.getHeight()); } else { bounds = new mxRectangle(Math.min(bounds.getX(), g.getX()), Math.min(bounds.getY(), g.getY()), Math.max(bounds.getX() + bounds.getWidth(), g.getX() + g.getWidth()), Math.max(bounds.getY() + bounds.getHeight(), g.getY() + g.getHeight())); } } return bounds; }
mxCellState gatewayState = graph.getView().getState(gatewayVertex); mxPoint northPoint = new mxPoint(gatewayState.getX() + (gatewayState.getWidth()) / 2, gatewayState.getY()); mxPoint southPoint = new mxPoint(gatewayState.getX() + (gatewayState.getWidth()) / 2, gatewayState.getY() + gatewayState.getHeight()); mxPoint eastPoint = new mxPoint(gatewayState.getX() + gatewayState.getWidth(), gatewayState.getY() + (gatewayState.getHeight()) / 2); mxPoint westPoint = new mxPoint(gatewayState.getX(), gatewayState.getY() + (gatewayState.getHeight()) / 2); startPoint.setX(closestPoint.getX()); startPoint.setY(closestPoint.getY()); nextPoint.setY(closestPoint.getY());
/** * Rotates the given point by the given cos and sin. */ public static mxPoint getRotatedPoint(mxPoint pt, double cos, double sin) { return getRotatedPoint(pt, cos, sin, new mxPoint()); }
/** * */ public mxRectangle getBounds() { if (!valid) { createCoreCurve(); } return new mxRectangle(minXBounds, minYBounds, maxXBounds - minXBounds, maxYBounds - minYBounds); }
protected void handleBoundaryEvents() { for (BoundaryEvent boundaryEvent : boundaryEvents) { mxGeometry geometry = new mxGeometry(0.8, 1.0, eventSize, eventSize); geometry.setOffset(new mxPoint(-(eventSize / 2), -(eventSize / 2))); geometry.setRelative(true); mxCell boundaryPort = new mxCell(null, geometry, "shape=ellipse;perimter=ellipsePerimeter"); boundaryPort.setId("boundary-event-" + boundaryEvent.getId()); boundaryPort.setVertex(true); Object portParent = null; if (boundaryEvent.getAttachedToRefId() != null) { portParent = generatedVertices.get(boundaryEvent.getAttachedToRefId()); } else if (boundaryEvent.getAttachedToRef() != null) { portParent = generatedVertices.get(boundaryEvent.getAttachedToRef().getId()); } else { throw new RuntimeException("Could not generate DI: boundaryEvent '" + boundaryEvent.getId() + "' has no attachedToRef"); } graph.addCell(boundaryPort, portParent); generatedVertices.put(boundaryEvent.getId(), boundaryPort); } }
double dy = 0; if (bounds.getX() < 0) { dx = Math.abs(x0 - bounds.getX()); if (bounds.getY() < 0) { dy = Math.abs(y0 - bounds.getY()); dx += size.getWidth(); dy += size.getHeight(); double width = bounds.getWidth() + size.getWidth() - bounds.getX() + 2 * x0; double height = bounds.getHeight() + size.getHeight() - bounds.getY() + 2 * y0;
protected List<mxPoint> optimizeEdgePoints(List<mxPoint> unoptimizedPointsList) { List<mxPoint> optimizedPointsList = new ArrayList<mxPoint>(); for (int i = 0; i < unoptimizedPointsList.size(); i++) { boolean keepPoint = true; mxPoint currentPoint = unoptimizedPointsList.get(i); // When three points are on the same x-axis with same y value, the // middle point can be removed if (i > 0 && i != unoptimizedPointsList.size() - 1) { mxPoint previousPoint = unoptimizedPointsList.get(i - 1); mxPoint nextPoint = unoptimizedPointsList.get(i + 1); if (currentPoint.getX() >= previousPoint.getX() && currentPoint.getX() <= nextPoint.getX() && currentPoint.getY() == previousPoint.getY() && currentPoint.getY() == nextPoint.getY()) { keepPoint = false; } else if (currentPoint.getY() >= previousPoint.getY() && currentPoint.getY() <= nextPoint.getY() && currentPoint.getX() == previousPoint.getX() && currentPoint.getX() == nextPoint.getX()) { keepPoint = false; } } if (keepPoint) { optimizedPointsList.add(currentPoint); } } return optimizedPointsList; }
protected void handleSubProcess(FlowElement flowElement) { BpmnAutoLayout bpmnAutoLayout = new BpmnAutoLayout(bpmnModel); bpmnAutoLayout.layout((SubProcess) flowElement); double subProcessWidth = bpmnAutoLayout.getGraph().getView().getGraphBounds().getWidth(); double subProcessHeight = bpmnAutoLayout.getGraph().getView().getGraphBounds().getHeight(); Object subProcessVertex = graph.insertVertex(cellParent, flowElement.getId(), "", 0, 0, subProcessWidth + 2 * subProcessMargin, subProcessHeight + 2 * subProcessMargin); generatedVertices.put(flowElement.getId(), subProcessVertex); }
/** * Rotates the given point by the given cos and sin. */ public static mxPoint getRotatedPoint(mxPoint pt, double cos, double sin) { return getRotatedPoint(pt, cos, sin, new mxPoint()); }
/** * */ public mxRectangle getBounds() { if (!valid) { createCoreCurve(); } return new mxRectangle(minXBounds, minYBounds, maxXBounds - minXBounds, maxYBounds - minYBounds); }
protected void createDiagramInterchangeInformation(BaseElement element, List<mxPoint> waypoints) { List<GraphicInfo> graphicInfoForWaypoints = new ArrayList<GraphicInfo>(); for (mxPoint waypoint : waypoints) { GraphicInfo graphicInfo = new GraphicInfo(); graphicInfo.setElement(element); graphicInfo.setX(waypoint.getX()); graphicInfo.setY(waypoint.getY()); graphicInfoForWaypoints.add(graphicInfo); } bpmnModel.addFlowGraphicInfoList(element.getId(), graphicInfoForWaypoints); }