Package org.eclipse.draw2d.geometry

Examples of org.eclipse.draw2d.geometry.Point


            super(owner);
        }

        @Override
    public Point getReferencePoint() {
        Point ref = getOwner().getBounds().getCenter();
          int o = ref.x % GRID_SIZE;
           if (o != 0) {
             ref.x += (o > GRID_SIZE/2) ? GRID_SIZE-o : -o;
           }
           o = ref.y % GRID_SIZE;
View Full Code Here


        return ref;
    }

    @Override
        public Point getLocation(Point reference) {
            Point p = super.getLocation(reference);
            if (Math.abs(p.x-reference.x) <= 3) {
              p.x = reference.x;
            }
            if (Math.abs(p.y-reference.y) <= 3) {
              p.y = reference.y;
View Full Code Here

        List<Bendpoint> bendpoints = (List<Bendpoint>) getConstraint(conn);
        if (bendpoints == null)
            bendpoints = new ArrayList<Bendpoint>();

        Point ref1, ref2;

        if (bendpoints.isEmpty()) {
            if (conn.getTargetAnchor() instanceof ReferencedConnectionAnchor) {
                Point reference = conn.getSourceAnchor().getReferencePoint();
                ref1 = ((ReferencedConnectionAnchor) conn.getTargetAnchor()).getReferencePoint(reference);
            } else {
                ref1 = conn.getTargetAnchor().getReferencePoint();
            }

            if (conn.getSourceAnchor() instanceof ReferencedConnectionAnchor) {
              Point reference = ref1.getCopy();
                ref2 = ((ReferencedConnectionAnchor) conn.getSourceAnchor()).getReferencePoint(reference);
            } else {
                ref2 = conn.getSourceAnchor().getReferencePoint();
            }
        } else {
            ref1 = new Point(bendpoints.get(0).getLocation());
            conn.translateToAbsolute(ref1);
            ref2 = new Point(bendpoints.get(bendpoints.size() - 1).getLocation());
            conn.translateToAbsolute(ref2);
        }

        A_POINT.setLocation(conn.getSourceAnchor().getLocation(ref1));
        conn.translateToRelative(A_POINT);
View Full Code Here

    public Point getLocation(Point reference) {
        Rectangle r = Rectangle.SINGLETON;
        r.setBounds(getOwner().getBounds());
        getOwner().translateToAbsolute(r);

        Point ref = r.getCenter().negate().translate(reference);

        float centerX = r.x + 0.5f * r.width;
        float centerY = r.y + 0.5f * r.height;
        float dx, dy;

        if (Math.abs(ref.x * r.height) == Math.abs(Math.abs(ref.y) * r.width)) {
            dx = ref.x > 0 ? r.width / 4 : -r.width / 4;
            dy = ref.y > 0 ? r.height / 4 : -r.height / 4;
        } else if (ref.x == 0) {
            dx = 0;
            dy = ref.y > 0 ? r.height / 2 : -r.height / 2;
        } else {

            float numerator = ref.x * r.height * r.width / 2;
            float firstDenominator = Math.abs(ref.y) * r.width + ref.x * r.height;
            float secondDenominator = Math.abs(ref.y) * r.width - ref.x * r.height;

            dx = (ref.x > 0) ? numerator / firstDenominator : numerator / secondDenominator;
            dy = dx * ref.y / ref.x;

        }

        return new Point(Math.round(centerX + dx), Math.round(centerY + dy));
    }
View Full Code Here

            int shift = actionIndex*(ACTION_SIZE+ACTION_DELIM) + addPixels;
            if (((TransitionFigure) figure).hasSourceDecoration()) {
              shift += 10;
            }
            PointList pointList = ((TransitionFigure) figure).getPoints();
            Point point0 = pointList.getPoint(0);
            Point point1 = pointList.getPoint(1);
            Dimension diff = point1.getDifference(point0);
            Point dist = new Point(diff.width, diff.height);
            double distance = new Point(0, 0).getDistance(dist);
            double scaleFactor = shift / distance;
            Point translation = dist.getScaled(scaleFactor);
            Point location = point0.getTranslated(translation);
            location.x -= ACTION_SIZE/2;
            location.y -= ACTION_SIZE/2;
            return location;
        } else {
            NodeFigure nodeFigure = (NodeFigure) figure;
            List<IFigure> children = nodeFigure.getActionsContainer().getChildren();
            IFigure prevFigure;
            if (children.size() > actionIndex) {
                prevFigure = children.get(children.size() - 1 - actionIndex);
            } else {
                prevFigure = children.get(0);
            }
            Rectangle prevActionBounds = prevFigure.getBounds();
            return new Point(prevActionBounds.x - 5, prevActionBounds.y);
            /*
            // invert visuals
            actionIndex = size - actionIndex;
            int xShift = actionIndex*(ACTION_SIZE+ACTION_DELIM) - addPixels;
            int yShift = 3*ACTION_SIZE/2;
 
View Full Code Here

        }
    }
   
    public static boolean areActionsFitInLine(TransitionFigure connection, int actionsSize) {
        PointList pointList = connection.getPoints();
        Point point0 = pointList.getPoint(0);
        Point point1 = pointList.getPoint(1);
        int shift = actionsSize*(ACTION_SIZE+ACTION_DELIM);
        Dimension diff = point1.getDifference(point0);
        Point dist = new Point(diff.width, diff.height);
        double distance = new Point(0, 0).getDistance(dist);
        if (connection.hasSourceDecoration()) {
          shift += 10;
        }
        return shift <= distance;
    }
View Full Code Here

            parentElement = parentElement.getParent();
        }
        if (targetElementConstraint != null) {
            Viewport viewport = (Viewport) ((FreeformGraphicalRootEditPart) getGraphicalViewer().getRootEditPart()).getFigure();
            Dimension dim = viewport.getSize();
            Point startLocation = viewport.getViewLocation().getCopy();
            Point preferredEndLocation = new Point(targetElementConstraint.x - dim.width / 2 + targetElementConstraint.width / 2,
                targetElementConstraint.y - dim.height / 2 + targetElementConstraint.height / 2);
            moveViewport(viewport, startLocation, preferredEndLocation);
        }
        getGraphicalViewer().select(target);
    }
View Full Code Here

                if (!running) {
                    break;
                }
                double delta = (double) (83 - (i - 10) * (i - 10)) / 1000;
                sumDelta += delta;
                final Point np = viewport.getLocation().getCopy();
                np.x = (int) (start.x + sumDelta * (end.x - start.x));
                np.y = (int) (start.y + sumDelta * (end.y - start.y));
                final int debug = i;
                display.asyncExec(new Runnable() {
                    public void run() {
View Full Code Here

    // }
    //
    // @Test
    // public void testConflictingSetRecords() {

    Point locOrig = polyLine.getLocation();
    Point loc1 = new Point(10, 10);
    Rectangle rect1 = new Rectangle(loc1, polyLine.getSize());

    ElementRecordChangeLayoutCommand cmd1 = new ElementRecordChangeLayoutCommand();
    cmd1.setModel(polyLine);
    cmd1.setConstraint(rect1);
    cmd1.execute();

    assertTrue(polyLine.getLocation().equals(loc1));

    Point loc2 = new Point(20, 20);
    Rectangle rect2 = new Rectangle(loc2, polyLine.getSize());

    ElementRecordChangeLayoutCommand cmd2 = new ElementRecordChangeLayoutCommand();
    cmd2.setModel(polyLine);
    cmd2.setConstraint(rect2);
View Full Code Here

  public Point getLocation() {
    int x = getAttributeInt(SVGConstants.SVG_CX_ATTRIBUTE)
        - getAttributeInt(SVGConstants.SVG_RX_ATTRIBUTE);
    int y = getAttributeInt(SVGConstants.SVG_CY_ATTRIBUTE)
        - getAttributeInt(SVGConstants.SVG_RY_ATTRIBUTE);
    return new Point(x, y);
  }
View Full Code Here

TOP

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

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.