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
  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);
  }