public class DrawPaint {\r
// HSL code is public domain - see https://tips4java.wordpress.com/contact-us/\r
\r
- private final static POILogger LOG = POILogFactory.getLogger(DrawPaint.class);\r
+ private static final POILogger LOG = POILogFactory.getLogger(DrawPaint.class);\r
\r
+ private static final Color TRANSPARENT = new Color(1f,1f,1f,0f);\r
+ \r
protected PlaceableShape<?,?> shape;\r
\r
public DrawPaint(PlaceableShape<?,?> shape) {\r
throw new NullPointerException("Color needs to be specified");\r
}\r
this.solidColor = new ColorStyle(){\r
- public Color getColor() { return color; }\r
- public int getAlpha() { return -1; }\r
+ public Color getColor() {\r
+ return new Color(color.getRed(), color.getGreen(), color.getBlue());\r
+ }\r
+ public int getAlpha() { return (int)Math.round(color.getAlpha()*100000./255.); }\r
public int getHueOff() { return -1; }\r
public int getHueMod() { return -1; }\r
public int getSatOff() { return -1; }\r
public static Color applyColorTransform(ColorStyle color){\r
// TODO: The colors don't match 100% the results of Powerpoint, maybe because we still\r
// operate in sRGB and not scRGB ... work in progress ...\r
-\r
+ if (color == null || color.getColor() == null) {\r
+ return TRANSPARENT;\r
+ }\r
+ \r
Color result = color.getColor();\r
- if (result == null) return null;\r
\r
double alpha = getAlpha(result, color);\r
double hsl[] = RGB2HSL(result); // values are in the range [0..100] (usually ...)\r
\r
int i = 0;\r
for (ColorStyle fc : fill.getGradientColors()) {\r
- if (fc == null) {\r
- // get color of background\r
- fc = new ColorStyle() {\r
- public int getTint() { return -1; }\r
- public int getShade() { return -1; }\r
- public int getSatOff() { return -1; }\r
- public int getSatMod() { return -1; }\r
- public int getLumOff() { return -1; }\r
- public int getLumMod() { return -1; }\r
- public int getHueOff() { return -1; }\r
- public int getHueMod() { return -1; }\r
- public Color getColor() { return Color.white; }\r
- public int getAlpha() { return 0; }\r
- };\r
- }\r
- colors[i++] = applyColorTransform(fc);\r
+ // if fc is null, use transparent color to get color of background\r
+ colors[i++] = (fc == null) ? TRANSPARENT : applyColorTransform(fc);\r
}\r
\r
AffineTransform grAt = new AffineTransform();\r