KickJava   Java API By Example, From Geeks To Geeks.

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


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: VerticalAlignShorthandParser.java 488960 2006-12-20 08:34:28Z spepping $ */
19
20 package org.apache.fop.fo.properties;
21 import org.apache.fop.fo.Constants;
22 import org.apache.fop.fo.PropertyList;
23
24 /**
25  * A shorthand parser for the vertical-align shorthand. It is used to set
26  * values for alignment-baseline, alignment-adjust, baseline-shift
27  * and dominant-baseline.
28  */

29 public class VerticalAlignShorthandParser implements ShorthandParser, Constants {
30
31     /**
32      * @see ShorthandParser#getValueForProperty(int, Property, PropertyMaker, PropertyList)
33      */

34     public Property getValueForProperty(int propId,
35                                         Property property,
36                                         PropertyMaker maker,
37                                         PropertyList propertyList) {
38         int propVal = property.getEnum();
39         switch (propVal) {
40             case EN_BASELINE:
41                 switch (propId) {
42                     case PR_ALIGNMENT_BASELINE:
43                         return EnumProperty.getInstance(EN_BASELINE, "BASELINE");
44                     case PR_ALIGNMENT_ADJUST:
45                         return new EnumLength(EnumProperty.getInstance(EN_AUTO, "AUTO"));
46                     case PR_BASELINE_SHIFT:
47                         return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
48                     case PR_DOMINANT_BASELINE:
49                         return EnumProperty.getInstance(EN_AUTO, "AUTO");
50                 }
51             case EN_TOP:
52                 switch (propId) {
53                     case PR_ALIGNMENT_BASELINE:
54                         return EnumProperty.getInstance(EN_BEFORE_EDGE, "BEFORE_EDGE");
55                     case PR_ALIGNMENT_ADJUST:
56                         return new EnumLength(EnumProperty.getInstance(EN_AUTO, "AUTO"));
57                     case PR_BASELINE_SHIFT:
58                         return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
59                     case PR_DOMINANT_BASELINE:
60                         return EnumProperty.getInstance(EN_AUTO, "AUTO");
61                 }
62             case EN_TEXT_TOP:
63                 switch (propId) {
64                     case PR_ALIGNMENT_BASELINE:
65                         return EnumProperty.getInstance(EN_TEXT_BEFORE_EDGE, "TEXT_BEFORE_EDGE");
66                     case PR_ALIGNMENT_ADJUST:
67                         return new EnumLength(EnumProperty.getInstance(EN_AUTO, "AUTO"));
68                     case PR_BASELINE_SHIFT:
69                         return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
70                     case PR_DOMINANT_BASELINE:
71                         return EnumProperty.getInstance(EN_AUTO, "AUTO");
72                 }
73             case EN_MIDDLE:
74                 switch (propId) {
75                     case PR_ALIGNMENT_BASELINE:
76                         return EnumProperty.getInstance(EN_MIDDLE, "MIDDLE");
77                     case PR_ALIGNMENT_ADJUST:
78                         return new EnumLength(EnumProperty.getInstance(EN_AUTO, "AUTO"));
79                     case PR_BASELINE_SHIFT:
80                         return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
81                     case PR_DOMINANT_BASELINE:
82                         return EnumProperty.getInstance(EN_AUTO, "AUTO");
83                 }
84             case EN_BOTTOM:
85                 switch (propId) {
86                     case PR_ALIGNMENT_BASELINE:
87                         return EnumProperty.getInstance(EN_AFTER_EDGE, "AFTER_EDGE");
88                     case PR_ALIGNMENT_ADJUST:
89                         return new EnumLength(EnumProperty.getInstance(EN_AUTO, "AUTO"));
90                     case PR_BASELINE_SHIFT:
91                         return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
92                     case PR_DOMINANT_BASELINE:
93                         return EnumProperty.getInstance(EN_AUTO, "AUTO");
94                 }
95             case EN_TEXT_BOTTOM:
96                 switch (propId) {
97                     case PR_ALIGNMENT_BASELINE:
98                         return EnumProperty.getInstance(EN_TEXT_AFTER_EDGE, "TEXT_AFTER_EDGE");
99                     case PR_ALIGNMENT_ADJUST:
100                         return new EnumLength(EnumProperty.getInstance(EN_AUTO, "AUTO"));
101                     case PR_BASELINE_SHIFT:
102                         return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
103                     case PR_DOMINANT_BASELINE:
104                         return EnumProperty.getInstance(EN_AUTO, "AUTO");
105                 }
106             case EN_SUB:
107                 switch (propId) {
108                     case PR_ALIGNMENT_BASELINE:
109                         return EnumProperty.getInstance(EN_BASELINE, "BASELINE");
110                     case PR_ALIGNMENT_ADJUST:
111                         return new EnumLength(EnumProperty.getInstance(EN_AUTO, "AUTO"));
112                     case PR_BASELINE_SHIFT:
113                         return new EnumLength(EnumProperty.getInstance(EN_SUB, "SUB"));
114                     case PR_DOMINANT_BASELINE:
115                         return EnumProperty.getInstance(EN_AUTO, "AUTO");
116                 }
117             case EN_SUPER:
118                 switch (propId) {
119                     case PR_ALIGNMENT_BASELINE:
120                         return EnumProperty.getInstance(EN_BASELINE, "BASELINE");
121                     case PR_ALIGNMENT_ADJUST:
122                         return new EnumLength(EnumProperty.getInstance(EN_AUTO, "AUTO"));
123                     case PR_BASELINE_SHIFT:
124                         return new EnumLength(EnumProperty.getInstance(EN_SUPER, "SUPER"));
125                     case PR_DOMINANT_BASELINE:
126                         return EnumProperty.getInstance(EN_AUTO, "AUTO");
127                 }
128             default:
129                 switch (propId) {
130                     case PR_ALIGNMENT_BASELINE:
131                         return EnumProperty.getInstance(EN_BASELINE, "BASELINE");
132                     case PR_ALIGNMENT_ADJUST:
133                         return property;
134                     case PR_BASELINE_SHIFT:
135                         return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
136                     case PR_DOMINANT_BASELINE:
137                         return EnumProperty.getInstance(EN_AUTO, "AUTO");
138                 }
139         }
140         return null;
141     }
142
143 }
144
Popular Tags