Example usage for org.apache.poi.hssf.usermodel HSSFSimpleShape getAnchor

List of usage examples for org.apache.poi.hssf.usermodel HSSFSimpleShape getAnchor

Introduction

In this page you can find the example usage for org.apache.poi.hssf.usermodel HSSFSimpleShape getAnchor.

Prototype

@Override
public HSSFAnchor getAnchor() 

Source Link

Usage

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);//  w  ww . ja v  a2 s . c o  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);

}