public void appendCubic(float xm, float ym, float xn, float yn, float x1, float y1) { path.curveTo(xm, ym, xn, yn, x1, y1); }
/** * Gets the freeform path * * @return the freeform path */ public GeneralPath GetPath(){ EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__SHAPEPATH, 0x4)); EscherArrayProperty verticesProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__VERTICES + 0x4000)); if(verticesProp == null) verticesProp = (EscherArrayProperty)getEscherProperty(opt, EscherProperties.GEOMETRY__VERTICES); EscherArrayProperty segmentsProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__SEGMENTINFO + 0x4000)); if(segmentsProp == null) segmentsProp = (EscherArrayProperty)getEscherProperty(opt, EscherProperties.GEOMETRY__SEGMENTINFO); //sanity check if(verticesProp == null) { logger.log(POILogger.WARN, "Freeform is missing GEOMETRY__VERTICES "); return null; } if(segmentsProp == null) { logger.log(POILogger.WARN, "Freeform is missing GEOMETRY__SEGMENTINFO "); return null; } GeneralPath path = new GeneralPath(); int numPoints = verticesProp.GetNumberOfElementsInArray(); int numSegments = segmentsProp.GetNumberOfElementsInArray(); for (int i = 0, j = 0; i < numSegments && j < numPoints; i++) { byte[] elem = segmentsProp.GetElement(i); if(Arrays.Equals(elem, SEGMENTINFO_MOVETO)){ byte[] p = verticesProp.GetElement(j++); short x = LittleEndian.Getshort(p, 0); short y = LittleEndian.Getshort(p, 2); path.moveTo( ((float)x*POINT_DPI/MASTER_DPI), ((float)y*POINT_DPI/MASTER_DPI)); } else if (Arrays.Equals(elem, SEGMENTINFO_CUBICTO) || Arrays.Equals(elem, SEGMENTINFO_CUBICTO2)){ i++; byte[] p1 = verticesProp.GetElement(j++); short x1 = LittleEndian.Getshort(p1, 0); short y1 = LittleEndian.Getshort(p1, 2); byte[] p2 = verticesProp.GetElement(j++); short x2 = LittleEndian.Getshort(p2, 0); short y2 = LittleEndian.Getshort(p2, 2); byte[] p3 = verticesProp.GetElement(j++); short x3 = LittleEndian.Getshort(p3, 0); short y3 = LittleEndian.Getshort(p3, 2); path.curveTo( ((float)x1*POINT_DPI/MASTER_DPI), ((float)y1*POINT_DPI/MASTER_DPI), ((float)x2*POINT_DPI/MASTER_DPI), ((float)y2*POINT_DPI/MASTER_DPI), ((float)x3*POINT_DPI/MASTER_DPI), ((float)y3*POINT_DPI/MASTER_DPI)); } else if (Arrays.Equals(elem, SEGMENTINFO_LINETO)){ i++; byte[] pnext = segmentsProp.GetElement(i); if(Arrays.Equals(pnext, SEGMENTINFO_ESCAPE)){ if(j + 1 < numPoints){ byte[] p = verticesProp.GetElement(j++); short x = LittleEndian.Getshort(p, 0); short y = LittleEndian.Getshort(p, 2); path.lineTo( ((float)x*POINT_DPI/MASTER_DPI), ((float)y*POINT_DPI/MASTER_DPI)); } } else if (Arrays.Equals(pnext, SEGMENTINFO_CLOSE)){ path.ClosePath(); } } } return path; }