mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/branches/REL_2_BRANCH@353497 13f79535-47bb-0310-9956-ffa450edef68
149 lines
3.3 KiB
Java
149 lines
3.3 KiB
Java
package org.apache.poi.hssf.usermodel;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Iterator;
|
|
|
|
/**
|
|
* A shape group may contain other shapes. It was no actual form on the
|
|
* sheet.
|
|
*
|
|
* @author Glen Stampoultzis (glens at apache.org)
|
|
*/
|
|
public class HSSFShapeGroup
|
|
extends HSSFShape
|
|
implements HSSFShapeContainer
|
|
{
|
|
List shapes = new ArrayList();
|
|
int x1 = 0;
|
|
int y1 = 0 ;
|
|
int x2 = 1023;
|
|
int y2 = 255;
|
|
|
|
|
|
public HSSFShapeGroup( HSSFShape parent, HSSFAnchor anchor )
|
|
{
|
|
super( parent, anchor );
|
|
}
|
|
|
|
/**
|
|
* Create another group under this group.
|
|
* @param anchor the position of the new group.
|
|
* @return the group
|
|
*/
|
|
public HSSFShapeGroup createGroup(HSSFChildAnchor anchor)
|
|
{
|
|
HSSFShapeGroup group = new HSSFShapeGroup(this, anchor);
|
|
group.anchor = anchor;
|
|
shapes.add(group);
|
|
return group;
|
|
}
|
|
|
|
/**
|
|
* Create a new simple shape under this group.
|
|
* @param anchor the position of the shape.
|
|
* @return the shape
|
|
*/
|
|
public HSSFSimpleShape createShape(HSSFChildAnchor anchor)
|
|
{
|
|
HSSFSimpleShape shape = new HSSFSimpleShape(this, anchor);
|
|
shape.anchor = anchor;
|
|
shapes.add(shape);
|
|
return shape;
|
|
}
|
|
|
|
/**
|
|
* Create a new textbox under this group.
|
|
* @param anchor the position of the shape.
|
|
* @return the textbox
|
|
*/
|
|
public HSSFTextbox createTextbox(HSSFChildAnchor anchor)
|
|
{
|
|
HSSFTextbox shape = new HSSFTextbox(this, anchor);
|
|
shape.anchor = anchor;
|
|
shapes.add(shape);
|
|
return shape;
|
|
}
|
|
|
|
/**
|
|
* Creates a polygon
|
|
*
|
|
* @param anchor the client anchor describes how this group is attached
|
|
* to the sheet.
|
|
* @return the newly created shape.
|
|
*/
|
|
public HSSFPolygon createPolygon(HSSFChildAnchor anchor)
|
|
{
|
|
HSSFPolygon shape = new HSSFPolygon(this, anchor);
|
|
shape.anchor = anchor;
|
|
shapes.add(shape);
|
|
return shape;
|
|
}
|
|
|
|
/**
|
|
* Return all children contained by this shape.
|
|
*/
|
|
public List getChildren()
|
|
{
|
|
return shapes;
|
|
}
|
|
|
|
/**
|
|
* Sets the coordinate space of this group. All children are contrained
|
|
* to these coordinates.
|
|
*/
|
|
public void setCoordinates( int x1, int y1, int x2, int y2 )
|
|
{
|
|
this.x1 = x1;
|
|
this.y1 = y1;
|
|
this.x2 = x2;
|
|
this.y2 = y2;
|
|
}
|
|
|
|
/**
|
|
* The top left x coordinate of this group.
|
|
*/
|
|
public int getX1()
|
|
{
|
|
return x1;
|
|
}
|
|
|
|
/**
|
|
* The top left y coordinate of this group.
|
|
*/
|
|
public int getY1()
|
|
{
|
|
return y1;
|
|
}
|
|
|
|
/**
|
|
* The bottom right x coordinate of this group.
|
|
*/
|
|
public int getX2()
|
|
{
|
|
return x2;
|
|
}
|
|
|
|
/**
|
|
* The bottom right y coordinate of this group.
|
|
*/
|
|
public int getY2()
|
|
{
|
|
return y2;
|
|
}
|
|
|
|
/**
|
|
* Count of all children and their childrens children.
|
|
*/
|
|
public int countOfAllChildren()
|
|
{
|
|
int count = shapes.size();
|
|
for ( Iterator iterator = shapes.iterator(); iterator.hasNext(); )
|
|
{
|
|
HSSFShape shape = (HSSFShape) iterator.next();
|
|
count += shape.countOfAllChildren();
|
|
}
|
|
return count;
|
|
}
|
|
}
|