You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LengthProperty.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * $Id$
  3. * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
  4. * For details on use and redistribution please refer to the
  5. * LICENSE file included with these sources.
  6. */
  7. package org.apache.fop.fo;
  8. import org.apache.fop.datatypes.Length;
  9. import org.apache.fop.datatypes.AutoLength;
  10. import org.apache.fop.fo.expr.Numeric;
  11. import org.apache.fop.apps.FOPException;
  12. public class LengthProperty extends Property {
  13. public static class Maker extends Property.Maker {
  14. public /* protected */ Maker(String name) {
  15. super(name);
  16. }
  17. /**
  18. * protected Property checkPropertyKeywords(String value) {
  19. * if (isAutoLengthAllowed() && value.equals("auto")) {
  20. * return new LengthProperty(Length.AUTO);
  21. * }
  22. * return null;
  23. * }
  24. */
  25. protected boolean isAutoLengthAllowed() {
  26. return false;
  27. }
  28. public Property convertProperty(Property p,
  29. PropertyList propertyList,
  30. FObj fo) throws FOPException {
  31. if (isAutoLengthAllowed()) {
  32. String pval = p.getString();
  33. if (pval != null && pval.equals("auto")) {
  34. return new LengthProperty(new AutoLength());
  35. }
  36. }
  37. if (p instanceof LengthProperty) {
  38. return p;
  39. }
  40. Length val = p.getLength();
  41. if (val != null) {
  42. return new LengthProperty(val);
  43. }
  44. return convertPropertyDatatype(p, propertyList, fo);
  45. }
  46. }
  47. /*
  48. * public static Property.Maker maker(String prop) {
  49. * return new Maker(prop);
  50. * }
  51. */
  52. /**
  53. * This object may be also be a subclass of Length, such
  54. * as PercentLength, TableColLength.
  55. */
  56. private Length length;
  57. public LengthProperty(Length length) {
  58. this.length = length;
  59. // System.err.println("Set LengthProperty: " + length.toString());
  60. }
  61. public Numeric getNumeric() {
  62. return length.asNumeric() ;
  63. }
  64. public Length getLength() {
  65. return this.length;
  66. }
  67. public Object getObject() {
  68. return this.length;
  69. }
  70. }