protected void generateActivityDiagramInterchangeElements() { for (String flowElementId : generatedVertices.keySet()) { Object vertex = generatedVertices.get(flowElementId); mxCellState cellState = graph.getView().getState(vertex); GraphicInfo subProcessGraphicInfo = createDiagramInterchangeInformation(handledFlowElements.get(flowElementId), (int) cellState.getX(), (int) cellState.getY(), (int) cellState.getWidth(), (int) cellState.getHeight()); // The DI for the elements of a subprocess are generated without // knowledge of the rest of the graph // So we must translate all it's elements with the x and y of the // subprocess itself if (handledFlowElements.get(flowElementId) instanceof SubProcess) { // Always expanded when auto layouting subProcessGraphicInfo.setExpanded(true); } } }
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);
protected void generateActivityDiagramInterchangeElements() { for (String flowElementId : generatedVertices.keySet()) { Object vertex = generatedVertices.get(flowElementId); mxCellState cellState = graph.getView().getState(vertex); GraphicInfo subProcessGraphicInfo = createDiagramInterchangeInformation(handledFlowElements.get(flowElementId), (int) cellState.getX(), (int) cellState.getY(), (int) cellState.getWidth(), (int) cellState.getHeight()); // The DI for the elements of a subprocess are generated without knowledge of the rest of the graph // So we must translate all it's elements with the x and y of the subprocess itself if (handledFlowElements.get(flowElementId) instanceof SubProcess) { // Always expanded when auto layouting subProcessGraphicInfo.setExpanded(true); } } }
/** * */ @Override public void paintShape(mxGraphics2DCanvas canvas, mxCellState state) { double x = state.getX(); double y = state.getY(); double w = state.getWidth(); double h = state.getHeight(); canvas.getGraphics().translate(x, y); double widthRatio = 1; double heightRatio = 1; if (boundingBox != null) { widthRatio = w / boundingBox.getWidth(); heightRatio = h / boundingBox.getHeight(); } this.paintNode(canvas, state, rootShape, widthRatio, heightRatio); canvas.getGraphics().translate(-x, -y); }
/** * */ @Override public void paintShape(mxGraphics2DCanvas canvas, mxCellState state) { double x = state.getX(); double y = state.getY(); double w = state.getWidth(); double h = state.getHeight(); canvas.getGraphics().translate(x, y); double widthRatio = 1; double heightRatio = 1; if (boundingBox != null) { widthRatio = w / boundingBox.getWidth(); heightRatio = h / boundingBox.getHeight(); } this.paintNode(canvas, state, rootShape, widthRatio, heightRatio); canvas.getGraphics().translate(-x, -y); }
/** * Returns the folding icon bounds. */ public Rectangle getFoldingIconBounds(mxCellState state, ImageIcon icon) { if (state.getCell() instanceof VSubProcess) { double scale = getGraph().getView().getScale(); int w = (int) Math.max(8, icon.getIconWidth() * scale); int h = (int) Math.max(8, icon.getIconHeight() * scale); int x = (int) Math.round(state.getX() + state.getWidth() * 0.5 - w * 0.5); int y = (int) Math.round(state.getY() + state.getHeight() - h * 1.25); return new Rectangle(x, y, w, h); } return super.getFoldingIconBounds(state, icon); }
/** * */ public void updateComponent(mxCellState state, Component c) { int x = (int) state.getX(); int y = (int) state.getY(); int width = (int) state.getWidth(); int height = (int) state.getHeight(); Dimension s = c.getMinimumSize(); if (s.width > width) { x -= (s.width - width) / 2; width = s.width; } if (s.height > height) { y -= (s.height - height) / 2; height = s.height; } c.setBounds(x, y, width, height); }
/** * */ public void updateComponent(mxCellState state, Component c) { int x = (int) state.getX(); int y = (int) state.getY(); int width = (int) state.getWidth(); int height = (int) state.getHeight(); Dimension s = c.getMinimumSize(); if (s.width > width) { x -= (s.width - width) / 2; width = s.width; } if (s.height > height) { y -= (s.height - height) / 2; height = s.height; } c.setBounds(x, y, width, height); }
/** * */ protected mxRectangle getGradientBounds(mxGraphics2DCanvas canvas, mxCellState state) { double start = getTitleSize(canvas, state); if (mxUtils .isTrue(state.getStyle(), mxConstants.STYLE_HORIZONTAL, true)) { start = Math.min(start, state.getHeight()); return new mxRectangle(state.getX(), state.getY(), state.getWidth(), start); } else { start = Math.min(start, state.getWidth()); return new mxRectangle(state.getX(), state.getY(), start, state.getHeight()); } }
/** * */ protected mxRectangle getGradientBounds(mxGraphics2DCanvas canvas, mxCellState state) { double start = getTitleSize(canvas, state); if (mxUtils .isTrue(state.getStyle(), mxConstants.STYLE_HORIZONTAL, true)) { start = Math.min(start, state.getHeight()); return new mxRectangle(state.getX(), state.getY(), state.getWidth(), start); } else { start = Math.min(start, state.getWidth()); return new mxRectangle(state.getX(), state.getY(), start, state.getHeight()); } }
/** * */ public Rectangle getFoldingIconBounds(mxCellState state, ImageIcon icon) { mxIGraphModel model = graph.getModel(); boolean isEdge = model.isEdge(state.getCell()); double scale = getGraph().getView().getScale(); int x = (int) Math.round(state.getX() + 4 * scale); int y = (int) Math.round(state.getY() + 4 * scale); int w = (int) Math.max(8, icon.getIconWidth() * scale); int h = (int) Math.max(8, icon.getIconHeight() * scale); if (isEdge) { mxPoint pt = graph.getView().getPoint(state); x = (int) pt.getX() - w / 2; y = (int) pt.getY() - h / 2; } return new Rectangle(x, y, w, h); }
/** * */ public Rectangle getFoldingIconBounds(mxCellState state, ImageIcon icon) { mxIGraphModel model = graph.getModel(); boolean isEdge = model.isEdge(state.getCell()); double scale = getGraph().getView().getScale(); int x = (int) Math.round(state.getX() + 4 * scale); int y = (int) Math.round(state.getY() + 4 * scale); int w = (int) Math.max(8, icon.getIconWidth() * scale); int h = (int) Math.max(8, icon.getIconHeight() * scale); if (isEdge) { mxPoint pt = graph.getView().getPoint(state); x = (int) pt.getX() - w / 2; y = (int) pt.getY() - h / 2; } return new Rectangle(x, y, w, h); }
/** * */ public mxPoint[] createPoints(mxGraphics2DCanvas canvas, mxCellState state) { String direction = mxUtils.getString(state.getStyle(), mxConstants.STYLE_DIRECTION, mxConstants.DIRECTION_EAST); mxPoint p0, pe; if (direction.equals(mxConstants.DIRECTION_EAST) || direction.equals(mxConstants.DIRECTION_WEST)) { double mid = state.getCenterY(); p0 = new mxPoint(state.getX(), mid); pe = new mxPoint(state.getX() + state.getWidth(), mid); } else { double mid = state.getCenterX(); p0 = new mxPoint(mid, state.getY()); pe = new mxPoint(mid, state.getY() + state.getHeight()); } mxPoint[] points = new mxPoint[2]; points[0] = p0; points[1] = pe; return points; }
/** * Sets the connection constraint that describes the given connection point. * If no constraint is given then nothing is changed. To remove an existing * constraint from the given edge, use an empty constraint instead. * * @param vertex Cell state that represents the vertex. * @param constraint Connection constraint that represents the connection point * constraint as returned by getConnectionConstraint. */ public mxPoint getConnectionPoint(mxCellState vertex, mxConnectionConstraint constraint) { mxPoint point = null; if (vertex != null && constraint.point != null) { point = new mxPoint(vertex.getX() + constraint.getPoint().getX() * vertex.getWidth(), vertex.getY() + constraint.getPoint().getY() * vertex.getHeight()); } if (point != null && constraint.perimeter) { point = view.getPerimeterPoint(vertex, point, false); } return point; }
/** * Returns the vector between the current rendered state and the future * location of the state after the display will be updated. */ protected mxPoint getDelta(mxCellState state) { mxGraph graph = graphComponent.getGraph(); mxPoint origin = getOriginForCell(state.getCell()); mxPoint translate = graph.getView().getTranslate(); double scale = graph.getView().getScale(); mxPoint current = new mxPoint(state.getX() / scale - translate.getX(), state.getY() / scale - translate.getY()); return new mxPoint((origin.getX() - current.getX()) * scale, (origin .getY() - current.getY()) * scale); }
/** * Returns the vector between the current rendered state and the future * location of the state after the display will be updated. */ protected mxPoint getDelta(mxCellState state) { mxGraph graph = graphComponent.getGraph(); mxPoint origin = getOriginForCell(state.getCell()); mxPoint translate = graph.getView().getTranslate(); double scale = graph.getView().getScale(); mxPoint current = new mxPoint(state.getX() / scale - translate.getX(), state.getY() / scale - translate.getY()); return new mxPoint((origin.getX() - current.getX()) * scale, (origin .getY() - current.getY()) * scale); }
/** * */ public void restoreState(mxCellState state, mxCellState from) { state.setLabelBounds(from.getLabelBounds()); state.setAbsolutePoints(from.getAbsolutePoints()); state.setOrigin(from.getOrigin()); state.setAbsoluteOffset(from.getAbsoluteOffset()); state.setBoundingBox(from.getBoundingBox()); state.setTerminalDistance(from.getTerminalDistance()); state.setSegments(from.getSegments()); state.setLength(from.getLength()); state.setX(from.getX()); state.setY(from.getY()); state.setWidth(from.getWidth()); state.setHeight(from.getHeight()); }
/** * */ public void restoreState(mxCellState state, mxCellState from) { state.setLabelBounds(from.getLabelBounds()); state.setAbsolutePoints(from.getAbsolutePoints()); state.setOrigin(from.getOrigin()); state.setAbsoluteOffset(from.getAbsoluteOffset()); state.setBoundingBox(from.getBoundingBox()); state.setTerminalDistance(from.getTerminalDistance()); state.setSegments(from.getSegments()); state.setLength(from.getLength()); state.setX(from.getX()); state.setY(from.getY()); state.setWidth(from.getWidth()); state.setHeight(from.getHeight()); }