1 17 18 19 20 package org.apache.fop.fo.flow; 21 22 import org.apache.fop.apps.FOPException; 23 import org.apache.fop.datatypes.Length; 24 import org.apache.fop.fo.FONode; 25 import org.apache.fop.fo.FObj; 26 import org.apache.fop.fo.PropertyList; 27 import org.apache.fop.fo.properties.CommonAccessibility; 28 import org.apache.fop.fo.properties.CommonAural; 29 import org.apache.fop.fo.properties.CommonBorderPaddingBackground; 30 import org.apache.fop.fo.properties.CommonMarginInline; 31 import org.apache.fop.fo.properties.CommonRelativePosition; 32 import org.apache.fop.fo.properties.KeepProperty; 33 import org.apache.fop.fo.properties.LengthRangeProperty; 34 import org.apache.fop.fo.properties.SpaceProperty; 35 36 40 public abstract class AbstractGraphics extends FObj { 41 42 private CommonBorderPaddingBackground commonBorderPaddingBackground; 45 private Length alignmentAdjust; 46 private int alignmentBaseline; 47 private Length baselineShift; 48 private LengthRangeProperty blockProgressionDimension; 49 private Length contentHeight; 51 private Length contentWidth; 52 private int displayAlign; 53 private int dominantBaseline; 54 private Length height; 55 private String id; 56 private LengthRangeProperty inlineProgressionDimension; 57 private SpaceProperty lineHeight; 58 private int overflow; 59 private int scaling; 60 private int textAlign; 61 private Length width; 62 73 74 75 80 public AbstractGraphics(FONode parent) { 81 super(parent); 82 } 83 84 87 public void bind(PropertyList pList) throws FOPException { 88 commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); 89 alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength(); 90 alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum(); 91 baselineShift = pList.get(PR_BASELINE_SHIFT).getLength(); 92 blockProgressionDimension = pList.get(PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange(); 93 contentHeight = pList.get(PR_CONTENT_HEIGHT).getLength(); 95 contentWidth = pList.get(PR_CONTENT_WIDTH).getLength(); 96 displayAlign = pList.get(PR_DISPLAY_ALIGN).getEnum(); 97 dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum(); 98 height = pList.get(PR_HEIGHT).getLength(); 99 id = pList.get(PR_ID).getString(); 100 inlineProgressionDimension = pList.get(PR_INLINE_PROGRESSION_DIMENSION).getLengthRange(); 101 lineHeight = pList.get(PR_LINE_HEIGHT).getSpace(); 102 overflow = pList.get(PR_OVERFLOW).getEnum(); 103 scaling = pList.get(PR_SCALING).getEnum(); 104 textAlign = pList.get(PR_TEXT_ALIGN).getEnum(); 105 width = pList.get(PR_WIDTH).getLength(); 106 } 107 108 115 public int computeXOffset (int ipd, int cwidth) { 116 int xoffset = 0; 117 switch (textAlign) { 118 case EN_CENTER: 119 xoffset = (ipd - cwidth) / 2; 120 break; 121 case EN_END: 122 xoffset = ipd - cwidth; 123 break; 124 case EN_START: 125 break; 126 case EN_JUSTIFY: 127 default: 128 break; 129 } 130 return xoffset; 131 } 132 133 140 public int computeYOffset(int bpd, int cheight) { 141 int yoffset = 0; 142 switch (displayAlign) { 143 case EN_BEFORE: 144 break; 145 case EN_AFTER: 146 yoffset = bpd - cheight; 147 break; 148 case EN_CENTER: 149 yoffset = (bpd - cheight) / 2; 150 break; 151 case EN_AUTO: 152 default: 153 break; 154 } 155 return yoffset; 156 } 157 158 161 public String getId() { 162 return id; 163 } 164 165 168 public CommonBorderPaddingBackground getCommonBorderPaddingBackground() { 169 return commonBorderPaddingBackground; 170 } 171 172 175 public SpaceProperty getLineHeight() { 176 return lineHeight; 177 } 178 179 182 public LengthRangeProperty getInlineProgressionDimension() { 183 return inlineProgressionDimension; 184 } 185 186 189 public LengthRangeProperty getBlockProgressionDimension() { 190 return blockProgressionDimension; 191 } 192 193 196 public Length getHeight() { 197 return height; 198 } 199 200 203 public Length getWidth() { 204 return width; 205 } 206 207 210 public Length getContentHeight() { 211 return contentHeight; 212 } 213 214 217 public Length getContentWidth() { 218 return contentWidth; 219 } 220 221 224 public int getScaling() { 225 return scaling; 226 } 227 228 231 public int getOverflow() { 232 return overflow; 233 } 234 235 238 public Length getAlignmentAdjust() { 239 return alignmentAdjust; 240 } 241 242 245 public int getAlignmentBaseline() { 246 return alignmentBaseline; 247 } 248 249 252 public Length getBaselineShift() { 253 return baselineShift; 254 } 255 256 259 public int getDominantBaseline() { 260 return dominantBaseline; 261 } 262 263 266 public abstract int getIntrinsicWidth(); 267 268 271 public abstract int getIntrinsicHeight(); 272 } 273 | Popular Tags |