/// <summary> /// Creates a polygon /// </summary> /// <param name="anchor">the client anchor describes how this Group is attached /// to the sheet.</param> /// <returns>the newly Created shape.</returns> public HSSFPolygon CreatePolygon(IClientAnchor anchor) { HSSFPolygon shape = new HSSFPolygon(null, (HSSFAnchor)anchor); shape.Anchor = (HSSFAnchor)anchor; AddShape(shape); return(shape); }
/// <summary> /// Creates a polygon /// </summary> /// <param name="anchor">the client anchor describes how this Group Is attached /// to the sheet.</param> /// <returns>the newly Created shape.</returns> public HSSFPolygon CreatePolygon(HSSFChildAnchor anchor) { HSSFPolygon shape = new HSSFPolygon(this, anchor); shape.Anchor = anchor; shapes.Add(shape); return(shape); }
/** * Fills a (closed) polygon, as defined by a pair of arrays, which * hold the <i>x</i> and <i>y</i> coordinates. * * This Draws the polygon, with <c>nPoint</c> line segments. * The first <c>nPoint - 1</c> line segments are * Drawn between sequential points * (<c>xPoints[i],yPoints[i],xPoints[i+1],yPoints[i+1]</c>). * The line segment Is a closing one, from the last point to * the first (assuming they are different). * * The area inside of the polygon Is defined by using an * even-odd Fill rule (also known as the alternating rule), and * the area inside of it Is Filled. * @param xPoints array of the <c>x</c> coordinates. * @param yPoints array of the <c>y</c> coordinates. * @param nPoints the total number of points in the polygon. * @see java.awt.Graphics#DrawPolygon(int[], int[], int) */ public void FillPolygon(int[] xPoints, int[] yPoints, int nPoints) { int right = FindBiggest(xPoints); int bottom = FindBiggest(yPoints); int left = FindSmallest(xPoints); int top = FindSmallest(yPoints); HSSFPolygon shape = escherGroup.CreatePolygon(new HSSFChildAnchor(left, top, right, bottom)); shape.SetPolygonDrawArea(right - left, bottom - top); shape.SetPoints(AddToAll(xPoints, -left), AddToAll(yPoints, -top)); shape.SetLineStyleColor(foreground.R, foreground.G, foreground.B); shape.SetFillColor(foreground.R, foreground.G, foreground.B); }
/// <summary> /// Creates a polygon /// </summary> /// <param name="anchor">the client anchor describes how this Group is attached /// to the sheet.</param> /// <returns>the newly Created shape.</returns> public HSSFPolygon CreatePolygon(IClientAnchor anchor) { HSSFPolygon shape = new HSSFPolygon(null, (HSSFAnchor)anchor); shape.Anchor = (HSSFAnchor)anchor; AddShape(shape); return shape; }
/// <summary> /// Creates a polygon /// </summary> /// <param name="anchor">the client anchor describes how this Group Is attached /// to the sheet.</param> /// <returns>the newly Created shape.</returns> public HSSFPolygon CreatePolygon(HSSFChildAnchor anchor) { HSSFPolygon shape = new HSSFPolygon(this, anchor); shape.Anchor = anchor; shapes.Add(shape); return shape; }
/// <summary> /// Creates the lowerlevel escher records for this shape. /// </summary> /// <param name="hssfShape">The HSSF shape.</param> /// <param name="shapeId">The shape id.</param> /// <returns></returns> private EscherContainerRecord CreateSpContainer(HSSFPolygon hssfShape, int shapeId) { HSSFShape shape = hssfShape; EscherContainerRecord spContainer = new EscherContainerRecord(); EscherSpRecord sp = new EscherSpRecord(); EscherOptRecord opt = new EscherOptRecord(); EscherClientDataRecord clientData = new EscherClientDataRecord(); spContainer.RecordId=EscherContainerRecord.SP_CONTAINER; spContainer.Options=(short)0x000F; sp.RecordId=EscherSpRecord.RECORD_ID; sp.Options=(short)((EscherAggregate.ST_DONUT << 4) | 0x2); sp.ShapeId=shapeId; if (hssfShape.Parent == null) sp.Flags=EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE; else sp.Flags=EscherSpRecord.FLAG_CHILD | EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE; opt.RecordId=EscherOptRecord.RECORD_ID; opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TRANSFORM__ROTATION, false, false, 0)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__RIGHT, false, false, hssfShape.DrawAreaWidth)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__BOTTOM, false, false, hssfShape.DrawAreaHeight)); opt.AddEscherProperty(new EscherShapePathProperty(EscherProperties.GEOMETRY__SHAPEPATH, EscherShapePathProperty.COMPLEX)); EscherArrayProperty verticesProp = new EscherArrayProperty(EscherProperties.GEOMETRY__VERTICES, false, new byte[0]); verticesProp.NumberOfElementsInArray=(hssfShape.XPoints.Length + 1); verticesProp.NumberOfElementsInMemory=(hssfShape.XPoints.Length + 1); verticesProp.SizeOfElements=unchecked((short)0xFFF0); for (int i = 0; i < hssfShape.XPoints.Length; i++) { byte[] data = new byte[4]; LittleEndian.PutShort(data, 0, (short)hssfShape.XPoints[i]); LittleEndian.PutShort(data, 2, (short)hssfShape.YPoints[i]); verticesProp.SetElement(i, data); } int point = hssfShape.XPoints.Length; byte[] data1 = new byte[4]; LittleEndian.PutShort(data1, 0, (short)hssfShape.XPoints[0]); LittleEndian.PutShort(data1, 2, (short)hssfShape.YPoints[0]); verticesProp.SetElement(point, data1); opt.AddEscherProperty(verticesProp); EscherArrayProperty segmentsProp = new EscherArrayProperty(EscherProperties.GEOMETRY__SEGMENTINFO, false, null); segmentsProp.SizeOfElements=(0x0002); segmentsProp.NumberOfElementsInArray=(hssfShape.XPoints.Length * 2 + 4); segmentsProp.NumberOfElementsInMemory=(hssfShape.XPoints.Length * 2 + 4); segmentsProp.SetElement(0, new byte[] { (byte)0x00, (byte)0x40 }); segmentsProp.SetElement(1, new byte[] { (byte)0x00, (byte)0xAC }); for (int i = 0; i < hssfShape.XPoints.Length; i++) { segmentsProp.SetElement(2 + i * 2, new byte[] { (byte)0x01, (byte)0x00 }); segmentsProp.SetElement(3 + i * 2, new byte[] { (byte)0x00, (byte)0xAC }); } segmentsProp.SetElement(segmentsProp.NumberOfElementsInArray - 2, new byte[] { (byte)0x01, (byte)0x60 }); segmentsProp.SetElement(segmentsProp.NumberOfElementsInArray - 1, new byte[] { (byte)0x00, (byte)0x80 }); opt.AddEscherProperty(segmentsProp); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__FillOK, false, false, 0x00010001)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINESTARTARROWHEAD, false, false, 0x0)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDARROWHEAD, false, false, 0x0)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDCAPSTYLE, false, false, 0x0)); AddStandardOptions(shape, opt); EscherRecord anchor = CreateAnchor(shape.Anchor); clientData.RecordId=(EscherClientDataRecord.RECORD_ID); clientData.Options=(short)0x0000; spContainer.AddChildRecord(sp); spContainer.AddChildRecord(opt); spContainer.AddChildRecord(anchor); spContainer.AddChildRecord(clientData); return spContainer; }
/// <summary> /// Creates the low evel records for an polygon. /// </summary> /// <param name="hssfShape">The highlevel shape.</param> /// <param name="shapeId">The shape id to use for this shape.</param> public PolygonShape(HSSFPolygon hssfShape, int shapeId) { spContainer = CreateSpContainer(hssfShape, shapeId); objRecord = CreateObjRecord(hssfShape, shapeId); }