Esempio 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);
  }
Esempio n. 2
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());
    }
  }
Esempio n. 3
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);
  }
Esempio n. 4
0
  public boolean render(MiPart obj, MiRenderer renderer) {
    if (!enabled) return (true);

    if (!(obj instanceof MiMultiPointShape)) return (true);

    MiDistance size;
    MiAttributes attributes = obj.getAttributes();
    Graphics g = renderer.getWindowSystemRenderer();
    MiPoint basePoint = new MiPoint();
    MiPoint endPoint = new MiPoint();

    // FIX: if line length < lineEndSize then exit

    int style = attributes.getLineStartStyle();
    int lwidth = renderer.getLineWidth();
    Color color;
    Color fillColor;
    if (useTargetObjectAttributes) color = attributes.getColor();
    else color = getAttributes().getColor();

    if (useTargetObjectAttributes) fillColor = attributes.getBackgroundColor();
    else fillColor = getAttributes().getBackgroundColor();

    if (style != Mi_NONE) {
      size = attributes.getLineStartSize();
      if (attributes.getLineEndsSizeFnOfLineWidth()) size += attributes.getLineWidth();

      double exitAngle = obj.getPointExitAngle(0) + Math.PI;
      obj.getPoint(0, basePoint);
      calcNewLineEndPoint(renderer, exitAngle, style, size, basePoint);
      obj.getPoint(0, endPoint);
      renderLineEnd(
          renderer, exitAngle, style, size, basePoint, endPoint, lwidth, color, fillColor);
    }
    style = attributes.getLineEndStyle();
    if (style != Mi_NONE) {
      size = attributes.getLineEndSize();
      if (attributes.getLineEndsSizeFnOfLineWidth()) size += attributes.getLineWidth();

      double entryAngle = obj.getPointEntryAngle(-1);
      obj.getPoint(-1, basePoint);
      calcNewLineEndPoint(renderer, entryAngle, style, size, basePoint);
      g.setColor(attributes.getColor());
      obj.getPoint(-1, endPoint);
      renderLineEnd(
          renderer, entryAngle, style, size, basePoint, endPoint, lwidth, color, fillColor);
    }
    return (true);
  }
Esempio n. 5
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);
  }
Esempio n. 6
0
 public void setColor(Color color) {
   if (graphics != null) graphics.setColor(color);
   else attributes = attributes.setColor(color);
 }
Esempio n. 7
0
 public Color getColor() {
   if (graphics != null) return (graphics.getColor());
   return (attributes.getColor());
 }
Esempio n. 8
0
 public MiiHelpInfo getToolHintHelp(MiPoint point) {
   return (attributes.getToolHintHelp());
 }
Esempio n. 9
0
 public void setToolHintHelp(MiiHelpInfo helpInfo) {
   this.attributes = attributes.setToolHintHelp(helpInfo);
 }
Esempio n. 10
0
 public MiiHelpInfo getStatusHelp(MiPoint point) {
   return (attributes.getStatusHelp());
 }
Esempio n. 11
0
 public void setStatusHelp(MiiHelpInfo helpInfo) {
   this.attributes = attributes.setStatusHelp(helpInfo);
 }
Esempio n. 12
0
 public MiiContextMenu getContextMenu(MiBounds area) {
   if ((graphics != null) && (graphics.getContextMenu(area) != null)) {
     return (graphics.getContextMenu(area));
   }
   return (attributes.getContextMenu());
 }