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 426576 2006-07-28 15:44:37Z jeremias $ */
019:
020: package org.apache.fop.area.inline;
021:
022: import org.apache.fop.fo.Constants;
023:
024: /**
025: * This is a leader inline area.
026: * This class is only used for leader with leader-pattern of rule.
027: */
028: public class Leader extends InlineArea {
029:
030: // in the case of use content or dots this is replaced
031: // with the set of inline areas
032: // if space replaced with a space
033: // otherwise this is a holder for a line
034:
035: private int ruleStyle = Constants.EN_SOLID;
036: private int ruleThickness = 1000;
037:
038: /**
039: * Create a new leader area.
040: */
041: public Leader() {
042: }
043:
044: /**
045: * Set the rule style of this leader area.
046: *
047: * @param style the rule style for the leader line
048: */
049: public void setRuleStyle(int style) {
050: ruleStyle = style;
051: }
052:
053: /**
054: * Set the rule style of this leader area.
055: * @param style the rule style for the leader area (XSL enum values)
056: */
057: public void setRuleStyle(String style) {
058: if ("dotted".equalsIgnoreCase(style)) {
059: setRuleStyle(Constants.EN_DOTTED);
060: } else if ("dashed".equalsIgnoreCase(style)) {
061: setRuleStyle(Constants.EN_DASHED);
062: } else if ("solid".equalsIgnoreCase(style)) {
063: setRuleStyle(Constants.EN_SOLID);
064: } else if ("double".equalsIgnoreCase(style)) {
065: setRuleStyle(Constants.EN_DOUBLE);
066: } else if ("groove".equalsIgnoreCase(style)) {
067: setRuleStyle(Constants.EN_GROOVE);
068: } else if ("ridge".equalsIgnoreCase(style)) {
069: setRuleStyle(Constants.EN_RIDGE);
070: } else if ("none".equalsIgnoreCase(style)) {
071: setRuleStyle(Constants.EN_NONE);
072: }
073: }
074:
075: /**
076: * Set the rule thickness of the rule in miilipoints.
077: *
078: * @param rt the rule thickness in millipoints
079: */
080: public void setRuleThickness(int rt) {
081: ruleThickness = rt;
082: }
083:
084: /**
085: * Get the rule style of this leader.
086: *
087: * @return the rule style
088: */
089: public int getRuleStyle() {
090: return ruleStyle;
091: }
092:
093: /** @return the rule style as string */
094: public String getRuleStyleAsString() {
095: switch (getRuleStyle()) {
096: case Constants.EN_DOTTED:
097: return "dotted";
098: case Constants.EN_DASHED:
099: return "dashed";
100: case Constants.EN_SOLID:
101: return "solid";
102: case Constants.EN_DOUBLE:
103: return "double";
104: case Constants.EN_GROOVE:
105: return "groove";
106: case Constants.EN_RIDGE:
107: return "ridge";
108: case Constants.EN_NONE:
109: return "none";
110: default:
111: throw new IllegalStateException("Unsupported rule style: "
112: + getRuleStyle());
113: }
114: }
115:
116: /**
117: * Get the rule thickness of the rule in miilipoints.
118: *
119: * @return the rule thickness in millipoints
120: */
121: public int getRuleThickness() {
122: return ruleThickness;
123: }
124:
125: }
|