protected void showChangeBoundsFeedback(ChangeBoundsRequest request) {
    IFigure feedback = getDragSourceFeedbackFigure();

    PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy());
    getHostFigure().translateToAbsolute(rect);
    rect.translate(request.getMoveDelta());
    rect.resize(request.getSizeDelta());

    IFigure f = getHostFigure();
    Dimension min = f.getMinimumSize().getCopy();
    Dimension max = f.getMaximumSize().getCopy();
    IMapMode mmode = MapModeUtil.getMapMode(f);
    min.height = mmode.LPtoDP(min.height);
    min.width = mmode.LPtoDP(min.width);
    max.height = mmode.LPtoDP(max.height);
    max.width = mmode.LPtoDP(max.width);

    if (min.width > rect.width) rect.width = min.width;
    else if (max.width < rect.width) rect.width = max.width;

    if (min.height > rect.height) rect.height = min.height;
    else if (max.height < rect.height) rect.height = max.height;

    feedback.translateToRelative(rect);
    feedback.setBounds(rect);
  }
Ejemplo n.º 2
0
  @SuppressWarnings("rawtypes")
  public void layout(IFigure parent) {
    Rectangle relativeArea = parent.getClientArea();
    constrainedData.area = transposer.t(relativeArea);

    // parent may not be set yet
    if (relativeArea.width == 0) return;

    Iterator iterator = parent.getChildren().iterator();
    int dx;

    initVariables(parent);
    initRow();
    int i = 0;
    while (iterator.hasNext()) {
      IFigure f = (IFigure) iterator.next();

      Rectangle bounds = getConstraint(f);

      // -- There is a constraint, process width and height
      int widthHint = bounds.width;
      int heightHint = bounds.height;
      if (widthHint == -1 || heightHint == -1) {
        Dimension _preferredSize = f.getPreferredSize(widthHint, heightHint);
        bounds = bounds.getCopy();
        if (widthHint == -1) bounds.width = _preferredSize.width;
        if (heightHint == -1) bounds.height = _preferredSize.height;
      }
      Dimension min = f.getMinimumSize(widthHint, heightHint);
      Dimension max = f.getMaximumSize();

      if (min.width > bounds.width) bounds.width = min.width;
      else if (max.width < bounds.width) bounds.width = max.width;

      if (min.height > bounds.height) bounds.height = min.height;
      else if (max.height < bounds.height) bounds.height = max.height;

      Rectangle r = new Rectangle(0, 0, bounds.width, bounds.height);

      if (constrainedData.rowCount > 0) {
        if (constrainedData.rowWidth + bounds.width > constrainedData.maxWidth) layoutRow(parent);
      }
      r.x = constrainedData.rowX;
      r.y = constrainedData.rowY;
      dx = r.width + getMinorSpacing();
      constrainedData.rowX += dx;
      constrainedData.rowWidth += dx;
      constrainedData.rowHeight = Math.max(constrainedData.rowHeight, r.height);
      constrainedData.row[constrainedData.rowCount] = f;
      constrainedData.bounds[constrainedData.rowCount] = r;
      constrainedData.rowCount++;
      i++;
    }
    if (constrainedData.rowCount != 0) layoutRow(parent);
    totalHeight = constrainedData.rowY;
    constrainedData.rowY = 0;
  }
  protected void showChangeBoundsFeedback(ChangeBoundsRequest request) {
    IFigure feedback = getDragSourceFeedbackFigure();

    PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy());
    getHostFigure().translateToAbsolute(rect);

    // Only enable horizontal dragging on lifelines(except lifelines that are result of a create
    // message).
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=364688
    if (this.getHost() instanceof LifelineEditPart) {
      LifelineEditPart lifelineEP = (LifelineEditPart) this.getHost();
      if (!SequenceUtil.isCreateMessageEndLifeline(lifelineEP)) {
        request.getMoveDelta().y = 0;
      }
    }

    rect.translate(request.getMoveDelta());
    rect.resize(request.getSizeDelta());

    IFigure f = getHostFigure();
    Dimension min = f.getMinimumSize().getCopy();
    Dimension max = f.getMaximumSize().getCopy();
    IMapMode mmode = MapModeUtil.getMapMode(f);
    min.height = mmode.LPtoDP(min.height);
    min.width = mmode.LPtoDP(min.width);
    max.height = mmode.LPtoDP(max.height);
    max.width = mmode.LPtoDP(max.width);

    if (min.width > rect.width) rect.width = min.width;
    else if (max.width < rect.width) rect.width = max.width;

    if (min.height > rect.height) rect.height = min.height;
    else if (max.height < rect.height) rect.height = max.height;

    feedback.translateToRelative(rect);
    feedback.setBounds(rect);
  }
  @Override
  public void layout(IFigure parent) {
    List children = parent.getChildren();
    int numChildren = children.size();
    Rectangle clientArea = transposer.t(parent.getClientArea());
    int x = clientArea.x;
    int y = clientArea.y;
    int availableHeight = clientArea.height;

    Dimension prefSizes[] = new Dimension[numChildren];
    Dimension minSizes[] = new Dimension[numChildren];

    int wHint = -1;
    int hHint = -1;
    if (isHorizontal()) {
      hHint = parent.getClientArea(Rectangle.SINGLETON).height;
    } else {
      wHint = parent.getClientArea(Rectangle.SINGLETON).width;
    }
    IFigure child;
    int totalHeight = 0;
    int totalMinHeight = 0;
    int prefMinSumHeight = 0;

    for (int i = 0; i < numChildren; i++) {
      child = (IFigure) children.get(i);

      prefSizes[i] = transposer.t(getChildPreferredSize(child, wHint, hHint));
      minSizes[i] = transposer.t(getChildMinimumSize(child, wHint, hHint));

      totalHeight += prefSizes[i].height;
      totalMinHeight += minSizes[i].height;
    }
    totalHeight += (numChildren - 1) * spacing;
    totalMinHeight += (numChildren - 1) * spacing;
    prefMinSumHeight = totalHeight - totalMinHeight;

    int amntShrinkHeight = totalHeight - Math.max(availableHeight, totalMinHeight);

    if (amntShrinkHeight < 0) {
      amntShrinkHeight = 0;
    }

    for (int i = 0; i < numChildren; i++) {
      int amntShrinkCurrentHeight = 0;
      int prefHeight = prefSizes[i].height;
      int minHeight = minSizes[i].height;
      int prefWidth = prefSizes[i].width;
      int minWidth = minSizes[i].width;
      Rectangle newBounds = new Rectangle(x, y, prefWidth, prefHeight);

      child = (IFigure) children.get(i);
      if (child instanceof AbstractTreeSettingContainer) {
        if (!tableMananger.isActivateCondensedTool()) {
          child.setBounds(new Rectangle(x, y, 0, 0));
          continue;
        }
      }

      if (child instanceof FilterContainer) {
        if (!tableMananger.isActivateExpressionFilter()) {
          child.setBounds(new Rectangle(x, y, 0, 0));
          continue;
        }
      }

      if (child instanceof AbstractGlobalMapContainer) {
        if (!tableMananger.isActivateGlobalMap()) {
          child.setBounds(new Rectangle(x, y, 0, 0));
          continue;
        }
      }

      int width = Math.min(prefWidth, transposer.t(child.getMaximumSize()).width);
      if (matchWidth) {
        width = transposer.t(child.getMaximumSize()).width;
      }
      width = Math.max(minWidth, Math.min(clientArea.width, width));
      newBounds.width = width;

      child.setBounds(transposer.t(newBounds));

      amntShrinkHeight -= amntShrinkCurrentHeight;
      prefMinSumHeight -= (prefHeight - minHeight);
      y += newBounds.height + spacing;

      if (child instanceof ScrollPane) {
        IFigure contents = ((ScrollPane) child).getViewport().getContents();
        if (contents instanceof AbstractTable) {
          // ((AbstractTable) contents).setDefautTableWidth(newBounds.width);
        }
      }
    }
  }