Search in sources :

Example 51 with AbstractEscherOptRecord

use of org.apache.poi.ddf.AbstractEscherOptRecord in project poi by apache.

the class HSLFSimpleShape method getLineCompound.

/**
     * Gets the line compound style
     *
     * @return the compound style of the line.
     */
public LineCompound getLineCompound() {
    AbstractEscherOptRecord opt = getEscherOptRecord();
    EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE);
    return (prop == null) ? LineCompound.SINGLE : LineCompound.fromNativeId(prop.getPropertyValue());
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

Example 52 with AbstractEscherOptRecord

use of org.apache.poi.ddf.AbstractEscherOptRecord in project poi by apache.

the class HSLFSimpleShape method createSpContainer.

/**
     * Create a new Shape
     *
     * @param isChild   <code>true</code> if the Line is inside a group, <code>false</code> otherwise
     * @return the record container which holds this shape
     */
@Override
protected EscherContainerRecord createSpContainer(boolean isChild) {
    EscherContainerRecord ecr = super.createSpContainer(isChild);
    ecr.setRecordId(EscherContainerRecord.SP_CONTAINER);
    EscherSpRecord sp = new EscherSpRecord();
    int flags = EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE;
    if (isChild) {
        flags |= EscherSpRecord.FLAG_CHILD;
    }
    sp.setFlags(flags);
    ecr.addChildRecord(sp);
    AbstractEscherOptRecord opt = new EscherOptRecord();
    opt.setRecordId(EscherOptRecord.RECORD_ID);
    ecr.addChildRecord(opt);
    EscherRecord anchor;
    if (isChild) {
        anchor = new EscherChildAnchorRecord();
    } else {
        anchor = new EscherClientAnchorRecord();
        //hack. internal variable EscherClientAnchorRecord.shortRecord can be
        //initialized only in fillFields(). We need to set shortRecord=false;
        byte[] header = new byte[16];
        LittleEndian.putUShort(header, 0, 0);
        LittleEndian.putUShort(header, 2, 0);
        LittleEndian.putInt(header, 4, 8);
        anchor.fillFields(header, 0, null);
    }
    ecr.addChildRecord(anchor);
    return ecr;
}
Also used : EscherChildAnchorRecord(org.apache.poi.ddf.EscherChildAnchorRecord) EscherSpRecord(org.apache.poi.ddf.EscherSpRecord) EscherClientAnchorRecord(org.apache.poi.ddf.EscherClientAnchorRecord) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord) DrawPaint(org.apache.poi.sl.draw.DrawPaint) SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord) EscherOptRecord(org.apache.poi.ddf.EscherOptRecord)

Example 53 with AbstractEscherOptRecord

use of org.apache.poi.ddf.AbstractEscherOptRecord in project poi by apache.

the class HSLFSimpleShape method getLineColor.

/**
     * @return color of the line. If color is not set returns {@code null}
     */
public Color getLineColor() {
    AbstractEscherOptRecord opt = getEscherOptRecord();
    EscherSimpleProperty p = getEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH);
    if (p != null && (p.getPropertyValue() & 0x8) == 0) {
        return null;
    }
    Color clr = getColor(EscherProperties.LINESTYLE__COLOR, EscherProperties.LINESTYLE__OPACITY, -1);
    return clr == null ? null : clr;
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) Color(java.awt.Color) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

Example 54 with AbstractEscherOptRecord

use of org.apache.poi.ddf.AbstractEscherOptRecord in project poi by apache.

the class HSLFSimpleShape method getLineBackgroundColor.

/**
     * @return background color of the line. If color is not set returns {@code null}
     */
public Color getLineBackgroundColor() {
    AbstractEscherOptRecord opt = getEscherOptRecord();
    EscherSimpleProperty p = getEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH);
    if (p != null && (p.getPropertyValue() & 0x8) == 0) {
        return null;
    }
    Color clr = getColor(EscherProperties.LINESTYLE__BACKCOLOR, EscherProperties.LINESTYLE__OPACITY, -1);
    return clr == null ? null : clr;
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) Color(java.awt.Color) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

Example 55 with AbstractEscherOptRecord

use of org.apache.poi.ddf.AbstractEscherOptRecord in project poi by apache.

the class HSLFSimpleShape method getShadowAngle.

public double getShadowAngle() {
    AbstractEscherOptRecord opt = getEscherOptRecord();
    EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.SHADOWSTYLE__OFFSETX);
    int offX = (prop == null) ? 0 : prop.getPropertyValue();
    prop = getEscherProperty(opt, EscherProperties.SHADOWSTYLE__OFFSETY);
    int offY = (prop == null) ? 0 : prop.getPropertyValue();
    return Math.toDegrees(Math.atan2(offY, offX));
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord) DrawPaint(org.apache.poi.sl.draw.DrawPaint) SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)

Aggregations

AbstractEscherOptRecord (org.apache.poi.ddf.AbstractEscherOptRecord)68 EscherSimpleProperty (org.apache.poi.ddf.EscherSimpleProperty)36 DrawPaint (org.apache.poi.sl.draw.DrawPaint)13 Color (java.awt.Color)8 GradientPaint (org.apache.poi.sl.usermodel.PaintStyle.GradientPaint)7 TexturePaint (org.apache.poi.sl.usermodel.PaintStyle.TexturePaint)7 EscherArrayProperty (org.apache.poi.ddf.EscherArrayProperty)6 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)6 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)6 EscherBSERecord (org.apache.poi.ddf.EscherBSERecord)4 Rectangle2D (java.awt.geom.Rectangle2D)3 EscherColorRef (org.apache.poi.ddf.EscherColorRef)3 EscherComplexProperty (org.apache.poi.ddf.EscherComplexProperty)3 EscherRecord (org.apache.poi.ddf.EscherRecord)3 EscherSpRecord (org.apache.poi.ddf.EscherSpRecord)3 AffineTransform (java.awt.geom.AffineTransform)2 EscherProperty (org.apache.poi.ddf.EscherProperty)2 Document (org.apache.poi.hslf.record.Document)2 Test (org.junit.Test)2 Insets (java.awt.Insets)1