/** * */ public void paint(Graphics g) { if (first != null && current != null) { ((Graphics2D) g).setStroke(new BasicStroke(lineWidth)); g.setColor(lineColor); Rectangle rect = current.getRectangle(); if (rounded) { g.drawRoundRect(rect.x, rect.y, rect.width, rect.height, 8, 8); } else { g.drawRect(rect.x, rect.y, rect.width, rect.height); } } }
/** * */ public void paint(Graphics g) { if (first != null && current != null) { ((Graphics2D) g).setStroke(new BasicStroke(lineWidth)); g.setColor(lineColor); Rectangle rect = current.getRectangle(); if (rounded) { g.drawRoundRect(rect.x, rect.y, rect.width, rect.height, 8, 8); } else { g.drawRect(rect.x, rect.y, rect.width, rect.height); } } }
/** * */ public void reset() { Rectangle dirty = null; if (current != null) { dirty = current.getRectangle(); } current = null; first = null; if (dirty != null) { int b = (int) Math.ceil(lineWidth); graphComponent.getGraphControl().repaint(dirty.x - b, dirty.y - b, dirty.width + 2 * b, dirty.height + 2 * b); } }
/** * */ public void reset() { Rectangle dirty = null; if (current != null) { dirty = current.getRectangle(); } current = null; first = null; if (dirty != null) { int b = (int) Math.ceil(lineWidth); graphComponent.getGraphControl().repaint(dirty.x - b, dirty.y - b, dirty.width + 2 * b, dirty.height + 2 * b); } }
/** * * @param x * @param y * @return Returns the inde of the handle at the given location. */ public int getIndexAt(int x, int y) { int index = super.getIndexAt(x, y); // Makes the complete label a trigger for the label handle if (index < 0 && handles != null && handlesVisible && isLabelMovable() && state.getLabelBounds().getRectangle().contains(x, y)) { index = handles.length - 1; } return index; }
/** * * @param x * @param y * @return Returns the inde of the handle at the given location. */ public int getIndexAt(int x, int y) { int index = super.getIndexAt(x, y); // Makes the complete label a trigger for the label handle if (index < 0 && handles != null && handlesVisible && isLabelMovable() && state.getLabelBounds().getRectangle().contains(x, y)) { index = handles.length - 1; } return index; }
/** * Updates the buffer (if one exists) and repaints the given cell state. */ public void redraw(mxCellState state) { if (state != null) { Rectangle dirty = state.getBoundingBox().getRectangle(); repaintTripleBuffer(new Rectangle(dirty)); dirty = SwingUtilities.convertRectangle(graphControl, dirty, this); repaint(dirty); } }
/** * Updates the buffer (if one exists) and repaints the given cell state. */ public void redraw(mxCellState state) { if (state != null) { Rectangle dirty = state.getBoundingBox().getRectangle(); repaintTripleBuffer(new Rectangle(dirty)); dirty = SwingUtilities.convertRectangle(graphControl, dirty, this); repaint(dirty); } }
/** * * @return Returns the bounds of the preview. */ protected Rectangle getPreviewBounds() { Rectangle bounds = null; if (isLabel(index)) { bounds = state.getLabelBounds().getRectangle(); } else { bounds = new Rectangle(p[0]); for (int i = 0; i < p.length; i++) { bounds.add(p[i]); } bounds.height += 1; bounds.width += 1; } return bounds; }
/** * Shows the changes in the given mxCellStatePreview. */ protected void show(mxCellStatePreview preview) { if (dirty != null) { graphComponent.getGraphControl().repaint(dirty.getRectangle()); } else { graphComponent.getGraphControl().repaint(); } dirty = preview.show(); if (dirty != null) { graphComponent.getGraphControl().repaint(dirty.getRectangle()); } }
/** * */ protected void repaint(mxRectangle dirty) { if (dirty != null) { graphComponent.getGraphControl().repaint(dirty.getRectangle()); } else { graphComponent.getGraphControl().repaint(); } }
/** * Shows the changes in the given mxCellStatePreview. */ protected void show(mxCellStatePreview preview) { if (dirty != null) { graphComponent.getGraphControl().repaint(dirty.getRectangle()); } else { graphComponent.getGraphControl().repaint(); } dirty = preview.show(); if (dirty != null) { graphComponent.getGraphControl().repaint(dirty.getRectangle()); } }
/** * */ protected void repaint(mxRectangle dirty) { if (dirty != null) { graphComponent.getGraphControl().repaint(dirty.getRectangle()); } else { graphComponent.getGraphControl().repaint(); } }
/** * Sets the translation of the preview. */ public void start(MouseEvent e, mxCellState state) { startState = state; movingCells = getCells(state); previewStates = (!placeholderPreview) ? getPreviewStates() : null; if (previewStates == null || previewStates.length >= threshold) { placeholder = getPlaceholderBounds(startState).getRectangle(); initialPlaceholder = new Rectangle(placeholder); graphComponent.getGraphControl().repaint(placeholder); } fireEvent(new mxEventObject(mxEvent.START, "event", e, "state", startState)); }
/** * Sets the translation of the preview. */ public void start(MouseEvent e, mxCellState state) { startState = state; movingCells = getCells(state); previewStates = (!placeholderPreview) ? getPreviewStates() : null; if (previewStates == null || previewStates.length >= threshold) { placeholder = getPlaceholderBounds(startState).getRectangle(); initialPlaceholder = new Rectangle(placeholder); graphComponent.getGraphControl().repaint(placeholder); } fireEvent(new mxEventObject(mxEvent.START, "event", e, "state", startState)); }
/** * */ public void stopAnimation() { graphComponent.getGraph().getView().revalidate(); super.stopAnimation(); preview = null; if (dirty != null) { graphComponent.getGraphControl().repaint(dirty.getRectangle()); } }
/** * */ public void stopAnimation() { graphComponent.getGraph().getView().revalidate(); super.stopAnimation(); preview = null; if (dirty != null) { graphComponent.getGraphControl().repaint(dirty.getRectangle()); } }
@Override public void zoomTo( final double newScale, final boolean center ) { final mxGraphView view = graph.getView(); final double scale = view.getScale(); final mxPoint translate = ( pageVisible && centerPage ) ? getPageTranslate( newScale ) : new mxPoint(); graph.getView().scaleAndTranslate( newScale, translate.getX(), translate.getY() ); if ( keepSelectionVisibleOnZoom && !graph.isSelectionEmpty() ) { getGraphControl().scrollRectToVisible( view.getBoundingBox( graph.getSelectionCells() ).getRectangle() ); } else { maintainScrollBar( true, newScale / scale, center ); maintainScrollBar( false, newScale / scale, center ); } }
@Override public void zoomTo( final double newScale, final boolean center ) { final mxGraphView view = graph.getView(); final double scale = view.getScale(); final mxPoint translate = ( pageVisible && centerPage ) ? getPageTranslate( newScale ) : new mxPoint(); graph.getView().scaleAndTranslate( newScale, translate.getX(), translate.getY() ); if ( keepSelectionVisibleOnZoom && !graph.isSelectionEmpty() ) { getGraphControl().scrollRectToVisible( view.getBoundingBox( graph.getSelectionCells() ).getRectangle() ); } else { maintainScrollBar( true, newScale / scale, center ); maintainScrollBar( false, newScale / scale, center ); } }
/** * 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()); } }