@Override public void setFillColor(Color color) { getFill().setForegroundColor(color); }
/** * Fill properties of this shape * * @return fill properties of this shape */ public HSLFFill getFill(){ if(_fill == null) { _fill = new HSLFFill(this); } return _fill; }
/** * Event which fires when a shape is inserted in the sheet. * In some cases we need to propagate changes to upper level containers. * <br> * Default implementation does nothing. * * @param sh - owning shape */ protected void afterInsert(HSLFSheet sh){ if(_fill != null) { _fill.afterInsert(sh); } }
@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; }
@Override public PaintStyle getPaint() { final int fillType = getFillType(); // TODO: fix gradient types, this mismatches with the MS-ODRAW definition ... // need to handle (not only) the type (radial,rectangular,linear), // the direction, e.g. top right, and bounds (e.g. for rectangular boxes) switch (fillType) { case FILL_SOLID: return DrawPaint.createSolidPaint(getForegroundColor()); case FILL_SHADE_SHAPE: return getGradientPaint(GradientType.shape); case FILL_SHADE_CENTER: case FILL_SHADE_TITLE: return getGradientPaint(GradientType.circular); case FILL_SHADE: case FILL_SHADE_SCALE: return getGradientPaint(GradientType.linear); case FILL_PICTURE: return getTexturePaint(); default: LOG.log(POILogger.WARN, "unsuported fill type: " + fillType); return null; } } };
/** */ protected void afterInsert(HSLFSheet sh){ AbstractEscherOptRecord opt = shape.getEscherOptRecord(); EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE); if(p != null) { int idx = p.getPropertyValue(); EscherBSERecord bse = getEscherBSERecord(idx); if (bse != null) { bse.setRef(bse.getRef() + 1); } } }
private TexturePaint getTexturePaint() { final HSLFPictureData pd = getPictureData(); if (pd == null) { return null; } return new TexturePaint() { @Override public InputStream getImageData() { return new ByteArrayInputStream(pd.getData()); } @Override public String getContentType() { return pd.getContentType(); } @Override public int getAlpha() { return (int)(shape.getAlpha(EscherProperties.FILL__FILLOPACITY)*100000.0); } }; }
@Override public Color getFillColor() { return getFill().getForegroundColor(); }
public FillStyle getFillStyle() { return getFill().getFillStyle(); }
return getFill().getForegroundColor(); col = getFill().getForegroundColor(); return getFill().getBackgroundColor(); Color col = getFill().getForegroundColor(); if (col == null && this instanceof HSLFSimpleShape) { col = ((HSLFSimpleShape)this).getLineColor();
/** * Assign picture used to fill the underlying shape. * * @param data the picture data added to this ppt by {@link HSLFSlideShow#addPicture(byte[], org.apache.poi.sl.usermodel.PictureData.PictureType)} method. */ public void setPictureData(HSLFPictureData data){ AbstractEscherOptRecord opt = shape.getEscherOptRecord(); HSLFShape.setEscherProperty(opt, (short)(EscherProperties.FILL__PATTERNTEXTURE + 0x4000), (data == null ? 0 : data.getIndex())); if(data != null && shape.getSheet() != null) { EscherBSERecord bse = getEscherBSERecord(data.getIndex()); if (bse != null) { bse.setRef(bse.getRef() + 1); } } }
static void create1stTable(HSLFSlide slide) { //six rows, two columns HSLFTable table1 = slide.createTable(6, 2); for (int i = 0; i < txt1.length; i++) { for (int j = 0; j < txt1[i].length; j++) { HSLFTableCell cell = table1.getCell(i, j); HSLFTextRun rt = cell.getTextParagraphs().get(0).getTextRuns().get(0); rt.setFontFamily("Arial"); rt.setFontSize(10d); if(i == 0){ cell.getFill().setForegroundColor(new Color(227, 227, 227)); } else { rt.setBold(true); } cell.setVerticalAlignment(VerticalAlignment.MIDDLE); cell.setHorizontalCentered(true); cell.setText(txt1[i][j]); } } DrawTableShape dts1 = new DrawTableShape(table1); dts1.setAllBorders(1.0, Color.black); table1.setColumnWidth(0, 300); table1.setColumnWidth(1, 150); int pgWidth = slide.getSlideShow().getPageSize().width; table1.moveTo((pgWidth - table1.getAnchor().getWidth())/2., 100.); }
rt.setFontFamily("Arial"); if(i == 0){ cell.getFill().setForegroundColor(new Color(0, 51, 102)); rt.setFontColor(Color.white); rt.setBold(true);