Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* ====================================================================
     Licensed to the Apache Software Foundation (ASF) under one or more
     contributor license agreements.  See the NOTICE file distributed with
     this work for additional information regarding copyright ownership.
     The ASF licenses this file to You under the Apache License, Version 2.0
     (the "License"); you may not use this file except in compliance with
     the License.  You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
 
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
 
 package org.apache.poi.hslf.model;
 
 import java.util.List;
 
 import java.awt.*;

Represents functionality provided by the 'Fill Effects' dialog in PowerPoint.

Author(s):
Yegor Kozlov
 
 public final class Fill {
     // For logging
     protected POILogger logger = POILogFactory.getLogger(this.getClass());

    
Fill with a solid color
 
     public static final int FILL_SOLID = 0;

    
Fill with a pattern (bitmap)
 
     public static final int FILL_PATTERN = 1;

    
A texture (pattern with its own color map)
 
     public static final int FILL_TEXTURE = 2;

    
Center a picture in the shape
 
     public static final int FILL_PICTURE = 3;

    
Shade from start to end points
 
     public static final int FILL_SHADE = 4;

    
Shade from bounding rectangle to end point
 
     public static final int FILL_SHADE_CENTER = 5;

    
Shade from shape outline to end point
 
     public static final int FILL_SHADE_SHAPE = 6;

    
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_SCALE = 7;

    
shade to title
 
     public static final int FILL_SHADE_TITLE = 8;

    
Use the background fill color/pattern
 
     public static final int FILL_BACKGROUND = 9;



    
The shape this background applies to
 
     protected Shape shape;

    
Construct a Fill object for a shape. Fill information will be read from shape's escher properties.

Parameters:
shape the shape this background applies to
    public Fill(Shape shape){
        this. = shape;
    }

    
Returns fill type. Must be one of the FILL_* constants defined in this class.

Returns:
type of fill
    public int getFillType(){
        return prop == null ?  : prop.getPropertyValue();
    }

    
    protected void afterInsert(Sheet sh){
        if(p != null) {
            int idx = p.getPropertyValue();
            EscherBSERecord bse = getEscherBSERecord(idx);
            bse.setRef(bse.getRef() + 1);
        }
    }
    protected EscherBSERecord getEscherBSERecord(int idx){
        Sheet sheet = .getSheet();
        if(sheet == null) {
            .log(."Fill has not yet been assigned to a sheet");
            return null;
        }
        SlideShow ppt = sheet.getSlideShow();
        Document doc = ppt.getDocumentRecord();
        EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
        if(bstore == null) {
            .log(."EscherContainerRecord.BSTORE_CONTAINER was not found ");
            return null;
        }
        List lst = bstore.getChildRecords();
        return (EscherBSERecord)lst.get(idx-1);
    }

    
Sets fill type. Must be one of the FILL_* constants defined in this class.

Parameters:
type type of the fill
    public void setFillType(int type){
        Shape.setEscherProperty(opt.type);
    }

    
Foreground color
    public Color getForegroundColor(){
        if(p != null && (p.getPropertyValue() & 0x10) == 0) return null;
    }

    
Foreground color
    public void setForegroundColor(Color color){
        if (color == null) {
            Shape.setEscherProperty(opt., 0x150000);
        }
        else {
            int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB();
            Shape.setEscherProperty(opt.rgb);
            Shape.setEscherProperty(opt., 0x150011);
        }
    }

    
Background color
    public Color getBackgroundColor(){
        if(p != null && (p.getPropertyValue() & 0x10) == 0) return null;
    }

    
Background color
    public void setBackgroundColor(Color color){
        if (color == null) {
            Shape.setEscherProperty(opt., -1);
        }
        else {
            int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB();
            Shape.setEscherProperty(opt.rgb);
        }
    }

    
PictureData object used in a texture, pattern of picture fill.
    public PictureData getPictureData(){
        if (p == nullreturn null;
        SlideShow ppt = .getSheet().getSlideShow();
        PictureData[] pict = ppt.getPictureData();
        Document doc = ppt.getDocumentRecord();
        EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
        java.util.List<EscherRecordlst = bstore.getChildRecords();
        int idx = p.getPropertyValue();
        if (idx == 0){
            .log(."no reference to picture data found ");
        } else {
            EscherBSERecord bse = (EscherBSERecord)lst.get(idx - 1);
            for ( int i = 0; i < pict.lengthi++ ) {
                if (pict[i].getOffset() ==  bse.getOffset()){
                    return pict[i];
                }
            }
        }
        return null;
    }

    
Assign picture used to fill the underlying shape.

Parameters:
idx 0-based index of the picture added to this ppt by SlideShow.addPicture method.
    public void setPictureData(int idx){
        Shape.setEscherProperty(opt, (short)(. + 0x4000), idx);
        ifidx != 0 ) {
            if.getSheet() != null ) {
                EscherBSERecord bse = getEscherBSERecord(idx);
                bse.setRef(bse.getRef() + 1);
            }
        }
    }
New to GrepCode? Check out our FAQ X