1 17 18 19 20 package org.apache.fop.fo.properties; 21 22 import org.apache.fop.datatypes.PercentBaseContext; 23 import org.apache.fop.datatypes.PercentBase; 24 import org.apache.fop.fo.expr.PropertyException; 25 26 29 public class PercentLength extends LengthProperty { 30 31 35 private double factor; 36 37 41 private PercentBase lbase = null; 42 43 private double resolvedValue; 44 45 53 public PercentLength(double factor, PercentBase lbase) { 54 this.factor = factor; 55 this.lbase = lbase; 56 } 57 58 61 public PercentBase getBaseLength() { 62 return this.lbase; 63 } 64 65 71 protected double getPercentage() { 72 return factor * 100; 73 } 74 75 79 public boolean isAbsolute() { 80 return false; 81 } 82 83 86 public double getNumericValue() { 87 return getNumericValue(null); 88 } 89 90 93 public double getNumericValue(PercentBaseContext context) { 94 try { 95 resolvedValue = factor * lbase.getBaseLength(context); 96 return resolvedValue; 97 } catch (PropertyException exc) { 98 log.error(exc); 99 return 0; 100 } 101 } 102 103 107 public int getValue() { 108 return (int) getNumericValue(); 109 } 110 111 114 public int getValue(PercentBaseContext context) { 115 return (int) getNumericValue(context); 116 } 117 118 121 public String toString() { 122 return (new Double (factor * 100.0).toString()) + "%"; 124 } 125 126 } 127 | Popular Tags |