KickJava   Java API By Example, From Geeks To Geeks.

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


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: ReferenceOrientationMaker.java 454018 2006-10-07 21:00:13Z pietsch $ */
19
20 package org.apache.fop.fo.properties;
21
22 import org.apache.fop.fo.PropertyList;
23 import org.apache.fop.fo.expr.PropertyException;
24 import org.apache.fop.fo.properties.NumberProperty.Maker;
25
26 /**
27  * Custom Maker adding validity check for reference-orientation
28  */

29 public class ReferenceOrientationMaker extends Maker {
30
31     /**
32      * Constructor
33      * @param propId the Constant Id for the property to be made
34      * @see org.apache.fop.fo.properties.NumberProperty.Maker#PropertyMaker(propId)
35      */

36     public ReferenceOrientationMaker(int propId) {
37         super(propId);
38     }
39     
40     /**
41      * Check the value of the reference-orientation property.
42      *
43      * @see org.apache.fop.fo.properties.PropertyMaker#get(int, PropertyList, boolean, boolean)
44      */

45     public Property get(int subpropId, PropertyList propertyList,
46                         boolean tryInherit, boolean tryDefault)
47             throws PropertyException {
48         
49         Property p = super.get(0, propertyList, tryInherit, tryDefault);
50         int ro = 0;
51         if (p != null) {
52             ro = p.getNumeric().getValue();
53         }
54         if ((Math.abs(ro) % 90) == 0 && (Math.abs(ro) / 90) <= 3) {
55             return p;
56         } else {
57             throw new PropertyException("Illegal property value: "
58                     + "reference-orientation=\"" + ro + "\" "
59                     + "on " + propertyList.getFObj().getName());
60         }
61     }
62
63 }
64
Popular Tags