1 17 18 19 20 package org.apache.fop.area.inline; 21 22 import org.apache.fop.area.Area; 23 import org.apache.fop.area.LineArea; 24 import org.apache.fop.area.Trait; 25 26 31 public class InlineArea extends Area { 32 33 38 protected class InlineAdjustingInfo { 39 40 protected int availableStretch; 41 42 protected int availableShrink; 43 44 protected int adjustment; 45 46 53 protected InlineAdjustingInfo(int stretch, int shrink, int adj) { 54 availableStretch = stretch; 55 availableShrink = shrink; 56 adjustment = adj; 57 } 58 59 65 protected int applyVariationFactor(double variationFactor) { 66 int oldAdjustment = adjustment; 67 adjustment *= variationFactor; 68 return adjustment - oldAdjustment; 69 } 70 } 71 72 75 protected int offset = 0; 76 77 82 private Area parentArea = null; 83 84 89 private int storedIPDVariation = 0; 90 91 94 protected InlineAdjustingInfo adjustingInfo = null; 95 96 99 public InlineAdjustingInfo getAdjustingInfo() { 100 return adjustingInfo; 101 } 102 103 109 public void setAdjustingInfo(int stretch, int shrink, int adjustment) { 110 adjustingInfo = new InlineAdjustingInfo(stretch, shrink, adjustment); 111 } 112 113 117 public void setAdjustment(int adjustment) { 118 if (adjustingInfo != null) { 119 adjustingInfo.adjustment = adjustment; 120 } 121 } 122 123 129 public void increaseIPD(int ipd) { 130 this.ipd += ipd; 131 } 132 133 140 public void setOffset(int offset) { 141 this.offset = offset; 142 } 143 144 151 public int getOffset() { 152 return offset; 153 } 154 155 158 public void setParentArea(Area parentArea) { 159 this.parentArea = parentArea; 160 } 161 162 165 public Area getParentArea() { 166 return parentArea; 167 } 168 169 174 public void addChildArea(Area childArea) { 175 super.addChildArea(childArea); 176 if (childArea instanceof InlineArea) { 177 ((InlineArea) childArea).setParentArea(this); 178 } 179 } 180 181 184 public boolean hasUnderline() { 185 return getBooleanTrait(Trait.UNDERLINE); 186 } 187 188 189 public boolean hasOverline() { 190 return getBooleanTrait(Trait.OVERLINE); 191 } 192 193 194 public boolean hasLineThrough() { 195 return getBooleanTrait(Trait.LINETHROUGH); 196 } 197 198 199 public boolean isBlinking() { 200 return getBooleanTrait(Trait.BLINK); 201 } 202 203 210 public boolean applyVariationFactor(double variationFactor, 211 int lineStretch, int lineShrink) { 212 if (adjustingInfo != null) { 214 setIPD(getIPD() + adjustingInfo.applyVariationFactor(variationFactor)); 215 } 216 return false; 217 } 218 219 public void handleIPDVariation(int ipdVariation) { 220 increaseIPD(ipdVariation); 221 notifyIPDVariation(ipdVariation); 222 } 223 224 229 protected void notifyIPDVariation(int ipdVariation) { 230 if (getParentArea() instanceof InlineArea) { 231 ((InlineArea) getParentArea()).handleIPDVariation(ipdVariation); 232 } else if (getParentArea() instanceof LineArea) { 233 ((LineArea) getParentArea()).handleIPDVariation(ipdVariation); 234 } else if (getParentArea() == null) { 235 storedIPDVariation += ipdVariation; 237 } 238 } 239 } 240 241 | Popular Tags |