KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > fo > properties > BackgroundPositionShorthandParser


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: BackgroundPositionShorthandParser.java 454018 2006-10-07 21:00:13Z pietsch $ */
19
20 package org.apache.fop.fo.properties;
21
22 import java.util.List JavaDoc;
23 import org.apache.fop.fo.Constants;
24 import org.apache.fop.fo.PropertyList;
25 import org.apache.fop.fo.expr.PropertyException;
26
27 /**
28  * A shorthand parser for the background-position shorthand
29  */

30
31 public class BackgroundPositionShorthandParser extends GenericShorthandParser {
32
33     /**
34      * @see org.apache.fop.fo.properties.ShorthandParser#getValueForProperty(int, Property, PropertyMaker, PropertyList)
35      */

36     public Property getValueForProperty(int propId,
37                                         Property property,
38                                         PropertyMaker maker,
39                                         PropertyList propertyList)
40                     throws PropertyException {
41         
42         int index = -1;
43         List JavaDoc propList = property.getList();
44         if (propId == Constants.PR_BACKGROUND_POSITION_HORIZONTAL) {
45             index = 0;
46         } else if (propId == Constants.PR_BACKGROUND_POSITION_VERTICAL) {
47             index = 1;
48             if (propList.size() == 1) {
49                 /* only background-position-horizontal specified
50                  * through the shorthand:
51                  * background-position-vertical=50% (see: XSL-FO 1.0 -- 7.29.2)
52                  */

53                 return maker.make(propertyList, "50%", propertyList.getParentFObj());
54             }
55         }
56         if (index >= 0) {
57             return (Property) propList.get(index);
58         } // else: invalid index? shouldn't happen...
59
return null;
60     }
61 }
62
Popular Tags