List of usage examples for java.awt.geom Rectangle2D setRect
public void setRect(Rectangle2D r)
From source file:com.igormaznitsa.mindmap.swing.panel.MindMapPanel.java
private void drawDestinationElement(final Graphics2D g, final MindMapPanelConfig cfg) { if (this.destinationElement != null && this.draggedElement != null) { g.setColor(new Color((cfg.getSelectLineColor().getRGB() & 0xFFFFFF) | 0x80000000, true)); g.setStroke(new BasicStroke(this.config.safeScaleFloatValue(3.0f, 0.1f))); final Rectangle2D rectToDraw = new Rectangle2D.Double(); rectToDraw.setRect(this.destinationElement.getBounds()); final double selectLineGap = cfg.getSelectLineGap() * 3.0d * cfg.getScale(); rectToDraw.setRect(rectToDraw.getX() - selectLineGap, rectToDraw.getY() - selectLineGap, rectToDraw.getWidth() + selectLineGap * 2, rectToDraw.getHeight() + selectLineGap * 2); final int position = calcDropPosition(this.destinationElement, this.draggedElement.getPosition()); boolean draw = !this.draggedElement.isPositionInside() && !this.destinationElement.getModel().hasAncestor(this.draggedElement.getElement().getModel()); switch (this.draggedElement.getModifier()) { case NONE: { switch (position) { case DRAG_POSITION_TOP: { rectToDraw.setRect(rectToDraw.getX(), rectToDraw.getY(), rectToDraw.getWidth(), rectToDraw.getHeight() / 2); }//from w w w . j a v a 2 s. c o m break; case DRAG_POSITION_BOTTOM: { rectToDraw.setRect(rectToDraw.getX(), rectToDraw.getY() + rectToDraw.getHeight() / 2, rectToDraw.getWidth(), rectToDraw.getHeight() / 2); } break; case DRAG_POSITION_LEFT: { rectToDraw.setRect(rectToDraw.getX(), rectToDraw.getY(), rectToDraw.getWidth() / 2, rectToDraw.getHeight()); } break; case DRAG_POSITION_RIGHT: { rectToDraw.setRect(rectToDraw.getX() + rectToDraw.getWidth() / 2, rectToDraw.getY(), rectToDraw.getWidth() / 2, rectToDraw.getHeight()); } break; default: draw = false; break; } } break; case MAKE_JUMP: { } break; default: throw new Error("Unexpected state " + this.draggedElement.getModifier()); } if (draw) { g.fill(rectToDraw); } } }