Package java.awt.geom

Examples of java.awt.geom.AffineTransform


  /**
   * @see Graphics2D#getTransform()
   */
  public AffineTransform getTransform()
  {
    return new AffineTransform(transform);
  }
View Full Code Here


  {
    final boolean antialias = RenderingHints.VALUE_TEXT_ANTIALIAS_ON.equals(getRenderingHint(
        RenderingHints.KEY_TEXT_ANTIALIASING));
    final boolean fractions = RenderingHints.VALUE_FRACTIONALMETRICS_ON.equals(getRenderingHint(
        RenderingHints.KEY_FRACTIONALMETRICS));
    return new FontRenderContext(new AffineTransform(), antialias, fractions);
  }
View Full Code Here

   * @see Graphics#create()
   */
  public Graphics create()
  {
    final PdfGraphics2D g2 = new PdfGraphics2D();
    g2.transform = new AffineTransform(this.transform);
    g2.metaData = this.metaData;
    g2.paint = this.paint;
    g2.fillGState = this.fillGState;
    g2.strokeGState = this.strokeGState;
    g2.background = this.background;
View Full Code Here

                           final ImageObserver observer)
  {
    waitForImage(img);
    final double scalex = width / (double) img.getWidth(observer);
    final double scaley = height / (double) img.getHeight(observer);
    final AffineTransform tx = AffineTransform.getTranslateInstance(x, y);
    tx.scale(scalex, scaley);
    return drawImage(img, null, tx, bgcolor, observer);
  }
View Full Code Here

    final double scalex = dwidth / swidth;
    final double scaley = dheight / sheight;

    final double transx = sx1 * scalex;
    final double transy = sy1 * scaley;
    final AffineTransform tx = AffineTransform.getTranslateInstance(dx1 - transx, dy1 - transy);
    tx.scale(scalex, scaley);

    final BufferedImage mask = new BufferedImage(img.getWidth(observer), img.getHeight(observer),
        BufferedImage.TYPE_BYTE_BINARY);
    final Graphics g = mask.getGraphics();
    g.fillRect(sx1, sy1, (int) swidth, (int) sheight);
View Full Code Here

  }

  private AffineTransform normalizeMatrix()
  {
    final double[] mx = new double[6];
    AffineTransform result = AffineTransform.getTranslateInstance(0, 0);
    result.getMatrix(mx);
    mx[3] = -1;
    mx[5] = height;
    result = new AffineTransform(mx);
    result.concatenate(transform);
    return result;
  }
View Full Code Here

    }

    xform.translate(0, img.getHeight(obs));
    xform.scale(img.getWidth(obs), img.getHeight(obs));

    final AffineTransform inverse = this.normalizeMatrix();
    final AffineTransform flipper = FLIP_TRANSFORM;
    inverse.concatenate(xform);
    inverse.concatenate(flipper);

    try
    {
View Full Code Here

        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);
        if (fill)
            cb.setPatternFill(pattern);
        else
            cb.setPatternStroke(pattern);

      }
      catch (Exception ex)
      {
        if (fill)
        {
          cb.setColorFill(Color.gray);
        }
        else
        {
          cb.setColorStroke(Color.gray);
        }
      }
    }
    else
    {
      try
      {
        int type = BufferedImage.TYPE_4BYTE_ABGR;
        if (paint.getTransparency() == Transparency.OPAQUE)
        {
          type = BufferedImage.TYPE_3BYTE_BGR;
        }
        final BufferedImage img = new BufferedImage((int) width, (int) height, type);
        final Graphics2D g = (Graphics2D) img.getGraphics();
        g.transform(transform);
        final AffineTransform inv = transform.createInverse();
        Shape fillRect = new Rectangle2D.Double(0, 0, img.getWidth(), img.getHeight());
        fillRect = inv.createTransformedShape(fillRect);
        g.setPaint(paint);
        g.fill(fillRect);
        if (invert)
        {
          final AffineTransform tx = new AffineTransform();
          tx.scale(1, -1);
          tx.translate(-xoffset, -yoffset);
          g.drawImage(img, tx, null);
        }
        g.dispose();
        // g = null;
        final com.lowagie.text.Image image = com.lowagie.text.Image.getInstance(img, null);
View Full Code Here

    }
   
    final String attributeText = String.valueOf(attribute);
    final PdfAction action = PdfAction.javaScript(attributeText, writer, false);

    final AffineTransform affineTransform = getGraphics().getTransform();
    final float translateX = (float) affineTransform.getTranslateX();

    final float leftX = translateX + (float) (StrictGeomUtility.toExternalValue(box.getX()));
    final float rightX = translateX + (float) (StrictGeomUtility.toExternalValue(box.getX() + box.getWidth()));
    final float lowerY = (float) (globalHeight - StrictGeomUtility.toExternalValue(box.getY() + box.getHeight()));
    final float upperY = (float) (globalHeight - StrictGeomUtility.toExternalValue(box.getY()));
View Full Code Here

    final String anchorName = (String) content.getStyleSheet().getStyleProperty(ElementStyleKeys.ANCHOR_NAME);
    if (anchorName == null)
    {
      return;
    }
    final AffineTransform affineTransform = getGraphics().getTransform();
    final float translateX = (float) affineTransform.getTranslateX();

    final float upperY = translateX + (float) (globalHeight - StrictGeomUtility.toExternalValue(content.getY()));
    final float leftX = (float) (StrictGeomUtility.toExternalValue(content.getX()));
    final PdfDestination dest = new PdfDestination(PdfDestination.FIT, leftX, upperY, 0);
    writer.getDirectContent().localDestination(anchorName, dest);
View Full Code Here

TOP

Related Classes of java.awt.geom.AffineTransform

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.