KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > svg > PDFBridgeContext


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: PDFBridgeContext.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.svg;
21
22 import java.awt.geom.AffineTransform JavaDoc;
23
24 import org.apache.batik.bridge.BridgeContext;
25 import org.apache.batik.bridge.DocumentLoader;
26 import org.apache.batik.bridge.UserAgent;
27 import org.apache.fop.fonts.FontInfo;
28
29 /**
30  * BridgeContext which registers the custom bridges for PDF output.
31  */

32 public class PDFBridgeContext extends BridgeContext {
33     
34     /** The font list. */
35     private final FontInfo fontInfo;
36
37     private AffineTransform JavaDoc linkTransform;
38     
39     /**
40      * Constructs a new bridge context.
41      * @param userAgent the user agent
42      * @param loader the Document Loader to use for referenced documents.
43      * @param fontInfo the font list for the text painter, may be null
44      * in which case text is painted as shapes
45      * @param linkTransform AffineTransform to properly place links,
46      * may be null
47      */

48     public PDFBridgeContext(UserAgent userAgent,
49                             DocumentLoader loader,
50                             FontInfo fontInfo,
51                             AffineTransform JavaDoc linkTransform) {
52         super(userAgent, loader);
53         this.fontInfo = fontInfo;
54         this.linkTransform = linkTransform;
55     }
56
57     /**
58      * Constructs a new bridge context.
59      * @param userAgent the user agent
60      * @param fontInfo the font list for the text painter, may be null
61      * in which case text is painted as shapes
62      * @param linkTransform AffineTransform to properly place links,
63      * may be null
64      */

65     public PDFBridgeContext(UserAgent userAgent, FontInfo fontInfo,
66                 AffineTransform JavaDoc linkTransform) {
67         super(userAgent);
68         this.fontInfo = fontInfo;
69         this.linkTransform = linkTransform;
70     }
71
72     /**
73      * Constructs a new bridge context.
74      * @param userAgent the user agent
75      * @param fontInfo the font list for the text painter, may be null
76      * in which case text is painted as shapes
77      */

78     public PDFBridgeContext(UserAgent userAgent, FontInfo fontInfo) {
79         this(userAgent, fontInfo, null);
80     }
81
82     /** @see org.apache.batik.bridge.BridgeContext#registerSVGBridges() */
83     public void registerSVGBridges() {
84         super.registerSVGBridges();
85
86         if (fontInfo != null) {
87             putBridge(new PDFTextElementBridge(fontInfo));
88         }
89
90         PDFAElementBridge pdfAElementBridge = new PDFAElementBridge();
91         if (linkTransform != null) {
92             pdfAElementBridge.setCurrentTransform(linkTransform);
93         } else {
94             pdfAElementBridge.setCurrentTransform(new AffineTransform JavaDoc());
95         }
96         putBridge(pdfAElementBridge);
97
98         putBridge(new PDFImageElementBridge());
99     }
100
101     // Make sure any 'sub bridge contexts' also have our bridges.
102
public BridgeContext createBridgeContext() {
103         return new PDFBridgeContext(getUserAgent(), getDocumentLoader(),
104                                     fontInfo, linkTransform);
105     }
106 }
107
Popular Tags