Package java.awt.geom

Examples of java.awt.geom.Rectangle2D


        double displayHeight = availableImageHeight;

        double ratioX = 1f;
        double ratioY = 1f;
       
        Rectangle2D clip = null;

        Dimension2D dimension = renderer.getDimension();
        if (dimension != null)
        {
          normalWidth = dimension.getWidth();
          normalHeight = dimension.getHeight();
          displayWidth = normalWidth;
          displayHeight = normalHeight;
         
          float xalignFactor = getXAlignFactor(printImage);
          float yalignFactor = getYAlignFactor(printImage);

          switch (printImage.getScaleImageValue())
          {
            case CLIP:
            {
              xoffset = (int) (xalignFactor * (availableImageWidth - normalWidth));
              yoffset = (int) (yalignFactor * (availableImageHeight - normalHeight));
              clip =
                new Rectangle2D.Double(
                  - xoffset,
                  - yoffset,
                  availableImageWidth,
                  availableImageHeight
                  );
              break;
            }
            case FILL_FRAME:
            {
              ratioX = availableImageWidth / normalWidth;
              ratioY = availableImageHeight / normalHeight;
              normalWidth *= ratioX;
              normalHeight *= ratioY;
              xoffset = 0;
              yoffset = 0;
              break;
            }
            case RETAIN_SHAPE:
            default:
            {
              ratioX = availableImageWidth / normalWidth;
              ratioY = availableImageHeight / normalHeight;
              ratioX = ratioX < ratioY ? ratioX : ratioY;
              ratioY = ratioX;
              normalWidth *= ratioX;
              normalHeight *= ratioY;
              xoffset = (int) (xalignFactor * (availableImageWidth - normalWidth));
              yoffset = (int) (yalignFactor * (availableImageHeight - normalHeight));
              break;
            }
          }
        }

        PdfTemplate template = pdfContentByte.createTemplate((float)displayWidth, (float)displayHeight);

        Graphics2D g = forceSvgShapes
          ? template.createGraphicsShapes((float)displayWidth, (float)displayHeight)
          : template.createGraphics(availableImageWidth, availableImageHeight, new LocalFontMapper());

        if (clip != null)
        {
          g.setClip(clip);
        }
       
        if (printImage.getModeValue() == ModeEnum.OPAQUE)
        {
          g.setColor(printImage.getBackcolor());
          g.fillRect(0, 0, (int)displayWidth, (int)displayHeight);
        }

        Rectangle2D rectangle = new Rectangle2D.Double(0, 0, displayWidth, displayHeight);

        renderer.render(g, rectangle);
        g.dispose();

        pdfContentByte.saveState();
View Full Code Here


     * @param src The <CODE>Raster</CODE> to be transformed.
     *
     * @return The zeroed destination <CODE>Raster</CODE>.
     */
    public WritableRaster createCompatibleDestRaster (Raster src) {
        Rectangle2D r = getBounds2D(src);

        return src.createCompatibleWritableRaster((int)r.getX(),
                                                  (int)r.getY(),
                                                  (int)r.getWidth(),
                                                  (int)r.getHeight());
    }
View Full Code Here

     * @param y the y-coordinate at which to render this <code>GlyphVector</code>.
     * @return a <code>Rectangle</code> bounding the pixels that would be affected.
     * @since 1.4
     */
    public Rectangle getPixelBounds(FontRenderContext renderFRC, float x, float y) {
    Rectangle2D rect = getVisualBounds();
    int l = (int)Math.floor(rect.getX() + x);
    int t = (int)Math.floor(rect.getY() + y);
    int r = (int)Math.ceil(rect.getMaxX() + x);
    int b = (int)Math.ceil(rect.getMaxY() + y);
    return new Rectangle(l, t, r - l, b - t);
  }
View Full Code Here

     * @param y the Y position at which to render this <code>GlyphVector</code>.
     * @return a <code>Rectangle</code> bounding the pixels that would be affected.
     * @since 1.4
     */
    public Rectangle getGlyphPixelBounds(int index, FontRenderContext renderFRC, float x, float y) {
    Rectangle2D rect = getGlyphVisualBounds(index).getBounds2D();
    int l = (int)Math.floor(rect.getX() + x);
    int t = (int)Math.floor(rect.getY() + y);
    int r = (int)Math.ceil(rect.getMaxX() + x);
    int b = (int)Math.ceil(rect.getMaxY() + y);
    return new Rectangle(l, t, r - l, b - t);
  }
View Full Code Here

     */
    public Rectangle2D getBounds() {
        ensureCache();

        if (boundsRect == null) {
            Rectangle2D vb = textLine.getVisualBounds();
            if (dx != 0 || dy != 0) {
                vb.setRect(vb.getX() - dx,
                           vb.getY() - dy,
                           vb.getWidth(),
                           vb.getHeight());
            }
            boundsRect = vb;
        }

        Rectangle2D bounds = new Rectangle2D.Float();
        bounds.setRect(boundsRect);

        return bounds;
    }
View Full Code Here

        if (firstEndpoint < characterCount) {
            for (int logIndex = firstEndpoint;
                        logIndex < secondEndpoint;
                        logIndex++) {

                Rectangle2D r = textLine.getCharBounds(logIndex);
                if (!r.isEmpty()) {
                    result.append(r, false);
                }
            }
        }
View Full Code Here

            if (result == null) {
                result = new Rectangle(0, 0, 0, 0);
            }
        } else { // draw and test
            final int MARGIN = 3;
            Rectangle2D r2d = getVisualBounds();
            if (lp != null) {
                r2d = lp.mapShape(r2d).getBounds();
            }
            Rectangle bounds = r2d.getBounds();
            BufferedImage im = new BufferedImage(bounds.width + MARGIN * 2,
                                                 bounds.height + MARGIN * 2,
                                                 BufferedImage.TYPE_INT_ARGB);

            Graphics2D g2d = im.createGraphics();
View Full Code Here

            int tlcLimit = tlcStart + fComponents[i].getNumCharacters();
            if (tlcLimit > logicalIndex) {

                TextLineComponent tlc = fComponents[i];
                int indexInTlc = logicalIndex - tlcStart;
                Rectangle2D chBounds = tlc.getCharVisualBounds(indexInTlc);

                int vi = fComponentVisualOrder == null ? i : fComponentVisualOrder[i];
                chBounds.setRect(chBounds.getX() + locs[vi * 2],
                                 chBounds.getY() + locs[vi * 2 + 1],
                                 chBounds.getWidth(),
                                 chBounds.getHeight());
                return chBounds;
            }
            else {
                tlcStart = tlcLimit;
            }
View Full Code Here

     * Return the union of the visual bounds of all the components.
     * This incorporates the path.  It does not include logical
     * bounds (used by carets).
     */
    public Rectangle2D getVisualBounds() {
        Rectangle2D result = null;

        for (int i = 0, n = 0; i < fComponents.length; i++, n += 2) {
            int vi = fComponentVisualOrder==null? i : fComponentVisualOrder[i];
            TextLineComponent tlc = fComponents[vi];
            Rectangle2D r = tlc.getVisualBounds();
           
            Point2D.Float pt = new Point2D.Float(locs[n], locs[n+1]);
            if (lp == null) {
                r.setRect(r.getMinX() + pt.x, r.getMinY() + pt.y,
                          r.getWidth(), r.getHeight());
            } else {
                lp.pathToPoint(pt, false, pt);

                AffineTransform at = tlc.getBaselineTransform();
                if (at != null) {
                    AffineTransform tx = AffineTransform.getTranslateInstance
                        (pt.x - at.getTranslateX(), pt.y - at.getTranslateY());
                    tx.concatenate(at);
                    r = tx.createTransformedShape(r).getBounds2D();
                } else {
                    r.setRect(r.getMinX() + pt.x, r.getMinY() + pt.y,
                              r.getWidth(), r.getHeight());
                }
            }

            if (result == null) {
                result = r;
View Full Code Here

        for (int i=0, n = 0; i < fComponents.length; i++, n += 2) {
            int vi = fComponentVisualOrder==null? i : fComponentVisualOrder[i];
            TextLineComponent tlc = fComponents[vi];

            Rectangle2D tlcBounds = tlc.getItalicBounds();
            float x = locs[n];
            float y = locs[n+1];

            left = Math.min(left, x + (float)tlcBounds.getX());
            right = Math.max(right, x + (float)tlcBounds.getMaxX());

            top = Math.min(top, y + (float)tlcBounds.getY());
            bottom = Math.max(bottom, y + (float)tlcBounds.getMaxY());
        }

        return new Rectangle2D.Float(left, top, right-left, bottom-top);
    }
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.