Package org.eclipse.draw2d.geometry

Examples of org.eclipse.draw2d.geometry.Transposer


  protected int getFeedbackIndexFor(Request request) {
        List<?> children = getHost().getChildren();
    if (children.isEmpty())
      return -1;

    Transposer transposer = new Transposer();
    transposer.setEnabled(!isLayoutHorizontal(request));

    Point p = transposer.t(getLocationFromRequest(request));

    // Current row bottom, initialize to above the top.
    int rowBottom = Integer.MIN_VALUE;
    int candidate = -1;
    for (int i = 0; i < children.size(); i++) {
      EditPart child = (EditPart) children.get(i);
      if (child instanceof ShapeEditPart) {
        ShapePresentation presentation = ((ShapeEditPart)child).getShapePresentation();
        if (presentation != null && presentation.isSeparator()) {
          continue;
        }
      }
      Rectangle rect = transposer
          .t(getAbsoluteBounds(((GraphicalEditPart) child)));
      if (rect.y > rowBottom) {
        /*
         * We are in a new row, so if we don't have a candidate but yet
         * are within the previous row, then the current entry becomes
View Full Code Here


   */
  protected void showLayoutTargetFeedback(Request request) {
    if (getHost().getChildren().size() == 0)
      return;
    Polyline fb = getLineFeedback();
    Transposer transposer = new Transposer();
    transposer.setEnabled(!isLayoutHorizontal(request));

    boolean before = true;
    int epIndex = getFeedbackIndexFor(request);
    Rectangle r = null;
    if (epIndex == -1) {
      before = false;
      epIndex = getHost().getChildren().size() - 1;
      EditPart editPart = (EditPart) getHost().getChildren().get(epIndex);
      r = transposer.t(getAbsoluteBounds((GraphicalEditPart) editPart));
    } else {
      EditPart editPart = (EditPart) getHost().getChildren().get(epIndex);
      r = transposer.t(getAbsoluteBounds((GraphicalEditPart) editPart));
      Point p = transposer.t(getLocationFromRequest(request));
      if (p.x <= r.x + (r.width / 2))
        before = true;
      else {
        /*
         * We are not to the left of this Figure, so the emphasis line
         * needs to be to the right of the previous Figure, which must
         * be on the previous row.
         */
        before = false;
        epIndex--;
        editPart = (EditPart) getHost().getChildren().get(epIndex);
        r = transposer
            .t(getAbsoluteBounds((GraphicalEditPart) editPart));
      }
    }
    int x = Integer.MIN_VALUE;
    if (before) {
      /*
       * Want the line to be halfway between the end of the previous and
       * the beginning of this one. If at the beginning of a line, then
       * start halfway between the left edge of the parent and the
       * beginning of the box, but no more than 5 pixels (it would be too
       * far and be confusing otherwise).
       */
      if (epIndex > 0) {
        // Need to determine if a line break.
        Rectangle boxPrev = transposer
            .t(getAbsoluteBounds((GraphicalEditPart) getHost()
                .getChildren().get(epIndex - 1)));
        int prevRight = boxPrev.right();
        if (prevRight < r.x) {
          // Not a line break
          x = prevRight + (r.x - prevRight) / 2;
        } else if (prevRight == r.x) {
          x = prevRight + 1;
        }
      }
      if (x == Integer.MIN_VALUE) {
        // It is a line break.
        Rectangle parentBox = transposer
            .t(getAbsoluteBounds((GraphicalEditPart) getHost()));
        x = r.x - 5;
        if (x < parentBox.x)
          x = parentBox.x + (r.x - parentBox.x) / 2;
      }
    } else {
      /*
       * We only have before==false if we are at the end of a line, so go
       * halfway between the right edge and the right edge of the parent,
       * but no more than 5 pixels.
       */
      Rectangle parentBox = transposer
          .t(getAbsoluteBounds((GraphicalEditPart) getHost()));
      int rRight = r.x + r.width;
      int pRight = parentBox.x + parentBox.width;
      x = rRight + 5;
      if (x > pRight)
        x = rRight + (pRight - rRight) / 2;
    }
    Point p1 = new Point(x, r.y);
    p1 = transposer.t(p1);
    fb.translateToRelative(p1);
    Point p2 = new Point(x, r.y + r.height);
    p2 = transposer.t(p2);
    fb.translateToRelative(p2);
    fb.setPoint(p1, 0);
    fb.setPoint(p2, 1);
  }
View Full Code Here

TOP

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

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.