/** * Constructs a rectangle using the given parameters. * * @param x X-coordinate of the new rectangle. * @param y Y-coordinate of the new rectangle. * @param width Width of the new rectangle. * @param height Height of the new rectangle. */ public mxRectangle(double x, double y, double width, double height) { super(x, y); setWidth(width); setHeight(height); }
/** * Constructs a rectangle using the given parameters. * * @param x X-coordinate of the new rectangle. * @param y Y-coordinate of the new rectangle. * @param width Width of the new rectangle. * @param height Height of the new rectangle. */ public mxRectangle(double x, double y, double width, double height) { super(x, y); setWidth(width); setHeight(height); }
/** * Returns a new instance of the same rectangle. */ public Object clone() { mxRectangle clone = (mxRectangle) super.clone(); clone.setWidth(getWidth()); clone.setHeight(getHeight()); return clone; }
/** * Returns a new instance of the same rectangle. */ public Object clone() { mxRectangle clone = (mxRectangle) super.clone(); clone.setWidth(getWidth()); clone.setHeight(getHeight()); return clone; }
mxRectangle bounds = new mxRectangle(); bounds.setHeight(80); bounds.setWidth(80); mxGraphTransferable t = new mxGraphTransferable(new Object[] { cell }, bounds); arg0.startDrag(null, mxSwingConstants.EMPTY_IMAGE, new Point(), t, null);
/** * Returns the start size of the given swimlane, that is, the width or * height of the part that contains the title, depending on the * horizontal style. The return value is an <mxRectangle> with either * width or height set as appropriate. * * @param swimlane <mxCell> whose start size should be returned. * @return Returns the startsize for the given swimlane. */ public mxRectangle getStartSize(Object swimlane) { mxRectangle result = new mxRectangle(); mxCellState state = view.getState(swimlane); Map<String, Object> style = (state != null) ? state.getStyle() : getCellStyle(swimlane); if (style != null) { double size = mxUtils.getDouble(style, mxConstants.STYLE_STARTSIZE, mxConstants.DEFAULT_STARTSIZE); if (mxUtils.isTrue(style, mxConstants.STYLE_HORIZONTAL, true)) { result.setHeight(size); } else { result.setWidth(size); } } return result; }
/** * Returns the start size of the given swimlane, that is, the width or * height of the part that contains the title, depending on the * horizontal style. The return value is an <mxRectangle> with either * width or height set as appropriate. * * @param swimlane <mxCell> whose start size should be returned. * @return Returns the startsize for the given swimlane. */ public mxRectangle getStartSize(Object swimlane) { mxRectangle result = new mxRectangle(); mxCellState state = view.getState(swimlane); Map<String, Object> style = (state != null) ? state.getStyle() : getCellStyle(swimlane); if (style != null) { double size = mxUtils.getDouble(style, mxConstants.STYLE_STARTSIZE, mxConstants.DEFAULT_STARTSIZE); if (mxUtils.isTrue(style, mxConstants.STYLE_HORIZONTAL, true)) { result.setHeight(size); } else { result.setWidth(size); } } 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; }
/** * 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 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); }
/** * 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()); } }
tmp.setWidth(tmp.getWidth() + mxConstants.SHADOW_OFFSETX); tmp.setHeight(tmp.getHeight() + mxConstants.SHADOW_OFFSETX);
tmp.setWidth(tmp.getWidth() + mxConstants.SHADOW_OFFSETX); tmp.setHeight(tmp.getHeight() + mxConstants.SHADOW_OFFSETX);
/** * */ 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); }
/** * 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()); } }
state.getLabelBounds().setWidth(state.getWidth());
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(); } } };