01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: PDFAElementBridge.java 430777 2006-08-11 12:47:35Z jeremias $ */
19:
20: package org.apache.fop.svg;
21:
22: import java.awt.geom.AffineTransform;
23:
24: import org.apache.batik.bridge.AbstractGraphicsNodeBridge;
25: import org.apache.batik.bridge.BridgeContext;
26:
27: import org.apache.batik.gvt.GraphicsNode;
28:
29: import org.w3c.dom.Element;
30: import org.w3c.dom.svg.SVGAElement;
31:
32: /**
33: * Bridge class for the <a> element.
34: *
35: * @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
36: */
37: public class PDFAElementBridge extends AbstractGraphicsNodeBridge {
38: private AffineTransform transform;
39:
40: /**
41: * Constructs a new bridge for the <a> element.
42: */
43: public PDFAElementBridge() {
44: }
45:
46: /**
47: * Set the current transform of this element.
48: * @param tf the transform
49: */
50: public void setCurrentTransform(AffineTransform tf) {
51: transform = tf;
52: }
53:
54: /** @return the transformation matrix for links */
55: public AffineTransform getCurrentTransform() {
56: return this .transform;
57: }
58:
59: /**
60: * Returns 'a'.
61: * @return the name of this node
62: */
63: public String getLocalName() {
64: return SVG_A_TAG;
65: }
66:
67: /**
68: * Creates a <tt>CompositeGraphicsNode</tt>.
69: * @return a new PDFANode
70: */
71: protected GraphicsNode instantiateGraphicsNode() {
72: return new PDFANode();
73: }
74:
75: /**
76: * Builds using the specified BridgeContext and element, the
77: * specified graphics node.
78: *
79: * @param ctx the bridge context to use
80: * @param e the element that describes the graphics node to build
81: * @return node the new graphics node
82: */
83: public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) {
84: PDFANode aNode = (PDFANode) super .createGraphicsNode(ctx, e);
85: aNode.setDestination(((SVGAElement) e).getHref().getBaseVal());
86: aNode.setTransform(transform);
87: return aNode;
88: }
89:
90: /**
91: * Returns true as the <a> element is a container.
92: * @return true if the a element is a container
93: */
94: public boolean isComposite() {
95: return true;
96: }
97:
98: }
|