use of org.apache.poi.sl.usermodel.AutoNumberingScheme in project poi by apache.
the class DrawTextParagraph method getBullet.
protected DrawTextFragment getBullet(Graphics2D graphics, AttributedCharacterIterator firstLineAttr) {
BulletStyle bulletStyle = paragraph.getBulletStyle();
if (bulletStyle == null) {
return null;
}
String buCharacter;
AutoNumberingScheme ans = bulletStyle.getAutoNumberingScheme();
if (ans != null) {
buCharacter = ans.format(autoNbrIdx);
} else {
buCharacter = bulletStyle.getBulletCharacter();
}
if (buCharacter == null) {
return null;
}
String buFont = bulletStyle.getBulletFont();
if (buFont == null) {
buFont = paragraph.getDefaultFontFamily();
}
assert (buFont != null);
PlaceableShape<?, ?> ps = getParagraphShape();
PaintStyle fgPaintStyle = bulletStyle.getBulletFontColor();
Paint fgPaint;
if (fgPaintStyle == null) {
fgPaint = (Paint) firstLineAttr.getAttribute(TextAttribute.FOREGROUND);
} else {
fgPaint = new DrawPaint(ps).getPaint(graphics, fgPaintStyle);
}
float fontSize = (Float) firstLineAttr.getAttribute(TextAttribute.SIZE);
Double buSz = bulletStyle.getBulletFontSize();
if (buSz == null) {
buSz = 100d;
}
if (buSz > 0) {
fontSize *= buSz * 0.01;
} else {
fontSize = (float) -buSz;
}
AttributedString str = new AttributedString(mapFontCharset(buCharacter, buFont));
str.addAttribute(TextAttribute.FOREGROUND, fgPaint);
str.addAttribute(TextAttribute.FAMILY, buFont);
str.addAttribute(TextAttribute.SIZE, fontSize);
TextLayout layout = new TextLayout(str.getIterator(), graphics.getFontRenderContext());
DrawFactory fact = DrawFactory.getInstance(graphics);
return fact.getTextFragment(layout, str);
}
use of org.apache.poi.sl.usermodel.AutoNumberingScheme in project poi by apache.
the class XSLFTextParagraph method getAutoNumberingScheme.
/**
* @return the auto numbering scheme, or null if not defined
*/
public AutoNumberingScheme getAutoNumberingScheme() {
ParagraphPropertyFetcher<AutoNumberingScheme> fetcher = new ParagraphPropertyFetcher<AutoNumberingScheme>(getIndentLevel()) {
public boolean fetch(CTTextParagraphProperties props) {
if (props.isSetBuAutoNum()) {
AutoNumberingScheme ans = AutoNumberingScheme.forOoxmlID(props.getBuAutoNum().getType().intValue());
if (ans != null) {
setValue(ans);
return true;
}
}
return false;
}
};
fetchParagraphProperty(fetcher);
return fetcher.getValue();
}
Aggregations