コード例 #1
0
    @Override
    public void relocate(IFigure target) {
      Rectangle bounds;
      if (reference instanceof HandleBounds) {
        bounds = new PrecisionRectangle(((HandleBounds) reference).getHandleBounds());
      } else {
        bounds = new PrecisionRectangle(reference.getBounds());
        // authorized rectangle without handle bounds is smaller: if the icon would be exactly on
        // one of the corners,
        // it would trigger an enlargement of the figure, followed by a reposition, i.e. an endless
        // loop.
        bounds.x++;
        bounds.y++;
        bounds.width -= 2;
        bounds.height -= 2;
      }

      reference.translateToAbsolute(bounds);
      target.translateToRelative(bounds);

      Point pTR = bounds.getTopRight();
      Point pTL = bounds.getTopLeft();
      Point pDecoration = new Point(pTR);

      int decorationX = pTR.x - target.getSize().width - rightMargin;
      if (decorationX > pTL.x) {
        // only set position, if it is inside the figure, i.e. bigger than left margin
        pDecoration.setX(decorationX);
      } else {
        pDecoration.setX(pTL.x);
      }
      target.setLocation(pDecoration);
    }
コード例 #2
0
ファイル: EllipseBorder.java プロジェクト: ReEng/sdm-commons
  public Insets getInsets(IFigure figure) {
    Dimension size = figure.getSize();
    int semiMajorAxis = (int) Math.ceil(size.width / 2.0);
    int semiMinorAxis = (int) Math.ceil(size.height / 2.0);

    int linearEccentricity =
        (int) Math.ceil(Math.sqrt(semiMajorAxis * semiMajorAxis - semiMinorAxis * semiMinorAxis));
    int left = semiMajorAxis - linearEccentricity;

    int semiLatusRectum = (int) Math.ceil((semiMinorAxis * semiMinorAxis) / semiMajorAxis);
    int top = semiMinorAxis - semiLatusRectum;

    return new Insets(top, left, top, left);
  }
コード例 #3
0
  /**
   * @param node a node
   * @return the size of the figure associated to this node
   */
  private Dimension getFigureSize(AbstractNode node) {

    IFigure fig = this.nodeToFigure.get(node);
    int width, height;
    if (fig != null) {
      width = fig.getSize().width;
      height = fig.getSize().height;

    } else {
      width = GRID_CELL_DEFAULT_WIDTH;
      ;
      height = GRID_CELL_DEFAULT_HEIGHT;
      PetalsEipPlugin.log(
          "No figure was found for the node "
              + node.getId()
              + " (EIP chain: "
              + node.getEipChain().getTitle()
              + " ).",
          IStatus.ERROR);
    }

    return new Dimension(width, height);
  }
コード例 #4
0
 /*
  * (non-Javadoc)
  *
  * @see org.xmind.ui.tools.DummyCreateTool#doCreateDummy()
  */
 protected IFigure doCreateDummy() {
   if (branchDummy == null) {
     branchDummy = new BranchDummy(getTargetViewer(), true);
     branchDummy.getTopic().setTitleText(MindMapMessages.TitleText_FloatingTopic);
     pack();
   }
   IFigure figure = branchDummy.getBranch().getFigure();
   if (getCursorPosition() != null) {
     if (figure instanceof IReferencedFigure) {
       ((IReferencedFigure) figure).setReference(getCursorPosition());
     } else {
       Dimension size = figure.getSize();
       figure.setLocation(getCursorPosition().getTranslated(-size.width / 2, -size.height / 2));
     }
   }
   return figure;
 }