import java.text.BreakIterator;
import java.util.Map;
+import org.apache.fop.apps.FOPException;
import org.apache.fop.datastructs.Node;
import org.apache.fop.datatypes.TextDecorations;
import org.apache.fop.fo.FOPageSeqNode;
* @param sync the synchronization object of this node
*/
public LineArea(String text, FoPageSequence pageSeq,
- FOPageSeqNode generatedBy, Node parent, Object sync) {
+ FOPageSeqNode generatedBy, Node parent, Object sync)
+ throws PropertyException, FOPException {
super(pageSeq, generatedBy, parent, sync);
generator = generatedBy;
this.text = text;
- try {
- preprocessText();
- } catch (PropertyException e) {
- throw new RuntimeException(e);
- } catch (FontException e) {
- throw new RuntimeException(e);
- }
+ preprocessText();
}
/** <code>generatedBy</code> as an <code>FOPageSeqNode</code> */
* attributes of the text are applied.
*/
private void preprocessText() throws PropertyException, FontException {
- // Get the font, size, style and weight attributes
- attributes = generator.getFontAttributes();
- font = generator.getFopFont(attributes);
- TextDecorations decorations = generator.getDecorations();
- // Add the text decorations
- // TODO separate color support for text decorations
- if (decorations.underlined()) {
- attributes.put(TextAttribute.UNDERLINE,
- TextAttribute.UNDERLINE_LOW_ONE_PIXEL);
- }
- if (decorations.overlined()) {
- // Not supported yet
- }
- if (decorations.struckthrough()) {
- attributes.put(TextAttribute.STRIKETHROUGH,
- TextAttribute.STRIKETHROUGH_ON);
- }
- attText = new AttributedString(text, attributes);
- AttributedCharacterIterator iter = attText.getIterator();
- FontRenderContext identityFRC =
- new FontRenderContext(
- null, IS_ANTI_ALIASED, USES_FRACTIONAL_METRICS);
- measurer = new TextMeasurer(iter, identityFRC);
- layout = new TextLayout(iter, identityFRC);
+ setupMeasurement();
// Find minima and maxima for this text
// Text dimensions based on baseline-to-baseline leading and the
// descent of the TextLayout
// To determine the minima, the shortest length of text is determined,
// a TextLayout is formed from that, and the corresponding BPDim and
// IPDim values are determined.
- iPDimMax = new Float(layout.getVisibleAdvance());
- bPDimMax =
- new Float(Math.max(
+ pageSpaceRange.setIPDimMax(layout.getVisibleAdvance());
+ pageSpaceRange.setBPDimMax(Math.max(
layout.getLeading(),
(layout.getAscent() + layout.getDescent())));
// Find the longest fragment of the text
maxWordWidth = Math.max(maxWordWidth, width);
begin = boundary;
}
- iPDimMin = new Float(maxWordWidth);
+ pageSpaceRange.setIPDimMin(maxWordWidth);
// For now, set bPDimMin = bPDimMax.
- bPDimMin = bPDimMax;
+ pageSpaceRange.setBPDimMin(maxWordWidth);
}
+ private void setupMeasurement() throws PropertyException, FontException {
+ // Get the font, size, style and weight attributes
+ attributes = generator.getFontAttributes();
+ font = generator.getFopFont(attributes);
+ TextDecorations decorations = generator.getDecorations();
+ // Add the text decorations
+ // TODO separate color support for text decorations
+ if (decorations.underlined()) {
+ attributes.put(TextAttribute.UNDERLINE,
+ TextAttribute.UNDERLINE_LOW_ONE_PIXEL);
+ }
+ if (decorations.overlined()) {
+ // Not supported yet
+ }
+ if (decorations.struckthrough()) {
+ attributes.put(TextAttribute.STRIKETHROUGH,
+ TextAttribute.STRIKETHROUGH_ON);
+ }
+ attText = new AttributedString(text, attributes);
+ AttributedCharacterIterator iter = attText.getIterator();
+ FontRenderContext identityFRC =
+ new FontRenderContext(
+ null, IS_ANTI_ALIASED, USES_FRACTIONAL_METRICS);
+ measurer = new TextMeasurer(iter, identityFRC);
+ layout = new TextLayout(iter, identityFRC);
+
+ }
}