示例#1
0
  public void draw(MiRenderer renderer) {
    if (!isVisible()) return;

    if (graphics != null) {
      graphics.draw(renderer);
    } else if (strValue != null) {
      renderer.setAttributes(attributes);
      renderer.drawText(strValue, innerBounds, attributes.getFont());
    }
  }
示例#2
0
  // Of graphics...
  public MiSize getPreferredSize(MiSize size) {
    if (graphics != null) {
      graphics.getPreferredSize(size);
    } else if (attributes != null) {
      attributes.getFont().getSize(strValue, size);
    } else {
      table.getAttributes().getFont().getSize(strValue, size);
    }
    if (insetMargins != null) size.addMargins(insetMargins);
    if (margins != null) size.addMargins(margins);

    return (size);
  }
示例#3
0
  protected void layoutParts(int h_sizing, int v_sizing, int h_justification, int v_justification) {
    if (graphics != null) graphics.getPreferredSize(tmpSize);
    else if (strValue != null) attributes.getFont().getSize(strValue, tmpSize);
    else tmpSize.zeroOut();

    MiBounds cellBounds = MiBounds.newBounds();
    cellBounds.setSize(tmpSize);
    MiBounds theInnerBounds = tmpBounds;
    theInnerBounds.copy(innerBounds);
    if (margins != null) theInnerBounds.subtractMargins(margins);
    cellBounds.setCenterX(theInnerBounds.getCenterX());
    cellBounds.setCenterY(theInnerBounds.getCenterY());
    switch (h_sizing) {
      case Mi_EXPAND_TO_FILL:
        cellBounds.setWidth(theInnerBounds.getWidth());
        break;
      case Mi_SAME_SIZE:
        cellBounds.setWidth(theInnerBounds.getWidth());
        break;
      case Mi_NONE:
      default:
        break;
    }

    switch (v_sizing) {
      case Mi_EXPAND_TO_FILL:
        cellBounds.setHeight(theInnerBounds.getHeight());
        break;
      case Mi_SAME_SIZE:
        cellBounds.setHeight(theInnerBounds.getHeight());
        break;
      case Mi_NONE:
      default:
        break;
    }
    switch (h_justification) {
      case Mi_JUSTIFIED:
      case Mi_CENTER_JUSTIFIED:
      case Mi_NONE:
        cellBounds.setCenterX(theInnerBounds.getCenterX());
        break;
      case Mi_LEFT_JUSTIFIED:
        cellBounds.translateXminTo(theInnerBounds.getXmin());
        break;
      case Mi_RIGHT_JUSTIFIED:
        cellBounds.translateXmaxTo(theInnerBounds.getXmax());
        break;
    }

    switch (v_justification) {
      case Mi_JUSTIFIED:
      case Mi_CENTER_JUSTIFIED:
      case Mi_NONE:
        cellBounds.setCenterY(theInnerBounds.getCenterY());
        break;
      case Mi_BOTTOM_JUSTIFIED:
        cellBounds.translateYminTo(theInnerBounds.getYmin());
        break;
      case Mi_TOP_JUSTIFIED:
        cellBounds.translateYmaxTo(theInnerBounds.getYmax());
        break;
    }

    if (graphics != null) {
      graphics.setBounds(cellBounds);
      if (!graphics.hasValidLayout()) {
        graphics.validateLayout();
      }
    } else {
      innerBounds.copy(cellBounds);
    }
    MiBounds.freeBounds(cellBounds);
  }