Exemplo n.º 1
0
        private boolean drawImage(Image img, Image mask, AffineTransform xform, Color bgColor, ImageObserver obs)
        {
            if (xform == null)
            {
                return(true);
            }

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

            AffineTransform inverse = this.normalizeMatrix();
            AffineTransform flipper = AffineTransform.getScaleInstance(1, -1);

            inverse.concatenate(xform);
            inverse.concatenate(flipper);

            double[] mx = new double[6];
            inverse.getMatrix(mx);

            try {
                com.lowagie.text.Image image = com.lowagie.text.Image.getInstance(img, bgColor);
                if (mask != null)
                {
                    com.lowagie.text.Image msk = com.lowagie.text.Image.getInstance(mask, null, true);
                    msk.makeMask();
                    msk.setInvertMask(true);
                    image.setImageMask(msk);
                }
                cb.addImage(image, (float)mx[0], (float)mx[1], (float)mx[2], (float)mx[3], (float)mx[4], (float)mx[5]);
            } catch (Exception ex) {
                throw new IllegalArgumentException();
            }

            return(true);
        }
Exemplo n.º 2
0
 /**
  * @see Graphics2D#drawString(String, float, float)
  */
 public void drawString(String s, float x, float y)
 {
     if (onlyShapes)
     {
         TextLayout tl = new TextLayout(s, this.font, new FontRenderContext(new AffineTransform(), false, true));
         tl.draw(this, x, y);
     }
     else
     {
         AffineTransform at  = getTransform();
         AffineTransform at2 = getTransform();
         at2.translate(x, y);
         at2.concatenate(font.getTransform());
         setTransform(at2);
         AffineTransform inverse = this.normalizeMatrix();
         AffineTransform flipper = AffineTransform.getScaleInstance(1, -1);
         inverse.concatenate(flipper);
         double[] mx = new double[6];
         inverse.getMatrix(mx);
         cb.beginText();
         cb.setFontAndSize(baseFont, fontSize);
         cb.setTextMatrix((float)mx[0], (float)mx[1], (float)mx[2], (float)mx[3], (float)mx[4], (float)mx[5]);
         cb.showText(s);
         cb.endText();
         setTransform(at);
     }
 }
Exemplo n.º 3
0
        private AffineTransform normalizeMatrix()
        {
            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);
        }