/// <summary> /// Returns a <code>Shape</code> whose interior corresponds to the /// visual representation of the specified glyph /// within this <code>GlyphVector</code>, offset to x, y. /// The outline returned by this method is positioned around the /// origin of each individual glyph. </summary> /// <param name="glyphIndex"> the index into this <code>GlyphVector</code> </param> /// <param name="x"> the X coordinate of the location of this {@code GlyphVector} </param> /// <param name="y"> the Y coordinate of the location of this {@code GlyphVector} </param> /// <returns> a <code>Shape</code> that is the outline of the glyph /// at the specified <code>glyphIndex</code> of this /// <code>GlyphVector</code> when rendered at the specified /// coordinates. </returns> /// <exception cref="IndexOutOfBoundsException"> if <code>glyphIndex</code> /// is less than 0 or greater than or equal to the number /// of glyphs in this <code>GlyphVector</code> /// @since 1.4 </exception> public virtual Shape GetGlyphOutline(int glyphIndex, float x, float y) { Shape s = GetGlyphOutline(glyphIndex); AffineTransform at = AffineTransform.GetTranslateInstance(x, y); return(at.CreateTransformedShape(s)); }
/// <summary> /// Return a <seealso cref="java.awt.Shape"/> that represents the region that /// this <code>GraphicAttribute</code> renders. This is used when a /// <seealso cref="TextLayout"/> is requested to return the outline of the text. /// The (untransformed) shape must not extend outside the rectangular /// bounds returned by <code>getBounds</code>. /// The default implementation returns the rectangle returned by /// <seealso cref="#getBounds"/>, transformed by the provided <seealso cref="AffineTransform"/> /// if present. </summary> /// <param name="tx"> an optional <seealso cref="AffineTransform"/> to apply to the /// outline of this <code>GraphicAttribute</code>. This can be null. </param> /// <returns> a <code>Shape</code> representing this graphic attribute, /// suitable for stroking or filling. /// @since 1.6 </returns> public virtual Shape GetOutline(AffineTransform tx) { Shape b = Bounds; if (tx != null) { b = tx.CreateTransformedShape(b); } return(b); }
public Rectangle2D GetLogicalAnchor2D() { Rectangle anchor = GetAnchor2D(); //if it is a groupped shape see if we need to transform the coordinates if (_parent != null) { Shape top = _parent; while (top.GetParent() != null) { top = top.GetParent(); } Rectangle clientAnchor = top.GetAnchor2D(); Rectangle spgrAnchor = ((ShapeGroup)top).GetCoordinates(); double scalex = spgrAnchor.Width / clientAnchor.Width; double scaley = spgrAnchor.Height / clientAnchor.Height; double x = clientAnchor.X + (anchor.X - spgrAnchor.X) / scalex; double y = clientAnchor.Y + (anchor.Y - spgrAnchor.Y) / scaley; double width = anchor.Width / scalex; double height = anchor.Height / scaley; anchor = new Rectangle2D.Double(x, y, width, height); } int angle = GetRotation(); if (angle != 0) { double centerX = anchor.X + anchor.Width / 2; double centerY = anchor.Y + anchor.Height / 2; AffineTransform trans = new AffineTransform(); trans.translate(centerX, centerY); trans.rotate(Math.ToRadians(angle)); trans.translate(-centerX, -centerY); Rectangle2D rect = trans.CreateTransformedShape(anchor).GetBounds2D(); if ((anchor.Width < anchor.Height && rect.Width > rect.Height) || (anchor.Width > anchor.Height && rect.Width < rect.Height)) { trans = new AffineTransform(); trans.translate(centerX, centerY); trans.rotate(Math.PI / 2); trans.translate(-centerX, -centerY); anchor = trans.CreateTransformedShape(anchor).GetBounds2D(); } } return(anchor); }
/// <summary> /// Return a <seealso cref="java.awt.Shape"/> that represents the region that /// this <code>ShapeGraphicAttribute</code> renders. This is used when a /// <seealso cref="TextLayout"/> is requested to return the outline of the text. /// The (untransformed) shape must not extend outside the rectangular /// bounds returned by <code>getBounds</code>. </summary> /// <param name="tx"> an optional <seealso cref="AffineTransform"/> to apply to the /// this <code>ShapeGraphicAttribute</code>. This can be null. </param> /// <returns> the <code>Shape</code> representing this graphic attribute, /// suitable for stroking or filling. /// @since 1.6 </returns> public override Shape GetOutline(AffineTransform tx) { return(tx == null ? FShape : tx.CreateTransformedShape(FShape)); }
public java.awt.Shape GetOutline(){ GeneralPath path = GetPath(); Rectangle2D anchor = GetAnchor2D(); Rectangle2D bounds = path.GetBounds2D(); AffineTransform at = new AffineTransform(); at.translate(anchor.GetX(), anchor.GetY()); at.scale( anchor.Width/bounds.Width, anchor.Height/bounds.Height ); return at.CreateTransformedShape(path); }
public Rectangle2D GetLogicalAnchor2D() { Rectangle anchor = GetAnchor2D(); //if it is a groupped shape see if we need to transform the coordinates if (_parent != null) { Shape top = _parent; while (top.GetParent() != null) top = top.GetParent(); Rectangle clientAnchor = top.GetAnchor2D(); Rectangle spgrAnchor = ((ShapeGroup)top).GetCoordinates(); double scalex = spgrAnchor.Width / clientAnchor.Width; double scaley = spgrAnchor.Height / clientAnchor.Height; double x = clientAnchor.X + (anchor.X - spgrAnchor.X) / scalex; double y = clientAnchor.Y + (anchor.Y - spgrAnchor.Y) / scaley; double width = anchor.Width / scalex; double height = anchor.Height / scaley; anchor = new Rectangle2D.Double(x, y, width, height); } int angle = GetRotation(); if (angle != 0) { double centerX = anchor.X + anchor.Width / 2; double centerY = anchor.Y + anchor.Height / 2; AffineTransform trans = new AffineTransform(); trans.translate(centerX, centerY); trans.rotate(Math.ToRadians(angle)); trans.translate(-centerX, -centerY); Rectangle2D rect = trans.CreateTransformedShape(anchor).GetBounds2D(); if ((anchor.Width < anchor.Height && rect.Width > rect.Height) || (anchor.Width > anchor.Height && rect.Width < rect.Height)) { trans = new AffineTransform(); trans.translate(centerX, centerY); trans.rotate(Math.PI / 2); trans.translate(-centerX, -centerY); anchor = trans.CreateTransformedShape(anchor).GetBounds2D(); } } return anchor; }
/** * Auto-shapes are defined in the [0,21600] coordinate system. * We need to transform it into normal slide coordinates * */ public static java.awt.Shape transform(java.awt.Shape outline, Rectangle2D anchor){ AffineTransform at = new AffineTransform(); at.translate(anchor.GetX(), anchor.GetY()); at.scale( 1.0f/21600*anchor.Width, 1.0f/21600*anchor.Height ); return at.CreateTransformedShape(outline); }