1 17 18 19 20 package org.apache.fop.fo.properties; 21 import org.apache.fop.fo.Constants; 22 import org.apache.fop.fo.FObj; 23 import org.apache.fop.fo.PropertyList; 24 import org.apache.fop.fo.expr.PropertyException; 25 26 30 public class FontStretchPropertyMaker 31 extends EnumProperty.Maker implements Constants { 32 33 35 private Property[] orderedFontStretchValues = null; 36 37 41 public FontStretchPropertyMaker(int propId) { 42 super(propId); 43 } 44 45 49 public Property convertProperty(Property p, 50 PropertyList propertyList, 51 FObj fo) throws PropertyException { 52 if (p.getEnum() == EN_NARROWER) { 55 return computeNextAbsoluteFontStretch(propertyList.getFromParent(this.getPropId()), -1); 56 } else if (p.getEnum() == EN_WIDER) { 57 return computeNextAbsoluteFontStretch(propertyList.getFromParent(this.getPropId()), 1); 58 } 59 return super.convertProperty(p, propertyList, fo); 60 } 61 62 68 private Property computeNextAbsoluteFontStretch(Property baseProperty, int direction) { 69 if (orderedFontStretchValues == null) { 72 orderedFontStretchValues = new Property[] { 73 checkEnumValues("ultra-condensed"), 74 checkEnumValues("extra-condensed"), 75 checkEnumValues("condensed"), 76 checkEnumValues("semi-condensed"), 77 checkEnumValues("normal"), 78 checkEnumValues("semi-expanded"), 79 checkEnumValues("expanded"), 80 checkEnumValues("extra-expanded"), 81 checkEnumValues("ultra-expanded") 82 }; 83 } 84 int baseValue = baseProperty.getEnum(); 85 for (int i = 0; i < orderedFontStretchValues.length; i++) { 86 if (baseValue == orderedFontStretchValues[i].getEnum()) { 87 i = Math.min(Math.max(0, i + direction), orderedFontStretchValues.length - 1); 89 return orderedFontStretchValues[i]; 90 } 91 } 92 return orderedFontStretchValues[4]; 94 } 95 96 } 97 | Popular Tags |