1 17 18 19 20 package org.apache.fop.fo.properties; 21 22 import org.apache.fop.datatypes.PercentBaseContext; 23 24 27 public class FixedLength extends LengthProperty { 28 private int millipoints; 29 30 35 public FixedLength(double numRelUnits, int iCurFontSize) { 36 millipoints = (int) (numRelUnits * (double)iCurFontSize); 37 } 38 39 44 public FixedLength(double numUnits, String units) { 45 convert(numUnits, units); 46 } 47 48 51 public FixedLength(int baseUnits) { 52 millipoints = baseUnits; 53 } 54 55 61 protected void convert(double dvalue, String unit) { 62 64 int assumedResolution = 1; 66 if (unit.equals("in")) { 67 dvalue = dvalue * 72; 68 } else if (unit.equals("cm")) { 69 dvalue = dvalue * 28.3464567; 70 } else if (unit.equals("mm")) { 71 dvalue = dvalue * 2.83464567; 72 } else if (unit.equals("pt")) { 73 } else if (unit.equals("mpt")) { } else if (unit.equals("pc")) { 80 dvalue = dvalue * 12; 81 85 } else if (unit.equals("px")) { 86 dvalue = dvalue * assumedResolution; 88 } else { 89 dvalue = 0; 90 log.error("Unknown length unit '" + unit + "'"); 91 } 92 if (unit.equals("mpt")) { 93 millipoints = (int)dvalue; 94 } else { 95 millipoints = (int)(dvalue * 1000); 96 } 97 } 98 99 102 public int getValue() { 103 return millipoints; 104 } 105 106 109 public int getValue(PercentBaseContext context) { 110 return millipoints; 111 } 112 113 116 public double getNumericValue() { 117 return millipoints; 118 } 119 120 123 public double getNumericValue(PercentBaseContext context) { 124 return millipoints; 125 } 126 127 131 public boolean isAbsolute() { 132 return true; 133 } 134 135 138 public String toString() { 139 return millipoints + "mpt"; 140 } 141 142 } 143 144 | Popular Tags |