Search in sources :

Example 1 with ColorSchemeAtom

use of org.apache.poi.hslf.record.ColorSchemeAtom in project poi by apache.

the class HSLFTextParagraph method getColorFromColorIndexStruct.

protected static Color getColorFromColorIndexStruct(int rgb, HSLFSheet sheet) {
    int cidx = rgb >>> 24;
    Color tmp;
    switch(cidx) {
        // Background ... Accent 3 color
        case 0:
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
        case 7:
            if (sheet == null) {
                return null;
            }
            ColorSchemeAtom ca = sheet.getColorScheme();
            tmp = new Color(ca.getColor(cidx), true);
            break;
        // Color is an sRGB value specified by red, green, and blue fields.
        case 0xFE:
            tmp = new Color(rgb, true);
            break;
        // Color is undefined.
        default:
        case 0xFF:
            return null;
    }
    return new Color(tmp.getBlue(), tmp.getGreen(), tmp.getRed());
}
Also used : Color(java.awt.Color) ColorSchemeAtom(org.apache.poi.hslf.record.ColorSchemeAtom) DrawPaint(org.apache.poi.sl.draw.DrawPaint) SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)

Example 2 with ColorSchemeAtom

use of org.apache.poi.hslf.record.ColorSchemeAtom in project poi by apache.

the class TestSheet method verify.

private void verify(HSLFSheet sheet) {
    assertNotNull(sheet.getSlideShow());
    ColorSchemeAtom colorscheme = sheet.getColorScheme();
    assertNotNull(colorscheme);
    PPDrawing ppdrawing = sheet.getPPDrawing();
    assertNotNull(ppdrawing);
    HSLFBackground background = sheet.getBackground();
    assertNotNull(background);
    assertTrue(sheet._getSheetNumber() != 0);
    assertTrue(sheet._getSheetRefId() != 0);
    List<List<HSLFTextParagraph>> txt = sheet.getTextParagraphs();
    // backgrounds.ppt has no texts
    for (List<HSLFTextParagraph> t : txt) {
        for (HSLFTextParagraph tp : t) {
            assertNotNull(tp.getSheet());
        }
    }
    List<HSLFShape> shape = sheet.getShapes();
    assertTrue("no shapes", shape != null && !shape.isEmpty());
    for (HSLFShape s : shape) {
        assertNotNull(s.getSpContainer());
        assertNotNull(s.getSheet());
        assertNotNull(s.getShapeName());
        assertNotNull(s.getAnchor());
    }
}
Also used : PPDrawing(org.apache.poi.hslf.record.PPDrawing) ColorSchemeAtom(org.apache.poi.hslf.record.ColorSchemeAtom) List(java.util.List)

Example 3 with ColorSchemeAtom

use of org.apache.poi.hslf.record.ColorSchemeAtom in project poi by apache.

the class HSLFShape method getColor.

Color getColor(EscherColorRef ecr) {
    boolean fPaletteIndex = ecr.hasPaletteIndexFlag();
    boolean fPaletteRGB = ecr.hasPaletteRGBFlag();
    boolean fSystemRGB = ecr.hasSystemRGBFlag();
    boolean fSchemeIndex = ecr.hasSchemeIndexFlag();
    boolean fSysIndex = ecr.hasSysIndexFlag();
    int[] rgb = ecr.getRGB();
    HSLFSheet sheet = getSheet();
    if (fSchemeIndex && sheet != null) {
        //red is the index to the color scheme
        ColorSchemeAtom ca = sheet.getColorScheme();
        int schemeColor = ca.getColor(ecr.getSchemeIndex());
        rgb[0] = (schemeColor >> 0) & 0xFF;
        rgb[1] = (schemeColor >> 8) & 0xFF;
        rgb[2] = (schemeColor >> 16) & 0xFF;
    } else if (fPaletteIndex) {
    //TODO
    } else if (fPaletteRGB) {
    //TODO
    } else if (fSystemRGB) {
    //TODO
    } else if (fSysIndex) {
        Color col = getSysIndexColor(ecr);
        col = applySysIndexProcedure(ecr, col);
        return col;
    }
    return new Color(rgb[0], rgb[1], rgb[2]);
}
Also used : Color(java.awt.Color) PresetColor(org.apache.poi.sl.usermodel.PresetColor) ColorSchemeAtom(org.apache.poi.hslf.record.ColorSchemeAtom)

Aggregations

ColorSchemeAtom (org.apache.poi.hslf.record.ColorSchemeAtom)3 Color (java.awt.Color)2 List (java.util.List)1 PPDrawing (org.apache.poi.hslf.record.PPDrawing)1 DrawPaint (org.apache.poi.sl.draw.DrawPaint)1 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)1 PresetColor (org.apache.poi.sl.usermodel.PresetColor)1