您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Leader.java 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. /* $Id$ */
  18. package org.apache.fop.area.inline;
  19. import org.apache.fop.fo.Constants;
  20. /**
  21. * This is a leader inline area.
  22. * This class is only used for leader with leader-pattern of rule.
  23. */
  24. public class Leader extends InlineArea {
  25. // in the case of use content or dots this is replaced
  26. // with the set of inline areas
  27. // if space replaced with a space
  28. // otherwise this is a holder for a line
  29. private int ruleStyle = Constants.EN_SOLID;
  30. private int ruleThickness = 1000;
  31. /**
  32. * Create a new leader area.
  33. */
  34. public Leader() {
  35. }
  36. /**
  37. * Set the rule style of this leader area.
  38. *
  39. * @param style the rule style for the leader line
  40. */
  41. public void setRuleStyle(int style) {
  42. ruleStyle = style;
  43. }
  44. /**
  45. * Set the rule style of this leader area.
  46. * @param style the rule style for the leader area (XSL enum values)
  47. */
  48. public void setRuleStyle(String style) {
  49. if ("dotted".equalsIgnoreCase(style)) {
  50. setRuleStyle(Constants.EN_DOTTED);
  51. } else if ("dashed".equalsIgnoreCase(style)) {
  52. setRuleStyle(Constants.EN_DASHED);
  53. } else if ("solid".equalsIgnoreCase(style)) {
  54. setRuleStyle(Constants.EN_SOLID);
  55. } else if ("double".equalsIgnoreCase(style)) {
  56. setRuleStyle(Constants.EN_DOUBLE);
  57. } else if ("groove".equalsIgnoreCase(style)) {
  58. setRuleStyle(Constants.EN_GROOVE);
  59. } else if ("ridge".equalsIgnoreCase(style)) {
  60. setRuleStyle(Constants.EN_RIDGE);
  61. } else if ("none".equalsIgnoreCase(style)) {
  62. setRuleStyle(Constants.EN_NONE);
  63. }
  64. }
  65. /**
  66. * Set the rule thickness of the rule in miilipoints.
  67. *
  68. * @param rt the rule thickness in millipoints
  69. */
  70. public void setRuleThickness(int rt) {
  71. ruleThickness = rt;
  72. }
  73. /**
  74. * Get the rule style of this leader.
  75. *
  76. * @return the rule style
  77. */
  78. public int getRuleStyle() {
  79. return ruleStyle;
  80. }
  81. /** @return the rule style as string */
  82. public String getRuleStyleAsString() {
  83. switch (getRuleStyle()) {
  84. case Constants.EN_DOTTED: return "dotted";
  85. case Constants.EN_DASHED: return "dashed";
  86. case Constants.EN_SOLID: return "solid";
  87. case Constants.EN_DOUBLE: return "double";
  88. case Constants.EN_GROOVE: return "groove";
  89. case Constants.EN_RIDGE: return "ridge";
  90. case Constants.EN_NONE: return "none";
  91. default:
  92. throw new IllegalStateException("Unsupported rule style: " + getRuleStyle());
  93. }
  94. }
  95. /**
  96. * Get the rule thickness of the rule in miilipoints.
  97. *
  98. * @return the rule thickness in millipoints
  99. */
  100. public int getRuleThickness() {
  101. return ruleThickness;
  102. }
  103. }