List of usage examples for org.apache.poi.hslf.model PPGraphics2D PPGraphics2D
public PPGraphics2D(HSLFGroupShape group)
From source file:org.activityinfo.server.report.renderer.ppt.PPTChartRenderer.java
License:Open Source License
public void render(PivotChartReportElement element, SlideShow ppt) throws IOException { // add first slide Slide slide = ppt.createSlide();/*from w w w . j a va2 s.c o m*/ // define position of the drawing in the slide Dimension pageSize = ppt.getPageSize(); Dimension chartSize = new Dimension((int) (pageSize.getWidth() - 72), (int) (pageSize.getHeight() - 183)); Rectangle bounds = new com.google.code.appengine.awt.Rectangle(new Point(36, 126), chartSize); ShapeGroup group = new ShapeGroup(); group.setAnchor(bounds); slide.addShape(group); Graphics2D graphics = new PPGraphics2D(group); ChartRendererJC jc = new ChartRendererJC(); jc.render(element, false, graphics, (int) chartSize.getWidth(), (int) chartSize.getHeight(), 72); }
From source file:org.sigmah.server.report.renderer.ppt.PPTChartRenderer.java
License:Open Source License
public void render(PivotChartElement element, SlideShow ppt) throws IOException { //add first slide Slide slide = ppt.createSlide();//from w w w .j a va 2 s . c o m //define position of the drawing in the slide Dimension pageSize = ppt.getPageSize(); Dimension chartSize = new Dimension((int) (pageSize.getWidth() - 72), (int) (pageSize.getHeight() - 183)); Rectangle bounds = new java.awt.Rectangle(new Point(36, 126), chartSize); ShapeGroup group = new ShapeGroup(); group.setAnchor(bounds); slide.addShape(group); Graphics2D graphics = new PPGraphics2D(group); ChartRendererJC jc = new ChartRendererJC(); jc.render(element, false, graphics, (int) chartSize.getWidth(), (int) chartSize.getHeight(), 72); }
From source file:poi.hslf.examples.ApacheconEU08.java
License:Apache License
public static void slide10(SlideShow ppt) throws IOException { //bar chart data. The first value is the bar color, the second is the width Object[] def = new Object[] { Color.yellow, new Integer(100), Color.green, new Integer(150), Color.gray, new Integer(75), Color.red, new Integer(200), }; Slide slide = ppt.createSlide();/*from w w w . java2 s . c om*/ ShapeGroup group = new ShapeGroup(); //define position of the drawing in the slide Rectangle bounds = new Rectangle(200, 100, 350, 300); group.setAnchor(bounds); slide.addShape(group); Graphics2D graphics = new PPGraphics2D(group); //draw a simple bar graph int x = bounds.x + 50, y = bounds.y + 50; graphics.setFont(new Font("Arial", Font.BOLD, 10)); for (int i = 0, idx = 1; i < def.length; i += 2, idx++) { graphics.setColor(Color.black); int width = ((Integer) def[i + 1]).intValue(); graphics.drawString("Q" + idx, x - 20, y + 20); graphics.drawString(width + "%", x + width + 10, y + 20); graphics.setColor((Color) def[i]); graphics.fill(new Rectangle(x, y, width, 30)); y += 40; } graphics.setColor(Color.black); graphics.setFont(new Font("Arial", Font.BOLD, 14)); graphics.draw(bounds); graphics.drawString("Performance", x + 70, y + 40); }
From source file:poi.hslf.examples.Graphics2DDemo.java
License:Apache License
/** * A simple bar chart demo//from w w w . ja va 2 s .c o m */ public static void main(String[] args) throws Exception { SlideShow ppt = new SlideShow(); //bar chart data. The first value is the bar color, the second is the width Object[] def = new Object[] { Color.yellow, new Integer(40), Color.green, new Integer(60), Color.gray, new Integer(30), Color.red, new Integer(80), }; Slide slide = ppt.createSlide(); ShapeGroup group = new ShapeGroup(); //define position of the drawing in the slide Rectangle bounds = new Rectangle(200, 100, 350, 300); group.setAnchor(bounds); group.setCoordinates(new Rectangle(0, 0, 100, 100)); slide.addShape(group); Graphics2D graphics = new PPGraphics2D(group); //draw a simple bar graph int x = 10, y = 10; graphics.setFont(new Font("Arial", Font.BOLD, 10)); for (int i = 0, idx = 1; i < def.length; i += 2, idx++) { graphics.setColor(Color.black); int width = ((Integer) def[i + 1]).intValue(); graphics.drawString("Q" + idx, x - 5, y + 10); graphics.drawString(width + "%", x + width + 3, y + 10); graphics.setColor((Color) def[i]); graphics.fill(new Rectangle(x, y, width, 10)); y += 15; } graphics.setColor(Color.black); graphics.setFont(new Font("Arial", Font.BOLD, 14)); graphics.draw(group.getCoordinates()); graphics.drawString("Performance", x + 30, y + 10); FileOutputStream out = new FileOutputStream("hslf-graphics.ppt"); ppt.write(out); out.close(); }