/// <summary> /// Constructs a <code>GlyphMetrics</code> object. </summary> /// <param name="horizontal"> if true, metrics are for a horizontal baseline, /// otherwise they are for a vertical baseline </param> /// <param name="advanceX"> the X-component of the glyph's advance </param> /// <param name="advanceY"> the Y-component of the glyph's advance </param> /// <param name="bounds"> the visual bounds of the glyph </param> /// <param name="glyphType"> the type of the glyph /// @since 1.4 </param> public GlyphMetrics(bool horizontal, float advanceX, float advanceY, Rectangle2D bounds, sbyte glyphType) { this.Horizontal = horizontal; this.AdvanceX_Renamed = advanceX; this.AdvanceY_Renamed = advanceY; this.Bounds = new Rectangle2D.Float(); this.Bounds.Rect = bounds; this.GlyphType = glyphType; }
/// <summary> /// Constructs a <code>GlyphMetrics</code> object. </summary> /// <param name="advance"> the advance width of the glyph </param> /// <param name="bounds"> the black box bounds of the glyph </param> /// <param name="glyphType"> the type of the glyph </param> public GlyphMetrics(float advance, Rectangle2D bounds, sbyte glyphType) { this.Horizontal = true; this.AdvanceX_Renamed = advance; this.AdvanceY_Renamed = 0; this.Bounds = new Rectangle2D.Float(); this.Bounds.Rect = bounds; this.GlyphType = glyphType; }
/** * Returns the anchor (the bounding box rectangle) of this shape group. * All coordinates are expressed in points (72 dpi). * * @return the anchor of this shape group */ public Rectangle2D GetAnchor2D(){ EscherContainerRecord spContainer = (EscherContainerRecord)_escherContainer.GetChild(0); EscherClientAnchorRecord clientAnchor = (EscherClientAnchorRecord)getEscherChild(spContainer, EscherClientAnchorRecord.RECORD_ID); Rectangle2D.Float anchor = new Rectangle2D.Float(); if(clientAnchor == null){ logger.log(POILogger.INFO, "EscherClientAnchorRecord was not found for shape group. Searching for EscherChildAnchorRecord."); EscherChildAnchorRecord rec = (EscherChildAnchorRecord)getEscherChild(spContainer, EscherChildAnchorRecord.RECORD_ID); anchor = new Rectangle2D.Float( (float)rec.GetDx1()*POINT_DPI/MASTER_DPI, (float)rec.GetDy1()*POINT_DPI/MASTER_DPI, (float)(rec.GetDx2()-rec.GetDx1())*POINT_DPI/MASTER_DPI, (float)(rec.GetDy2()-rec.GetDy1())*POINT_DPI/MASTER_DPI ); } else { anchor.x = (float)clientAnchor.GetCol1()*POINT_DPI/MASTER_DPI; anchor.y = (float)clientAnchor.GetFlag()*POINT_DPI/MASTER_DPI; anchor.width = (float)(clientAnchor.GetDx1() - clientAnchor.GetCol1())*POINT_DPI/MASTER_DPI ; anchor.height = (float)(clientAnchor.GetRow1() - clientAnchor.GetFlag())*POINT_DPI/MASTER_DPI; } return anchor; }
/** * Gets the coordinate space of this group. All children are constrained * to these coordinates. * * @return the coordinate space of this group */ public Rectangle2D GetCoordinates(){ EscherContainerRecord spContainer = (EscherContainerRecord)_escherContainer.GetChild(0); EscherSpgrRecord spgr = (EscherSpgrRecord)getEscherChild(spContainer, EscherSpgrRecord.RECORD_ID); Rectangle2D.Float anchor = new Rectangle2D.Float(); anchor.x = (float)spgr.GetRectX1()*POINT_DPI/MASTER_DPI; anchor.y = (float)spgr.GetRectY1()*POINT_DPI/MASTER_DPI; anchor.width = (float)(spgr.GetRectX2() - spgr.GetRectX1())*POINT_DPI/MASTER_DPI; anchor.height = (float)(spgr.GetRectY2() - spgr.GetRectY1())*POINT_DPI/MASTER_DPI; return anchor; }