use of org.apache.poi.ddf.EscherSimpleProperty in project poi by apache.
the class HSLFShapeFactory method createShapeGroup.
public static HSLFGroupShape createShapeGroup(EscherContainerRecord spContainer, ShapeContainer<HSLFShape, HSLFTextParagraph> parent) {
boolean isTable = false;
EscherContainerRecord ecr = (EscherContainerRecord) spContainer.getChild(0);
EscherRecord opt = HSLFShape.getEscherChild(ecr, RecordTypes.EscherUserDefined);
if (opt != null) {
EscherPropertyFactory f = new EscherPropertyFactory();
List<EscherProperty> props = f.createProperties(opt.serialize(), 8, opt.getInstance());
for (EscherProperty ep : props) {
if (ep.getPropertyNumber() == EscherProperties.GROUPSHAPE__TABLEPROPERTIES && ep instanceof EscherSimpleProperty && (((EscherSimpleProperty) ep).getPropertyValue() & 1) == 1) {
isTable = true;
break;
}
}
}
HSLFGroupShape group;
if (isTable) {
group = new HSLFTable(spContainer, parent);
} else {
group = new HSLFGroupShape(spContainer, parent);
}
return group;
}
use of org.apache.poi.ddf.EscherSimpleProperty in project poi by apache.
the class HSLFShape method getEscherProperty.
/**
* Get the value of a simple escher property for this shape.
*
* @param propId The id of the property. One of the constants defined in EscherOptRecord.
*/
public int getEscherProperty(short propId) {
AbstractEscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = getEscherProperty(opt, propId);
return prop == null ? 0 : prop.getPropertyValue();
}
use of org.apache.poi.ddf.EscherSimpleProperty in project poi by apache.
the class HSLFShape method setEscherProperty.
/**
* Set an escher property for this shape.
*
* @param opt The opt record to set the properties to.
* @param propId The id of the property. One of the constants defined in EscherOptRecord.
* @param value value of the property. If value = -1 then the property is removed.
*/
public static void setEscherProperty(AbstractEscherOptRecord opt, short propId, int value) {
java.util.List<EscherProperty> props = opt.getEscherProperties();
for (Iterator<EscherProperty> iterator = props.iterator(); iterator.hasNext(); ) {
if (iterator.next().getPropertyNumber() == propId) {
iterator.remove();
break;
}
}
if (value != -1) {
opt.addEscherProperty(new EscherSimpleProperty(propId, value));
opt.sortProperties();
}
}
use of org.apache.poi.ddf.EscherSimpleProperty in project poi by apache.
the class HSLFShape method getColor.
Color getColor(short colorProperty, short opacityProperty, int defaultColor) {
AbstractEscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty p = getEscherProperty(opt, colorProperty);
if (p == null && defaultColor == -1)
return null;
int val = (p == null) ? defaultColor : p.getPropertyValue();
EscherColorRef ecr = new EscherColorRef(val);
Color col = getColor(ecr);
if (col == null) {
return null;
}
double alpha = getAlpha(opacityProperty);
return new Color(col.getRed(), col.getGreen(), col.getBlue(), (int) (alpha * 255.0));
}
use of org.apache.poi.ddf.EscherSimpleProperty in project poi by apache.
the class HSLFShape method getAlpha.
double getAlpha(short opacityProperty) {
AbstractEscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty op = getEscherProperty(opt, opacityProperty);
int defaultOpacity = 0x00010000;
int opacity = (op == null) ? defaultOpacity : op.getPropertyValue();
return Units.fixedPointToDouble(opacity);
}
Aggregations