Package java.awt.geom

Examples of java.awt.geom.Rectangle2D


    {
      return;
    }

    graphics2D.setColor(Color.RED);
    final Rectangle2D dataArea = getDataAreaOffset();
    final EntityCollection entityCollection = chartRenderingInfo.getEntityCollection();
    for (int i = 0; i < entityCollection.getEntityCount(); i++)
    {
      final ChartEntity chartEntity = entityCollection.getEntity(i);
      if (chartEntity instanceof XYItemEntity ||
          chartEntity instanceof CategoryItemEntity ||
          chartEntity instanceof PieSectionEntity)
      {
        final Area a = new Area(chartEntity.getArea());
        if (buggyDrawArea)
        {
          a.transform(AffineTransform.getTranslateInstance(dataArea.getX(), dataArea.getY()));
        }
        a.intersect(new Area(dataArea));
        graphics2D.draw(a);
      }
      else
View Full Code Here


  {
    if (chartRenderingInfo == null)
    {
      return null;
    }
    final Rectangle2D dataArea = getDataAreaOffset();
    final Rectangle2D otherArea = new Rectangle2D.Double();

    if ((ObjectUtilities.equal(bounds, this.bounds)) == false)
    {
      final BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR);
      final Graphics2D graphics = image.createGraphics();
View Full Code Here

              (float) (ellipse2D.getCenterY() + dataArea.getY()), (float) (ellipse2D.getWidth() / 2));
        }
      }
      else if (area instanceof Rectangle2D)
      {
        final Rectangle2D rect = (Rectangle2D) area;
        return (new RectangleImageMapEntry((float) (rect.getX() + dataArea.getX()),
            (float) (rect.getY() + dataArea.getY()),
            (float) (rect.getX() + rect.getWidth()),
            (float) (rect.getY() + rect.getHeight())));
      }
    }
    else
    {
      if (area instanceof Ellipse2D)
      {
        final Ellipse2D ellipse2D = (Ellipse2D) area;
        if (ellipse2D.getWidth() == ellipse2D.getHeight())
        {
          return new CircleImageMapEntry((float) (ellipse2D.getCenterX()),
              (float) (ellipse2D.getCenterY()), (float) (ellipse2D.getWidth() / 2));
        }
      }
      else if (area instanceof Rectangle2D)
      {
        final Rectangle2D rect = (Rectangle2D) area;
        return (new RectangleImageMapEntry((float) (rect.getX()),
            (float) (rect.getY()),
            (float) (rect.getX() + rect.getWidth()),
            (float) (rect.getY() + rect.getHeight())));
      }
    }

    final Area a = new Area(area);
    if (buggyDrawArea)
View Full Code Here

    // The code below may be weird, but at least it is predictable weird.
    final ExtendedBaselineInfo baselineInfo = renderableText.getBaselineInfo();
    final long baseline = baselineInfo.getBaseline(baselineInfo.getDominantBaseline());

    final FontMetrics fm = g2.getFontMetrics();
    final Rectangle2D rect = fm.getMaxCharBounds(g2);
    final long awtBaseLine = StrictGeomUtility.toInternalValue(-rect.getY());

    final GlyphList gs = renderableText.getGlyphs();
    if (metaData.isFeatureSupported(OutputProcessorFeature.FAST_FONTRENDERING) &&
        isNormalTextSpacing(renderableText))
    {
View Full Code Here

    double width = 0;
    if (fontSize > 0)
    {
      final float scale = 1000 / fontSize;
      final Font font = this.font.deriveFont(AffineTransform.getScaleInstance(scale, scale));
      final Rectangle2D stringBounds = font.getStringBounds(s, getFontRenderContext());
      width = stringBounds.getWidth() / scale;
    }
    if (s.length() > 1)
    {
      final float adv = ((float) width - lastBaseFont.getWidthPoint(s, fontSize)) / (s.length() - 1);
      cb.setCharacterSpacing(adv);
View Full Code Here

  /**
   * @see Graphics#clipRect(int, int, int, int)
   */
  public void clipRect(final int x, final int y, final int width, final int height)
  {
    final Rectangle2D rect = new Rectangle2D.Double(x, y, width, height);
    clip(rect);
  }
View Full Code Here

  /**
   * @see Graphics#setClip(int, int, int, int)
   */
  public void setClip(final int x, final int y, final int width, final int height)
  {
    final Rectangle2D rect = new Rectangle2D.Double(x, y, width, height);
    setClip(rect);
  }
View Full Code Here

    {
      try
      {
        final TexturePaint tp = (TexturePaint)paint;
        final BufferedImage img = tp.getImage();
        final Rectangle2D rect = tp.getAnchorRect();
        final com.lowagie.text.Image image = com.lowagie.text.Image.getInstance(img, null);
        final PdfPatternPainter pattern = cb.createPattern(image.getWidth(), image.getHeight());
        final AffineTransform inverse = this.normalizeMatrix();
        inverse.translate(rect.getX(), rect.getY());
        inverse.scale(rect.getWidth() / image.getWidth(), -rect.getHeight() / image.getHeight());
        final double[] mx = new double[6];
        inverse.getMatrix(mx);
        pattern.setPatternMatrix((float)mx[0], (float)mx[1], (float)mx[2], (float)mx[3], (float)mx[4], (float)mx[5]) ;
        image.setAbsolutePosition(0,0);
        pattern.addImage(image);
View Full Code Here

    {
      height = computeDimension(name, y1, y2);
    }

    // create the bounds as specified by the user
    final Rectangle2D bounds =
        new Rectangle2D.Float(computePosition(name, x1, x2),
            computePosition(name, y1, y2), width, height);

    if (x1 == x2)
    {
      // assume that we have a vertical line
      final VerticalLineElementFactory elementFactory = new VerticalLineElementFactory();
      elementFactory.setName(name);
      elementFactory.setColor(c);
      elementFactory.setStroke(stroke);
      elementFactory.setX(new Float(bounds.getX()));
      elementFactory.setY(new Float(bounds.getY()));
      elementFactory.setMinimumWidth(new Float(bounds.getWidth()));
      elementFactory.setMinimumHeight(new Float(bounds.getHeight()));
      elementFactory.setScale(Boolean.TRUE);
      elementFactory.setKeepAspectRatio(Boolean.FALSE);
      elementFactory.setShouldDraw(Boolean.TRUE);
      element = elementFactory.createElement();
    }
    else if (y1 == y2)
    {
      // assume that we have a horizontal line
      final HorizontalLineElementFactory elementFactory = new HorizontalLineElementFactory();
      elementFactory.setName(name);
      elementFactory.setColor(c);
      elementFactory.setStroke(stroke);
      elementFactory.setX(new Float(bounds.getX()));
      elementFactory.setY(new Float(bounds.getY()));
      elementFactory.setMinimumWidth(new Float(bounds.getWidth()));
      elementFactory.setMinimumHeight(new Float(bounds.getHeight()));
      elementFactory.setScale(Boolean.TRUE);
      elementFactory.setKeepAspectRatio(Boolean.FALSE);
      elementFactory.setShouldDraw(Boolean.TRUE);
      element = elementFactory.createElement();
    }
    else
    {
      // here comes the magic - we transform the line into the absolute space;
      // this should preserve the general appearance. Heck, and if not, then
      // it is part of the users responsibility to resolve that. Magic does not
      // solve all problems, you know.
      final Line2D line = new Line2D.Float
          (Math.abs(x1), Math.abs(y1), Math.abs(x2), Math.abs(y2));
      final Rectangle2D shapeBounds = line.getBounds2D();
      final Shape transformedShape =
          ShapeTransform.translateShape(line, -shapeBounds.getX(), -shapeBounds.getY());
      // and use that shape with the user's bounds to create the element.
      final ContentElementFactory elementFactory = new ContentElementFactory();
      elementFactory.setName(name);
      elementFactory.setColor(c);
      elementFactory.setStroke(stroke);
View Full Code Here

    {
      height = Math.max(y2, y1) - Math.min(y2, y1);
    }

    // create the bounds as specified by the user
    final Rectangle2D bounds =
        new Rectangle2D.Float(Math.min(x1, x2), Math.min(y1, y2), width, height);


    if (x1 == x2)
    {
      // assume that we have a vertical line
      final VerticalLineElementFactory elementFactory = new VerticalLineElementFactory();
      elementFactory.setName(name);
      elementFactory.setColor(c);
      elementFactory.setStroke(stroke);
      elementFactory.setX(new Float(bounds.getX()));
      elementFactory.setY(new Float(bounds.getY()));
      elementFactory.setMinimumWidth(new Float(bounds.getWidth()));
      elementFactory.setMinimumHeight(new Float(bounds.getHeight()));
      elementFactory.setScale(Boolean.TRUE);
      elementFactory.setKeepAspectRatio(Boolean.FALSE);
      elementFactory.setShouldDraw(Boolean.TRUE);
      element = elementFactory.createElement();
    }
    else if (y1 == y2)
    {
      // assume that we have a horizontal line
      final HorizontalLineElementFactory elementFactory = new HorizontalLineElementFactory();
      elementFactory.setName(name);
      elementFactory.setColor(c);
      elementFactory.setStroke(stroke);
      elementFactory.setX(new Float(bounds.getX()));
      elementFactory.setY(new Float(bounds.getY()));
      elementFactory.setMinimumWidth(new Float(bounds.getWidth()));
      elementFactory.setMinimumHeight(new Float(bounds.getHeight()));
      elementFactory.setScale(Boolean.TRUE);
      elementFactory.setKeepAspectRatio(Boolean.FALSE);
      elementFactory.setShouldDraw(Boolean.TRUE);
      element = elementFactory.createElement();
    }
    else
    {
      // here comes the magic - we transform the line into the absolute space;
      // this should preserve the general appearance. Heck, and if not, then
      // it is part of the users reponsibility to resolve that. Magic does not
      // solve all problems, you know.
      final Line2D line = new Line2D.Float
          (Math.abs(x1), Math.abs(y1), Math.abs(x2), Math.abs(y2));
      final Rectangle2D shapeBounds = line.getBounds2D();
      final Shape transformedShape =
          ShapeTransform.translateShape(line, -shapeBounds.getX(), -shapeBounds.getY());
      // and use that shape with the user's bounds to create the element.
      final ContentElementFactory elementFactory = new ContentElementFactory();
      elementFactory.setName(name);
      elementFactory.setColor(c);
      elementFactory.setStroke(stroke);
      elementFactory.setX(new Float(shapeBounds.getX()));
      elementFactory.setY(new Float(shapeBounds.getY()));
      elementFactory.setMinimumWidth(new Float(shapeBounds.getWidth()));
      elementFactory.setMinimumHeight(new Float(shapeBounds.getHeight()));
      elementFactory.setContent(transformedShape);
      elementFactory.setScale(Boolean.TRUE);
      elementFactory.setKeepAspectRatio(Boolean.FALSE);
      elementFactory.setShouldDraw(Boolean.TRUE);
      element = elementFactory.createElement();
View Full Code Here

TOP

Related Classes of java.awt.geom.Rectangle2D

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.