Package java.awt.geom

Examples of java.awt.geom.Rectangle2D


  private int findPageFormat(final Rectangle2D[] positions, final long xPosition, final long yPosition)
  {
    final int posCount = positions.length;
    for (int i = 0; i < posCount; i++)
    {
      final Rectangle2D rect = positions[i];
      if (StrictGeomUtility.toInternalValue(rect.getMinY()) == yPosition &&
          StrictGeomUtility.toInternalValue(rect.getMinX()) == xPosition)
      {
        return i;
      }
    }
    return -1;
View Full Code Here


    if (draw == false && fill == false)
    {
      return;
    }

    final Rectangle2D b = this.shape.getBounds2D();
    double x = area.getMinX() + b.getWidth() / 2.0 + 1.0;
    final double y = area.getCenterY();
    final Shape s = getShape();
    g2.translate(x, y);
    g2.setPaint(Color.black);
    if (this.draw)
    {
      g2.setStroke(new BasicStroke(0.5f));
      g2.draw(s);
    }
    if (this.fill)
    {
      g2.fill(s);
    }
    g2.translate(-x, -y);
    x += b.getWidth() / 2.0 + 3.0;
    g2.setFont(this.font);

    final FontRenderContext frc = g2.getFontRenderContext();
    final Font f = g2.getFont();
//    final FontMetrics fm = g2.getFontMetrics(f);
View Full Code Here

     * Always scale to the maximum bounds ...
     */
    if (scale)
    {

      final Rectangle2D boundsShape = s.getBounds2D();
      final double w = boundsShape.getWidth();
      final double h = boundsShape.getHeight();
      double scaleX = 1;

      if (w != 0)
      {
        scaleX = width / w;
View Full Code Here

        return new GeneralPath();
      }
      return new Line2D.Float(clipped[0], clipped[1]);
    }

    final Rectangle2D boundsCorrected = bounds.getBounds2D();
    boundsCorrected.setRect(-DELTA, -DELTA,
        DELTA + boundsCorrected.getWidth(), DELTA + boundsCorrected.getHeight());
    final Area a = new Area(boundsCorrected);
    if (a.isEmpty())
    {
      // don't clip  ... Area does not like lines
      // operations with lines always result in an empty Bounds:(0,0,0,0) area
View Full Code Here

   */
  private static Shape performDefaultTransformation(final Shape shape,
                                                    final double scaleX,
                                                    final double scaleY)
  {
    /**
     * Apply the normalisation shape transform ... bring the shape to pos (0,0)
     */
    final Rectangle2D bounds = shape.getBounds2D();
    final AffineTransform translateTransform
        = AffineTransform.getTranslateInstance(0 - bounds.getX(), 0 - bounds.getY());
    // apply normalisation translation ...
    final Shape translatedShape = translateTransform.createTransformedShape(shape);

    final AffineTransform scaleTransform = AffineTransform.getScaleInstance(scaleX, scaleY);
    // apply scaling ...
    final Shape scaledShape = scaleTransform.createTransformedShape(translatedShape);

    // now retranslate the shape to its original position ...
    final AffineTransform translateBackTransform =
        AffineTransform.getTranslateInstance(bounds.getX(), bounds.getY());
    return translateBackTransform.createTransformedShape(scaledShape);
  }
View Full Code Here

    {
      return Printable.NO_SUCH_PAGE;
    }

    final Graphics2D g2 = (Graphics2D) graphics;
    final Rectangle2D bounds = new Rectangle2D.Double
        (0, 0, pageFormat.getImageableWidth(), pageFormat.getImageableHeight());
    drawable.draw(g2, bounds);
    return Printable.PAGE_EXISTS;
  }
View Full Code Here

      }
    }
    else if (content instanceof Shape)
    {
      final Shape s = (Shape) content;
      final Rectangle2D bounds2D = s.getBounds2D();
      contentWidth = StrictGeomUtility.toInternalValue(bounds2D.getWidth());
      contentHeight = StrictGeomUtility.toInternalValue(bounds2D.getHeight());
    }
  }
View Full Code Here

    {
      throw new NullPointerException("The given pageformat must not be null.");
    }
    width = Math.max(width, (float) (format.getImageableWidth() + x));
    height = Math.max(height, (float) (format.getImageableHeight() + y));
    final Rectangle2D bounds = new Rectangle2D.Double
        (x, y, format.getImageableWidth(), format.getImageableHeight());
    pageBoundsList.add(bounds);
    pageFormatList.add(format.clone());
  }
View Full Code Here

   * @param index the index of the page.
   * @return the position of the page (within the global page).
   */
  public Rectangle2D getPagePosition(final int index)
  {
    final Rectangle2D rec = (Rectangle2D) pageBoundsList.get(index);
    return rec.getBounds2D();
  }
View Full Code Here

  public Rectangle2D[] getPagePositions()
  {
    final Rectangle2D[] rects = new Rectangle2D[pageBoundsList.size()];
    for (int i = 0; i < pageBoundsList.size(); i++)
    {
      final Rectangle2D rec = (Rectangle2D) pageBoundsList.get(i);
      rects[i] = rec.getBounds2D();
    }
    return rects;
  }
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.