首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > PowerDesigner >

icepdf-bug-436 批改

2012-06-29 
icepdf-bug-436 修改icepdf解析pdf文件空白bug修改。bug编号 pdf-436,修改人 wenwuhttp://jira.icesoft.org

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);
        }
    }

热点排行