Color getColor(short colorProperty, short opacityProperty, int defaultColor){ AbstractEscherOptRecord opt = getEscherOptRecord(); EscherSimpleProperty p = getEscherProperty(opt, colorProperty); if(p == null && defaultColor == -1) return null; int val = (p == null) ? defaultColor : p.getPropertyValue(); EscherColorRef ecr = new EscherColorRef(val); Color col = getColor(ecr); if (col == null) { return null; } double alpha = getAlpha(opacityProperty); return new Color(col.getRed(), col.getGreen(), col.getBlue(), (int)(alpha*255.0)); }
/** * Foreground color */ public Color getForegroundColor(){ AbstractEscherOptRecord opt = shape.getEscherOptRecord(); EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST); int propVal = (p == null) ? 0 : p.getPropertyValue(); return (FILL_USE_FILLED.isSet(propVal) && !FILL_FILLED.isSet(propVal)) ? null : shape.getColor(EscherProperties.FILL__FILLCOLOR, EscherProperties.FILL__FILLOPACITY, -1); }
/** * Background color */ public Color getBackgroundColor(){ AbstractEscherOptRecord opt = shape.getEscherOptRecord(); EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST); int propVal = (p == null) ? 0 : p.getPropertyValue(); return (FILL_USE_FILLED.isSet(propVal) && !FILL_FILLED.isSet(propVal)) ? null : shape.getColor(EscherProperties.FILL__FILLBACKCOLOR, EscherProperties.FILL__FILLOPACITY, -1); }
@Override public ColorStyle[] getGradientColors() { ColorStyle cs[]; if (colorCnt == 0) { cs = new ColorStyle[2]; cs[0] = wrapColor(getBackgroundColor()); cs[1] = wrapColor(getForegroundColor()); } else { cs = new ColorStyle[colorCnt]; int idx = 0; // TODO: handle palette colors and alpha(?) value for (byte data[] : ep) { EscherColorRef ecr = new EscherColorRef(data, 0, 4); cs[idx++] = wrapColor(shape.getColor(ecr)); } } return cs; }