Search in sources :

Example 6 with AbstractEscherOptRecord

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

the class TestShapes method lineWidth.

@Test
public void lineWidth() {
    HSLFSimpleShape sh = new HSLFAutoShape(ShapeType.RT_TRIANGLE);
    AbstractEscherOptRecord opt = sh.getEscherOptRecord();
    EscherSimpleProperty prop = HSLFSimpleShape.getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
    assertNull(prop);
    assertEquals(HSLFSimpleShape.DEFAULT_LINE_WIDTH, sh.getLineWidth(), 0);
    sh.setLineWidth(1.0);
    prop = HSLFSimpleShape.getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
    assertNotNull(prop);
    assertEquals(1.0, sh.getLineWidth(), 0);
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) HSLFAutoShape(org.apache.poi.hslf.usermodel.HSLFAutoShape) HSLFSimpleShape(org.apache.poi.hslf.usermodel.HSLFSimpleShape) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord) Test(org.junit.Test)

Example 7 with AbstractEscherOptRecord

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

the class HSLFPictureShape method getPictureName.

/**
     * Name of this picture.
     *
     * @return name of this picture
     */
public String getPictureName() {
    AbstractEscherOptRecord opt = getEscherOptRecord();
    EscherComplexProperty prop = getEscherProperty(opt, EscherProperties.BLIP__BLIPFILENAME);
    if (prop == null)
        return null;
    String name = StringUtil.getFromUnicodeLE(prop.getComplexData());
    return name.trim();
}
Also used : EscherComplexProperty(org.apache.poi.ddf.EscherComplexProperty) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

Example 8 with AbstractEscherOptRecord

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

the class HSLFPictureShape method getClipping.

@Override
public Insets getClipping() {
    // The anchor specified by the escher properties is the displayed size,
    // i.e. the size of the already clipped image
    AbstractEscherOptRecord opt = getEscherOptRecord();
    double top = getFractProp(opt, EscherProperties.BLIP__CROPFROMTOP);
    double bottom = getFractProp(opt, EscherProperties.BLIP__CROPFROMBOTTOM);
    double left = getFractProp(opt, EscherProperties.BLIP__CROPFROMLEFT);
    double right = getFractProp(opt, EscherProperties.BLIP__CROPFROMRIGHT);
    // if all crop values are zero (the default) then no crop rectangle is set, return null
    return (top == 0 && bottom == 0 && left == 0 && right == 0) ? null : new Insets((int) (top * 100000), (int) (left * 100000), (int) (bottom * 100000), (int) (right * 100000));
}
Also used : Insets(java.awt.Insets) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

Example 9 with AbstractEscherOptRecord

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

the class HSLFPictureShape method getPictureIndex.

/**
     * Returns index associated with this picture.
     * Index starts with 1 and points to a EscherBSE record which
     * holds information about this picture.
     *
     * @return the index to this picture (1 based).
     */
public int getPictureIndex() {
    AbstractEscherOptRecord opt = getEscherOptRecord();
    EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.BLIP__BLIPTODISPLAY);
    return prop == null ? 0 : prop.getPropertyValue();
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

Example 10 with AbstractEscherOptRecord

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

the class HSLFPictureShape method setPictureName.

/**
     * Name of this picture.
     *
     * @param name of this picture
     */
public void setPictureName(String name) {
    AbstractEscherOptRecord opt = getEscherOptRecord();
    byte[] data = StringUtil.getToUnicodeLE(name + '');
    EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.BLIP__BLIPFILENAME, false, data);
    opt.addEscherProperty(prop);
}
Also used : EscherComplexProperty(org.apache.poi.ddf.EscherComplexProperty) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

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