Java 类org.eclipse.gef.handles.HandleBounds 实例源码

项目:PDFReporter-Studio    文件:ElementLineBorder.java   
@Override
public void paint(IFigure figure, Graphics graphics, Insets insets) {
    Rectangle tempRect = figure.getBounds();
    if (figure instanceof HandleBounds)
        tempRect = ((HandleBounds) figure).getHandleBounds();
    Graphics2D g = ComponentFigure.getG2D(graphics);
    if (g != null) {
        Stroke oldStroke = g.getStroke();
        g.setStroke(new BasicStroke(0.1f));

        if (getColor() != null)
            g.setColor((J2DGraphics.toAWTColor(getColor())));
        g.drawRect(tempRect.x, tempRect.y, tempRect.width - 1, tempRect.height - 1);

        g.setStroke(oldStroke);
    }
}
项目:PDFReporter-Studio    文件:ComponentFigure.java   
@Override
public void paint(Graphics graphics) {
    Rectangle b = (this instanceof HandleBounds) ? ((HandleBounds) this).getHandleBounds() : this.getBounds();
    try {
        graphics.translate(b.x, b.y);
        Graphics2D graphics2d = getG2D(graphics);
        if (graphics2d != null) {
            if (drawVisitor != null) {
                drawVisitor.setGraphics2D(graphics2d);

                draw(drawVisitor, jrElement);
            } else
                graphics2d.drawRect(b.x, b.y, b.width, b.height);
        } else {
            System.out.println("not a 2d");
        }
    } catch (Exception e) {
        // when a font is missing exception is thrown by DrawVisitor
        // FIXME: maybe draw something, else?
        e.printStackTrace();
    } finally {
        graphics.translate(-b.x, -b.y);
    }
    paintBorder(graphics);
    paintDecorators(graphics);
}
项目:statecharts    文件:PreferredSizeHandlerEditPolicy.java   
public PreferredSizeSquareHandle(GraphicalEditPart editpart) {
    super(editpart, new RelativeLocator(getHostFigure(), 0.75, 1) {
        protected Rectangle getReferenceBox() {
            IFigure f = getReferenceFigure();
            if (f instanceof HandleBounds)
                return ((HandleBounds) f).getHandleBounds();
            return super.getReferenceBox();
        }
    });
}
项目:PDFReporter-Studio    文件:EmptyCellFigure.java   
@Override
public void paint(Graphics graphics) {
    Rectangle b = (this instanceof HandleBounds) ? ((HandleBounds) this).getHandleBounds() : this.getBounds();

    Graphics2D g = ComponentFigure.getG2D(graphics);
    if (g != null) {
        g.setPaint(tp);
        g.fillRect(b.x, b.y, b.width - 1, b.height - 1);
    }
    paintBorder(graphics);
}
项目:PDFReporter-Studio    文件:EmptyCellFigure.java   
@Override
public void paint(Graphics graphics) {
    Rectangle b = (this instanceof HandleBounds) ? ((HandleBounds) this).getHandleBounds() : this.getBounds();

    Graphics2D g = ComponentFigure.getG2D(graphics);
    if (g != null) {
        g.setPaint(tp);
        g.fillRect(b.x, b.y, b.width - 1, b.height - 1);
    }
    paintBorder(graphics);
}
项目:PDFReporter-Studio    文件:CellResizeHandleLocator.java   
@Override
public void relocate(IFigure target) {
    IFigure reference = getReferenceFigure();
    Rectangle referenceBox = ((HandleBounds) reference).getHandleBounds();
    Rectangle targetBounds = new PrecisionRectangle(referenceBox.getResized(-1, -1));
    reference.translateToAbsolute(targetBounds);
    target.translateToRelative(targetBounds);
    targetBounds.resize(1, 1);

    int w = 2;
    int h = 2;
    switch (direction & PositionConstants.NORTH_SOUTH) {
    case PositionConstants.NORTH:
        w = targetBounds.width;
        targetBounds.y += (int) (targetBounds.height * relativeY - ((h / 2))) + 1;
        break;
    case PositionConstants.SOUTH:
        w = targetBounds.width;
        targetBounds.y += (int) (targetBounds.height * relativeY - (h / 2)) - 1;
        targetBounds.x += -1;
        break;
    }
    switch (direction & PositionConstants.EAST_WEST) {
    case PositionConstants.WEST:
        h = targetBounds.height;
        targetBounds.y += (int) relativeY - 1;
        targetBounds.x += (int) (targetBounds.width * relativeX - (w / 2)) - 1;
        break;
    case PositionConstants.EAST:
        h = targetBounds.height;
        targetBounds.y += (int) relativeY - 1;
        targetBounds.x += (int) (targetBounds.width * relativeX - (w / 2) - 1);
        break;
    }

    targetBounds.setSize(w, h);
    target.setBounds(targetBounds);
}
项目:PDFReporter-Studio    文件:PageLayoutEditPolicy.java   
@Override
protected Object getConstraintFor(ChangeBoundsRequest request, GraphicalEditPart child) {
    // if (child instanceof IContainerPart) {
    // return ((IContainerPart) child).getConstraintFor(request, child);
    // }
    // If we are dragging a band, we need to check the bounds and suggest a
    // proper
    // new location accordingly with the max and min band size.
    IFigure figure = child.getFigure();
    Rectangle bounds = figure.getBounds();
    if (figure instanceof HandleBounds) {
        bounds = ((HandleBounds) figure).getHandleBounds();
        // if (request.getResizeDirection() == PositionConstants.NORTH
        // || request.getResizeDirection() == PositionConstants.SOUTH)
        bounds.width--;
        // if (request.getResizeDirection() == PositionConstants.EAST
        // || request.getResizeDirection() == PositionConstants.WEST)
        bounds.height--;
    }
    Rectangle rect = new PrecisionRectangle(bounds);
    figure.translateToAbsolute(rect);
    rect = request.getTransformedRectangle(rect);
    figure.translateToRelative(rect);
    rect.translate(getLayoutOrigin().getNegated());
    if (request.getSizeDelta().width == 0 && request.getSizeDelta().height == 0) {
        Rectangle cons = getCurrentConstraintFor(child);
        if (cons != null) // Bug 86473 allows for unintended use of this method
            rect.setSize(cons.width, cons.height);
    } else { // resize
        Dimension minSize = getMinimumSizeFor(child);
        if (rect.width < minSize.width) {
            rect.width = minSize.width;
        }
        if (rect.height < minSize.height) {
            rect.height = minSize.height;
        }
    }
    return getConstraintFor(rect);
}
项目:PDFReporter-Studio    文件:ShadowBorder.java   
public void paint(IFigure figure, Graphics graphics, Insets insets) {

        Graphics2D g = ComponentFigure.getG2D(graphics);
        if (g != null) {
            org.eclipse.draw2d.geometry.Rectangle bounds = figure.getBounds();
            if (figure instanceof HandleBounds)
                bounds = ((HandleBounds) figure).getHandleBounds();

            paintShadowBorder(g, bounds.x - insets.left, bounds.y - insets.top, bounds.width + insets.right + insets.left,
                    bounds.height + insets.top + insets.bottom);
        }

    }
项目:PDFReporter-Studio    文件:CornerBorder.java   
@Override
public void paint(IFigure figure, Graphics graphics, Insets insets) {
    Rectangle bounds = figure.getBounds();
    if (figure instanceof HandleBounds)
        bounds = ((HandleBounds) figure).getHandleBounds();

    Graphics2D g = ComponentFigure.getG2D(graphics);
    if (g != null) {
        Stroke oldStroke = g.getStroke();

        g.setStroke(new BasicStroke(0.1f));

        if (getColor() != null)
            g.setColor((J2DGraphics.toAWTColor(getColor())));

        int bottom = bounds.y + bounds.height - 1;
        int right = bounds.x + bounds.width - 1;

        // top left
        g.drawLine(bounds.x, bounds.y, bounds.x + o, bounds.y);
        g.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + o);
        // top right
        g.drawLine(right - o, bounds.y, right, bounds.y);
        g.drawLine(right, bounds.y, right, bounds.y + o);
        // bottom left
        g.drawLine(bounds.x, bottom, bounds.x + o, bottom);
        g.drawLine(bounds.x, bottom, bounds.x, bottom - o);
        // bottom right
        g.drawLine(right - o, bottom, right, bottom);
        g.drawLine(right, bottom, right, bottom - o);
        if (bounds.width > 50) {
            g.drawLine(bounds.x + bounds.width / 2 - o / 2, bounds.y, bounds.x + bounds.width / 2 + o / 2, bounds.y);
            g.drawLine(bounds.x + bounds.width / 2 - o / 2, bottom, bounds.x + bounds.width / 2 + o / 2, bottom);
        }
        g.setStroke(oldStroke);
    }
}
项目:PDFReporter-Studio    文件:SimpleShadowBorder.java   
public void paint(IFigure figure, Graphics graphics, Insets insets) {
    org.eclipse.draw2d.geometry.Rectangle bounds = figure.getBounds();
    if (figure instanceof HandleBounds)
        bounds = ((HandleBounds) figure).getHandleBounds();

    paintShadowBorder(graphics, bounds.x - insets.left, bounds.y - insets.top, bounds.width + insets.right
            + insets.left, bounds.height + insets.top + insets.bottom);
}
项目:gef-gwt    文件:NonResizableEditPolicy.java   
/**
 * Shows a focus rectangle around the host's figure. The focus rectangle is
 * expanded by 5 pixels from the figure's bounds.
 * 
 * @see org.eclipse.gef.editpolicies.SelectionEditPolicy#showFocus()
 */
protected void showFocus() {
    focusRect = new AbstractHandle((GraphicalEditPart) getHost(),
            new Locator() {
                public void relocate(IFigure target) {
                    IFigure figure = getHostFigure();
                    Rectangle r;
                    if (figure instanceof HandleBounds)
                        r = ((HandleBounds) figure).getHandleBounds()
                                .getCopy();
                    else
                        r = getHostFigure().getBounds().getResized(-1, -1);
                    getHostFigure().translateToAbsolute(r);
                    target.translateToRelative(r);
                    target.setBounds(r.expand(5, 5).resize(1, 1));
                }
            }) {
        {
            setBorder(new FocusBorder());
        }

        protected DragTracker createDragTracker() {
            return null;
        }
    };
    addFeedback(focusRect);
}
项目:PDFReporter-Studio    文件:CellResizeHandleLocator2.java   
@Override
public void relocate(IFigure target) {
    IFigure reference = getReferenceFigure();
    Rectangle referenceBox = ((HandleBounds) reference).getHandleBounds();
    Rectangle targetBounds = new PrecisionRectangle(referenceBox.getResized(-1, -1));
    reference.translateToAbsolute(targetBounds);
    target.translateToRelative(targetBounds);
    targetBounds.resize(1, 1);

    double xzoom = GEFUtil.getZoom(editPart);

    Dimension targetSize = target.getPreferredSize();
    Dimension d = targetSize;
    if (editPart instanceof IContainerPart) {
        d = ((IContainerPart) editPart).getContaierSize();
        // Commented for back-compatibility in 3.6. 
        // Replaced with the following 3 lines.
        // d = d.getCopy().setHeight(d.height + 18).scale(xzoom);
        Dimension dcopy = d.getCopy();
        dcopy.height = d.height + 18;
        d = dcopy.scale(xzoom);
    }

    int w = 4;
    int h = 4;
    switch (direction & PositionConstants.NORTH_SOUTH) {
    case PositionConstants.NORTH:
        w = d.width + 1;
        targetBounds.y += (int) (targetBounds.height * relativeY - ((targetSize.height)));// + 1;
        targetBounds.x = (int) Math.floor(10 * xzoom);
        break;
    case PositionConstants.SOUTH:
        w = d.width + 1;
        targetBounds.y += (int) (targetBounds.height * relativeY - ((targetSize.height))) - 1;// + 1) / 2)) + 1;
        targetBounds.x = (int) Math.floor(10 * xzoom);
        break;
    }
    switch (direction & PositionConstants.EAST_WEST) {
    case PositionConstants.WEST:
        h = d.height - (int) Math.floor(10 * xzoom);
        targetBounds.y = (int) Math.floor(7 * xzoom);// += (int) relativeY - 1;
        targetBounds.x += (int) (targetBounds.width * relativeX - (targetSize.width));// + 1;// + 1;
        break;
    case PositionConstants.EAST:
        h = d.height - (int) Math.floor(10 * xzoom);
        targetBounds.y = (int) Math.floor(7 * xzoom);// += (int) relativeY - 1;
        targetBounds.x += (int) (targetBounds.width * relativeX - (targetSize.width)) - 1;// / 2);// + 1;
        break;
    }
    targetBounds.setSize(w + 1, h + 1);
    target.setBounds(targetBounds);
}
项目:OpenSPIFe    文件:TemporalNodeDecoratorTextEditPolicy.java   
public TextOverlay() {
    super((GraphicalEditPart) getHost(), new MoveHandleLocator(getHostFigure()) {

        @Override
        public void relocate(IFigure target) {
            if (!getHostFigure().isShowing() 
                    || nodeText == null || nodeText.length() == 0) {
                super.relocate(target);
                return;
            }

            Rectangle figureBounds;
            if (getReference() instanceof HandleBounds) {
                figureBounds = ((HandleBounds)getReference()).getHandleBounds();
            } else {
                figureBounds = getReference().getBounds();
            }
            figureBounds = new Rectangle(figureBounds.getResized(-1, -1));

            int xInset = 3;
            switch (getDesiredAlignment()) {
            case TRUNCATE:
                figureBounds.x += xInset;
                figureBounds.width = figureBounds.width - 2*xInset;
                break;
            case LEFT:
                figureBounds.x += xInset;
                figureBounds.width = textSize.width + 2*xInset;
                break;
            case CENTER:
                figureBounds.x = figureBounds.x + figureBounds.width/2 - textSize.width/2;
                figureBounds.width = textSize.width + 2*xInset;
                break;
            case RIGHT:
                figureBounds.x = figureBounds.x + figureBounds.width - textSize.width - xInset;
                figureBounds.width = textSize.width + 2*xInset;
                break;
            case TRAILING:
                figureBounds.x = figureBounds.x + figureBounds.width + xInset;
                figureBounds.width = textSize.width + 2*xInset;
                break;
            }
            figureBounds.y = figureBounds.y + figureBounds.height/2 - textSize.height/2;

            Insets insets = target.getInsets();
            figureBounds.translate(-insets.left, -insets.top);
            figureBounds.resize(insets.getWidth() + 1, insets.getHeight() + 1);
            if (!CommonUtils.equals(target.getBounds(), figureBounds)) {
                target.setBounds(figureBounds);
            }
        }

    });
}
项目:gef-gwt    文件:NonResizableEditPolicy.java   
/**
 * Returns the bounds of the host's figure by reference to be used to
 * calculate the initial location of the feedback. The returned Rectangle
 * should not be modified. Uses handle bounds if available.
 * 
 * @return the host figure's bounding Rectangle
 */
protected Rectangle getInitialFeedbackBounds() {
    if (((GraphicalEditPart) getHost()).getFigure() instanceof HandleBounds)
        return ((HandleBounds) ((GraphicalEditPart) getHost()).getFigure())
                .getHandleBounds();
    return ((GraphicalEditPart) getHost()).getFigure().getBounds();
}
项目:gef-gwt    文件:SnapToGeometry.java   
/**
 * Returns the rectangular contribution for the given editpart. This is the
 * rectangle with which snapping is performed.
 * 
 * @since 3.0
 * @param part
 *            the child
 * @return the rectangular guide for that part
 */
protected Rectangle getFigureBounds(GraphicalEditPart part) {
    IFigure fig = part.getFigure();
    if (fig instanceof HandleBounds)
        return ((HandleBounds) fig).getHandleBounds();
    return fig.getBounds();
}
项目:NEXCORE-UML-Modeler    文件:MessageBendpointEditPolicy.java   
/**
 * Returns the bounds of the host's figure by reference to be used to
 * calculate the initial location of the feedback. The returned Rectangle
 * should not be modified. Uses handle bounds if available.
 * 
 * @return the host figure's bounding Rectangle
 */
protected Rectangle getInitialFeedbackBounds() {
    if (((GraphicalEditPart) getHost()).getFigure() instanceof HandleBounds)
        return ((HandleBounds) ((GraphicalEditPart) getHost()).getFigure()).getHandleBounds();
    return ((GraphicalEditPart) getHost()).getFigure().getBounds();
}