/** * Convert color transformations in {@link ColorStyle} to a {@link Color} instance * * @see <a href="https://msdn.microsoft.com/en-us/library/dd560821%28v=office.12%29.aspx">Using Office Open XML to Customize Document Formatting in the 2007 Office System</a> * @see <a href="https://social.msdn.microsoft.com/Forums/office/en-US/040e0a1f-dbfe-4ce5-826b-38b4b6f6d3f7/saturation-modulation-satmod">saturation modulation (satMod)</a> * @see <a href="http://stackoverflow.com/questions/6754127/office-open-xml-satmod-results-in-more-than-100-saturation">Office Open XML satMod results in more than 100% saturation</a> */ public static Color applyColorTransform(ColorStyle color){ // TODO: The colors don't match 100% the results of Powerpoint, maybe because we still // operate in sRGB and not scRGB ... work in progress ... if (color == null || color.getColor() == null) { return TRANSPARENT; } Color result = color.getColor(); double alpha = getAlpha(result, color); double[] hsl = RGB2HSL(result); // values are in the range [0..100] (usually ...) applyHslModOff(hsl, 0, color.getHueMod(), color.getHueOff()); applyHslModOff(hsl, 1, color.getSatMod(), color.getSatOff()); applyHslModOff(hsl, 2, color.getLumMod(), color.getLumOff()); applyShade(hsl, color); applyTint(hsl, color); result = HSL2RGB(hsl[0], hsl[1], hsl[2], alpha); return result; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof ColorStyle)) { return false; } return Objects.equals(DrawPaint.applyColorTransform(this), DrawPaint.applyColorTransform((ColorStyle)o)); }
@SuppressWarnings("WeakerAccess") public void setBulletFontColor(Color color) { setBulletFontColor(DrawPaint.createSolidPaint(color)); }
@SuppressWarnings("WeakerAccess") protected Paint getGradientPaint(GradientPaint fill, Graphics2D graphics) { switch (fill.getGradientType()) { case linear: return createLinearGradientPaint(fill, graphics); case circular: return createRadialGradientPaint(fill, graphics); case shape: return createPathGradientPaint(fill, graphics); default: throw new UnsupportedOperationException("gradient fill of type "+fill+" not supported."); } }
int s = hsl.getSat2(); int l = hsl.getLum2(); color = DrawPaint.HSL2RGB(h / 60000d, s / 1000d, l / 1000d, 1d); } else if (ch instanceof CTPresetColor) { CTPresetColor prst = (CTPresetColor)ch; color = new Color(DrawPaint.lin2srgb(scrgb.getR()), DrawPaint.lin2srgb(scrgb.getG()), DrawPaint.lin2srgb(scrgb.getB())); } else if (ch instanceof CTSRgbColor) {
public DrawPaint getPaint(PlaceableShape<?,?> shape) { return new DrawPaint(shape); }
@SuppressWarnings("WeakerAccess") protected Paint getGradientPaint(GradientPaint fill, Graphics2D graphics) { switch (fill.getGradientType()) { case linear: return createLinearGradientPaint(fill, graphics); case circular: return createRadialGradientPaint(fill, graphics); case shape: return createPathGradientPaint(fill, graphics); default: throw new UnsupportedOperationException("gradient fill of type "+fill+" not supported."); } }
int s = hsl.getSat2(); int l = hsl.getLum2(); color = DrawPaint.HSL2RGB(h / 60000d, s / 1000d, l / 1000d, 1d); } else if (ch instanceof CTPresetColor) { CTPresetColor prst = (CTPresetColor)ch; color = new Color(DrawPaint.lin2srgb(scrgb.getR()), DrawPaint.lin2srgb(scrgb.getG()), DrawPaint.lin2srgb(scrgb.getB())); } else if (ch instanceof CTSRgbColor) {
public DrawPaint getPaint(PlaceableShape<?,?> shape) { return new DrawPaint(shape); }
/** * Convert color transformations in {@link ColorStyle} to a {@link Color} instance * * @see <a href="https://msdn.microsoft.com/en-us/library/dd560821%28v=office.12%29.aspx">Using Office Open XML to Customize Document Formatting in the 2007 Office System</a> * @see <a href="https://social.msdn.microsoft.com/Forums/office/en-US/040e0a1f-dbfe-4ce5-826b-38b4b6f6d3f7/saturation-modulation-satmod">saturation modulation (satMod)</a> * @see <a href="http://stackoverflow.com/questions/6754127/office-open-xml-satmod-results-in-more-than-100-saturation">Office Open XML satMod results in more than 100% saturation</a> */ public static Color applyColorTransform(ColorStyle color){ // TODO: The colors don't match 100% the results of Powerpoint, maybe because we still // operate in sRGB and not scRGB ... work in progress ... if (color == null || color.getColor() == null) { return TRANSPARENT; } Color result = color.getColor(); double alpha = getAlpha(result, color); double[] hsl = RGB2HSL(result); // values are in the range [0..100] (usually ...) applyHslModOff(hsl, 0, color.getHueMod(), color.getHueOff()); applyHslModOff(hsl, 1, color.getSatMod(), color.getSatOff()); applyHslModOff(hsl, 2, color.getLumMod(), color.getLumOff()); applyShade(hsl, color); applyTint(hsl, color); result = HSL2RGB(hsl[0], hsl[1], hsl[2], alpha); return result; }
@Override public PaintStyle getPaint() { return DrawPaint.createSolidPaint(getBorderColor(edge)); }
/** * * @return the displayed color as a Java Color. * If not color information was found in the supplied xml object then a null is returned. */ public Color getColor() { return DrawPaint.applyColorTransform(getColorStyle()); }
@Override public void setBulletFontColor(Color color) { setBulletFontColor(DrawPaint.createSolidPaint(color)); }
@Override public int hashCode() { return DrawPaint.applyColorTransform(this).hashCode(); }