KickJava   Java API By Example, From Geeks To Geeks.

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


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: BorderWidthPropertyMaker.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.fo.properties;
21
22 import org.apache.fop.fo.Constants;
23 import org.apache.fop.fo.PropertyList;
24 import org.apache.fop.fo.expr.PropertyException;
25
26 /**
27  * This subclass of LengthProperty.Maker handles the special treatment of
28  * border width described in 7.7.20.
29  */

30 public class BorderWidthPropertyMaker extends LengthProperty.Maker {
31     int borderStyleId = 0;
32     
33     /**
34      * Create a length property which check the value of the border-*-style
35      * property and return a length of 0 when the style is "none".
36      * @param propId the border-*-width of the property.
37      */

38     public BorderWidthPropertyMaker(int propId) {
39         super(propId);
40     }
41     
42     /**
43      * Set the propId of the style property for the same side.
44      * @param borderStyleId
45      */

46     public void setBorderStyleId(int borderStyleId) {
47         this.borderStyleId = borderStyleId;
48     }
49
50     /**
51      * Check the value of the style property and return a length of 0 when
52      * the style is NONE.
53      * @see org.apache.fop.fo.properties.PropertyMaker#get(int, PropertyList, boolean, boolean)
54      */

55    
56     public Property get(int subpropId, PropertyList propertyList,
57                         boolean bTryInherit, boolean bTryDefault)
58         throws PropertyException
59     {
60         Property p = super.get(subpropId, propertyList,
61                                bTryInherit, bTryDefault);
62
63         // Calculate the values as described in 7.7.20.
64
Property style = propertyList.get(borderStyleId);
65         if (style.getEnum() == Constants.EN_NONE) {
66             return new FixedLength(0);
67         }
68         return p;
69     }
70 }
71
Popular Tags