*/
int start = aci.getRunStart(extendedAtts);
int end = aci.getRunLimit(extendedAtts);
AttributedCharacterIterator runaci =
new AttributedCharacterSpanIterator(aci, start, end);
TextLayout layout = new TextLayout(runaci, frc);
if (layout.isVertical()) {
AttributedString as = new AttributedString(runaci);
if (runaci.getAttribute(GVTAttributedCharacterIterator.
TextAttribute.UNDERLINE) != null) {
as.addAttribute(TextAttribute.UNDERLINE,
TextAttribute.UNDERLINE_ON);
}
if (runaci.getAttribute(GVTAttributedCharacterIterator.
TextAttribute.STRIKETHROUGH) != null) {
as.addAttribute(TextAttribute.STRIKETHROUGH,
TextAttribute.STRIKETHROUGH_ON);
}
runaci = as.getIterator();
}
TextRun run = new TextRun(layout, runaci);
textRuns.add(run);
advance += (double) layout.getAdvance();
// FIXME: not BIDI compliant yet!
aci.setIndex(end);
}
double x = 0d;
switch(anchor.getType()){
case TextNode.Anchor.ANCHOR_MIDDLE:
x = -advance/2d;
break;
case TextNode.Anchor.ANCHOR_END:
x = -advance;
}
/*
* Adjust for Anchor (above), then
* we render each of the TextLayout glyphsets
* in turn.
*/
for (int i=0; i<textRuns.size(); ++i) {
TextRun textRun = (TextRun) textRuns.get(i);
AttributedCharacterIterator runaci = textRun.getACI();
TextLayout layout = textRun.getLayout();
runaci.first();
//System.out.print("Painting text: ");
//for (int j=runaci.getBeginIndex(); j<runaci.getEndIndex(); ++j) {
// System.out.print(runaci.setIndex(j));
//}
//System.out.println("");
runaci.first();
Composite opacity = (Composite)
runaci.getAttribute(GVTAttributedCharacterIterator.
TextAttribute.OPACITY);
if (opacity != null) {
g2d.setComposite(opacity);
}
boolean underline =
(runaci.getAttribute(GVTAttributedCharacterIterator.
TextAttribute.UNDERLINE) != null);
// paint over-and-underlines first, then layer glyphs over them
float thickness = getDecorationThickness(runaci, layout);
if (underline && !layout.isVertical()) {
paintUnderline(textRun, location, x, thickness, g2d);
}
boolean overline =
(runaci.getAttribute(GVTAttributedCharacterIterator.
TextAttribute.OVERLINE) != null);
if (overline && !layout.isVertical()) {
paintOverline(textRun, location, x, thickness, g2d);
}
AffineTransform tx = AffineTransform.getTranslateInstance(
location.getX() + x, location.getY());
Shape outline = layout.getOutline(tx);
// check if we need to fill this glyph
Paint paint = (Paint)
runaci.getAttribute(TextAttribute.FOREGROUND);
if (paint != null) {
g2d.setPaint(paint);
g2d.fill(outline);
}
// check if we need to draw the outline of this glyph
Stroke stroke = (Stroke) runaci.getAttribute(
GVTAttributedCharacterIterator.TextAttribute.STROKE);
paint = (Paint) runaci.getAttribute(
GVTAttributedCharacterIterator.TextAttribute.STROKE_PAINT);
if (stroke != null && paint != null) {
g2d.setStroke(stroke);
g2d.setPaint(paint);
g2d.draw(outline);
}
boolean strikethrough =
(runaci.getAttribute(GVTAttributedCharacterIterator.
TextAttribute.STRIKETHROUGH) ==
GVTAttributedCharacterIterator.
TextAttribute.STRIKETHROUGH_ON);
// paint strikethrough last
if (strikethrough && !layout.isVertical()) {