Ejemplo n.º 1
0
  // Return true if bounds of point extend beyond point
  public boolean getLineEndBounds(MiPart obj, MiBounds b, boolean start) {
    if (!(obj instanceof MiMultiPointShape)) return (false);

    MiAttributes attributes = obj.getAttributes();
    boolean changed = false;
    boolean styleExtendsBeyondEndOfLine = false;

    MiDistance size = 0;
    if (start) {
      int style = attributes.getLineStartStyle();
      if (style != Mi_NONE) {
        size = attributes.getLineStartSize();
        if (attributes.getLineEndsSizeFnOfLineWidth()) size += attributes.getLineWidth();

        styleExtendsBeyondEndOfLine |= stylesExtendsBeyondEndOfLine[style];
        changed = true;
        obj.getPoint(0, tmpPoint);
        b.setBounds(tmpPoint);
      }
    } else {
      int style = attributes.getLineEndStyle();
      if (style != Mi_NONE) {
        size = attributes.getLineEndSize();
        if (attributes.getLineEndsSizeFnOfLineWidth()) size += attributes.getLineWidth();

        styleExtendsBeyondEndOfLine |= stylesExtendsBeyondEndOfLine[style];
        changed = true;
        obj.getPoint(-1, tmpPoint);
        b.setBounds(tmpPoint);
      }
    }
    if (changed) {
      MiMultiPointShape shape = (MiMultiPointShape) obj;

      if (styleExtendsBeyondEndOfLine) {
        b.addMargins(size);
      } else if (shape.isVertical()) {
        b.setXmin(b.getXmin() - size);
        b.setXmax(b.getXmax() + size);
      } else if (shape.isHorizontal()) {
        b.setYmin(b.getYmin() - size);
        b.setYmax(b.getYmax() + size);
      } else {
        b.addMargins(size);
      }
    }

    return (changed);
  }
Ejemplo n.º 2
0
 /**
  * ------------------------------------------------------ Constructs a new MiVisibleContainer.
  * ------------------------------------------------------
  */
 public MiVisibleContainer() {
   setInsetMargins(4);
   MiBounds tmpBounds = MiBounds.newBounds();
   tmpBounds.zeroOut();
   tmpBounds.addMargins(getInsetMargins(tmpMargins));
   replaceBounds(tmpBounds);
   setTarget(this);
   setBorderLook(Mi_NONE);
   MiBounds.freeBounds(tmpBounds);
 }
Ejemplo n.º 3
0
  /**
   * ------------------------------------------------------ Realculates the outer bounds of this
   * container.
   *
   * @param bounds the (returned) outer bounds
   *     ------------------------------------------------------
   */
  protected void reCalcBounds(MiBounds bounds) {
    getBounds(bounds);

    if (!autoLayoutEnabled) {
      return;
    }

    MiBounds contents = MiBounds.newBounds();
    MiMargins insetMargins = getInsetMargins();
    MiMargins cellMargins = getCellMargins();

    super.reCalcBounds(contents);
    if (contents.isReversed()) {
      contents.copy(bounds);
      if (contents.isReversed()) {
        contents.setBounds(0, 0, 0, 0);
        contents.addMargins(insetMargins);
        contents.addMargins(cellMargins);
        contents.addMargins(getMargins(tmpMargins));
      } else if ((contents.getWidth()
              < insetMargins.getWidth()
                  + getMargins(tmpMargins).getWidth()
                  + cellMargins.getWidth())
          || (contents.getHeight()
              < insetMargins.getHeight()
                  + getMargins(tmpMargins).getHeight()
                  + cellMargins.getHeight())) {
        contents.setWidth(
            insetMargins.getWidth() + getMargins(tmpMargins).getWidth() + cellMargins.getWidth());
        contents.setHeight(
            insetMargins.getHeight()
                + getMargins(tmpMargins).getHeight()
                + cellMargins.getHeight());
      }
      bounds.copy(contents);
    } else {
      // SUPER CLASS DOES THIS contents.addMargins(insetMargins);
      contents.addMargins(cellMargins);
      // SUPER CLASS DOES THIS contents.addMargins(getMargins(tmpMargins));
    }

    if ((autoLayoutRule == MAKE_CONTAINER_SAME_SIZE_AS_CONTENTS)) {
      bounds.copy(contents);
    } else if ((autoLayoutRule == MAKE_CONTAINER_SAME_SIZE_OR_BIGGER_THAN_CONTENTS)) {
      if (!contents.isContainedIn(bounds)) bounds.copy(contents);
    } else if ((autoLayoutRule
        == MAKE_CONTAINER_SAME_SIZE_AS_CONTENTS_OR_OVERRIDDEN_PREFERRED_SIZE)) {
      bounds.copy(contents);
      if (hasOverriddenPreferredSize()) {
        bounds.setSize(getPreferredSize(new MiSize()));
      }
    }

    if (hasFixedWidthOrHeight) {
      getBounds(contents);

      if (hasFixedWidth()) {
        bounds.xmin = contents.xmin;
        bounds.xmax = contents.xmax;
      }
      if (hasFixedHeight()) {
        bounds.ymin = contents.ymin;
        bounds.ymax = contents.ymax;
      }
    }
    MiBounds.freeBounds(contents);
  }