List of usage examples for org.apache.poi.hssf.usermodel HSSFChildAnchor HSSFChildAnchor
public HSSFChildAnchor(int dx1, int dy1, int dx2, int dy2)
From source file:poi.hssf.usermodel.examples.OfficeDrawing.java
License:Apache License
private static void drawSheet3(HSSFSheet sheet3) { // Create a row and size one of the cells reasonably large HSSFRow row = sheet3.createRow(2);//from w w w . j a v a 2s . co m row.setHeightInPoints(140); row.createCell(1); sheet3.setColumnWidth(2, 9000); // Create the drawing patriarch. This is the top level container for // all shapes. This will clear out any existing shapes for that sheet. HSSFPatriarch patriarch = sheet3.createDrawingPatriarch(); // Create a shape group. HSSFShapeGroup group = patriarch .createGroup(new HSSFClientAnchor(0, 0, 900, 200, (short) 2, 2, (short) 2, 2)); // Create a couple of lines in the group. HSSFSimpleShape shape1 = group.createShape(new HSSFChildAnchor(3, 3, 500, 500)); shape1.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE); ((HSSFChildAnchor) shape1.getAnchor()).setAnchor((short) 3, 3, 500, 500); HSSFSimpleShape shape2 = group.createShape(new HSSFChildAnchor((short) 1, 200, 400, 600)); shape2.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE); }
From source file:poi.hssf.usermodel.examples.OfficeDrawing.java
License:Apache License
private static void drawPolygon(HSSFPatriarch patriarch) { // HSSFClientAnchor a = new HSSFClientAnchor( 0, 0, 1023, 255, (short) 2, 2, (short) 3, 3 ); // HSSFPolygon p = patriarch.createPolygon(a); // p.setPolygonDrawArea(100,100); // p.setPoints( new int[]{30, 90, 50}, new int[]{88, 5, 44} ); HSSFClientAnchor a = new HSSFClientAnchor(); a.setAnchor((short) 2, 2, 0, 0, (short) 3, 3, 1023, 255); HSSFShapeGroup g = patriarch.createGroup(a); g.setCoordinates(0, 0, 200, 200);// w w w . j av a2s . c o m HSSFPolygon p1 = g.createPolygon(new HSSFChildAnchor(0, 0, 200, 200)); p1.setPolygonDrawArea(100, 100); p1.setPoints(new int[] { 0, 90, 50 }, new int[] { 5, 5, 44 }); p1.setFillColor(0, 255, 0); HSSFPolygon p2 = g.createPolygon(new HSSFChildAnchor(20, 20, 200, 200)); p2.setPolygonDrawArea(200, 200); p2.setPoints(new int[] { 120, 20, 150 }, new int[] { 105, 30, 195 }); p2.setFillColor(255, 0, 0); }