use of org.apache.poi.xslf.model.PropertyFetcher in project poi by apache.
the class XSLFSimpleShape method getLineWidth.
/**
* @return line width in points. <code>0</code> means no line.
*/
public double getLineWidth() {
PropertyFetcher<Double> fetcher = new PropertyFetcher<Double>() {
@Override
public boolean fetch(XSLFShape shape) {
CTLineProperties ln = getLn(shape, false);
if (ln != null) {
if (ln.isSetNoFill()) {
setValue(0.);
return true;
}
if (ln.isSetW()) {
setValue(Units.toPoints(ln.getW()));
return true;
}
}
return false;
}
};
fetchShapeProperty(fetcher);
double lineWidth = 0;
if (fetcher.getValue() == null) {
CTLineProperties defaultLn = getDefaultLineProperties();
if (defaultLn != null) {
if (defaultLn.isSetW()) {
lineWidth = Units.toPoints(defaultLn.getW());
}
}
} else {
lineWidth = fetcher.getValue();
}
return lineWidth;
}
use of org.apache.poi.xslf.model.PropertyFetcher in project poi by apache.
the class XSLFShape method getFillPaint.
protected PaintStyle getFillPaint() {
final XSLFTheme theme = getSheet().getTheme();
final boolean hasPlaceholder = getPlaceholder() != null;
PropertyFetcher<PaintStyle> fetcher = new PropertyFetcher<PaintStyle>() {
public boolean fetch(XSLFShape shape) {
XSLFFillProperties fp = XSLFPropertiesDelegate.getFillDelegate(shape.getShapeProperties());
if (fp == null) {
return false;
}
if (fp.isSetNoFill()) {
setValue(null);
return true;
}
PackagePart pp = shape.getSheet().getPackagePart();
PaintStyle paint = selectPaint(fp, null, pp, theme, hasPlaceholder);
if (paint != null) {
setValue(paint);
return true;
}
CTShapeStyle style = shape.getSpStyle();
if (style != null) {
fp = XSLFPropertiesDelegate.getFillDelegate(style.getFillRef());
paint = selectPaint(fp, null, pp, theme, hasPlaceholder);
}
if (paint != null) {
setValue(paint);
return true;
}
return false;
}
};
fetchShapeProperty(fetcher);
return fetcher.getValue();
}
use of org.apache.poi.xslf.model.PropertyFetcher in project poi by apache.
the class XSLFSimpleShape method getLineCompound.
/**
* @return the line compound
*/
public LineCompound getLineCompound() {
PropertyFetcher<Integer> fetcher = new PropertyFetcher<Integer>() {
@Override
public boolean fetch(XSLFShape shape) {
CTLineProperties ln = getLn(shape, false);
if (ln != null) {
STCompoundLine.Enum stCmpd = ln.getCmpd();
if (stCmpd != null) {
setValue(stCmpd.intValue());
return true;
}
}
return false;
}
};
fetchShapeProperty(fetcher);
Integer cmpd = fetcher.getValue();
if (cmpd == null) {
CTLineProperties defaultLn = getDefaultLineProperties();
if (defaultLn != null && defaultLn.isSetCmpd()) {
switch(defaultLn.getCmpd().intValue()) {
default:
case STCompoundLine.INT_SNG:
return LineCompound.SINGLE;
case STCompoundLine.INT_DBL:
return LineCompound.DOUBLE;
case STCompoundLine.INT_THICK_THIN:
return LineCompound.THICK_THIN;
case STCompoundLine.INT_THIN_THICK:
return LineCompound.THIN_THICK;
case STCompoundLine.INT_TRI:
return LineCompound.TRIPLE;
}
}
}
return null;
}
Aggregations