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); } }
if (g.isRelative()) { g = model.getGeometry(model.getParent(root)); x0 = g.getX(); y0 = g.getY(); double height = bounds.getHeight() + size.getHeight() - bounds.getY() + 2 * y0; g = (mxGeometry) g.clone(); if (g.getWidth() > width) { dx += (g.getWidth() - width) / 2; } else { g.setWidth(width); if (g.getHeight() > height) { if (horizontal) { dy += (g.getHeight() - height) / 2; g.setHeight(height);
clone.setX(getX()); clone.setY(getY()); clone.setWidth(getWidth()); clone.setHeight(getHeight()); clone.setRelative(isRelative()); List<mxPoint> pts = getPoints(); mxPoint tp = getTargetPoint(); clone.setTargetPoint((mxPoint) tp.clone()); mxPoint sp = getSourcePoint(); setSourcePoint((mxPoint) sp.clone()); mxPoint off = getOffset(); clone.setOffset((mxPoint) off.clone()); mxRectangle alt = getAlternateBounds(); setAlternateBounds((mxRectangle) alt.clone());
pgeo = new mxGeometry(0, 0, tmp.getWidth(), tmp.getHeight()); fillValue = (horizontal) ? pgeo.getHeight() : pgeo.getWidth(); geo = (mxGeometry) geo.clone(); if ((horizontal && last.getX() + last.getWidth() + geo.getWidth() + 2 || (!horizontal && last.getY() + last.getHeight() + geo.getHeight() + 2 * spacing > wrap)) .getHeight() : geo.getWidth()); geo.setX(last.getX() + last.getWidth() + spacing); geo.setY(last.getY() + last.getHeight() + spacing); geo.setX(x0); geo.setY(y0); geo.setY(y0); geo.setX(x0);
&& (geo.getX() != tmp.getX() || geo.getY() != tmp.getY() || geo.getWidth() != tmp.getWidth() || geo .getHeight() != tmp.getHeight())) geo = (mxGeometry) geo.clone(); if (geo.isRelative()) mxPoint offset = geo.getOffset(); geo.setX(tmp.getX()); geo.setY(tmp.getY()); geo.setWidth(tmp.getWidth()); geo.setHeight(tmp.getHeight()); if (!geo.isRelative() && model.isVertex(cells[i]) && !isAllowNegativeCoordinates()) geo.setX(Math.max(0, geo.getX())); geo.setY(Math.max(0, geo.getY()));
geometry = (mxGeometry) geometry.clone(); geometry.setX(geometry.getX() + bounds.getX() - border - left); geometry.setY(geometry.getY() + bounds.getY() - border - top); geometry.setWidth(bounds.getWidth() + 2 * border + left); geometry.setHeight(bounds.getHeight() + 2 * border + top); graph.getModel().setGeometry(group, geometry); graph.moveCells(children, border + left - bounds.getX(),
public class Parallelogram extends mxBasicShape { public Shape createShape(mxGraphics2DCanvas canvas, mxCellState state){ mxCell cell = (mxCell)state.getCell(); Polygon polygon = new Polygon(); if(cell != null && cell.getGeometry() != null) { mxGeometry g = cell.getGeometry(); int dx = (int) (cell.getGeometry().getHeight()/4.0); polygon.addPoint((int)(g.getX()+dx), (int)g.getY()); polygon.addPoint((int)(g.getX()+g.getWidth()+dx), (int)g.getY()); polygon.addPoint((int)(g.getX()+g.getWidth()-dx), (int)(g.getY()+g.getHeight())); polygon.addPoint((int)((int)g.getX()-dx), (int)(g.getY()+g.getHeight())); } return polygon; }
geo = (mxGeometry) geo.clone(); geo.translate(dx, dy); if (!geo.isRelative() && model.isVertex(cell) && !isAllowNegativeCoordinates()) geo.setX(Math.max(0, geo.getX())); geo.setY(Math.max(0, geo.getY())); if (geo.isRelative() && !model.isEdge(cell)) if (geo.getOffset() == null) geo.setOffset(new mxPoint(dx, dy)); mxPoint offset = geo.getOffset();
if (!geo.isRelative() && (geo.getX() < area.getX() || geo.getY() < area.getY() || area.getWidth() < geo.getX() + geo.getWidth() || area.getHeight() < geo .getY() + geo.getHeight())) geo.setX(Math.min(geo.getX(), area.getX() + area.getWidth() - (1 - overlap) * geo.getWidth())); geo.setY(Math.min(geo.getY(), area.getY() + area.getHeight() - (1 - overlap) * geo.getHeight())); geo.setX(Math.max(geo.getX(), area.getX() - geo.getWidth() geo.setY(Math.max(geo.getY(), area.getY() - geo.getHeight()
/** * Hook method that creates the new edge for insertEdge. This * implementation does not set the source and target of the edge, these * are set when the edge is added to the model. * * @param parent Cell that specifies the parent of the new edge. * @param id Optional string that defines the Id of the new edge. * @param value Object to be used as the user object. * @param source Cell that defines the source of the edge. * @param target Cell that defines the target of the edge. * @param style Optional string that defines the cell style. * @return Returns the new edge to be inserted. */ public Object createEdge(Object parent, String id, Object value, Object source, Object target, String style) { mxCell edge = new mxCell(value, new mxGeometry(), style); edge.setId(id); edge.setEdge(true); edge.getGeometry().setRelative(true); return edge; }
double pw = vparent.getGeometry().getWidth(); Dimension evtsize = new Dimension(BpmnStylesheetColor.DEFAULT_ACTIVITY_SIZES.get(VActivity.class.getSimpleName() + "_" + EventShape.class.getSimpleName() + "_BOUNDARY")); double vpos = vparent.getGeometry().getHeight() - 0.5 * evtsize.height - 1; double dist = evtsize.width * 1.15;// 1.5; geo.setWidth(evtsize.width); geo.setHeight(evtsize.height); geo.setX(dist * 0.2 + dist * count++); geo.setY(vpos); graph.getView().invalidate(vactivity);
mxCell cell = new mxCell(component, new mxGeometry(), "");
geometry = new mxGeometry(); geometry.setRelative(true); geometry = (mxGeometry) geometry.clone(); geometry.setPoints(points); model.setGeometry(edge, geometry);
public mxPoint getParentOffset(Object parent) { mxPoint result = new mxPoint(); if (parent != null && parent != this.parent) { mxIGraphModel model = graph.getModel(); if (model.isAncestor(this.parent, parent)) { mxGeometry parentGeo = model.getGeometry(parent); while (parent != this.parent) { result.setX(result.getX() + parentGeo.getX()); result.setY(result.getY() + parentGeo.getY()); parent = model.getParent(parent);; parentGeo = model.getGeometry(parent); } } } return result; }
/** * */ public Object createTargetVertex(MouseEvent e, Object source) { mxGraph graph = graphComponent.getGraph(); Object clone = graph.cloneCells(new Object[] { source })[0]; mxIGraphModel model = graph.getModel(); mxGeometry geo = model.getGeometry(clone); if (geo != null) { mxPoint point = graphComponent.getPointForEvent(e); geo.setX(graph.snap(point.getX() - geo.getWidth() / 2)); geo.setY(graph.snap(point.getY() - geo.getHeight() / 2)); } return clone; }
/** * Moves the label to the given position. */ protected void moveLabelTo(mxCellState edgeState, double x, double y) { mxGraph graph = graphComponent.getGraph(); mxIGraphModel model = graph.getModel(); mxGeometry geometry = model.getGeometry(state.getCell()); if (geometry != null) { geometry = (mxGeometry) geometry.clone(); // Resets the relative location stored inside the geometry mxPoint pt = graph.getView().getRelativePoint(edgeState, x, y); geometry.setX(pt.getX()); geometry.setY(pt.getY()); // Resets the offset inside the geometry to find the offset // from the resulting point double scale = graph.getView().getScale(); geometry.setOffset(new mxPoint(0, 0)); pt = graph.getView().getPoint(edgeState, geometry); geometry.setOffset(new mxPoint(Math.round((x - pt.getX()) / scale), Math.round((y - pt.getY()) / scale))); model.setGeometry(edgeState.getCell(), geometry); } }