public void setFontColor(Color color){ CTTextCharacterProperties rPr = getRPr(); CTSolidColorFillProperties fill = rPr.isSetSolidFill() ? rPr.getSolidFill() : rPr.addNewSolidFill(); CTSRgbColor clr = fill.isSetSrgbClr() ? fill.getSrgbClr() : fill.addNewSrgbClr(); clr.setVal(new byte[]{(byte)color.getRed(), (byte)color.getGreen(), (byte)color.getBlue()}); if(fill.isSetHslClr()) fill.unsetHslClr(); if(fill.isSetPrstClr()) fill.unsetPrstClr(); if(fill.isSetSchemeClr()) fill.unsetSchemeClr(); if(fill.isSetScrgbClr()) fill.unsetScrgbClr(); if(fill.isSetSysClr()) fill.unsetSysClr(); }
public XDDFColor getColor() { if (props.isSetHslClr()) { return new XDDFColorHsl(props.getHslClr()); } else if (props.isSetPrstClr()) { return new XDDFColorPreset(props.getPrstClr()); } else if (props.isSetSchemeClr()) { return new XDDFColorSchemeBased(props.getSchemeClr()); } else if (props.isSetScrgbClr()) { return new XDDFColorRgbPercent(props.getScrgbClr()); } else if (props.isSetSrgbClr()) { return new XDDFColorRgbBinary(props.getSrgbClr()); } else if (props.isSetSysClr()) { return new XDDFColorSystemDefined(props.getSysClr()); } return null; }
public void setColor(XDDFColor color) { if (props.isSetHslClr()) { props.unsetHslClr(); if (props.isSetPrstClr()) { props.unsetPrstClr(); if (props.isSetSchemeClr()) { props.unsetSchemeClr(); if (props.isSetScrgbClr()) { props.unsetScrgbClr(); if (props.isSetSrgbClr()) { props.unsetSrgbClr(); if (props.isSetSysClr()) { props.unsetSysClr(); props.setHslClr((CTHslColor) color.getXmlObject()); } else if (color instanceof XDDFColorPreset) { props.setPrstClr((CTPresetColor) color.getXmlObject()); } else if (color instanceof XDDFColorSchemeBased) { props.setSchemeClr((CTSchemeColor) color.getXmlObject()); } else if (color instanceof XDDFColorRgbPercent) { props.setScrgbClr((CTScRgbColor) color.getXmlObject()); } else if (color instanceof XDDFColorRgbBinary) { props.setSrgbClr((CTSRgbColor) color.getXmlObject()); } else if (color instanceof XDDFColorSystemDefined) { props.setSysClr((CTSystemColor) color.getXmlObject());
/** * Specifies a solid color fill. The shape is filled entirely with the * specified color. * * @param color the solid color fill. The value of <code>null</code> unsets * the solidFIll attribute from the underlying xml */ public void setFillColor(Color color) { CTShapeProperties spPr = getSpPr(); if (color == null) { if (spPr.isSetSolidFill()) spPr.unsetSolidFill(); if (!spPr.isSetNoFill()) spPr.addNewNoFill(); } else { if (spPr.isSetNoFill()) spPr.unsetNoFill(); CTSolidColorFillProperties fill = spPr.isSetSolidFill() ? spPr .getSolidFill() : spPr.addNewSolidFill(); CTSRgbColor rgb = CTSRgbColor.Factory.newInstance(); rgb.setVal(new byte[]{(byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()}); fill.setSrgbClr(rgb); if(fill.isSetHslClr()) fill.unsetHslClr(); if(fill.isSetPrstClr()) fill.unsetPrstClr(); if(fill.isSetSchemeClr()) fill.unsetSchemeClr(); if(fill.isSetScrgbClr()) fill.unsetScrgbClr(); if(fill.isSetSysClr()) fill.unsetSysClr(); } }
org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor xlsColor = pr.getColorArray(0); if (xlsColor.isSetRgb()) { CTSRgbColor clr = fill.isSetSrgbClr() ? fill.getSrgbClr() : fill.addNewSrgbClr(); clr.setVal(xlsColor.getRgb()); } else if (xlsColor.isSetIndexed()) { rgb[1] = (byte) indexed.getTriplet()[1]; rgb[2] = (byte) indexed.getTriplet()[2]; CTSRgbColor clr = fill.isSetSrgbClr() ? fill.getSrgbClr() : fill.addNewSrgbClr(); clr.setVal(rgb);
public Color getFontColor(){ CTTextCharacterProperties rPr = getRPr(); if(rPr.isSetSolidFill()){ CTSolidColorFillProperties fill = rPr.getSolidFill(); if(fill.isSetSrgbClr()){ CTSRgbColor clr = fill.getSrgbClr(); byte[] rgb = clr.getVal(); return new Color(0xFF & rgb[0], 0xFF & rgb[1], 0xFF & rgb[2]); } } return new Color(0, 0, 0); }
@Override public void setBorderColor(BorderEdge edge, Color color) { if (color == null) { throw new IllegalArgumentException("Colors need to be specified."); } CTLineProperties ln = setBorderDefaults(edge); CTSolidColorFillProperties fill = ln.addNewSolidFill(); XSLFColor c = new XSLFColor(fill, getSheet().getTheme(), fill.getSchemeClr()); c.setColor(color); }
@SuppressWarnings("WeakerAccess") protected static PaintStyle selectPaint(CTSolidColorFillProperties solidFill, CTSchemeColor phClr, final XSLFTheme theme) { if (solidFill.isSetSchemeClr()) { // if there's a reference to the placeholder color, // stop evaluating further and let the caller select // the next style inheritance level // if (STSchemeColorVal.PH_CLR.equals(solidFill.getSchemeClr().getVal())) { // return null; // } if (phClr == null) { phClr = solidFill.getSchemeClr(); } } final XSLFColor c = new XSLFColor(solidFill, theme, phClr); return DrawPaint.createSolidPaint(c.getColorStyle()); }
@Override public void setFillColor(int red, int green, int blue) { CTShapeProperties props = getShapeProperties(); CTSolidColorFillProperties fill = props.isSetSolidFill() ? props.getSolidFill() : props.addNewSolidFill(); CTSRgbColor rgb = CTSRgbColor.Factory.newInstance(); rgb.setVal(new byte[]{(byte)red, (byte)green, (byte)blue}); fill.setSrgbClr(rgb); }
/** * @param color the color to paint the shape outline. * A <code>null</code> value turns off the shape outline. */ public void setLineColor(Color color) { CTShapeProperties spPr = getSpPr(); if (color == null) { if (spPr.isSetLn() && spPr.getLn().isSetSolidFill()) spPr.getLn().unsetSolidFill(); } else { CTLineProperties ln = spPr.isSetLn() ? spPr.getLn() : spPr .addNewLn(); CTSRgbColor rgb = CTSRgbColor.Factory.newInstance(); rgb.setVal(new byte[]{(byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()}); CTSolidColorFillProperties fill = ln.isSetSolidFill() ? ln .getSolidFill() : ln.addNewSolidFill(); fill.setSrgbClr(rgb); if(fill.isSetHslClr()) fill.unsetHslClr(); if(fill.isSetPrstClr()) fill.unsetPrstClr(); if(fill.isSetSchemeClr()) fill.unsetSchemeClr(); if(fill.isSetScrgbClr()) fill.unsetScrgbClr(); if(fill.isSetSysClr()) fill.unsetSysClr(); } }
org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor xlsColor = pr.getColorArray(0); if(xlsColor.isSetRgb()) { CTSRgbColor clr = fill.isSetSrgbClr() ? fill.getSrgbClr() : fill.addNewSrgbClr(); clr.setVal(xlsColor.getRgb()); rgb[1] = (byte) indexed.getTriplet()[1]; rgb[2] = (byte) indexed.getTriplet()[2]; CTSRgbColor clr = fill.isSetSrgbClr() ? fill.getSrgbClr() : fill.addNewSrgbClr(); clr.setVal(rgb);
public Color getFontColor(){ CTTextCharacterProperties rPr = getRPr(); if(rPr.isSetSolidFill()){ CTSolidColorFillProperties fill = rPr.getSolidFill(); if(fill.isSetSrgbClr()){ CTSRgbColor clr = fill.getSrgbClr(); byte[] rgb = clr.getVal(); return new Color(0xFF & rgb[0], 0xFF & rgb[1], 0xFF & rgb[2]); } } return new Color(0, 0, 0); }
@SuppressWarnings("WeakerAccess") public Color getBorderColor(BorderEdge edge) { CTLineProperties ln = getCTLine(edge, false); if (ln == null || ln.isSetNoFill() || !ln.isSetSolidFill()) { return null; } CTSolidColorFillProperties fill = ln.getSolidFill(); XSLFColor c = new XSLFColor(fill, getSheet().getTheme(), fill.getSchemeClr()); return c.getColor(); }
@SuppressWarnings("WeakerAccess") protected static PaintStyle selectPaint(CTSolidColorFillProperties solidFill, CTSchemeColor phClr, final XSLFTheme theme) { if (solidFill.isSetSchemeClr()) { // if there's a reference to the placeholder color, // stop evaluating further and let the caller select // the next style inheritance level // if (STSchemeColorVal.PH_CLR.equals(solidFill.getSchemeClr().getVal())) { // return null; // } if (phClr == null) { phClr = solidFill.getSchemeClr(); } } final XSLFColor c = new XSLFColor(solidFill, theme, phClr); return DrawPaint.createSolidPaint(c.getColorStyle()); }
@Override public void setLineStyleColor( int red, int green, int blue ) { CTShapeProperties props = getShapeProperties(); CTLineProperties ln = props.isSetLn() ? props.getLn() : props.addNewLn(); CTSolidColorFillProperties fill = ln.isSetSolidFill() ? ln.getSolidFill() : ln.addNewSolidFill(); CTSRgbColor rgb = CTSRgbColor.Factory.newInstance(); rgb.setVal(new byte[]{(byte)red, (byte)green, (byte)blue}); fill.setSrgbClr(rgb); }
if (fill.isSetSrgbClr()) { fill.unsetSrgbClr(); if (fill.isSetScrgbClr()) { fill.unsetScrgbClr(); if (fill.isSetHslClr()) { fill.unsetHslClr(); if (fill.isSetPrstClr()) { fill.unsetPrstClr(); if (fill.isSetSchemeClr()) { fill.unsetSchemeClr(); if (fill.isSetSysClr()) { fill.unsetSysClr(); CTSRgbColor rgb = fill.addNewSrgbClr(); alphaPct = (addAlpha) ? rgb.addNewAlpha() : null; } else { CTScRgbColor rgb = fill.addNewScrgbClr(); rgb.setR(DrawPaint.srgb2lin(rgbaf[0])); rgb.setG(DrawPaint.srgb2lin(rgbaf[1]));
public void setColor(XDDFColor color) { if (props.isSetHslClr()) { props.unsetHslClr(); if (props.isSetPrstClr()) { props.unsetPrstClr(); if (props.isSetSchemeClr()) { props.unsetSchemeClr(); if (props.isSetScrgbClr()) { props.unsetScrgbClr(); if (props.isSetSrgbClr()) { props.unsetSrgbClr(); if (props.isSetSysClr()) { props.unsetSysClr(); props.setHslClr((CTHslColor) color.getXmlObject()); } else if (color instanceof XDDFColorPreset) { props.setPrstClr((CTPresetColor) color.getXmlObject()); } else if (color instanceof XDDFColorSchemeBased) { props.setSchemeClr((CTSchemeColor) color.getXmlObject()); } else if (color instanceof XDDFColorRgbPercent) { props.setScrgbClr((CTScRgbColor) color.getXmlObject()); } else if (color instanceof XDDFColorRgbBinary) { props.setSrgbClr((CTSRgbColor) color.getXmlObject()); } else if (color instanceof XDDFColorSystemDefined) { props.setSysClr((CTSystemColor) color.getXmlObject());
public XDDFColor getColor() { if (props.isSetHslClr()) { return new XDDFColorHsl(props.getHslClr()); } else if (props.isSetPrstClr()) { return new XDDFColorPreset(props.getPrstClr()); } else if (props.isSetSchemeClr()) { return new XDDFColorSchemeBased(props.getSchemeClr()); } else if (props.isSetScrgbClr()) { return new XDDFColorRgbPercent(props.getScrgbClr()); } else if (props.isSetSrgbClr()) { return new XDDFColorRgbBinary(props.getSrgbClr()); } else if (props.isSetSysClr()) { return new XDDFColorSystemDefined(props.getSysClr()); } return null; }
org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor xlsColor = pr.getColorArray(0); if (xlsColor.isSetRgb()) { CTSRgbColor clr = fill.isSetSrgbClr() ? fill.getSrgbClr() : fill.addNewSrgbClr(); clr.setVal(xlsColor.getRgb()); } else if (xlsColor.isSetIndexed()) { rgb[1] = (byte) indexed.getTriplet()[1]; rgb[2] = (byte) indexed.getTriplet()[2]; CTSRgbColor clr = fill.isSetSrgbClr() ? fill.getSrgbClr() : fill.addNewSrgbClr(); clr.setVal(rgb);
private Color getLineColor(CTLineProperties ln){ if(ln == null || ln.isSetNoFill() || !ln.isSetSolidFill()) return null; CTSolidColorFillProperties fill = ln.getSolidFill(); if(!fill.isSetSrgbClr()) { // TODO for now return null for all colors except explicit RGB return null; } byte[] val = fill.getSrgbClr().getVal(); return new Color(0xFF & val[0], 0xFF & val[1], 0xFF & val[2]); } /**