Package org.eclipse.draw2d.geometry

Examples of org.eclipse.draw2d.geometry.Rectangle


    } else {
      pref = text.computeSize(-1, -1);
    }

    Label label = vertexFigure.getLabelId();
    Rectangle labelBounds = label.getBounds().getCopy();
    label.translateToAbsolute(labelBounds);

    Rectangle figureBounds = vertexFigure.getBounds().getCopy();
    vertexFigure.translateToAbsolute(figureBounds);
    int start = (figureBounds.width - pref.x) / 2;

    text.setBounds(figureBounds.x + start, labelBounds.y, pref.x, pref.y);
  }
View Full Code Here


        label = figure.getOutputPortLabel(portName);
        if (label == null) {
          return null;
        }

        Rectangle bounds = label.getBounds();
        int x = bounds.x + bounds.width + 5;
        int y = bounds.y + bounds.height / 2;

        Point ref = new Point(x, y);
        label.translateToAbsolute(ref);

        return ref;
      } else {
        label = figure.getInputPortLabel(portName);
        if (label == null) {
          return null;
        }

        Rectangle bounds = label.getBounds();
        int x = bounds.x - 5;
        int y = bounds.y + bounds.height / 2;

        Point ref = new Point(x, y);
        label.translateToAbsolute(ref);
View Full Code Here

        int w = 4;
        int dw = 2;
        int xCenter = getXShift() + r.width/2;
        int y = r.height - GRID_SIZE;
        List<Rectangle> rects = new ArrayList<Rectangle>();
        rects.add(new Rectangle(xCenter - 3*w/2 - dw, y, w, GRID_SIZE));
        rects.add(new Rectangle(xCenter - w/2, y, w, GRID_SIZE));
        rects.add(new Rectangle(xCenter + w/2 + dw, y, w, GRID_SIZE));
        Color bgColor = g.getBackgroundColor();
        g.setBackgroundColor(g.getForegroundColor());
        for (Rectangle rectangle : rects) {
            g.fillRectangle(rectangle);
        }
View Full Code Here

        //return bpmnNotation ? GRID_SIZE : GRID_SIZE / 2;
        return GRID_SIZE / 2;
    }
   
    private void paintSurroudingBoxes(Graphics g, int shift) {
        Rectangle b = getBounds();
        List<Rectangle> rects = new ArrayList<Rectangle>();
        rects.add(new Rectangle(shift, b.height/2-3*GRID_SIZE/2, GRID_SIZE, GRID_SIZE));
        rects.add(new Rectangle(shift, b.height/2-GRID_SIZE/2, GRID_SIZE, GRID_SIZE));
        rects.add(new Rectangle(shift, b.height/2+GRID_SIZE/2, GRID_SIZE, GRID_SIZE));
        rects.add(new Rectangle(b.width-GRID_SIZE-1-shift, b.height/2-3*GRID_SIZE/2, GRID_SIZE, GRID_SIZE));
        rects.add(new Rectangle(b.width-GRID_SIZE-1-shift, b.height/2-GRID_SIZE/2, GRID_SIZE, GRID_SIZE));
        rects.add(new Rectangle(b.width-GRID_SIZE-1-shift, b.height/2+GRID_SIZE/2, GRID_SIZE, GRID_SIZE));
        for (Rectangle rectangle : rects) {
            g.fillRectangle(rectangle);
            g.drawRectangle(rectangle);
        }
    }
View Full Code Here

        }
    }

    @Override
    public Rectangle getClientArea(Rectangle rect) {
        Rectangle r = super.getClientArea(rect);
        Rectangle borderRect = r.getCopy();
        if (!bpmnNotation) {
            borderRect.expand(-GRID_SIZE / 2, 0);
        }
        return borderRect;
    }
View Full Code Here

        Element processDiagramInfo = document.getDocumentElement();
        addProcessDiagramInfo(definition, processDiagramInfo);
        List<Element> children = getNamedChildren(processDiagramInfo, NODE_ELEMENT_NAME);
        for (Element element : children) {
            Node node = definition.getNodeByNameNotNull(element.getAttribute(NAME_ATTRIBUTE_NAME));
            Rectangle constraint = new Rectangle();
            constraint.x = Integer.valueOf(element.getAttribute(X_ATTRIBUTE_NAME)).intValue();
            constraint.y = Integer.valueOf(element.getAttribute(Y_ATTRIBUTE_NAME)).intValue();
            constraint.width = Integer.valueOf(element.getAttribute(WIDTH_ATTRIBUTE_NAME)).intValue();
            constraint.height = Integer.valueOf(element.getAttribute(HEIGHT_ATTRIBUTE_NAME)).intValue();
            String minimizedViewStr = element.getAttribute(MIN_VIEW_ATTRIBUTE_NAME);
View Full Code Here

        int xOffset = 0;
        int yOffset = 0;
        // calculating negative offsets;
        for (Node node : definition.getNodes()) {
            Rectangle constraints = node.getConstraint();
            if (constraints.x < xOffset) {
                xOffset = constraints.x;
            }
            if (constraints.y < yOffset) {
                yOffset = constraints.y;
            }
            for (Transition transition : node.getLeavingTransitions()) {
                for (Bendpoint bendpoint : transition.getBendpoints()) {
                    if (bendpoint.getX() < xOffset) {
                        xOffset = bendpoint.getX();
                    }
                    if (bendpoint.getY() < yOffset) {
                        yOffset = bendpoint.getY();
                    }
                }
            }
        }

        for (Node node : definition.getNodes()) {
            Element element = addElement(root, NODE_ELEMENT_NAME);
            addAttribute(element, NAME_ATTRIBUTE_NAME, node.getName());
            Rectangle constraint = node.getConstraint();
            if (constraint.width == 0 || constraint.height == 0) {
                throw new Exception("Invalid figure size: " + constraint.getSize());
            }
            addAttribute(element, X_ATTRIBUTE_NAME, String.valueOf(constraint.x - xOffset));
            addAttribute(element, Y_ATTRIBUTE_NAME, String.valueOf(constraint.y - yOffset));
            addAttribute(element, WIDTH_ATTRIBUTE_NAME, String.valueOf(constraint.width));
            addAttribute(element, HEIGHT_ATTRIBUTE_NAME, String.valueOf(constraint.height));
View Full Code Here

        this.label = label;
    }

    public void relocate(CellEditor celleditor) {
        Text text = (Text) celleditor.getControl();
        Rectangle rect = label.getClientArea().getCopy();
        label.translateToAbsolute(rect);
        org.eclipse.swt.graphics.Rectangle trim = text.computeTrim(0, 0, 0, 0);
        rect.translate(trim.x, trim.y);
        rect.width += trim.width;
        rect.height += trim.height;
        text.setBounds(rect.x, rect.y, rect.width, rect.height);
    }
View Full Code Here

        getFeedbackFigure().setLocation(feedbackPoint);
        addFeedback(getFeedbackFigure());
    }

    private Rectangle getAbsoluteBounds(GraphicalEditPart ep) {
        Rectangle bounds = ep.getFigure().getBounds().getCopy();
        ep.getFigure().translateToAbsolute(bounds);
        return bounds;
    }
View Full Code Here

    @Override
    protected Command createChangeConstraintCommand(EditPart child, Object constraint) {
        NodeChangeConstraintCommand locationCommand = new NodeChangeConstraintCommand();
        locationCommand.setNode((Node) child.getModel());
        Rectangle newRect = getClosestRectangle((Rectangle) constraint);
        locationCommand.setNewConstraint(newRect);
        return locationCommand;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.draw2d.geometry.Rectangle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.