001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /* $Id: Leader.java 554094 2007-07-07 00:04:25Z adelmelle $ */
019:
020: package org.apache.fop.fo.flow;
021:
022: import org.apache.fop.apps.FOPException;
023: import org.apache.fop.datatypes.Length;
024: import org.apache.fop.fo.FONode;
025: import org.apache.fop.fo.PropertyList;
026: import org.apache.fop.fo.properties.CommonRelativePosition;
027: import org.apache.fop.fo.properties.KeepProperty;
028: import org.apache.fop.fo.properties.LengthRangeProperty;
029: import org.apache.fop.fo.properties.SpaceProperty;
030:
031: /**
032: * Class modelling fo:leader object.
033: * The main property of fo:leader is leader-pattern.
034: * The following patterns are treated: rule, space, dots and use-content.
035: * @todo implement validateChildNode()
036: */
037: public class Leader extends InlineLevel {
038: // The value of properties relevant for fo:leader.
039: // See also superclass InlineLevel
040: private Length alignmentAdjust;
041: private int alignmentBaseline;
042: private Length baselineShift;
043: private int dominantBaseline;
044: private int leaderAlignment;
045: private LengthRangeProperty leaderLength;
046: private int leaderPattern;
047: private Length leaderPatternWidth;
048: private int ruleStyle;
049: private Length ruleThickness;
050:
051: // private ToBeImplementedProperty letterSpacing;
052: // private ToBeImplementedProperty textShadow;
053: // Unused but valid items, commented out for performance:
054: // private CommonRelativePosition commonRelativePosition;
055: // private Length textDepth;
056: // private Length textAltitude;
057: // private KeepProperty keepWithNext;
058: // private KeepProperty keepWithPrevious;
059: // private SpaceProperty wordSpacing;
060: // End of property values
061:
062: /**
063: * @param parent FONode that is the parent of this object
064: */
065: public Leader(FONode parent) {
066: super (parent);
067: }
068:
069: /**
070: * @see org.apache.fop.fo.FObj#bind(PropertyList)
071: */
072: public void bind(PropertyList pList) throws FOPException {
073: super .bind(pList);
074: alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength();
075: alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum();
076: baselineShift = pList.get(PR_BASELINE_SHIFT).getLength();
077: dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum();
078: leaderAlignment = pList.get(PR_LEADER_ALIGNMENT).getEnum();
079: leaderLength = pList.get(PR_LEADER_LENGTH).getLengthRange();
080: leaderPattern = pList.get(PR_LEADER_PATTERN).getEnum();
081: leaderPatternWidth = pList.get(PR_LEADER_PATTERN_WIDTH)
082: .getLength();
083: switch (leaderPattern) {
084: case EN_SPACE:
085: // use Space
086: break;
087: case EN_RULE:
088: // the following properties only apply
089: // for leader-pattern = "rule"
090: ruleStyle = pList.get(PR_RULE_STYLE).getEnum();
091: ruleThickness = pList.get(PR_RULE_THICKNESS).getLength();
092: break;
093: case EN_DOTS:
094: break;
095: case EN_USECONTENT:
096: // use inline layout manager to create inline areas
097: // add the inline parent multiple times until leader full
098: break;
099: default:
100: throw new RuntimeException("Invalid leader pattern: "
101: + leaderPattern);
102: }
103: // letterSpacing = pList.get(PR_LETTER_SPACING);
104: // textShadow = pList.get(PR_TEXT_SHADOW);
105: }
106:
107: /**
108: * @return the "rule-style" property.
109: */
110: public int getRuleStyle() {
111: return ruleStyle;
112: }
113:
114: /**
115: * @return the "rule-thickness" property.
116: */
117: public Length getRuleThickness() {
118: return ruleThickness;
119: }
120:
121: /**
122: * @return the "leader-alignment" property.
123: */
124: public int getLeaderAlignment() {
125: return leaderAlignment;
126: }
127:
128: /**
129: * @return the "leader-length" property.
130: */
131: public LengthRangeProperty getLeaderLength() {
132: return leaderLength;
133: }
134:
135: /**
136: * @return the "leader-pattern" property.
137: */
138: public int getLeaderPattern() {
139: return leaderPattern;
140: }
141:
142: /**
143: * @return the "leader-pattern-width" property.
144: */
145: public Length getLeaderPatternWidth() {
146: return leaderPatternWidth;
147: }
148:
149: /**
150: * @return the "alignment-adjust" property
151: */
152: public Length getAlignmentAdjust() {
153: return alignmentAdjust;
154: }
155:
156: /**
157: * @return the "alignment-baseline" property
158: */
159: public int getAlignmentBaseline() {
160: return alignmentBaseline;
161: }
162:
163: /**
164: * @return the "baseline-shift" property
165: */
166: public Length getBaselineShift() {
167: return baselineShift;
168: }
169:
170: /**
171: * @return the "dominant-baseline" property
172: */
173: public int getDominantBaseline() {
174: return dominantBaseline;
175: }
176:
177: /** @see org.apache.fop.fo.FONode#getLocalName() */
178: public String getLocalName() {
179: return "leader";
180: }
181:
182: /**
183: * @see org.apache.fop.fo.FObj#getNameId()
184: */
185: public int getNameId() {
186: return FO_LEADER;
187: }
188: }
|