1 17 18 19 20 package org.apache.fop.area.inline; 21 22 25 public abstract class AbstractTextArea extends InlineParent { 26 27 32 protected class TextAdjustingInfo extends InlineAdjustingInfo { 33 34 38 protected int spaceDifference = 0; 39 40 47 protected TextAdjustingInfo(int stretch, int shrink, int adj) { 48 super(stretch, shrink, adj); 49 } 50 } 51 52 private int textWordSpaceAdjust = 0; 53 private int textLetterSpaceAdjust = 0; 54 private TextAdjustingInfo textAdjustingInfo = null; 55 private int baselineOffset = 0; 56 57 60 public AbstractTextArea() { 61 } 62 63 70 public AbstractTextArea(int stretch, int shrink, int adj) { 71 textAdjustingInfo = new TextAdjustingInfo(stretch, shrink, adj); 72 } 73 74 79 public int getTextWordSpaceAdjust() { 80 return textWordSpaceAdjust; 81 } 82 83 88 public void setTextWordSpaceAdjust(int textWordSpaceAdjust) { 89 this.textWordSpaceAdjust = textWordSpaceAdjust; 90 } 91 92 97 public int getTextLetterSpaceAdjust() { 98 return textLetterSpaceAdjust; 99 } 100 101 106 public void setTextLetterSpaceAdjust(int textLetterSpaceAdjust) { 107 this.textLetterSpaceAdjust = textLetterSpaceAdjust; 108 } 109 110 117 public void setSpaceDifference(int spaceDiff) { 118 textAdjustingInfo.spaceDifference = spaceDiff; 119 } 120 121 128 public boolean applyVariationFactor(double variationFactor, 129 int lineStretch, int lineShrink) { 130 if (textAdjustingInfo != null) { 131 double balancingFactor = 1.0; 139 if (variationFactor < 0) { 140 if (textWordSpaceAdjust < 0) { 141 balancingFactor 143 = ((double) textAdjustingInfo.availableStretch / textAdjustingInfo.availableShrink) 144 * ((double) lineShrink / lineStretch); 145 } else { 146 balancingFactor 148 = ((double) textAdjustingInfo.availableShrink / textAdjustingInfo.availableStretch) 149 * ((double) lineStretch / lineShrink); 150 } 151 } 152 textWordSpaceAdjust = (int) ((textWordSpaceAdjust - textAdjustingInfo.spaceDifference) 153 * variationFactor * balancingFactor) 154 + textAdjustingInfo.spaceDifference; 155 textLetterSpaceAdjust *= variationFactor; 156 int oldAdjustment = textAdjustingInfo.adjustment; 158 textAdjustingInfo.adjustment *= balancingFactor * variationFactor; 159 ipd += textAdjustingInfo.adjustment - oldAdjustment; 160 } 161 return false; 162 } 163 164 170 public int getBaselineOffset() { 171 return baselineOffset; 172 } 173 174 179 public void setBaselineOffset(int baselineOffset) { 180 this.baselineOffset = baselineOffset; 181 } 182 } 183 | Popular Tags |