KickJava   Java API By Example, From Geeks To Geeks.

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


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: DimensionPropertyMaker.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  * @author me
28  *
29  * To change the template for this generated type comment go to
30  * Window - Preferences - Java - Code Generation - Code and Comments
31  */

32 public class DimensionPropertyMaker extends CorrespondingPropertyMaker {
33     int[][] extraCorresponding = null;
34
35     public DimensionPropertyMaker(PropertyMaker baseMaker) {
36         super(baseMaker);
37     }
38     
39     public void setExtraCorresponding(int[][] extraCorresponding) {
40         this.extraCorresponding = extraCorresponding;
41     }
42
43     public boolean isCorrespondingForced(PropertyList propertyList) {
44         if (super.isCorrespondingForced(propertyList))
45             return true;
46         for (int i = 0; i < extraCorresponding.length; i++) {
47             int wmcorr = extraCorresponding[i][0]; //propertyList.getWritingMode()];
48
if (propertyList.getExplicit(wmcorr) != null)
49                 return true;
50         }
51         return false;
52     }
53
54     public Property compute(PropertyList propertyList) throws PropertyException {
55         // Based on [width|height]
56
Property p = super.compute(propertyList);
57         if (p == null) {
58             p = baseMaker.make(propertyList);
59         }
60
61         // Based on min-[width|height]
62
int wmcorr = propertyList.getWritingMode(extraCorresponding[0][0],
63                                         extraCorresponding[0][1],
64                                         extraCorresponding[0][2]);
65         Property subprop = propertyList.getExplicitOrShorthand(wmcorr);
66         if (subprop != null) {
67             baseMaker.setSubprop(p, Constants.CP_MINIMUM, subprop);
68         }
69
70         // Based on max-[width|height]
71
wmcorr = propertyList.getWritingMode(extraCorresponding[1][0],
72                                     extraCorresponding[1][1],
73                                     extraCorresponding[1][2]);
74         subprop = propertyList.getExplicitOrShorthand(wmcorr);
75         // TODO: Don't set when NONE.
76
if (subprop != null) {
77             baseMaker.setSubprop(p, Constants.CP_MAXIMUM, subprop);
78         }
79
80         return p;
81     }
82 }
83
Popular Tags