/* ====================================================================
Licensed to the Apache Software Foundation (ASF) Under one or more
contributor license agreements. See the NOTICE file distributed with
this work for Additional information regarding copyright ownership.
The ASF licenses this file to You Under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed Under the License is distributed on an "AS Is" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations Under the License.
==================================================================== */
namespace HH.WMS.Utils.NPOI.HSSF.UserModel
{
using System;
using System.Collections;
///
/// 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 : HSSFShape, HSSFShapeContainer
{
IList shapes = new ArrayList();
int x1 = 0;
int y1 = 0;
int x2 = 1023;
int y2 = 255;
public HSSFShapeGroup(HSSFShape parent, HSSFAnchor anchor):base(parent, anchor)
{
}
///
/// Create another Group Under this Group.
///
/// the position of the new Group.
/// 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.
///
/// the position of the shape.
/// 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.
///
/// the position of the shape.
/// the textbox
public HSSFTextbox CreateTextbox(HSSFChildAnchor anchor)
{
HSSFTextbox shape = new HSSFTextbox(this, anchor);
shape.Anchor = anchor;
shapes.Add(shape);
return shape;
}
///
/// Creates a polygon
///
/// the client anchor describes how this Group Is attached
/// to the sheet.
/// the newly Created shape.
public HSSFPolygon CreatePolygon(HSSFChildAnchor anchor)
{
HSSFPolygon shape = new HSSFPolygon(this, anchor);
shape.Anchor = anchor;
shapes.Add(shape);
return shape;
}
///
/// Creates a picture.
///
/// the client anchor describes how this Group Is attached
/// to the sheet.
/// Index of the picture.
/// the newly Created shape.
public HSSFPicture CreatePicture(HSSFChildAnchor anchor, int pictureIndex)
{
HSSFPicture shape = new HSSFPicture(this, anchor);
shape.Anchor = anchor;
shape.PictureIndex=pictureIndex;
shapes.Add(shape);
return shape;
}
///
/// Return all children contained by this shape.
///
///
public System.Collections.IList Children
{
get { return shapes; }
}
///
/// Sets the coordinate space of this Group. All children are constrained
/// to these coordinates.
///
/// The x1.
/// The y1.
/// The x2.
/// The y2.
public void SetCoordinates(int x1, int y1, int x2, int y2)
{
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
}
///
/// Gets The top left x coordinate of this Group.
///
/// The x1.
public int X1
{
get { return x1; }
}
///
/// Gets The top left y coordinate of this Group.
///
/// The y1.
public int Y1
{
get
{
return y1;
}
}
///
/// Gets The bottom right x coordinate of this Group.
///
/// The x2.
public int X2
{
get
{
return x2;
}
}
///
/// Gets the bottom right y coordinate of this Group.
///
/// The y2.
public int Y2
{
get
{
return y2;
}
}
///
/// Count of all children and their childrens children.
///
///
public override int CountOfAllChildren
{
get
{
int count = shapes.Count;
for (IEnumerator iterator = shapes.GetEnumerator(); iterator.MoveNext(); )
{
HSSFShape shape = (HSSFShape)iterator.Current;
count += shape.CountOfAllChildren;
}
return count;
}
}
}
}