Package org.openxmlformats.schemas.drawingml.x2006.main

Examples of org.openxmlformats.schemas.drawingml.x2006.main.CTColor


        this.theme = theme;
    }

    public XSSFColor getThemeColor(int idx) {
        CTColorScheme colorScheme = theme.getTheme().getThemeElements().getClrScheme();
        CTColor ctColor = null;
        int cnt = 0;
        for (XmlObject obj : colorScheme.selectPath("./*")) {
            if (obj instanceof org.openxmlformats.schemas.drawingml.x2006.main.CTColor) {
                if (cnt == idx) {
                    ctColor = (org.openxmlformats.schemas.drawingml.x2006.main.CTColor) obj;
                   
                    byte[] rgb = null;
                    if (ctColor.getSrgbClr() != null) {
                       // Colour is a regular one
                       rgb = ctColor.getSrgbClr().getVal();
                    } else if (ctColor.getSysClr() != null) {
                       // Colour is a tint of white or black
                       rgb = ctColor.getSysClr().getLastClr();
                    }

                    return new XSSFColor(rgb);
                }
                cnt++;
View Full Code Here


        this.theme = theme;
    }

    public XSSFColor getThemeColor(int idx) {
        CTColorScheme colorScheme = theme.getTheme().getThemeElements().getClrScheme();
        CTColor ctColor = null;
        int cnt = 0;
        for (XmlObject obj : colorScheme.selectPath("./*")) {
            if (obj instanceof org.openxmlformats.schemas.drawingml.x2006.main.CTColor) {
                if (cnt == idx) {
                    ctColor = (org.openxmlformats.schemas.drawingml.x2006.main.CTColor) obj;
                   
                    byte[] rgb = null;
                    if (ctColor.getSrgbClr() != null) {
                       // Colour is a regular one
                       rgb = ctColor.getSrgbClr().getVal();
                    } else if (ctColor.getSysClr() != null) {
                       // Colour is a tint of white or black
                       rgb = ctColor.getSysClr().getLastClr();
                    }

                    return new XSSFColor(rgb);
                }
                cnt++;
View Full Code Here

* @author Yegor Kozlov
*/
public class TestXSLFColor extends TestCase {

    public void testGetters() {
        CTColor xml = CTColor.Factory.newInstance();
        CTSRgbColor c = xml.addNewSrgbClr();
        c.setVal(new byte[]{(byte)0xFF, 0, 0});

        XSLFColor color = new XSLFColor(xml, null, null);

        assertEquals(-1, color.getAlpha());
View Full Code Here

        c.addNewTint().setVal(50000);
        assertEquals(50, color.getTint());
    }

    public void testHSL() {
        CTColor xml = CTColor.Factory.newInstance();
        CTHslColor c = xml.addNewHslClr();
        c.setHue2(14400000);
        c.setSat2(100000);
        c.setLum2(50000);

        XSLFColor color = new XSLFColor(xml, null, null);
View Full Code Here

        XSLFColor color = new XSLFColor(xml, null, null);
        assertEquals(new Color(128, 00, 00), color.getColor());
    }

    public void testSRgb() {
        CTColor xml = CTColor.Factory.newInstance();
        xml.addNewSrgbClr().setVal(new byte[]{ (byte)0xFF, (byte)0xFF, 0});

        XSLFColor color = new XSLFColor(xml, null, null);
        assertEquals(new Color(0xFF, 0xFF, 0), color.getColor());
    }
View Full Code Here

    public void testSchemeColor() {
        XMLSlideShow ppt = new XMLSlideShow();
        XSLFTheme theme = ppt.createSlide().getTheme();

        CTColor xml = CTColor.Factory.newInstance();
        xml.addNewSchemeClr().setVal(STSchemeColorVal.ACCENT_2);

        XSLFColor color = new XSLFColor(xml, theme, null);
        // accent2 is theme1.xml is <a:srgbClr val="C0504D"/>
        assertEquals(Color.decode("0xC0504D"), color.getColor());

        xml = CTColor.Factory.newInstance();
        xml.addNewSchemeClr().setVal(STSchemeColorVal.LT_1);
        color = new XSLFColor(xml, theme, null);
        // <a:sysClr val="window" lastClr="FFFFFF"/>
        assertEquals(Color.decode("0xFFFFFF"), color.getColor());

        xml = CTColor.Factory.newInstance();
        xml.addNewSchemeClr().setVal(STSchemeColorVal.DK_1);
        color = new XSLFColor(xml, theme, null);
        // <a:sysClr val="windowText" lastClr="000000"/>
        assertEquals(Color.decode("0x000000"), color.getColor());
    }
View Full Code Here

        // <a:sysClr val="windowText" lastClr="000000"/>
        assertEquals(Color.decode("0x000000"), color.getColor());
    }

    public void testPresetColor() {
        CTColor xml = CTColor.Factory.newInstance();
        xml.addNewPrstClr().setVal(STPresetColorVal.AQUAMARINE);
        XSLFColor color = new XSLFColor(xml, null, null);
        assertEquals(new Color(127, 255, 212), color.getColor());


        for(String colorName : XSLFColor.presetColors.keySet()){
            xml = CTColor.Factory.newInstance();
            STPresetColorVal.Enum val = STPresetColorVal.Enum.forString(colorName);
            assertNotNull(colorName, val);
            xml.addNewPrstClr().setVal(val);
            color = new XSLFColor(xml, null, null);
            assertEquals(XSLFColor.presetColors.get(colorName), color.getColor());
        }
    }
View Full Code Here

        return fetcher.getValue();
    }

    public void setBulletFontColor(Color color){
        CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
        CTColor c = pr.isSetBuClr() ? pr.getBuClr() : pr.addNewBuClr();
        CTSRgbColor clr = c.isSetSrgbClr() ? c.getSrgbClr() : c.addNewSrgbClr();
        clr.setVal(new byte[]{(byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()});
    }
View Full Code Here

        this.theme = theme;
    }

    public XSSFColor getThemeColor(int idx) {
        CTColorScheme colorScheme = theme.getTheme().getThemeElements().getClrScheme();
        CTColor ctColor = null;
        int cnt = 0;
        for (XmlObject obj : colorScheme.selectPath("./*")) {
            if (obj instanceof org.openxmlformats.schemas.drawingml.x2006.main.CTColor) {
                if (cnt == idx) {
                    ctColor = (org.openxmlformats.schemas.drawingml.x2006.main.CTColor) obj;
                    return new XSSFColor(ctColor.getSrgbClr().getVal());
                }
                cnt++;
            }
        }
        return null;
View Full Code Here

        this.theme = theme;
    }

    public XSSFColor getThemeColor(int idx) {
        CTColorScheme colorScheme = theme.getTheme().getThemeElements().getClrScheme();
        CTColor ctColor = null;
        int cnt = 0;
        for (XmlObject obj : colorScheme.selectPath("./*")) {
            if (obj instanceof org.openxmlformats.schemas.drawingml.x2006.main.CTColor) {
                if (cnt == idx) {
                    ctColor = (org.openxmlformats.schemas.drawingml.x2006.main.CTColor) obj;
                   
                    byte[] rgb = null;
                    if (ctColor.getSrgbClr() != null) {
                       // Colour is a regular one
                       rgb = ctColor.getSrgbClr().getVal();
                    } else if (ctColor.getSysClr() != null) {
                       // Colour is a tint of white or black
                       rgb = ctColor.getSysClr().getLastClr();
                    }

                    return new XSSFColor(rgb);
                }
                cnt++;
View Full Code Here

TOP

Related Classes of org.openxmlformats.schemas.drawingml.x2006.main.CTColor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.