use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint in project poi by apache.
the class DrawPaint method getSolidPaint.
protected Paint getSolidPaint(SolidPaint fill, Graphics2D graphics, final PaintModifier modifier) {
final ColorStyle orig = fill.getSolidColor();
ColorStyle cs = new ColorStyle() {
@Override
public Color getColor() {
return orig.getColor();
}
@Override
public int getAlpha() {
return orig.getAlpha();
}
@Override
public int getHueOff() {
return orig.getHueOff();
}
@Override
public int getHueMod() {
return orig.getHueMod();
}
@Override
public int getSatOff() {
return orig.getSatOff();
}
@Override
public int getSatMod() {
return orig.getSatMod();
}
@Override
public int getLumOff() {
return orig.getLumOff();
}
@Override
public int getLumMod() {
return orig.getLumMod();
}
@Override
public int getShade() {
int shade = orig.getShade();
switch(modifier) {
case DARKEN:
return Math.min(100000, Math.max(0, shade) + 40000);
case DARKEN_LESS:
return Math.min(100000, Math.max(0, shade) + 20000);
default:
return shade;
}
}
@Override
public int getTint() {
int tint = orig.getTint();
switch(modifier) {
case LIGHTEN:
return Math.min(100000, Math.max(0, tint) + 40000);
case LIGHTEN_LESS:
return Math.min(100000, Math.max(0, tint) + 20000);
default:
return tint;
}
}
};
return applyColorTransform(cs);
}
use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint in project poi by apache.
the class TestXSLFTheme method slide1.
void slide1(XSLFSlide slide) {
assertEquals(Color.WHITE, slide.getBackground().getFillColor());
XSLFTheme theme = slide.getTheme();
assertEquals("Office Theme", theme.getName());
XSLFTextShape sh1 = (XSLFTextShape) getShape(slide, "Rectangle 3");
XSLFTextRun run1 = sh1.getTextParagraphs().get(0).getTextRuns().get(0);
assertTrue(sameColor(Color.white, run1.getFontColor()));
assertEquals(new Color(79, 129, 189), sh1.getFillColor());
// solid fill
assertTrue(sh1.getFillStyle().getPaint() instanceof SolidPaint);
}
use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint in project poi by apache.
the class TestBugs method bug55983.
@Test
public void bug55983() throws IOException {
HSLFSlideShow ppt1 = new HSLFSlideShow();
HSLFSlide sl = ppt1.createSlide();
sl.getBackground().getFill().setForegroundColor(Color.blue);
HSLFFreeformShape fs = sl.createFreeform();
Ellipse2D.Double el = new Ellipse2D.Double(0, 0, 300, 200);
fs.setAnchor(new Rectangle2D.Double(100, 100, 300, 200));
fs.setPath(new Path2D.Double(el));
Color cExp = new Color(50, 100, 150, 200);
fs.setFillColor(cExp);
HSLFSlideShow ppt2 = HSLFTestDataSamples.writeOutAndReadBack(ppt1);
ppt1.close();
sl = ppt2.getSlides().get(0);
fs = (HSLFFreeformShape) sl.getShapes().get(0);
Color cAct = fs.getFillColor();
assertEquals(cExp.getRed(), cAct.getRed());
assertEquals(cExp.getGreen(), cAct.getGreen());
assertEquals(cExp.getBlue(), cAct.getBlue());
assertEquals(cExp.getAlpha(), cAct.getAlpha(), 1);
PaintStyle ps = fs.getFillStyle().getPaint();
assertTrue(ps instanceof SolidPaint);
ColorStyle cs = ((SolidPaint) ps).getSolidColor();
cAct = cs.getColor();
assertEquals(cExp.getRed(), cAct.getRed());
assertEquals(cExp.getGreen(), cAct.getGreen());
assertEquals(cExp.getBlue(), cAct.getBlue());
assertEquals(255, cAct.getAlpha());
assertEquals(cExp.getAlpha() * 100000. / 255., cs.getAlpha(), 1);
ppt2.close();
}
use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint in project poi by apache.
the class TestBugs method bug45124.
@Test
public void bug45124() throws IOException {
SlideShow<?, ?> ppt = open("bug45124.ppt");
Slide<?, ?> slide1 = ppt.getSlides().get(1);
TextBox<?, ?> res = slide1.createTextBox();
res.setAnchor(new java.awt.Rectangle(60, 150, 700, 100));
res.setText("I am italic-false, bold-true inserted text");
TextParagraph<?, ?, ?> tp = res.getTextParagraphs().get(0);
TextRun rt = tp.getTextRuns().get(0);
rt.setItalic(false);
assertTrue(rt.isBold());
tp.setBulletStyle(Color.red, 'A');
SlideShow<?, ?> ppt2 = HSLFTestDataSamples.writeOutAndReadBack((HSLFSlideShow) ppt);
ppt.close();
res = (TextBox<?, ?>) ppt2.getSlides().get(1).getShapes().get(1);
tp = res.getTextParagraphs().get(0);
rt = tp.getTextRuns().get(0);
assertFalse(rt.isItalic());
assertTrue(rt.isBold());
PaintStyle ps = tp.getBulletStyle().getBulletFontColor();
assertTrue(ps instanceof SolidPaint);
Color actColor = DrawPaint.applyColorTransform(((SolidPaint) ps).getSolidColor());
assertEquals(Color.red, actColor);
assertEquals("A", tp.getBulletStyle().getBulletCharacter());
ppt2.close();
}
Aggregations