Beispiel #1
0
  /** @return the shapes contained in this group container */
  public Shape[] getShapes() {
    // Out escher container record should contain serveral
    //  SpContainers, the first of which is the group shape itself
    List lst = _escherContainer.getChildRecords();

    ArrayList shapeList = new ArrayList();
    // Don't include the first SpContainer, it is always NotPrimitive
    for (int i = 1; i < lst.size(); i++) {
      EscherRecord r = (EscherRecord) lst.get(i);
      if (r instanceof EscherContainerRecord) {
        // Create the Shape for it
        EscherContainerRecord container = (EscherContainerRecord) r;
        Shape shape = ShapeFactory.createShape(container, this);
        shape.setSheet(getSheet());
        shapeList.add(shape);
      } else {
        // Should we do anything special with these non
        //  Container records?
        logger.log(
            POILogger.ERROR,
            "Shape contained non container escher record, was " + r.getClass().getName());
      }
    }

    // Put the shapes into an array, and return
    Shape[] shapes = (Shape[]) shapeList.toArray(new Shape[shapeList.size()]);
    return shapes;
  }
Beispiel #2
0
  /**
   * Add a shape to this group.
   *
   * @param shape - the Shape to add
   */
  public void addShape(Shape shape) {
    _escherContainer.addChildRecord(shape.getSpContainer());

    Sheet sheet = getSheet();
    shape.setSheet(sheet);
    shape.setShapeId(sheet.allocateShapeId());
    shape.afterInsert(sheet);
  }