Search in sources :

Example 6 with SolidPaint

use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint in project poi by apache.

the class HSLFTextRun method setFontColor.

@Override
public void setFontColor(PaintStyle color) {
    if (!(color instanceof SolidPaint)) {
        throw new IllegalArgumentException("HSLF only supports solid paint");
    }
    // In PowerPont RGB bytes are swapped, as BGR
    SolidPaint sp = (SolidPaint) color;
    Color c = DrawPaint.applyColorTransform(sp.getSolidColor());
    int rgb = new Color(c.getBlue(), c.getGreen(), c.getRed(), 254).getRGB();
    setFontColor(rgb);
}
Also used : SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) Color(java.awt.Color) SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) DrawPaint(org.apache.poi.sl.draw.DrawPaint)

Example 7 with SolidPaint

use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint in project poi by apache.

the class DrawSimpleShape method drawShadow.

protected void drawShadow(Graphics2D graphics, Collection<Outline> outlines, Paint fill, Paint line) {
    Shadow<?, ?> shadow = getShape().getShadow();
    if (shadow == null || (fill == null && line == null)) {
        return;
    }
    SolidPaint shadowPaint = shadow.getFillStyle();
    Color shadowColor = DrawPaint.applyColorTransform(shadowPaint.getSolidColor());
    double shapeRotation = getShape().getRotation();
    if (getShape().getFlipVertical()) {
        shapeRotation += 180;
    }
    double angle = shadow.getAngle() - shapeRotation;
    double dist = shadow.getDistance();
    double dx = dist * Math.cos(Math.toRadians(angle));
    double dy = dist * Math.sin(Math.toRadians(angle));
    graphics.translate(dx, dy);
    for (Outline o : outlines) {
        java.awt.Shape s = o.getOutline();
        Path p = o.getPath();
        graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, s);
        graphics.setPaint(shadowColor);
        if (fill != null && p.isFilled()) {
            graphics.fill(s);
        } else if (line != null && p.isStroked()) {
            graphics.draw(s);
        }
    }
    graphics.translate(-dx, -dy);
}
Also used : Path(org.apache.poi.sl.draw.geom.Path) SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) Color(java.awt.Color) Outline(org.apache.poi.sl.draw.geom.Outline)

Example 8 with SolidPaint

use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint in project poi by apache.

the class TestXSLFTheme method slide4.

void slide4(XSLFSlide slide) {
    PaintStyle fs = slide.getBackground().getFillStyle().getPaint();
    assertTrue(fs instanceof GradientPaint);
    XSLFTextShape sh1 = (XSLFTextShape) getShape(slide, "Rectangle 4");
    XSLFTextRun run1 = sh1.getTextParagraphs().get(0).getTextRuns().get(0);
    assertTrue(sameColor(Color.white, run1.getFontColor()));
    assertEquals(new Color(148, 198, 0), sh1.getFillColor());
    // solid fill
    assertTrue(sh1.getFillStyle().getPaint() instanceof SolidPaint);
    XSLFTextShape sh2 = (XSLFTextShape) getShape(slide, "Title 3");
    XSLFTextRun run2 = sh2.getTextParagraphs().get(0).getTextRuns().get(0);
    assertTrue(sameColor(new Color(148, 198, 0), run2.getFontColor()));
    // no fill
    assertNull(sh2.getFillColor());
    assertTrue(slide.getSlideLayout().getFollowMasterGraphics());
}
Also used : SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) PaintStyle(org.apache.poi.sl.usermodel.PaintStyle) Color(java.awt.Color) TestCommonSL.sameColor(org.apache.poi.sl.TestCommonSL.sameColor) GradientPaint(org.apache.poi.sl.usermodel.PaintStyle.GradientPaint)

Example 9 with SolidPaint

use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint in project poi by apache.

the class HSLFTextRun method getFontColor.

/**
	 * @return font color as PaintStyle
	 */
@Override
public SolidPaint getFontColor() {
    TextProp tp = getTextParagraph().getPropVal(characterStyle, masterStyle, "font.color");
    if (tp == null) {
        return null;
    }
    Color color = HSLFTextParagraph.getColorFromColorIndexStruct(tp.getValue(), parentParagraph.getSheet());
    SolidPaint ps = DrawPaint.createSolidPaint(color);
    return ps;
}
Also used : SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) CharFlagsTextProp(org.apache.poi.hslf.model.textproperties.CharFlagsTextProp) TextProp(org.apache.poi.hslf.model.textproperties.TextProp) BitMaskTextProp(org.apache.poi.hslf.model.textproperties.BitMaskTextProp) Color(java.awt.Color)

Example 10 with SolidPaint

use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint in project poi by apache.

the class HSLFTextParagraph method getBulletStyle.

@Override
public BulletStyle getBulletStyle() {
    if (!isBullet() && getAutoNumberingScheme() == null) {
        return null;
    }
    return new BulletStyle() {

        @Override
        public String getBulletCharacter() {
            Character chr = HSLFTextParagraph.this.getBulletChar();
            return (chr == null || chr == 0) ? "" : "" + chr;
        }

        @Override
        public String getBulletFont() {
            return HSLFTextParagraph.this.getBulletFont();
        }

        @Override
        public Double getBulletFontSize() {
            return HSLFTextParagraph.this.getBulletSize();
        }

        @Override
        public void setBulletFontColor(Color color) {
            setBulletFontColor(DrawPaint.createSolidPaint(color));
        }

        @Override
        public void setBulletFontColor(PaintStyle color) {
            if (!(color instanceof SolidPaint)) {
                throw new IllegalArgumentException("HSLF only supports SolidPaint");
            }
            SolidPaint sp = (SolidPaint) color;
            Color col = DrawPaint.applyColorTransform(sp.getSolidColor());
            HSLFTextParagraph.this.setBulletColor(col);
        }

        @Override
        public PaintStyle getBulletFontColor() {
            Color col = HSLFTextParagraph.this.getBulletColor();
            return DrawPaint.createSolidPaint(col);
        }

        @Override
        public AutoNumberingScheme getAutoNumberingScheme() {
            return HSLFTextParagraph.this.getAutoNumberingScheme();
        }

        @Override
        public Integer getAutoNumberingStartAt() {
            return HSLFTextParagraph.this.getAutoNumberingStartAt();
        }
    };
}
Also used : SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) Color(java.awt.Color) PaintStyle(org.apache.poi.sl.usermodel.PaintStyle)

Aggregations

SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)14 Color (java.awt.Color)12 PaintStyle (org.apache.poi.sl.usermodel.PaintStyle)4 BitMaskTextProp (org.apache.poi.hslf.model.textproperties.BitMaskTextProp)2 TextProp (org.apache.poi.hslf.model.textproperties.TextProp)2 TestCommonSL.sameColor (org.apache.poi.sl.TestCommonSL.sameColor)2 ColorStyle (org.apache.poi.sl.usermodel.ColorStyle)2 GradientPaint (org.apache.poi.sl.usermodel.PaintStyle.GradientPaint)2 Test (org.junit.Test)2 CTSchemeColor (org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor)2 LinearGradientPaint (java.awt.LinearGradientPaint)1 Paint (java.awt.Paint)1 RadialGradientPaint (java.awt.RadialGradientPaint)1 Ellipse2D (java.awt.geom.Ellipse2D)1 Path2D (java.awt.geom.Path2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 CharFlagsTextProp (org.apache.poi.hslf.model.textproperties.CharFlagsTextProp)1 ParagraphFlagsTextProp (org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp)1 DrawPaint (org.apache.poi.sl.draw.DrawPaint)1 Outline (org.apache.poi.sl.draw.geom.Outline)1