1 51 package org.apache.fop.datatypes; 52 53 import org.apache.fop.fo.expr.Numeric; 54 import org.apache.fop.messaging.MessageHandler; 55 56 59 public class FixedLength extends Length { 60 61 65 public FixedLength(double numRelUnits, int iCurFontSize) { 66 setComputedValue((int)(numRelUnits * (double)iCurFontSize)); 67 } 68 69 72 public FixedLength(double numUnits, String units) { 73 convert(numUnits, units); 74 } 75 76 79 public FixedLength(int baseUnits) { 80 setComputedValue(baseUnits); 81 } 82 83 87 protected void convert(double dvalue, String unit) { 88 89 int assumed_resolution = 1; 91 if (unit.equals("in")) 92 dvalue = dvalue * 72; 93 else if (unit.equals("cm")) 94 dvalue = dvalue * 28.3464567; 95 else if (unit.equals("mm")) 96 dvalue = dvalue * 2.83464567; 97 else if (unit.equals("pt")) 98 dvalue = dvalue; 99 else if (unit.equals("pc")) 100 dvalue = dvalue * 12; 101 105 else if (unit.equals("px")) 106 dvalue = dvalue * assumed_resolution; 107 else { 108 dvalue = 0; 109 MessageHandler.errorln("unknown length unit '" + unit 110 + "'"); 111 } 112 setComputedValue((int)(dvalue * 1000)); 113 } 114 115 public Numeric asNumeric() { 116 return new Numeric(this); 117 } 118 } 119 | Popular Tags |