/** * Returns the bounds to be used for the given group and children. This * implementation computes the bounding box of the geometries of all * vertices in the given children array. Edges are ignored. If the group * cell is a swimlane the title region is added to the bounds. */ public mxRectangle getBoundsForGroup(Object group, Object[] children, double border) { mxRectangle result = getBoundingBoxFromGeometry(children); if (result != null) { if (isSwimlane(group)) { mxRectangle size = getStartSize(group); result.setX(result.getX() - size.getWidth()); result.setY(result.getY() - size.getHeight()); result.setWidth(result.getWidth() + size.getWidth()); result.setHeight(result.getHeight() + size.getHeight()); } // Adds the border result.setX(result.getX() - border); result.setY(result.getY() - border); result.setWidth(result.getWidth() + 2 * border); result.setHeight(result.getHeight() + 2 * border); } return result; }
/** * Returns the bounds to be used for the given group and children. This * implementation computes the bounding box of the geometries of all * vertices in the given children array. Edges are ignored. If the group * cell is a swimlane the title region is added to the bounds. */ public mxRectangle getBoundsForGroup(Object group, Object[] children, double border) { mxRectangle result = getBoundingBoxFromGeometry(children); if (result != null) { if (isSwimlane(group)) { mxRectangle size = getStartSize(group); result.setX(result.getX() - size.getWidth()); result.setY(result.getY() - size.getHeight()); result.setWidth(result.getWidth() + size.getWidth()); result.setHeight(result.getHeight() + size.getHeight()); } // Adds the border result.setX(result.getX() - border); result.setY(result.getY() - border); result.setWidth(result.getWidth() + 2 * border); result.setHeight(result.getHeight() + 2 * border); } return result; }
/** * */ public mxGraphTransferable createGraphTransferable( mxGraphComponent graphComponent, Object[] cells, ImageIcon icon) { mxGraph graph = graphComponent.getGraph(); mxPoint tr = graph.getView().getTranslate(); double scale = graph.getView().getScale(); mxRectangle bounds = graph.getPaintBounds(cells); // Removes the scale and translation from the bounds bounds.setX(bounds.getX() / scale - tr.getX()); bounds.setY(bounds.getY() / scale - tr.getY()); bounds.setWidth(bounds.getWidth() / scale); bounds.setHeight(bounds.getHeight() / scale); return createGraphTransferable(graphComponent, cells, bounds, icon); }
/** * */ public void mouseReleased(MouseEvent e) { if (graphComponent.isEnabled() && isEnabled() && !e.isConsumed() && current != null) { mxGraph graph = graphComponent.getGraph(); double scale = graph.getView().getScale(); mxPoint tr = graph.getView().getTranslate(); current.setX(current.getX() / scale - tr.getX()); current.setY(current.getY() / scale - tr.getY()); current.setWidth(current.getWidth() / scale); current.setHeight(current.getHeight() / scale); Object cell = insertCell(current); eventSource.fireEvent(new mxEventObject(mxEvent.INSERT, "cell", cell)); e.consume(); } reset(); }
/** * Scrolls the graph so that it shows the given cell. * * @param cell */ public void scrollCellToVisible(Object cell, boolean center) { mxCellState state = graph.getView().getState(cell); if (state != null) { mxRectangle bounds = state; if (center) { bounds = (mxRectangle) bounds.clone(); bounds.setX(bounds.getCenterX() - getWidth() / 2); bounds.setWidth(getWidth()); bounds.setY(bounds.getCenterY() - getHeight() / 2); bounds.setHeight(getHeight()); } getGraphControl().scrollRectToVisible(bounds.getRectangle()); } }
geo.getAlternateBounds().setY(geo.getY());
/** * */ public void mouseReleased(MouseEvent e) { if (graphComponent.isEnabled() && isEnabled() && !e.isConsumed() && current != null) { mxGraph graph = graphComponent.getGraph(); double scale = graph.getView().getScale(); mxPoint tr = graph.getView().getTranslate(); current.setX(current.getX() / scale - tr.getX()); current.setY(current.getY() / scale - tr.getY()); current.setWidth(current.getWidth() / scale); current.setHeight(current.getHeight() / scale); Object cell = insertCell(current); eventSource.fireEvent(new mxEventObject(mxEvent.INSERT, "cell", cell)); e.consume(); } reset(); }
/** * */ public mxGraphTransferable createGraphTransferable( mxGraphComponent graphComponent, Object[] cells, ImageIcon icon) { mxGraph graph = graphComponent.getGraph(); mxPoint tr = graph.getView().getTranslate(); double scale = graph.getView().getScale(); mxRectangle bounds = graph.getPaintBounds(cells); // Removes the scale and translation from the bounds bounds.setX(bounds.getX() / scale - tr.getX()); bounds.setY(bounds.getY() / scale - tr.getY()); bounds.setWidth(bounds.getWidth() / scale); bounds.setHeight(bounds.getHeight() / scale); return createGraphTransferable(graphComponent, cells, bounds, icon); }
geo.getAlternateBounds().setY(geo.getY());
/** * Scrolls the graph so that it shows the given cell. * * @param cell */ public void scrollCellToVisible(Object cell, boolean center) { mxCellState state = graph.getView().getState(cell); if (state != null) { mxRectangle bounds = state; if (center) { bounds = (mxRectangle) bounds.clone(); bounds.setX(bounds.getCenterX() - getWidth() / 2); bounds.setWidth(getWidth()); bounds.setY(bounds.getCenterY() - getHeight() / 2); bounds.setHeight(getHeight()); } getGraphControl().scrollRectToVisible(bounds.getRectangle()); } }
public void invoke(Object source, mxEventObject evt) { updateScaleAndTranslate(); mxRectangle dirty = (mxRectangle) evt.getProperty("region"); if (dirty != null) { repaintClip = new mxRectangle(dirty); } else { repaintBuffer = true; } if (dirty != null) { updateFinder(true); dirty.grow(1 / scale); dirty.setX(dirty.getX() * scale + translate.x); dirty.setY(dirty.getY() * scale + translate.y); dirty.setWidth(dirty.getWidth() * scale); dirty.setHeight(dirty.getHeight() * scale); repaint(dirty.getRectangle()); } else { updateFinder(false); repaint(); } } };
public void invoke(Object source, mxEventObject evt) { updateScaleAndTranslate(); mxRectangle dirty = (mxRectangle) evt.getProperty("region"); if (dirty != null) { repaintClip = new mxRectangle(dirty); } else { repaintBuffer = true; } if (dirty != null) { updateFinder(true); dirty.grow(1 / scale); dirty.setX(dirty.getX() * scale + translate.x); dirty.setY(dirty.getY() * scale + translate.y); dirty.setWidth(dirty.getWidth() * scale); dirty.setHeight(dirty.getHeight() * scale); repaint(dirty.getRectangle()); } else { updateFinder(false); repaint(); } } };
repaintClip.setY(repaintClip.getY() * scale + translate.y); repaintClip.setWidth(repaintClip.getWidth() * scale); repaintClip.setHeight(repaintClip.getHeight() * scale);
repaintClip.setY(repaintClip.getY() * scale + translate.y); repaintClip.setWidth(repaintClip.getWidth() * scale); repaintClip.setHeight(repaintClip.getHeight() * scale);
dirty.setY(dirty.getY() + dy);
dirty.setY(dirty.getY() + dy);
geo.setY(geo.getY() + parentOffset.getY());
geo.setY(geo.getY() + parentOffset.getY());