1 16 17 package org.apache.poi.hssf.usermodel; 18 19 import java.util.ArrayList ; 20 import java.util.List ; 21 import java.util.Iterator ; 22 23 29 public class HSSFShapeGroup 30 extends HSSFShape 31 implements HSSFShapeContainer 32 { 33 List shapes = new ArrayList (); 34 int x1 = 0; 35 int y1 = 0 ; 36 int x2 = 1023; 37 int y2 = 255; 38 39 40 public HSSFShapeGroup( HSSFShape parent, HSSFAnchor anchor ) 41 { 42 super( parent, anchor ); 43 } 44 45 50 public HSSFShapeGroup createGroup(HSSFChildAnchor anchor) 51 { 52 HSSFShapeGroup group = new HSSFShapeGroup(this, anchor); 53 group.anchor = anchor; 54 shapes.add(group); 55 return group; 56 } 57 58 63 public HSSFSimpleShape createShape(HSSFChildAnchor anchor) 64 { 65 HSSFSimpleShape shape = new HSSFSimpleShape(this, anchor); 66 shape.anchor = anchor; 67 shapes.add(shape); 68 return shape; 69 } 70 71 76 public HSSFTextbox createTextbox(HSSFChildAnchor anchor) 77 { 78 HSSFTextbox shape = new HSSFTextbox(this, anchor); 79 shape.anchor = anchor; 80 shapes.add(shape); 81 return shape; 82 } 83 84 91 public HSSFPolygon createPolygon(HSSFChildAnchor anchor) 92 { 93 HSSFPolygon shape = new HSSFPolygon(this, anchor); 94 shape.anchor = anchor; 95 shapes.add(shape); 96 return shape; 97 } 98 99 102 public List getChildren() 103 { 104 return shapes; 105 } 106 107 111 public void setCoordinates( int x1, int y1, int x2, int y2 ) 112 { 113 this.x1 = x1; 114 this.y1 = y1; 115 this.x2 = x2; 116 this.y2 = y2; 117 } 118 119 122 public int getX1() 123 { 124 return x1; 125 } 126 127 130 public int getY1() 131 { 132 return y1; 133 } 134 135 138 public int getX2() 139 { 140 return x2; 141 } 142 143 146 public int getY2() 147 { 148 return y2; 149 } 150 151 154 public int countOfAllChildren() 155 { 156 int count = shapes.size(); 157 for ( Iterator iterator = shapes.iterator(); iterator.hasNext(); ) 158 { 159 HSSFShape shape = (HSSFShape) iterator.next(); 160 count += shape.countOfAllChildren(); 161 } 162 return count; 163 } 164 } 165 | Popular Tags |