FileDocCategorySizeDatePackage
Fill.javaAPI DocApache Poi 3.0.18013Thu May 31 18:45:28 BST 2007org.apache.poi.hslf.model

Fill

public class Fill extends Object
Represents functionality provided by the 'Fill Effects' dialog in PowerPoint.
author
Yegor Kozlov

Fields Summary
public static final int
FILL_SOLID
Fill with a solid color
public static final int
FILL_PATTERN
Fill with a pattern (bitmap)
public static final int
FILL_TEXTURE
A texture (pattern with its own color map)
public static final int
FILL_PICTURE
Center a picture in the shape
public static final int
FILL_SHADE
Shade from start to end points
public static final int
FILL_SHADE_CENTER
Shade from bounding rectangle to end point
public static final int
FILL_SHADE_SHAPE
Shade from shape outline to end point
public static final int
FILL_SHADE_SCALE
Similar to FILL_SHADE, but the fill angle is additionally scaled by the aspect ratio of the shape. If shape is square, it is the same as FILL_SHADE
public static final int
FILL_SHADE_TITLE
shade to title
public static final int
FILL_BACKGROUND
Use the background fill color/pattern
protected Shape
shape
The shape this background applies to
Constructors Summary
public Fill(Shape shape)
Construct a Fill object for a shape. Fill information will be read from shape's escher properties.

param
shape the shape this background applies to


                                 
      
        this.shape = shape;
    
Methods Summary
public java.awt.ColorgetBackgroundColor()
Background color

        EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
        EscherSimpleProperty p1 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR);
        EscherSimpleProperty p2 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);

        int p2val = p2 == null ? 0 : p2.getPropertyValue();

        Color clr = null;
        if (p1 != null && (p2val  & 0x10) != 0){
            int rgb = p1.getPropertyValue();
            clr = shape.getColor(rgb);
        }
        return clr;
    
public intgetFillType()
Returns fill type. Must be one of the FILL_* constants defined in this class.

return
type of fill

        EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
        EscherSimpleProperty prop = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__FILLTYPE);
        return prop == null ? FILL_SOLID : prop.getPropertyValue();
    
public java.awt.ColorgetForegroundColor()
Foreground color

        EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
        EscherSimpleProperty p1 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__FILLCOLOR);
        EscherSimpleProperty p2 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);

        int p2val = p2 == null ? 0 : p2.getPropertyValue();

        Color clr = null;
        if (p1 != null && (p2val  & 0x10) != 0){
            int rgb = p1.getPropertyValue();
            clr = shape.getColor(rgb);
        }
        return clr;
    
public org.apache.poi.hslf.usermodel.PictureDatagetPictureData()
PictureData object used in a texture, pattern of picture fill.

        EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
        EscherSimpleProperty p = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
        if (p == null) return null;

        SlideShow ppt = shape.getSheet().getSlideShow();
        PictureData[] pict = ppt.getPictureData();
        Document doc = ppt.getDocumentRecord();

        EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
        EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);

        java.util.List lst = bstore.getChildRecords();
        int idx = p.getPropertyValue();
        EscherBSERecord bse = (EscherBSERecord)lst.get(idx);
        for ( int i = 0; i < pict.length; i++ ) {
			if (pict[i].getOffset() ==  bse.getOffset()){
                return pict[i];
            }
        }
        throw new HSLFException("Picture data not found: \n" +
                "  bse: " + bse + " at " + bse.getOffset() );

    
public voidsetBackgroundColor(java.awt.Color color)
Background color

        EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
        if (color == null) {
            Shape.setEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR, -1);
        }
        else {
            int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB();
            Shape.setEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR, rgb);
        }
    
public voidsetFillType(int type)
Sets fill type. Must be one of the FILL_* constants defined in this class.

param
type type of the fill

        EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
        Shape.setEscherProperty(opt, EscherProperties.FILL__FILLTYPE, type);
    
public voidsetForegroundColor(java.awt.Color color)
Foreground color

        EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
        if (color == null) {
            Shape.setEscherProperty(opt, EscherProperties.FILL__FILLCOLOR, -1);
        }
        else {
            int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB();
            Shape.setEscherProperty(opt, EscherProperties.FILL__FILLCOLOR, rgb);
        }
    
public voidsetPictureData(int idx)
Assign picture used to fill the underlying shape.

param
idx 0-based index of the picture added to this ppt by SlideShow.addPicture method.

        EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
        Shape.setEscherProperty(opt, (short)(EscherProperties.FILL__PATTERNTEXTURE + 0x4000), idx);