Search in sources :

Example 26 with EscherSimpleProperty

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;
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) EscherPropertyFactory(org.apache.poi.ddf.EscherPropertyFactory) EscherProperty(org.apache.poi.ddf.EscherProperty)

Example 27 with EscherSimpleProperty

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();
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

Example 28 with EscherSimpleProperty

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();
    }
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) EscherProperty(org.apache.poi.ddf.EscherProperty)

Example 29 with EscherSimpleProperty

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));
}
Also used : EscherColorRef(org.apache.poi.ddf.EscherColorRef) EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) Color(java.awt.Color) PresetColor(org.apache.poi.sl.usermodel.PresetColor) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

Example 30 with EscherSimpleProperty

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);
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

Aggregations

EscherSimpleProperty (org.apache.poi.ddf.EscherSimpleProperty)48 AbstractEscherOptRecord (org.apache.poi.ddf.AbstractEscherOptRecord)36 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)8 DrawPaint (org.apache.poi.sl.draw.DrawPaint)8 EscherBSERecord (org.apache.poi.ddf.EscherBSERecord)6 GradientPaint (org.apache.poi.sl.usermodel.PaintStyle.GradientPaint)6 TexturePaint (org.apache.poi.sl.usermodel.PaintStyle.TexturePaint)6 Color (java.awt.Color)5 EscherOptRecord (org.apache.poi.ddf.EscherOptRecord)5 EscherRecord (org.apache.poi.ddf.EscherRecord)4 EscherArrayProperty (org.apache.poi.ddf.EscherArrayProperty)3 EscherSpRecord (org.apache.poi.ddf.EscherSpRecord)3 AffineTransform (java.awt.geom.AffineTransform)2 Rectangle2D (java.awt.geom.Rectangle2D)2 EscherBoolProperty (org.apache.poi.ddf.EscherBoolProperty)2 EscherColorRef (org.apache.poi.ddf.EscherColorRef)2 EscherDgRecord (org.apache.poi.ddf.EscherDgRecord)2 EscherProperty (org.apache.poi.ddf.EscherProperty)2 EscherRGBProperty (org.apache.poi.ddf.EscherRGBProperty)2 Document (org.apache.poi.hslf.record.Document)2