/** * 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 boolean hitFoldingIcon(Object cell, int x, int y) { if (cell != null) { mxIGraphModel model = graph.getModel(); // Draws the collapse/expand icons boolean isEdge = model.isEdge(cell); if (foldingEnabled && (model.isVertex(cell) || isEdge)) { mxCellState state = graph.getView().getState(cell); if (state != null) { ImageIcon icon = getFoldingIcon(state); if (icon != null) { return getFoldingIconBounds(state, icon).contains(x, y); } } } } return false; }
/** * */ public boolean hitFoldingIcon(Object cell, int x, int y) { if (cell != null) { mxIGraphModel model = graph.getModel(); // Draws the collapse/expand icons boolean isEdge = model.isEdge(cell); if (foldingEnabled && (model.isVertex(cell) || isEdge)) { mxCellState state = graph.getView().getState(cell); if (state != null) { ImageIcon icon = getFoldingIcon(state); if (icon != null) { return getFoldingIconBounds(state, icon).contains(x, y); } } } } return false; }
/** * */ protected void cellDrawn(mxICanvas canvas, mxCellState state) { if (isFoldingEnabled() && canvas instanceof mxGraphics2DCanvas) { mxIGraphModel model = graph.getModel(); mxGraphics2DCanvas g2c = (mxGraphics2DCanvas) canvas; Graphics2D g2 = g2c.getGraphics(); // Draws the collapse/expand icons boolean isEdge = model.isEdge(state.getCell()); if (state.getCell() != graph.getCurrentRoot() && (model.isVertex(state.getCell()) || isEdge)) { ImageIcon icon = getFoldingIcon(state); if (icon != null) { Rectangle bounds = getFoldingIconBounds(state, icon); g2.drawImage(icon.getImage(), bounds.x, bounds.y, bounds.width, bounds.height, this); } } } }
/** * */ protected void cellDrawn(mxICanvas canvas, mxCellState state) { if (isFoldingEnabled() && canvas instanceof mxGraphics2DCanvas) { mxIGraphModel model = graph.getModel(); mxGraphics2DCanvas g2c = (mxGraphics2DCanvas) canvas; Graphics2D g2 = g2c.getGraphics(); // Draws the collapse/expand icons boolean isEdge = model.isEdge(state.getCell()); if (state.getCell() != graph.getCurrentRoot() && (model.isVertex(state.getCell()) || isEdge)) { ImageIcon icon = getFoldingIcon(state); if (icon != null) { Rectangle bounds = getFoldingIconBounds(state, icon); g2.drawImage(icon.getImage(), bounds.x, bounds.y, bounds.width, bounds.height, this); } } } }