| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057 |
- //
- // System.Drawing.Drawing2D.GraphicsPath.cs
- //
- // Author:
- // Konstantin Triger <[email protected]>
- // Bors Kirzner <[email protected]>
- //
- // Copyright (C) 2005 Mainsoft Corporation, (http://www.mainsoft.com)
- //
- // Permission is hereby granted, free of charge, to any person obtaining
- // a copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to
- // permit persons to whom the Software is furnished to do so, subject to
- // the following conditions:
- //
- // The above copyright notice and this permission notice shall be
- // included in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- //
- using System;
- using System.Drawing;
- using System.Collections;
- using java.awt.geom;
- using java.awt;
- namespace System.Drawing.Drawing2D
- {
- public sealed class GraphicsPath : BasicShape, ICloneable
- {
- internal enum JPI {
- SEG_MOVETO = ExtendedGeneralPath.SEG_MOVETO,
- SEG_LINETO = ExtendedGeneralPath.SEG_LINETO,
- SEG_QUADTO = ExtendedGeneralPath.SEG_QUADTO,
- SEG_CUBICTO = ExtendedGeneralPath.SEG_CUBICTO,
- SEG_CLOSE = ExtendedGeneralPath.SEG_CLOSE
- }
- #region Internal
- internal ExtendedGeneralPath NativeObject
- {
- get
- {
- return (ExtendedGeneralPath)Shape;
- }
- }
- GraphicsPath (ExtendedGeneralPath ptr) : base(ptr)
- {
- }
- #endregion
- #region C-tors.
- public GraphicsPath ():
- this(FillMode.Alternate)
- {
- }
-
- public GraphicsPath (FillMode fillMode) : this(new ExtendedGeneralPath ())
- {
- FillMode = fillMode;
- }
-
- public GraphicsPath (Point[] pts, byte[] types) : this(pts, types, FillMode.Alternate)
- {
- }
-
- public GraphicsPath (PointF [] pts, byte [] types) : this(pts, types, FillMode.Alternate)
- {
- }
-
- public GraphicsPath (Point [] pts, byte [] types, FillMode fillMode) : this(new ExtendedGeneralPath ())
- {
- FillMode = fillMode;
- SetPath (pts, types);
- }
- public GraphicsPath (PointF [] pts, byte [] types, FillMode fillMode) : this(new ExtendedGeneralPath ())
- {
- FillMode = fillMode;
- SetPath (pts, types);
- }
- #endregion
- #region Clone
- public object Clone ()
- {
- return new GraphicsPath ((ExtendedGeneralPath) NativeObject.Clone ());
- }
- #endregion
- #region Properties
- public FillMode FillMode
- {
- get
- { if(NativeObject.getWindingRule() == GeneralPath.WIND_NON_ZERO)
- return FillMode.Alternate;
- else
- return FillMode.Winding;
- }
- set
- {
- if (value == FillMode.Alternate)
- NativeObject.setWindingRule (GeneralPath.WIND_NON_ZERO);
- else
- NativeObject.setWindingRule (GeneralPath.WIND_EVEN_ODD);
- }
- }
- public PathData PathData
- {
- get { return NativeObject.PathData; }
- }
- public PointF [] PathPoints
- {
- get
- {
- return PathData.Points;
- }
- }
- public byte [] PathTypes
- {
- get
- {
- return PathData.Types;
- }
- }
- #endregion
- #region PointCount
- public int PointCount
- {
- get
- {
- return NativeObject.PointCount;
- }
- }
- #endregion
-
- #region AddArc
- public void AddArc (Rectangle rect, float startAngle, float sweepAngle)
- {
- AddArc(rect.X,rect.Y,rect.Width,rect.Height,startAngle,sweepAngle);
- }
- public void AddArc (RectangleF rect, float startAngle, float sweepAngle)
- {
- AddArc(rect.X,rect.Y,rect.Width,rect.Height,startAngle,sweepAngle);
- }
- public void AddArc (int x, int y, int width, int height, float startAngle, float sweepAngle)
- {
- AddArc((float)x,(float)y,(float)width,(float)height,startAngle,sweepAngle);
- }
- public void AddArc (float x, float y, float width, float height, float startAngle, float sweepAngle)
- {
- Shape shape = null;
- if (sweepAngle >= 360)
- shape = new Ellipse2D.Float(x, y, width, height);
- else {
- double d1Tod2 = width/height;
- double sqrd1Tod2 = d1Tod2*d1Tod2;
- double start = ConvertArcAngle(sqrd1Tod2, startAngle);
- double extent = ConvertArcAngle(sqrd1Tod2, startAngle+sweepAngle) - start;
- shape = new Arc2D.Double(x,y,width,height,-start,-extent,Arc2D.OPEN);
- }
- NativeObject.append(shape);
- }
- /// <summary>
- /// .Net computes an angle by intersection of ellipse with a ray
- /// java does the following: x1 = d1*cos(a), y1 = d2*sin(a)
- /// where: d1 = width/2, d2 = height/2
- /// we need to find angle x, which satisfies:
- /// x1 = m*cos(a) = d1*cos(x)
- /// y1 = m*sin(a) = d2*sin(x)
- /// (x1*x1)/(d1*d1) + (x2*x2)/(d2*d2) = 1
- /// </summary>
- /// <param name="sqrd1Tod2">(d1/d2)*(d1/d2)</param>
- /// <param name="angle">angle in degrees</param>
- /// <returns>converted angle in degrees</returns>
- static double ConvertArcAngle(double sqrd1Tod2, double angle) {
- double angleRad = java.lang.Math.toRadians(angle);
- double tan = Math.Tan(angleRad);
- double cosx = 1/Math.Sqrt( sqrd1Tod2 * (tan*tan) + 1);
- double xRad = Math.Acos(cosx);
- double x = java.lang.Math.toDegrees(xRad);
- int q = ((int)angle)/90;
- switch (q&3) {
- case 1:
- x = 180-x;
- break;
- case 2:
- x = 180+x;
- break;
- case 3:
- x = 360-x;
- break;
- }
- if (angle < 0)
- x = -x;
- x += (((int)angle)/360)*360;
- return x;
- }
- #endregion
-
- #region AddBezier(s)
- public void AddBezier (Point pt1, Point pt2, Point pt3, Point pt4)
- {
- AddBezier(pt1.X,pt1.Y,pt2.X,pt2.Y,pt3.X,pt3.Y,pt4.X,pt4.Y);
- }
- public void AddBezier (PointF pt1, PointF pt2, PointF pt3, PointF pt4)
- {
- AddBezier(pt1.X,pt1.Y,pt2.X,pt2.Y,pt3.X,pt3.Y,pt4.X,pt4.Y);
- }
- public void AddBezier (int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
- {
- AddBezier((float)x1,(float)y1,(float)x2,(float)y2,(float)x3,(float)y3,(float)x4,(float)y4);
- }
- public void AddBezier (float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
- {
- CubicCurve2D cc = new CubicCurve2D.Float(x1,y1,x2,y2,x3,y3,x4,y4);
- NativeObject.append(cc);
- }
- public void AddBeziers (Point [] pts)
- {
- if (pts == null)
- throw new ArgumentNullException("points");
- AddBezier(pts [0].X,pts [0].Y,
- pts [1].X,pts [1].Y,
- pts [2].X,pts [2].Y,
- pts [3].X,pts [3].Y);
- for (int i = 4; i < pts.Length; i += 3) {
- NativeObject.curveTo(
- pts [i].X,pts [i].Y,
- pts [i+1].X,pts [i+1].Y,
- pts [i+2].X,pts [i+2].Y);
- }
- }
- public void AddBeziers (PointF [] pts)
- {
- if (pts == null)
- throw new ArgumentNullException("points");
- AddBezier(pts [0].X,pts [0].Y,
- pts [1].X,pts [1].Y,
- pts [2].X,pts [2].Y,
- pts [3].X,pts [3].Y);
- for (int i = 4; i < pts.Length; i += 3) {
- NativeObject.curveTo(
- pts [i].X,pts [i].Y,
- pts [i+1].X,pts [i+1].Y,
- pts [i+2].X,pts [i+2].Y);
- }
- }
- #endregion
- #region AddEllipse
- public void AddEllipse (float x, float y, float width, float height)
- {
- Ellipse2D e = new Ellipse2D.Float(x,y,width,height);
- NativeObject.append(e,false);
- }
- public void AddEllipse (RectangleF r)
- {
- AddEllipse(r.X,r.Y,r.Width,r.Height);
- }
-
- public void AddEllipse (Rectangle r)
- {
- AddEllipse(r.X,r.Y,r.Width,r.Height);
- }
-
- public void AddEllipse (int x, int y, int width, int height)
- {
- AddEllipse((float)x, (float)y, (float)width, (float)height);
- }
- #endregion
-
- #region AddLine
- public void AddLine (float x1, float y1, float x2, float y2)
- {
- Line2D l = new Line2D.Float(x1,y1,x2,y2);
- NativeObject.append(l);
- }
- public void AddLine (Point a, Point b)
- {
- AddLine(a.X,a.Y,b.X,b.Y);
- }
- public void AddLine (PointF a, PointF b)
- {
- AddLine(a.X,a.Y,b.X,b.Y);
- }
- public void AddLine (int x1, int y1, int x2, int y2)
- {
- AddLine((float)x1,(float)y1,(float)x2,(float)y2);
- }
- public void AddLines (Point [] points)
- {
- if (points == null)
- throw new ArgumentNullException("points");
- if (points.Length == 0)
- return;
- if (NativeObject.LastFigureClosed)
- NativeObject.moveTo(points[0].X, points[0].Y);
- else
- NativeObject.lineTo(points[0].X, points[0].Y);
- for (int i = 1; i < points.Length; i ++)
- NativeObject.lineTo(points[i].X, points[i].Y);
- }
- public void AddLines (PointF [] points)
- {
- if (points == null)
- throw new ArgumentNullException("points");
- if (points.Length == 0)
- return;
- if (NativeObject.LastFigureClosed)
- NativeObject.moveTo(points[0].X, points[0].Y);
- else
- NativeObject.lineTo(points[0].X, points[0].Y);
- for (int i = 1; i < points.Length; i ++)
- NativeObject.lineTo(points[i].X, points[i].Y);
- }
- #endregion
-
- #region AddPie
- public void AddPie (float x, float y, float width, float height, float startAngle, float sweepAngle)
- {
- Shape shape = null;
- if (sweepAngle >= 360)
- shape = new Ellipse2D.Float(x, y, width, height);
- else {
- double d1Tod2 = width/height;
- double sqrd1Tod2 = d1Tod2*d1Tod2;
- double start = ConvertArcAngle(sqrd1Tod2, startAngle);
- double extent = ConvertArcAngle(sqrd1Tod2, startAngle+sweepAngle) - start;
- shape = new Arc2D.Double(x,y,width,height,-start,-extent,Arc2D.PIE);
- }
- NativeObject.append(shape,false);
- }
- public void AddPie (Rectangle rect, float startAngle, float sweepAngle)
- {
- AddPie((float)rect.X, (float)rect.Y,(float)rect.Width,(float)rect.Height,startAngle,sweepAngle);
- }
- public void AddPie (int x, int y, int width, int height, float startAngle, float sweepAngle)
- {
- AddPie((float)x,(float)y,(float)width,(float)height,startAngle,sweepAngle);
- }
- #endregion
- #region AddPolygon
- public void AddPolygon (Point [] points)
- {
- if (points == null)
- throw new ArgumentNullException("points");
- if (points.Length < 3)
- throw new ArgumentException("Invalid parameter used.");
- NativeObject.moveTo((float)points[0].X,(float)points[0].Y);
- for (int i = 1; i< points.Length; i++)
- {
- NativeObject.lineTo((float)points[i].X,(float)points[i].Y);
- }
- NativeObject.closePath();
- }
- public void AddPolygon (PointF [] points)
- {
- if (points == null)
- throw new ArgumentNullException("points");
- if (points.Length < 3)
- throw new ArgumentException("Invalid parameter used.");
- NativeObject.moveTo(points[0].X,points[0].Y);
- for (int i = 1; i < points.Length; i++)
- {
- NativeObject.lineTo(points[i].X,points[i].Y);
- }
- NativeObject.closePath();
- }
- #endregion
- #region AddRectangle(s)
- internal void AddRectangle(float x,float y, float w, float h)
- {
- NativeObject.moveTo(x, y);
- NativeObject.lineTo (x + w, y);
- NativeObject.lineTo (x + w, y + h);
- NativeObject.lineTo (x, y + h);
- NativeObject.closePath ();
- }
- public void AddRectangle (RectangleF rect)
- {
- AddRectangle(rect.X,rect.Y,rect.Width,rect.Height);
- }
- public void AddRectangle (Rectangle rect)
- {
- AddRectangle(rect.X,rect.Y,rect.Width,rect.Height);
- }
- public void AddRectangles (Rectangle [] rects)
- {
- foreach(Rectangle rect in rects)
- AddRectangle(rect.X,rect.Y,rect.Width,rect.Height);
- }
- public void AddRectangles (RectangleF [] rects)
- {
- foreach(RectangleF rect in rects)
- AddRectangle(rect.X,rect.Y,rect.Width,rect.Height);
- }
- #endregion
- #region AddPath
- public void AddPath (GraphicsPath addingPath, bool connect)
- {
- NativeObject.append(addingPath.NativeObject,connect);
- }
- #endregion
- #region GetLastPoint
- public PointF GetLastPoint ()
- {
- return NativeObject.GetLastPoint ();
- }
- #endregion
- #region Reset
- public void Reset ()
- {
- NativeObject.reset();
- }
- #endregion
- #region GetBounds
- public RectangleF GetBounds ()
- {
- return GetBounds (null, null);
- }
- public RectangleF GetBounds (Matrix matrix)
- {
- return GetBounds (matrix, null);
- }
- public RectangleF GetBounds (Matrix matrix, Pen pen)
- {
- // FIXME : we do not know exacly how the bounding rectangle
- // is calculated so this implementation obtains different bounds
- // that still contains the path widened by oen and transformed by matrix
- // the order of operations is similar to widening, as .Net does.
- // first get original shape bounds
- //Shape shape = NativeObject.getBounds2D();
- Shape shape = NativeObject;
- // stroke bounds
- if (pen != null)
- shape = ((Stroke)pen).createStrokedShape (shape);
- Rectangle2D rect = shape.getBounds2D ();
- // transform bounds
- if (matrix != null)
- rect = matrix.NativeObject.createTransformedShape(rect).getBounds2D();
- return new RectangleF (rect);
- }
- #endregion
-
- #region Transform
- public void Transform (Matrix matrix)
- {
- if(matrix == null)
- return;
- NativeObject.transform(matrix.NativeObject);
- }
- #endregion
- #region IsVisible
- public bool IsVisible (Point point)
- {
- return IsVisible (point.X, point.Y, null);
- }
-
- public bool IsVisible (PointF point)
- {
- return IsVisible (point.X, point.Y, null);
- }
-
- public bool IsVisible (int x, int y)
- {
- return IsVisible (x, y, null);
- }
- public bool IsVisible (float x, float y)
- {
- return IsVisible (x, y, null);
- }
-
- public bool IsVisible (Point pt, Graphics graphics)
- {
- return IsVisible (pt.X, pt.Y, graphics);
- }
-
- public bool IsVisible (PointF pt, Graphics graphics)
- {
- return IsVisible (pt.X, pt.Y, graphics);
- }
-
- public bool IsVisible (int x, int y, Graphics graphics)
- {
- return IsVisible((float)x,(float)y,null);
- }
-
- public bool IsVisible (float x, float y, Graphics graphics)
- {
- // LAMESPEC : .Net is currently ignorig Graphics object
- //if (graphics != null && !graphics.IsVisible(x,y))
- // return false;
- return NativeObject.contains(x,y);
- }
- #endregion
-
- #region Reverse
- public void Reverse ()
- {
- NativeObject.Reverse ();
- }
- #endregion
-
- #region AddClosedCurve
- public void AddClosedCurve (Point [] points)
- {
- AddClosedCurve(points, 0.5f);
- }
- public void AddClosedCurve (PointF [] points)
- {
- AddClosedCurve(points, 0.5f);
- }
- public void AddClosedCurve (Point [] points, float tension)
- {
- if (points == null)
- throw new ArgumentNullException("points");
- if (points.Length < 3)
- throw new ArgumentException("Invalid parameter used.");
- int length = (points.Length + 3)*2;
- float[] pts = new float[length];
- pts[--length] = points[1].Y;
- pts[--length] = points[1].X;
- pts[--length] = points[0].Y;
- pts[--length] = points[0].X;
- for (int i = points.Length-1; i >= 0; i--) {
- pts[--length] = points[i].Y;
- pts[--length] = points[i].X;
- }
- pts[--length] = points[points.Length-1].Y;
- pts[--length] = points[points.Length-1].X;
- AddCurve(pts, !NativeObject.LastFigureClosed, tension);
- CloseFigure ();
- }
- public void AddClosedCurve (PointF [] points, float tension)
- {
- if (points == null)
- throw new ArgumentNullException("points");
- if (points.Length < 3)
- throw new ArgumentException("Invalid parameter used.");
- int length = (points.Length + 3)*2;
- float[] pts = new float[length];
- pts[--length] = points[1].Y;
- pts[--length] = points[1].X;
- pts[--length] = points[0].Y;
- pts[--length] = points[0].X;
- for (int i = points.Length-1; i >= 0; i--) {
- pts[--length] = points[i].Y;
- pts[--length] = points[i].X;
- }
- pts[--length] = points[points.Length-1].Y;
- pts[--length] = points[points.Length-1].X;
- AddCurve(pts, !NativeObject.LastFigureClosed, tension);
- CloseFigure ();
- }
- #endregion
- #region AddCurve
- //we have now two approaches for drawing cardinal curves
- //the first one is to convert cardinals into approximate beziers
- //the second one - to draw curve ourself with all interpolation staff
- //here. I preffer the first one because we could utilize java antialiasing and
- //flattening features, otherwise curves will be more strict but less cool
- public void AddCurve (Point [] points)
- {
- AddCurve(points,0.5F);
- }
-
- public void AddCurve (PointF [] points)
- {
- AddCurve(points,0.5f);
- }
-
- public void AddCurve (Point [] points, float tension)
- {
- AddCurve(points, 0, points.Length-1, tension);
- }
-
- public void AddCurve (PointF [] points, float tension)
- {
- AddCurve(points, 0, points.Length-1, tension);
- }
- public void AddCurve (Point [] points, int offset, int numberOfSegments, float tension)
- {
- int nPoints = numberOfSegments + 1;
- int length = nPoints*2 + 4;
- float[] pts = new float[length];
- int lastP = offset + nPoints;
- if (lastP == points.Length) {
- lastP--;
- pts[--length] = points[lastP].Y;
- pts[--length] = points[lastP].X;
- }
- for (; length > 0 && lastP >= 0; lastP--) {
- pts[--length] = points[lastP].Y;
- pts[--length] = points[lastP].X;
- }
- if (length > 0) {
- pts[1] = points[0].Y;
- pts[0] = points[0].X;
- }
- AddCurve(pts, !NativeObject.LastFigureClosed, tension);
- }
-
- public void AddCurve (PointF [] points, int offset, int numberOfSegments, float tension)
- {
- int nPoints = numberOfSegments + 1;
- int length = nPoints*2 + 4;
- float[] pts = new float[length];
- int lastP = offset + nPoints;
- if (lastP == points.Length) {
- lastP--;
- pts[--length] = points[lastP].Y;
- pts[--length] = points[lastP].X;
- }
- for (; length > 0 && lastP >= 0; lastP--) {
- pts[--length] = points[lastP].Y;
- pts[--length] = points[lastP].X;
- }
- if (length > 0) {
- pts[1] = points[0].Y;
- pts[0] = points[0].X;
- }
- AddCurve(pts, !NativeObject.LastFigureClosed, tension);
- }
- /// <summary>
- /// Based on http://pubpages.unh.edu/~cs770/a5/cardinal.html
- /// </summary>
- /// <param name="pts">point array (x1,y1,x2,y2 ...).
- /// The first and last points considered only for calculations, but are not added.</param>
- void AddCurve(float[] pts, bool connect, float tension) {
- tension /= 3f; //looks like a good pick
- if (connect)
- NativeObject.lineTo(pts[2],pts[3]);
- else
- NativeObject.moveTo(pts[2],pts[3]);
- float dx = pts[4] - pts[0];
- float dy = pts[5] - pts[1];
- float sx = pts[2] + tension*dx;
- float sy = pts[3] + tension*dy;
- for (int offset = 2, total = pts.Length-4; offset < total; offset += 2) {
- int cur_offset = offset;
- int pX = cur_offset++;
- int pY = cur_offset++;
- int X = cur_offset++;
- int Y = cur_offset++;
- int nX = cur_offset++;
- int nY = cur_offset++;
- dx = pts[nX] - pts[pX];
- dy = pts[nY] - pts[pY];
- float rx = pts[X] - tension*dx;
- float ry = pts[Y] - tension*dy;
-
- NativeObject.curveTo(sx, sy, rx, ry, pts[X], pts[Y]);
- sx = pts[X] + tension*dx;
- sy = pts[Y] + tension*dy;
- }
- }
- #endregion
- #region AddString
- [MonoTODO]
- public void AddString (string s, FontFamily family, int style, float emSize, Point origin, StringFormat format)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- public void AddString (string s, FontFamily family, int style, float emSize, PointF origin, StringFormat format)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- public void AddString (string s, FontFamily family, int style, float emSize, Rectangle layoutRect, StringFormat format)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- public void AddString (string s, FontFamily family, int style, float emSize, RectangleF layoutRect, StringFormat format)
- {
- throw new NotImplementedException ();
- }
- #endregion
-
- #region ClearMarkers
- public void ClearMarkers()
- {
- NativeObject.ClearMarkers ();
- }
- #endregion
-
- #region Close
- public void CloseAllFigures()
- {
- ExtendedGeneralPath p = new ExtendedGeneralPath();
- PathIterator pi = NativeObject.getPathIterator(null);
- JPI lastSeg = JPI.SEG_CLOSE;
- float [] points = new float[6];
-
- p.setWindingRule(pi.getWindingRule());
- while(!pi.isDone())
- {
- JPI curSeg = (JPI)pi.currentSegment(points);
- switch(curSeg)
- {
- case JPI.SEG_CLOSE:
- p.closePath();
- break;
- case JPI.SEG_MOVETO:
- if(lastSeg != JPI.SEG_CLOSE)
- p.closePath();
- p.moveTo(points[0],points[1]);
- break;
- case JPI.SEG_LINETO:
- p.lineTo(points[0],points[1]);
- break;
- case JPI.SEG_QUADTO:
- p.quadTo(points[0],points[1],points[2],points[3]);
- break;
- case JPI.SEG_CUBICTO:
- p.curveTo(points[0],points[1],points[2],points[3],points[4],points[5]);
- break;
- default:
- break;
- }
- lastSeg = curSeg;
- pi.next();
- }
- p.closePath();
- Shape = p;
- }
-
- public void CloseFigure()
- {
- NativeObject.closePath();
- }
- #endregion
- #region Flatten
- public void Flatten ()
- {
- // 1/4 is the FlatnessDefault as defined in GdiPlusEnums.h
- Flatten (null, 1.0f / 4.0f);
- }
-
- public void Flatten (Matrix matrix)
- {
- Flatten (matrix, 1.0f / 4.0f);
- }
-
- public void Flatten (Matrix matrix, float flatness)
- {
- AffineTransform tr = null;
- if(matrix != null)
- tr = matrix.NativeObject;
- //FIXME : Review (perfomance reasons).
- PathIterator pi = NativeObject.getPathIterator(tr,flatness);
- ExtendedGeneralPath newPath = new ExtendedGeneralPath();
- newPath.append(pi,false);
- Shape = newPath;
- }
- #endregion
-
- #region GetOutlineVisible
- public bool IsOutlineVisible (Point point, Pen pen)
- {
- return IsOutlineVisible (point.X, point.Y, pen, null);
- }
-
- public bool IsOutlineVisible (PointF point, Pen pen)
- {
- return IsOutlineVisible (point.X, point.Y, pen, null);
- }
-
- public bool IsOutlineVisible (int x, int y, Pen pen)
- {
- return IsOutlineVisible (x, y, pen, null);
- }
- public bool IsOutlineVisible (float x, float y, Pen pen)
- {
- return IsOutlineVisible (x, y, pen, null);
- }
-
- public bool IsOutlineVisible (Point pt, Pen pen, Graphics graphics)
- {
- return IsOutlineVisible (pt.X, pt.Y, pen, graphics);
- }
-
- public bool IsOutlineVisible (PointF pt, Pen pen, Graphics graphics)
- {
- return IsOutlineVisible (pt.X, pt.Y, pen, graphics);
- }
-
- public bool IsOutlineVisible (int x, int y, Pen pen, Graphics graphics)
- {
- // LAMESPEC : .Net is currently ignorig Graphics object
- //if (graphics != null) {
- // if (!graphics.IsVisible (x, y))
- // return false;
- //}
- return ((Stroke)pen).createStrokedShape (NativeObject).contains (x, y);
- }
-
- public bool IsOutlineVisible (float x, float y, Pen pen, Graphics graphics)
- {
- return ((Stroke)pen).createStrokedShape (NativeObject).contains (x, y);
- }
- #endregion
-
- #region SetMarkers
- public void SetMarkers ()
- {
- NativeObject.SetMarkers ();
- }
- #endregion
-
- #region StartFigure
- public void StartFigure()
- {
- NativeObject.StartFigure ();
- }
- #endregion
-
- #region Warp
- [MonoTODO]
- public void Warp (PointF[] destPoints, RectangleF srcRect)
- {
- Warp (destPoints, srcRect, null, WarpMode.Perspective, 1.0f / 4.0f);
- }
- [MonoTODO]
- public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix)
- {
- Warp (destPoints, srcRect, matrix, WarpMode.Perspective, 1.0f / 4.0f);
- }
- [MonoTODO]
- public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode)
- {
- Warp (destPoints, srcRect, matrix, warpMode, 1.0f / 4.0f);
- }
- [MonoTODO]
- public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode, float flatness)
- {
- throw new NotImplementedException();
- }
- #endregion
-
- #region Widen
- public void Widen (Pen pen)
- {
- Widen (pen, null);
- }
-
- public void Widen (Pen pen, Matrix matrix)
- {
- Widen (pen, matrix, 2f/3f);
- }
-
- public void Widen (Pen pen, Matrix matrix, float flatness)
- {
- if (pen == null)
- throw new ArgumentNullException("pen");
- Shape = new ExtendedGeneralPath(((Stroke)pen).createStrokedShape(this));
- Flatten(matrix, flatness);
- }
- #endregion
- private void SetPath (Point [] pts, byte [] types)
- {
- NativeObject.Clear ();
- if (((PathPointType)types [0] & PathPointType.PathTypeMask) != PathPointType.Start)
- NativeObject.moveTo (pts [0].X, pts [0].Y);
- for (int i=0; i < pts.Length; i++) {
- switch (((PathPointType)types [i] & PathPointType.PathTypeMask)) {
- case PathPointType.Start :
- NativeObject.moveTo (pts [i].X, pts [i].Y);
- break;
- case PathPointType.Line :
- NativeObject.lineTo (pts [i].X, pts [i].Y);
- break;
- case PathPointType.Bezier3 :
- float x1 = pts [i].X;
- float y1 = pts [i].Y;
- i++;
- float x2 = pts [i].X;
- float y2 = pts [i].Y;
- i++;
- float x3 = pts [i].X;
- float y3 = pts [i].Y;
- NativeObject.curveTo (x1,y1, x2, y2, x3, y3);
- break;
- }
- if (((PathPointType)types [i] & PathPointType.CloseSubpath) != 0)
- NativeObject.closePath();
- if (((PathPointType)types [i] & PathPointType.PathMarker) != 0)
- NativeObject.SetMarkers ();
- }
- }
- internal void SetPath (PointF [] pts, byte [] types)
- {
- NativeObject.Clear ();
- if (((PathPointType)types [0] & PathPointType.PathTypeMask) != PathPointType.Start)
- NativeObject.moveTo (pts [0].X, pts [0].Y);
- for (int i=0; i < pts.Length; i++) {
- switch (((PathPointType)types [i] & PathPointType.PathTypeMask)) {
- case PathPointType.Start :
- NativeObject.moveTo (pts [i].X, pts [i].Y);
- break;
- case PathPointType.Line :
- NativeObject.lineTo (pts [i].X, pts [i].Y);
- break;
- case PathPointType.Bezier3 :
- float x1 = pts [i].X;
- float y1 = pts [i].Y;
- i++;
- float x2 = pts [i].X;
- float y2 = pts [i].Y;
- i++;
- float x3 = pts [i].X;
- float y3 = pts [i].Y;
- NativeObject.curveTo (x1,y1, x2, y2, x3, y3);
- break;
- }
- if (((PathPointType)types [i] & PathPointType.CloseSubpath) != 0)
- NativeObject.closePath();
- if (((PathPointType)types [i] & PathPointType.PathMarker) != 0)
- NativeObject.SetMarkers ();
- }
- }
- }
- }
|