示例#1
0
  /**
   * Sets the bounds, but the size will be at least the one returned by {@link #getMinimumSize()},
   * unless checking of size is disabled.
   *
   * <p>If the required height is bigger, then the additional height is equally distributed among
   * all figs (i.e. compartments), such that the cumulated height of all visible figs equals the
   * demanded height
   *
   * <p>.
   *
   * <p>Some of this has "magic numbers" hardcoded in. In particular there is a knowledge that the
   * minimum height of a name compartment is 21 pixels.
   *
   * <p>
   *
   * @param x Desired X coordinate of upper left corner
   * @param y Desired Y coordinate of upper left corner
   * @param w Desired width of the FigClass
   * @param h Desired height of the FigClass
   */
  protected void setBoundsImpl(final int x, final int y, final int w, final int h) {
    Rectangle oldBounds = getBounds();

    // set bounds of big box
    getBigPort().setBounds(x, y, w, h);
    borderFig.setBounds(x, y, w, h);

    // Save our old boundaries (needed later), and get minimum size
    // info. "whitespace" will be used to maintain a running calculation of our
    // size at various points.

    final int whitespace = h - getMinimumSize().height;

    getNameFig().setLineWidth(0);
    getNameFig().setLineColor(Color.red);
    int currentHeight = 0;

    if (getStereotypeFig().isVisible()) {
      int stereotypeHeight = getStereotypeFig().getMinimumSize().height;
      getStereotypeFig().setBounds(x, y, w, stereotypeHeight);
      currentHeight = stereotypeHeight;
    }

    int nameHeight = getNameFig().getMinimumSize().height;
    getNameFig().setBounds(x, y + currentHeight, w, nameHeight);
    currentHeight += nameHeight;

    if (isAttributesVisible()) {
      int attributesHeight = getAttributesFig().getMinimumSize().height;
      if (isOperationsVisible()) {
        attributesHeight += whitespace / 2;
      }
      getAttributesFig().setBounds(x, y + currentHeight, w, attributesHeight);
      currentHeight += attributesHeight;
    }

    if (isOperationsVisible()) {
      int operationsY = y + currentHeight;
      int operationsHeight = (h + y) - operationsY - 1;
      if (operationsHeight < getOperationsFig().getMinimumSize().height) {
        operationsHeight = getOperationsFig().getMinimumSize().height;
      }
      getOperationsFig().setBounds(x, operationsY, w, operationsHeight);
    }

    // Now force calculation of the bounds of the figure, update the edges
    // and trigger anyone who's listening to see if the "bounds" property
    // has changed.

    calcBounds();
    updateEdges();
    firePropChange("bounds", oldBounds, getBounds());
  }
示例#2
0
  /*
   * @see org.tigris.gef.presentation.Fig#setBoundsImpl(int, int, int, int)
   */
  @Override
  protected void setBoundsImpl(int x, int y, int w, int h) {
    int newW = w;
    int newH = h;

    int fw;
    int yy = y;
    for (Fig fig : (Collection<Fig>) getFigs()) {
      if (fig.isVisible() && fig != getBigPort()) {
        fw = fig.getMinimumSize().width;
        // set new bounds for all included figs
        fig.setBounds(x + 1, yy + 1, fw, fig.getMinimumSize().height);
        if (newW < fw + 2) {
          newW = fw + 2;
        }
        yy += fig.getMinimumSize().height;
      }
    }
    getBigPort().setBounds(x, y, newW, newH);
    calcBounds();
  }
示例#3
0
  /**
   * Change the bounds of the target fig. Called whenever the bounds box is edited.
   *
   * <p>Format of the bounds is four integers representing x, y, width and height separated by
   * spaces or commas. An empty field is treated as no change and leading and trailing spaces are
   * ignored.
   *
   * <p><em>Note</em>. There is a note in the old code that more work might be needed, because this
   * could change the graph model. I don't see how that could ever be.
   */
  protected void setTargetBBox() {
    Fig target = getPanelTarget();
    // Can't do anything if we don't have a fig.
    if (target == null) {
      return;
    }
    // Parse the boundary box text. Null is
    // returned if it is empty or
    // invalid, which causes no change. Otherwise we tell
    // GEF we are making
    // a change, make the change and tell GEF we've
    // finished.
    Rectangle bounds = parseBBox();
    if (bounds == null) {
      return;
    }

    if (!target.getBounds().equals(bounds)) {
      target.setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
      target.endTrans();
    }
  }