~ubuntu-branches/ubuntu/karmic/batik/karmic

« back to all changes in this revision

Viewing changes to pdf-transcoder/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java

  • Committer: Bazaar Package Importer
  • Author(s): Matvey Kozhev, Onkar Shinde, Matvey Kozhev
  • Date: 2008-07-19 01:03:05 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080719010305-0b24skqy185kdsb9
Tags: 1.7.dfsg-0ubuntu1
[ Onkar Shinde ]
* New upstream version (LP: #147818)
* debian/control
  - Add Sun JDK 1.5 as build dependency. Fixes FTBFS on buildd. (LP: #150484)
    Also add Sun JRE as runtime dependencies.
  - Add ant-optional as build dependency.
  - Add libxml-commons-external-java and libxmlgraphics-commons-java as
    build and runtime dependencies.
  - Add 'Homepage' field and correct the url.
  - Change standards version to 3.8.0.
  - Modify Maintainer value to match the DebianMaintainerField
    specification.
* debian/rules
  - Change JAVA_HOME_DIRS for Sun JDK.
  - Add jar file names to DEB_JARS to match new build requirements.
  - Extract version from changelog.
  - Delete bundled jar files in clean target.
  - Don't use hardcoded version in install target.
  - Add get-orig-source target.
* debian/README.Debian-source
  - Change the fo tag name to the one used for this version.
* debian/watch
  - Change expression to match src distribution.
* debian/patches/
  - 01_build_xml.patch, 02_fix_jar_target.patch - Refresh for current source.
  - 03_fix_lib_dirs.patch - Fix the library and classpath references needed
    for pdf transcoder build.
  - 04_fix_transcoder_pkg.patch - Fix transcoder-pkg target to not copy
    files from other jar files.

[ Matvey Kozhev ]
* debian/changelog:
  - Added ".dfsg" to version.
* debian/control, debian/rules:
  - Build with openjdk-6-jdk, depend on openjdk-6-jre.
  - Added java-6-sun as an alternate build JAVA_HOME directory.
  - Fixed get-orig-source to not include debian/ and delete the source dir,
    and made it delete jars from lib/, as done in the current batik package.
* debian/wrappers.sh:
  - Changed java-7-icedtea reference to java-6-openjdk, as the former has been
    removed back in Hardy.
  - Added newline.
* debian/libbatik-java.install:
  - Added newline.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
 
3
 * contributor license agreements.  See the NOTICE file distributed with
 
4
 * this work for additional information regarding copyright ownership.
 
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
 
6
 * (the "License"); you may not use this file except in compliance with
 
7
 * the License.  You may obtain a copy of the License at
 
8
 * 
 
9
 *      http://www.apache.org/licenses/LICENSE-2.0
 
10
 * 
 
11
 * Unless required by applicable law or agreed to in writing, software
 
12
 * distributed under the License is distributed on an "AS IS" BASIS,
 
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
 * See the License for the specific language governing permissions and
 
15
 * limitations under the License.
 
16
 */
 
17
 
 
18
/* $Id: PSGraphics2DAdapter.java 426576 2006-07-28 15:44:37Z jeremias $ */
 
19
 
 
20
package org.apache.fop.render.ps;
 
21
 
 
22
import java.awt.Dimension;
 
23
import java.awt.geom.AffineTransform;
 
24
import java.awt.geom.Rectangle2D;
 
25
import java.io.IOException;
 
26
 
 
27
import org.apache.fop.render.Graphics2DAdapter;
 
28
import org.apache.fop.render.Graphics2DImagePainter;
 
29
import org.apache.fop.render.RendererContext;
 
30
import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
 
31
import org.apache.xmlgraphics.ps.PSGenerator;
 
32
 
 
33
/**
 
34
 * Graphics2DAdapter implementation for PostScript.
 
35
 */
 
36
public class PSGraphics2DAdapter implements Graphics2DAdapter {
 
37
 
 
38
    private PSRenderer renderer;
 
39
 
 
40
    /**
 
41
     * Main constructor
 
42
     * @param renderer the Renderer instance to which this instance belongs
 
43
     */
 
44
    public PSGraphics2DAdapter(PSRenderer renderer) {
 
45
        this.renderer = renderer;
 
46
    }
 
47
    
 
48
    /** @see org.apache.fop.render.Graphics2DAdapter */
 
49
    public void paintImage(Graphics2DImagePainter painter, 
 
50
            RendererContext context,
 
51
            int x, int y, int width, int height) throws IOException {
 
52
        PSGenerator gen = renderer.gen;
 
53
        
 
54
        float fwidth = width / 1000f;
 
55
        float fheight = height / 1000f;
 
56
        float fx = x / 1000f;
 
57
        float fy = y / 1000f;
 
58
        
 
59
        // get the 'width' and 'height' attributes of the SVG document
 
60
        Dimension dim = painter.getImageSize();
 
61
        float imw = (float)dim.getWidth() / 1000f;
 
62
        float imh = (float)dim.getHeight() / 1000f;
 
63
 
 
64
        float sx = fwidth / (float)imw;
 
65
        float sy = fheight / (float)imh;
 
66
 
 
67
        gen.commentln("%FOPBeginGraphics2D");
 
68
        gen.saveGraphicsState();
 
69
        // Clip to the image area.
 
70
        gen.writeln("newpath");
 
71
        gen.defineRect(fx, fy, fwidth, fheight);
 
72
        gen.writeln("clip");
 
73
        
 
74
        // transform so that the coordinates (0,0) is from the top left
 
75
        // and positive is down and to the right. (0,0) is where the
 
76
        // viewBox puts it.
 
77
        gen.concatMatrix(sx, 0, 0, sy, fx, fy);
 
78
 
 
79
        final boolean textAsShapes = false;
 
80
        PSGraphics2D graphics = new PSGraphics2D(textAsShapes, gen);
 
81
        graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
 
82
        AffineTransform transform = new AffineTransform();
 
83
        // scale to viewbox
 
84
        transform.translate(fx, fy);
 
85
        gen.getCurrentState().concatMatrix(transform);
 
86
        Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh);
 
87
        painter.paint(graphics, area);
 
88
 
 
89
        gen.restoreGraphicsState();
 
90
        gen.commentln("%FOPEndGraphics2D");
 
91
    }
 
92
 
 
93
}