Package com.lowagie.text

Examples of com.lowagie.text.Rectangle


      Color fontColor = Color.black;
      if (labelType.getFontStyle() != null) {
        fontColor = context
            .getColor(labelType.getFontStyle().getColor(), labelType.getFontStyle().getOpacity());
      }
      Rectangle rect = calculateLabelRect(context, f, label, font);
      Color bgColor = Color.white;
      if (labelType.getBackgroundStyle() != null) {
        bgColor = context.getColor(labelType.getBackgroundStyle().getFillColor(), labelType
            .getBackgroundStyle().getFillOpacity());
      }
      context.fillRoundRectangle(rect, bgColor, 3);
      Color borderColor = Color.black;
      if (labelType.getBackgroundStyle() != null) {
        borderColor = context.getColor(labelType.getBackgroundStyle().getStrokeColor(), labelType
            .getBackgroundStyle().getStrokeOpacity());
      }
      float linewidth = 0.5f;
      if (labelType.getBackgroundStyle() != null) {
        linewidth = labelType.getBackgroundStyle().getStrokeWidth();
      }
      context.strokeRoundRectangle(rect, borderColor, linewidth, 3);
      context.drawText(label, font, rect, fontColor);
      if (f.getGeometry() instanceof Point) {
        context.drawLine(0.5f * (rect.getLeft() + rect.getRight()), rect.getBottom(),
            0.5f * (rect.getLeft() + rect.getRight()), rect.getBottom() - SYMBOL_CONNECT_LENGTH,
            borderColor, linewidth);
      }
    }
  }
View Full Code Here


      return info.getRect().getH();
    }
  }

  private Rectangle calculateLabelRect(PdfContext context, InternalFeature f, String label, Font font) {
    Rectangle textSize = context.getTextSize(label, font);
    float margin = 0.25f * font.getSize();
    Rectangle rect = new Rectangle(textSize.getWidth() + 2 * margin, textSize.getHeight() + 2 * margin);
    Coordinate labelPosition = geoService.calcDefaultLabelPosition(f);
    context.moveRectangleTo(rect, (float) labelPosition.x - rect.getWidth() / 2f,
        (float) labelPosition.y - rect.getHeight() / 2f);
    if (f.getGeometry() instanceof Point) {
      float shiftHeight = 0.5f * (rect.getHeight() + getSymbolHeight(f));
      // move up 15 pixels to make the symbol visible
      context.moveRectangleTo(rect, rect.getLeft(), rect.getBottom() + shiftHeight + SYMBOL_CONNECT_LENGTH);
    }
    if (rect.getLeft() < 0) {
      context.moveRectangleTo(rect, 10, rect.getBottom());
    }
    if (rect.getBottom() < 0) {
      context.moveRectangleTo(rect, rect.getLeft(), 10);
    }
    if (rect.getTop() > getBounds().getHeight()) {
      context.moveRectangleTo(rect, rect.getLeft(), getBounds().getHeight() - rect.getHeight() - 10);
    }
    if (rect.getRight() > getBounds().getWidth()) {
      context.moveRectangleTo(rect, getBounds().getWidth() - rect.getWidth() - 10, rect.getBottom());
    }
    return rect;
  }
View Full Code Here

      }
    }
  }

  private float getPageSizeRelativeToA3(PrintGetTemplateRequest request) {
    Rectangle r;
    if (request.getPageSize() != null) {
      r = PageSize.getRectangle(request.getPageSize());
    } else {
      float width = request.getTemplate().getPage().getLayoutConstraint().getWidth();
      float height = request.getTemplate().getPage().getLayoutConstraint().getHeight();
      r = new Rectangle(0, 0, width, height);
    }
    return (r.getWidth() / PageSize.A3.getWidth() + r.getHeight() / PageSize.A3.getHeight()) / 2;
  }
View Full Code Here

    float textWidth = template.getEffectiveStringWidth(text, false);
    float ascent = bf.getAscentPoint(text, font.getSize());
    float descent = bf.getDescentPoint(text, font.getSize());
    float textHeight = ascent - descent;
    template.restoreState();
    return new Rectangle(0, 0, textWidth, textHeight);
  }
View Full Code Here

    if (text != null) {
      descent = bf.getDescentPoint(text, font.getSize());
    }

    // calculate the fitting size
    Rectangle fit = getTextSize(text, font);

    // draw text if necessary
    template.setColorFill(fontColor);
    template.beginText();
    template.showTextAligned(PdfContentByte.ALIGN_LEFT, text, origX + box.getLeft() + 0.5f
        * (box.getWidth() - fit.getWidth()), origY + box.getBottom() + 0.5f
        * (box.getHeight() - fit.getHeight()) - descent, 0);
    template.endText();
    template.restoreState();
  }
View Full Code Here

    }
    float left = Float.parseFloat(st.nextToken());
    float bottom = Float.parseFloat(st.nextToken());
    float right = Float.parseFloat(st.nextToken());
    float top = Float.parseFloat(st.nextToken());
    return new Rectangle(left, bottom, right, top);
  }
View Full Code Here

    return new Rectangle(left, bottom, right, top);
  }

  @Override
  public String toString(Object obj) {
    Rectangle rectangle = (Rectangle) obj;
    if (obj == null) {
      return null;
    }
    return rectangle.getLeft() + "," + rectangle.getBottom() + "," + rectangle.getRight() + ","
        + rectangle.getTop();
  }
View Full Code Here

   *
   * @param rect absolute rectangle
   * @return relative rectangle
   */
  public Rectangle toRelative(Rectangle rect) {
    return new Rectangle(rect.getLeft() - origX, rect.getBottom() - origY, rect.getRight() - origX, rect.getTop()
        - origY);
  }
View Full Code Here

      tickSizes.add(context.getTextSize(label, font));
    }

    // Calculate size
    width = ticWidth * ticCount;
    Rectangle first = context.getTextSize(tickLabels.get(0), font);
    Rectangle last = context.getTextSize(tickLabels.get(ticCount), font);
    width += 0.5 * first.getWidth();
    width += 0.5 * last.getWidth();
    float height = ticHeight;
    height += first.getHeight();
    setBounds(new Rectangle(0, 0, width, height));
  }
View Full Code Here

    // draw the tics
    float lowX = 0.5f * tickSizes.get(0).getWidth();
    float lowY = 0;
    float highX = lowX;
    float highY = 0.333f * ticHeight;
    Rectangle baseRect = new Rectangle(0, 0, ticWidth, 0.333f * ticHeight);

    // fills
    for (int i = 0; i < ticNumber; i++) {
      if (i % 2 == 0) {
        context.moveRectangleTo(baseRect, lowX, lowY);
        context.fillRectangle(baseRect, Color.white);
        context.strokeRectangle(baseRect, Color.black, 0.5f);
        context.moveRectangleTo(baseRect, highX, highY);
        context.fillRectangle(baseRect, Color.black);
        context.strokeRectangle(baseRect, Color.black, 0.5f);
      } else {
        context.moveRectangleTo(baseRect, highX, highY);
        context.fillRectangle(baseRect, Color.white);
        context.strokeRectangle(baseRect, Color.black, 0.5f);
        context.moveRectangleTo(baseRect, lowX, lowY);
        context.fillRectangle(baseRect, Color.black);
        context.strokeRectangle(baseRect, Color.black, 0.5f);
      }
      lowX += ticWidth;
      highX += ticWidth;
    }

    // tick extensions
    highX = 0.5f * tickSizes.get(0).getWidth();
    highY = 0.6666f * ticHeight;
    for (int i = 0; i <= ticNumber; i++) {
      context.drawRelativePath(new float[] { 0, 0 }, new float[] { 0, 1 }, new Rectangle(highX, highY, highX,
          0.75f * ticHeight), Color.black, 0.5f, null);
      highX += ticWidth;
    }

    // position and print the labels
    float labelX = 0.5f * tickSizes.get(0).getWidth();
    float labelY = ticHeight;
    for (int i = 0; i < tickLabels.size(); i++) {
      Rectangle box = tickSizes.get(i);
      // center the label
      context.moveRectangleTo(box, labelX - 0.5f * box.getWidth(), labelY);
      context.drawText(tickLabels.get(i), font, box, Color.black);
      labelX += ticWidth;
    }
  }
View Full Code Here

TOP

Related Classes of com.lowagie.text.Rectangle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.