专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > PowerDesigner

icepdf-bug-436 批改

发布时间:2011-06-20 20:20:58 文章来源:www.iduyao.cn 采编人员:星星草
icepdf-bug-436 修改
icepdf解析pdf文件空白bug修改。bug编号 pdf-436,修改人 wenwu
http://jira.icesoft.org/browse/PDF-436

问题修改如下:
Modify TilingPattern.java

1. public void init() {

        if (inited) {
            return;
        }
        
        //Modify bug by wuwen.55@gmail.com, see bug PDF-436
        inited = true;
        //Modify bug by wuwen.55@gmail.com end.

    ...

}

2. public void paintPattern(Graphics2D g, Page parentPage) {
        if (patternPaint == null) {
            AffineTransform matrixInv = getInvMatrix();
            Rectangle2D bBoxMod = matrix.createTransformedShape(bBox).getBounds2D();

            int width = (int) bBoxMod.getWidth();
            int height = (int) bBoxMod.getHeight();

            // corner cases where some bBoxes don't have a dimension.
            if (width == 0) {
                width = 1;
            }
            if (height == 0) {
                height = 1;
            }

            // create the new image to write too.
            final BufferedImage bi = new BufferedImage(width, height,
                    BufferedImage.TYPE_INT_ARGB);
            Graphics2D canvas = bi.createGraphics();
            // apply current hints
            canvas.setRenderingHints(g.getRenderingHints());
            // copy over the rendering hints
            // get shapes and paint them.
            Shapes tilingShapes = getShapes();
          
            //Modify bug by wuwen.55@gmail.com, see bug PDF-436
           // finally paint the graphic using the current gs.
            patternPaint = new TexturePaint(bi, bBoxMod);
            g.setPaint(patternPaint);
            //Modify by wuwen.55@gmail.com end.
            
            if (tilingShapes != null) {
                // setup resource parent
                tilingShapes.setPageParent(parentPage);
                canvas.setClip(0, 0, width, height);
                // apply the pattern space
                canvas.setTransform(matrix);
                // move it back by any shear/rotation distance.
                canvas.translate(matrixInv.getTranslateX(),
                        matrixInv.getTranslateY());

                if (paintType == TilingPattern.PAINTING_TYPE_UNCOLORED_TILING_PATTERN) {
                    canvas.setColor(unColored);
                }
                // paint the pattern content stream.
                tilingShapes.paint(canvas);

                // do a little tiling if there is a shear so that we
                // don't end up with any white space around the rotate
                // pattern cell. Java texture paint can't take a transform
                // when painting so this will have to do.
                if (matrix.getShearX() > 0 ||
                        matrix.getShearY() > 0) {
                    canvas.translate(bBox.getWidth(), 0);
                    tilingShapes.paint(canvas);
                    canvas.translate(0, -bBox.getHeight());
                    tilingShapes.paint(canvas);
                    canvas.translate(-bBox.getWidth(), 0);
                    tilingShapes.paint(canvas);
                    canvas.translate(-bBox.getWidth(), 0);
                    tilingShapes.paint(canvas);
                    canvas.translate(0, bBox.getHeight());
                    tilingShapes.paint(canvas);
                    canvas.translate(0, bBox.getHeight());
                    tilingShapes.paint(canvas);
                    canvas.translate(bBox.getWidth(), 0);
                    tilingShapes.paint(canvas);
                    canvas.translate(bBox.getWidth(), 0);
                    tilingShapes.paint(canvas);
                }
                // release the page parent
                tilingShapes.setPageParent(null);
            }
            

            // show it in a frame
// final JFrame f = new JFrame("Test");
// f.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
// f.getContentPane().add(new JComponent() {
// @Override
// public void paint(Graphics g_) {
// super.paint(g_);
// g_.drawImage(bi, 0, 0, f);
// }
// });
// f.setSize(new Dimension(800, 800));
// f.setVisible(true);
            // post paint cleanup
            canvas.dispose();
            bi.flush();
        } else {
            g.setPaint(patternPaint);
        }
    }
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: