KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > layoutmgr > inline > BasicLinkLayoutManager


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: BasicLinkLayoutManager.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.layoutmgr.inline;
21
22 import org.apache.fop.datatypes.URISpecification;
23 import org.apache.fop.fo.flow.BasicLink;
24 import org.apache.fop.layoutmgr.LayoutManager;
25 import org.apache.fop.area.inline.InlineArea;
26 import org.apache.fop.area.Trait;
27 import org.apache.fop.area.LinkResolver;
28 import org.apache.fop.area.PageViewport;
29
30 /**
31  * LayoutManager for the fo:basic-link formatting object
32  */

33 public class BasicLinkLayoutManager extends InlineLayoutManager {
34     private BasicLink fobj;
35     
36     /**
37      * Create an fo:basic-link layout manager.
38      *
39      * @param node the formatting object that creates the area
40      */

41     public BasicLinkLayoutManager(BasicLink node) {
42         super(node);
43         fobj = node;
44     }
45
46     /** @see org.apache.fop.layoutmgr.inline.InlineLayoutManager#createArea(boolean) */
47     protected InlineArea createArea(boolean bInlineParent) {
48         InlineArea area = super.createArea(bInlineParent);
49         setupBasicLinkArea(parentLM, area);
50         return area;
51     }
52     
53     private void setupBasicLinkArea(LayoutManager parentLM,
54                                       InlineArea area) {
55          if (fobj.getExternalDestination() != null) {
56              area.addTrait(Trait.EXTERNAL_LINK,
57                      URISpecification.getURL(fobj.getExternalDestination()));
58          } else {
59              String JavaDoc idref = fobj.getInternalDestination();
60              PageViewport page = getPSLM().getFirstPVWithID(idref);
61              if (page != null) {
62                  area.addTrait(Trait.INTERNAL_LINK, page.getKey());
63              } else {
64                  LinkResolver res = new LinkResolver(idref, area);
65                  getPSLM().addUnresolvedArea(idref, res);
66              }
67          }
68      }
69 }
70
71
Popular Tags