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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Ems.java
  3. * $Id$
  4. * Created: Wed Nov 21 15:39:30 2001
  5. *
  6. *
  7. * Copyright 1999-2003 The Apache Software Foundation.
  8. *
  9. * Licensed under the Apache License, Version 2.0 (the "License");
  10. * you may not use this file except in compliance with the License.
  11. * You may obtain a copy of the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing, software
  16. * distributed under the License is distributed on an "AS IS" BASIS,
  17. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. * See the License for the specific language governing permissions and
  19. * limitations under the License.
  20. *
  21. *
  22. */
  23. package org.apache.fop.datatypes;
  24. import org.apache.fop.fo.FONode;
  25. import org.apache.fop.fo.PropNames;
  26. import org.apache.fop.fo.PropertyConsts;
  27. import org.apache.fop.fo.expr.PropertyException;
  28. /**
  29. * Constructor class for relative lengths measured in <i>ems</i>. Constructs
  30. * a <tt>Numeric</tt>.
  31. * @author <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
  32. * @version $Revision$ $Name$
  33. */
  34. public class Ems {
  35. private static final String tag = "$Name$";
  36. private static final String revision = "$Revision$";
  37. /**
  38. * Private constructor - don't instantiate a <i>Ems</i> object.
  39. */
  40. private Ems() {}
  41. /**
  42. * Construct a <tt>Numeric</tt> with a given unit and quantity.
  43. * The unit power is assumed as 1. The base unit is millipoints.
  44. * @param node - the <tt>FONode</tt> with reference to which this
  45. * <i>EM</i> value is being consructed. A null value imples the
  46. * construction of an <i>initial value</i>.
  47. * @param property the index of the property with which this value
  48. * is associated.
  49. * @param value the number of units.
  50. * @return a <tt>Numeric</tt> representing this <i>Ems</i>.
  51. */
  52. public static Numeric makeEms(FONode node, int property, double value)
  53. throws PropertyException
  54. {
  55. Numeric numeric = new Numeric(property, value, Numeric.EMS, 0, 0);
  56. if (node == null)
  57. numeric.expandEms((Numeric)
  58. (PropertyConsts.pconsts.getInitialValue(PropNames.FONT_SIZE)));
  59. else
  60. numeric.expandEms(node.currentFontSize());
  61. return numeric;
  62. }
  63. /**
  64. * Construct a <tt>Numeric</tt> with a given unit and quantity.
  65. * The unit power is assumed as 1. The base unit is millipoints.
  66. * @param node - the <tt>FONode</tt> with reference to which this
  67. * <i>EM</i> value is being consructed. A null value imples the
  68. * construction of an <i>initial value</i>.
  69. * @param propertyName the name of the property with which this value
  70. * is associated.
  71. * @param value the number of units.
  72. * @return a <tt>Numeric</tt> representing this <i>Ems</i>.
  73. */
  74. public static Numeric makeEms
  75. (FONode node, String propertyName, double value)
  76. throws PropertyException
  77. {
  78. return makeEms(node, PropNames.getPropertyIndex(propertyName), value);
  79. }
  80. }