GraphicsPath.jvm.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using java.awt.geom;
  5. using java.awt;
  6. namespace System.Drawing.Drawing2D
  7. {
  8. public sealed class GraphicsPath : BasicShape, ICloneable
  9. {
  10. internal enum JPI {
  11. SEG_MOVETO = 0,
  12. SEG_LINETO = 1,
  13. SEG_QUADTO = 2,
  14. SEG_CUBICTO = 3,
  15. SEG_CLOSE = 4
  16. }
  17. #region Vars
  18. bool _isNewFigure = true;
  19. #endregion
  20. #region Internal
  21. internal GeneralPath NativeObject
  22. {
  23. get
  24. {
  25. return (GeneralPath)Shape;
  26. }
  27. }
  28. GraphicsPath (GeneralPath ptr) : base(ptr)
  29. {
  30. }
  31. #endregion
  32. #region C-tors.
  33. public GraphicsPath ():
  34. this(FillMode.Alternate)
  35. {
  36. }
  37. public GraphicsPath (FillMode fillMode) : this(new GeneralPath())
  38. {
  39. FillMode = fillMode;
  40. }
  41. public GraphicsPath (Point[] pts, byte[] types) : this(null)
  42. {
  43. throw new NotImplementedException();
  44. }
  45. public GraphicsPath (PointF[] pts, byte[] types) : this(null)
  46. {
  47. throw new NotImplementedException();
  48. }
  49. public GraphicsPath (Point[] pts, byte[] types, FillMode fillMode) : this(null)
  50. {
  51. throw new NotImplementedException();
  52. }
  53. public GraphicsPath (PointF[] pts, byte[] types, FillMode fillMode) : this(null)
  54. {
  55. throw new NotImplementedException();
  56. }
  57. GraphicsPath (GeneralPath path, bool isNewFigure) : this(path)
  58. {
  59. _isNewFigure = isNewFigure;
  60. }
  61. #endregion
  62. #region Clone
  63. public object Clone ()
  64. {
  65. return new GraphicsPath ((GeneralPath)NativeObject.clone(), _isNewFigure);
  66. }
  67. #endregion
  68. #region Properties
  69. public FillMode FillMode
  70. {
  71. get
  72. { if(NativeObject.getWindingRule() == GeneralPath.WIND_NON_ZERO)
  73. return FillMode.Alternate;
  74. else
  75. return FillMode.Winding;
  76. }
  77. set
  78. {
  79. if(value == FillMode.Alternate)
  80. NativeObject.setWindingRule(GeneralPath.WIND_NON_ZERO);
  81. else
  82. NativeObject.setWindingRule(GeneralPath.WIND_EVEN_ODD);
  83. }
  84. }
  85. public PathData PathData
  86. {
  87. get
  88. {
  89. throw new NotImplementedException();
  90. }
  91. }
  92. public PointF [] PathPoints
  93. {
  94. get
  95. {
  96. return PathData.Points;
  97. }
  98. }
  99. public byte [] PathTypes
  100. {
  101. get
  102. {
  103. return PathData.Types;
  104. }
  105. }
  106. #endregion
  107. #region PointCount [TODO]
  108. public int PointCount
  109. {
  110. get
  111. {
  112. //TODO
  113. throw new NotImplementedException();
  114. }
  115. }
  116. #endregion
  117. #region AddArc
  118. public void AddArc (Rectangle rect, float startAngle, float sweepAngle)
  119. {
  120. AddArc(rect.X,rect.Y,rect.Width,rect.Height,startAngle,sweepAngle);
  121. }
  122. public void AddArc (RectangleF rect, float startAngle, float sweepAngle)
  123. {
  124. AddArc(rect.X,rect.Y,rect.Width,rect.Height,startAngle,sweepAngle);
  125. }
  126. public void AddArc (int x, int y, int width, int height, float startAngle, float sweepAngle)
  127. {
  128. AddArc((float)x,(float)y,(float)width,(float)height,startAngle,sweepAngle);
  129. }
  130. public void AddArc (float x, float y, float width, float height, float startAngle, float sweepAngle)
  131. {
  132. Shape shape = null;
  133. if (sweepAngle >= 360)
  134. shape = new Ellipse2D.Float(x, y, width, height);
  135. else {
  136. double d1Tod2 = width/height;
  137. double sqrd1Tod2 = d1Tod2*d1Tod2;
  138. double start = ConvertArcAngle(sqrd1Tod2, startAngle);
  139. double extent = ConvertArcAngle(sqrd1Tod2, startAngle+sweepAngle) - start;
  140. shape = new Arc2D.Double(x,y,width,height,-start,-extent,Arc2D.OPEN);
  141. }
  142. NativeObject.append(shape,!_isNewFigure);
  143. _isNewFigure = false;
  144. }
  145. /// <summary>
  146. /// .Net computes an angle by intersection of ellipse with a ray
  147. /// java does the following: x1 = d1*cos(a), y1 = d2*sin(a)
  148. /// where: d1 = width/2, d2 = height/2
  149. /// we need to find angle x, which satisfies:
  150. /// x1 = m*cos(a) = d1*cos(x)
  151. /// y1 = m*sin(a) = d2*sin(x)
  152. /// (x1*x1)/(d1*d1) + (x2*x2)/(d2*d2) = 1
  153. /// </summary>
  154. /// <param name="sqrd1Tod2">(d1/d2)*(d1/d2)</param>
  155. /// <param name="angle">angle in degrees</param>
  156. /// <returns>converted angle in degrees</returns>
  157. static double ConvertArcAngle(double sqrd1Tod2, double angle) {
  158. double angleRad = java.lang.Math.toRadians(angle);
  159. double tan = Math.Tan(angleRad);
  160. double cosx = 1/Math.Sqrt( sqrd1Tod2 * (tan*tan) + 1);
  161. double xRad = Math.Acos(cosx);
  162. double x = java.lang.Math.toDegrees(xRad);
  163. int q = ((int)angle)/90;
  164. switch (q&3) {
  165. default:
  166. return x;
  167. case 1:
  168. return 180-x;
  169. case 2:
  170. return 180+x;
  171. case 3:
  172. return 360-x;
  173. }
  174. }
  175. #endregion
  176. #region AddBezier(s)
  177. public void AddBezier (Point pt1, Point pt2, Point pt3, Point pt4)
  178. {
  179. AddBezier(pt1.X,pt1.Y,pt2.X,pt2.Y,pt3.X,pt3.Y,pt4.X,pt4.Y);
  180. }
  181. public void AddBezier (PointF pt1, PointF pt2, PointF pt3, PointF pt4)
  182. {
  183. AddBezier(pt1.X,pt1.Y,pt2.X,pt2.Y,pt3.X,pt3.Y,pt4.X,pt4.Y);
  184. }
  185. public void AddBezier (int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
  186. {
  187. AddBezier((float)x1,(float)y1,(float)x2,(float)y2,(float)x3,(float)y3,(float)x4,(float)y4);
  188. }
  189. public void AddBezier (float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
  190. {
  191. CubicCurve2D cc = new CubicCurve2D.Float(x1,y1,x2,y2,x3,y3,x4,y4);
  192. NativeObject.append(cc,!_isNewFigure);
  193. _isNewFigure = false;
  194. }
  195. public void AddBeziers (Point [] pts)
  196. {
  197. if (pts == null)
  198. throw new ArgumentNullException("points");
  199. AddBezier(pts [0].X,pts [0].Y,
  200. pts [1].X,pts [1].Y,
  201. pts [2].X,pts [2].Y,
  202. pts [3].X,pts [3].Y);
  203. for (int i = 4; i < pts.Length; i += 3) {
  204. NativeObject.curveTo(
  205. pts [i].X,pts [i].Y,
  206. pts [i+1].X,pts [i+1].Y,
  207. pts [i+2].X,pts [i+2].Y);
  208. }
  209. }
  210. public void AddBeziers (PointF [] pts)
  211. {
  212. if (pts == null)
  213. throw new ArgumentNullException("points");
  214. AddBezier(pts [0].X,pts [0].Y,
  215. pts [1].X,pts [1].Y,
  216. pts [2].X,pts [2].Y,
  217. pts [3].X,pts [3].Y);
  218. for (int i = 4; i < pts.Length; i += 3) {
  219. NativeObject.curveTo(
  220. pts [i].X,pts [i].Y,
  221. pts [i+1].X,pts [i+1].Y,
  222. pts [i+2].X,pts [i+2].Y);
  223. }
  224. }
  225. #endregion
  226. #region AdEllipse
  227. public void AddEllipse (float x, float y, float width, float height)
  228. {
  229. Ellipse2D e = new Ellipse2D.Float(x,y,width,height);
  230. NativeObject.append(e,false);
  231. _isNewFigure = true;
  232. }
  233. public void AddEllipse (RectangleF r)
  234. {
  235. AddEllipse(r.X,r.Y,r.Width,r.Height);
  236. }
  237. public void AddEllipse (Rectangle r)
  238. {
  239. AddEllipse(r.X,r.Y,r.Width,r.Height);
  240. }
  241. public void AddEllipse (int x, int y, int width, int height)
  242. {
  243. AddEllipse((float)x, (float)y, (float)width, (float)height);
  244. }
  245. #endregion
  246. #region AddLine
  247. public void AddLine (float x1, float y1, float x2, float y2)
  248. {
  249. Line2D l = new Line2D.Float(x1,y1,x2,y2);
  250. NativeObject.append(l,!_isNewFigure);
  251. _isNewFigure = false;
  252. }
  253. public void AddLine (Point a, Point b)
  254. {
  255. AddLine(a.X,a.Y,b.X,b.Y);
  256. }
  257. public void AddLine (PointF a, PointF b)
  258. {
  259. AddLine(a.X,a.Y,b.X,b.Y);
  260. }
  261. public void AddLine (int x1, int y1, int x2, int y2)
  262. {
  263. AddLine((float)x1,(float)y1,(float)x2,(float)y2);
  264. }
  265. public void AddLines (Point [] points)
  266. {
  267. if (points == null)
  268. throw new ArgumentNullException("points");
  269. if (points.Length == 0)
  270. return;
  271. if (_isNewFigure)
  272. NativeObject.moveTo(points[0].X, points[0].Y);
  273. else
  274. NativeObject.lineTo(points[0].X, points[0].Y);
  275. _isNewFigure = false;
  276. for (int i = 1; i < points.Length; i ++)
  277. NativeObject.lineTo(points[i].X, points[i].Y);
  278. }
  279. public void AddLines (PointF [] points)
  280. {
  281. if (points == null)
  282. throw new ArgumentNullException("points");
  283. if (points.Length == 0)
  284. return;
  285. if (_isNewFigure)
  286. NativeObject.moveTo(points[0].X, points[0].Y);
  287. else
  288. NativeObject.lineTo(points[0].X, points[0].Y);
  289. _isNewFigure = false;
  290. for (int i = 1; i < points.Length; i ++)
  291. NativeObject.lineTo(points[i].X, points[i].Y);
  292. }
  293. #endregion
  294. #region AddPie
  295. public void AddPie (float x, float y, float width, float height, float startAngle, float sweepAngle)
  296. {
  297. Shape shape = null;
  298. if (sweepAngle >= 360)
  299. shape = new Ellipse2D.Float(x, y, width, height);
  300. else {
  301. double d1Tod2 = width/height;
  302. double sqrd1Tod2 = d1Tod2*d1Tod2;
  303. double start = ConvertArcAngle(sqrd1Tod2, startAngle);
  304. double extent = ConvertArcAngle(sqrd1Tod2, startAngle+sweepAngle) - start;
  305. shape = new Arc2D.Double(x,y,width,height,-start,-extent,Arc2D.PIE);
  306. }
  307. NativeObject.append(shape,false);
  308. _isNewFigure = true;
  309. }
  310. public void AddPie (Rectangle rect, float startAngle, float sweepAngle)
  311. {
  312. AddPie((float)rect.X, (float)rect.Y,(float)rect.Width,(float)rect.Height,startAngle,sweepAngle);
  313. }
  314. public void AddPie (int x, int y, int width, int height, float startAngle, float sweepAngle)
  315. {
  316. AddPie((float)x,(float)y,(float)width,(float)height,startAngle,sweepAngle);
  317. }
  318. #endregion
  319. #region AddPolygon
  320. public void AddPolygon (Point [] points)
  321. {
  322. if (points == null)
  323. throw new ArgumentNullException("points");
  324. if (points.Length < 3)
  325. throw new ArgumentException("Invalid parameter used.");
  326. NativeObject.moveTo((float)points[0].X,(float)points[0].Y);
  327. for (int i = 1; i< points.Length; i++)
  328. {
  329. NativeObject.lineTo((float)points[i].X,(float)points[i].Y);
  330. }
  331. NativeObject.closePath();
  332. _isNewFigure = true;
  333. }
  334. public void AddPolygon (PointF [] points)
  335. {
  336. if (points == null)
  337. throw new ArgumentNullException("points");
  338. if (points.Length < 3)
  339. throw new ArgumentException("Invalid parameter used.");
  340. NativeObject.moveTo(points[0].X,points[0].Y);
  341. for (int i = 1; i < points.Length; i++)
  342. {
  343. NativeObject.lineTo(points[i].X,points[i].Y);
  344. }
  345. NativeObject.closePath();
  346. _isNewFigure = true;
  347. }
  348. #endregion
  349. #region AddRectangle(s)
  350. internal void AddRectangle(float x,float y, float w, float h)
  351. {
  352. Rectangle2D r = new Rectangle2D.Float(x,y,w,h);
  353. NativeObject.append(r,false);
  354. _isNewFigure = true;
  355. }
  356. public void AddRectangle (RectangleF rect)
  357. {
  358. AddRectangle(rect.X,rect.Y,rect.Width,rect.Height);
  359. }
  360. public void AddRectangle (Rectangle rect)
  361. {
  362. AddRectangle(rect.X,rect.Y,rect.Width,rect.Height);
  363. }
  364. public void AddRectangles (Rectangle [] rects)
  365. {
  366. foreach(Rectangle rect in rects)
  367. AddRectangle(rect.X,rect.Y,rect.Width,rect.Height);
  368. }
  369. public void AddRectangles (RectangleF [] rects)
  370. {
  371. foreach(RectangleF rect in rects)
  372. AddRectangle(rect.X,rect.Y,rect.Width,rect.Height);
  373. }
  374. #endregion
  375. #region AddPath
  376. public void AddPath (GraphicsPath addingPath, bool connect)
  377. {
  378. NativeObject.append(addingPath.NativeObject,connect);
  379. _isNewFigure = false;
  380. }
  381. #endregion
  382. #region GetLastPoint
  383. public PointF GetLastPoint ()
  384. {
  385. java.awt.geom.Point2D p2d = NativeObject.getCurrentPoint();
  386. return new PointF((float)p2d.getX(),(float)p2d.getY());
  387. }
  388. #endregion
  389. #region Reset
  390. public void Reset ()
  391. {
  392. NativeObject.reset();
  393. _isNewFigure = true;
  394. }
  395. #endregion
  396. #region GetBounds
  397. public RectangleF GetBounds ()
  398. {
  399. Rectangle2D rect = NativeObject.getBounds2D();
  400. return new RectangleF((float)rect.getX(),(float)rect.getY(),(float)rect.getWidth(),(float)rect.getHeight());
  401. }
  402. public RectangleF GetBounds (Matrix matrix)
  403. {
  404. Shape shape = matrix != null ?
  405. NativeObject.createTransformedShape(matrix.NativeObject) : NativeObject;
  406. Rectangle2D rect = shape.getBounds2D();
  407. return new RectangleF((float)rect.getX(),(float)rect.getY(),(float)rect.getWidth(),(float)rect.getHeight());
  408. }
  409. public RectangleF GetBounds (Matrix matrix, Pen pen)
  410. {
  411. throw new NotImplementedException();
  412. }
  413. #endregion
  414. #region Transform
  415. public void Transform (Matrix matrix)
  416. {
  417. if(matrix == null)
  418. return;
  419. NativeObject.transform(matrix.NativeObject);
  420. }
  421. #endregion
  422. #region IsVisible
  423. public bool IsVisible (Point point)
  424. {
  425. return IsVisible (point.X, point.Y, null);
  426. }
  427. public bool IsVisible (PointF point)
  428. {
  429. return IsVisible (point.X, point.Y, null);
  430. }
  431. public bool IsVisible (int x, int y)
  432. {
  433. return IsVisible (x, y, null);
  434. }
  435. public bool IsVisible (float x, float y)
  436. {
  437. return IsVisible (x, y, null);
  438. }
  439. public bool IsVisible (Point pt, Graphics graphics)
  440. {
  441. return IsVisible (pt.X, pt.Y, graphics);
  442. }
  443. public bool IsVisible (PointF pt, Graphics graphics)
  444. {
  445. return IsVisible (pt.X, pt.Y, graphics);
  446. }
  447. public bool IsVisible (int x, int y, Graphics graphics)
  448. {
  449. return IsVisible((float)x,(float)y,null);
  450. }
  451. public bool IsVisible (float x, float y, Graphics graphics)
  452. {
  453. if (graphics != null && !graphics.IsVisible(x,y))
  454. return false;
  455. return NativeObject.contains(x,y);
  456. }
  457. #endregion
  458. #region Reverse [TODO]
  459. public void Reverse ()
  460. {
  461. throw new NotImplementedException();
  462. }
  463. #endregion
  464. #region AddClosedCurve [TODO]
  465. //this could be simply implemented using the same
  466. //mechnizm as AddCurve. Simply use the last point for
  467. //first point tangent calculation
  468. public void AddClosedCurve (Point [] points)
  469. {
  470. throw new NotImplementedException ();
  471. }
  472. public void AddClosedCurve (PointF [] points)
  473. {
  474. throw new NotImplementedException ();
  475. }
  476. public void AddClosedCurve (Point [] points, float tension)
  477. {
  478. throw new NotImplementedException ();
  479. }
  480. public void AddClosedCurve (PointF [] points, float tension)
  481. {
  482. throw new NotImplementedException ();
  483. }
  484. #endregion
  485. #region AddCurve
  486. //we have now two approaches for drawing cardinal curves
  487. //the first one is to convert cardinals into approximate beziers
  488. //the second one - to draw curve ourself with all interpolation staff
  489. //here. I preffer the first one because we could utilize java antialiasing and
  490. //flattening features, otherwise curves will be more strict but less cool
  491. public void AddCurve (Point [] points)
  492. {
  493. AddCurve(points,0.5F);
  494. }
  495. public void AddCurve (PointF [] points)
  496. {
  497. AddCurve(points,0.5f);
  498. }
  499. public void AddCurve (Point [] points, float tension)
  500. {
  501. AddCurve(points, 0, points.Length-1, tension);
  502. }
  503. public void AddCurve (PointF [] points, float tension)
  504. {
  505. AddCurve(points, 0, points.Length-1, tension);
  506. }
  507. public void AddCurve (Point [] points, int offset, int numberOfSegments, float tension)
  508. {
  509. int nPoints = numberOfSegments + 1;
  510. int length = nPoints*2 + 4;
  511. float[] pts = new float[length];
  512. int lastP = offset + nPoints;
  513. if (lastP == points.Length) {
  514. lastP--;
  515. pts[--length] = points[lastP].Y;
  516. pts[--length] = points[lastP].X;
  517. }
  518. for (; length > 0 && lastP >= 0; lastP--) {
  519. pts[--length] = points[lastP].Y;
  520. pts[--length] = points[lastP].X;
  521. }
  522. if (length > 0) {
  523. pts[1] = points[0].Y;
  524. pts[0] = points[0].X;
  525. }
  526. AddCurve(pts, !_isNewFigure, tension);
  527. _isNewFigure = false;
  528. }
  529. public void AddCurve (PointF [] points, int offset, int numberOfSegments, float tension)
  530. {
  531. int nPoints = numberOfSegments + 1;
  532. int length = nPoints*2 + 4;
  533. float[] pts = new float[length];
  534. int lastP = offset + nPoints;
  535. if (lastP == points.Length) {
  536. lastP--;
  537. pts[--length] = points[lastP].Y;
  538. pts[--length] = points[lastP].X;
  539. }
  540. for (; length > 0 && lastP >= 0; lastP--) {
  541. pts[--length] = points[lastP].Y;
  542. pts[--length] = points[lastP].X;
  543. }
  544. if (length > 0) {
  545. pts[1] = points[0].Y;
  546. pts[0] = points[0].X;
  547. }
  548. AddCurve(pts, !_isNewFigure, tension);
  549. _isNewFigure = false;
  550. }
  551. /// <summary>
  552. /// Based on http://pubpages.unh.edu/~cs770/a5/cardinal.html
  553. /// </summary>
  554. /// <param name="pts">point array (x1,y1,x2,y2 ...).
  555. /// The first and last points considered only for calculations, but are not added.</param>
  556. void AddCurve(float[] pts, bool connect, float tension) {
  557. tension /= 3f; //looks like a good pick
  558. if (connect)
  559. NativeObject.lineTo(pts[2],pts[3]);
  560. else
  561. NativeObject.moveTo(pts[2],pts[3]);
  562. float dx = pts[4] - pts[0];
  563. float dy = pts[5] - pts[1];
  564. float sx = pts[2] + tension*dx;
  565. float sy = pts[3] + tension*dy;
  566. for (int offset = 2, total = pts.Length-4; offset < total; offset += 2) {
  567. int cur_offset = offset;
  568. int pX = cur_offset++;
  569. int pY = cur_offset++;
  570. int X = cur_offset++;
  571. int Y = cur_offset++;
  572. int nX = cur_offset++;
  573. int nY = cur_offset++;
  574. dx = pts[nX] - pts[pX];
  575. dy = pts[nY] - pts[pY];
  576. float rx = pts[X] - tension*dx;
  577. float ry = pts[Y] - tension*dy;
  578. NativeObject.curveTo(sx, sy, rx, ry, pts[X], pts[Y]);
  579. sx = pts[X] + tension*dx;
  580. sy = pts[Y] + tension*dy;
  581. }
  582. }
  583. #endregion
  584. #region AddString [TODO]
  585. public void AddString (string s, FontFamily family, int style, float emSize, Point origin, StringFormat format)
  586. {
  587. throw new NotImplementedException ();
  588. }
  589. public void AddString (string s, FontFamily family, int style, float emSize, PointF origin, StringFormat format)
  590. {
  591. throw new NotImplementedException ();
  592. }
  593. public void AddString (string s, FontFamily family, int style, float emSize, Rectangle layoutRect, StringFormat format)
  594. {
  595. throw new NotImplementedException ();
  596. }
  597. public void AddString (string s, FontFamily family, int style, float emSize, RectangleF layoutRect, StringFormat format)
  598. {
  599. throw new NotImplementedException ();
  600. }
  601. #endregion
  602. #region ClearMarkers [TODO]
  603. public void ClearMarkers()
  604. {
  605. throw new NotImplementedException ();
  606. }
  607. #endregion
  608. #region Close(All) [REVIEW-EXTEND]
  609. public void CloseAllFigures()
  610. {
  611. GeneralPath p = new GeneralPath();
  612. PathIterator pi = NativeObject.getPathIterator(null);
  613. JPI lastSeg = JPI.SEG_CLOSE;
  614. float [] points = new float[6];
  615. p.setWindingRule(pi.getWindingRule());
  616. while(!pi.isDone())
  617. {
  618. JPI curSeg = (JPI)pi.currentSegment(points);
  619. switch(curSeg)
  620. {
  621. case JPI.SEG_CLOSE:
  622. p.closePath();
  623. break;
  624. case JPI.SEG_MOVETO:
  625. if(lastSeg != JPI.SEG_CLOSE)
  626. p.closePath();
  627. p.moveTo(points[0],points[1]);
  628. break;
  629. case JPI.SEG_LINETO:
  630. p.lineTo(points[0],points[1]);
  631. break;
  632. case JPI.SEG_QUADTO:
  633. p.quadTo(points[0],points[1],points[2],points[3]);
  634. break;
  635. case JPI.SEG_CUBICTO:
  636. p.curveTo(points[0],points[1],points[2],points[3],points[4],points[5]);
  637. break;
  638. default:
  639. break;
  640. }
  641. lastSeg = curSeg;
  642. pi.next();
  643. }
  644. Shape = p;
  645. //_isNewFigure = (lastSeg == PathIterator.SEG_CLOSE);
  646. }
  647. public void CloseFigure()
  648. {
  649. NativeObject.closePath();
  650. }
  651. #endregion
  652. #region Flatten [REVIEW]
  653. public void Flatten ()
  654. {
  655. // 1/4 is the FlatnessDefault as defined in GdiPlusEnums.h
  656. Flatten (null, 1.0f / 4.0f);
  657. }
  658. public void Flatten (Matrix matrix)
  659. {
  660. Flatten (matrix, 1.0f / 4.0f);
  661. }
  662. public void Flatten (Matrix matrix, float flatness)
  663. {
  664. AffineTransform tr = null;
  665. if(matrix != null)
  666. tr = matrix.NativeObject;
  667. //REVIEW. Perfomance reasons.
  668. PathIterator pi = NativeObject.getPathIterator(tr,flatness);
  669. GeneralPath newPath = new GeneralPath();
  670. newPath.append(pi,false);
  671. Shape = newPath;
  672. }
  673. #endregion
  674. #region GetOutlineVisible [TODO]
  675. public bool IsOutlineVisible (Point point, Pen pen)
  676. {
  677. throw new NotImplementedException();
  678. }
  679. public bool IsOutlineVisible (PointF point, Pen pen)
  680. {
  681. throw new NotImplementedException();
  682. }
  683. public bool IsOutlineVisible (int x, int y, Pen pen)
  684. {
  685. throw new NotImplementedException();
  686. }
  687. public bool IsOutlineVisible (float x, float y, Pen pen)
  688. {
  689. throw new NotImplementedException();
  690. }
  691. public bool IsOutlineVisible (Point pt, Pen pen, Graphics graphics)
  692. {
  693. throw new NotImplementedException();
  694. }
  695. public bool IsOutlineVisible (PointF pt, Pen pen, Graphics graphics)
  696. {
  697. throw new NotImplementedException();
  698. }
  699. public bool IsOutlineVisible (int x, int y, Pen pen, Graphics graphics)
  700. {
  701. throw new NotImplementedException();
  702. }
  703. public bool IsOutlineVisible (float x, float y, Pen pen, Graphics graphics)
  704. {
  705. throw new NotImplementedException();
  706. }
  707. #endregion
  708. #region SetMarkers [TODO]
  709. public void SetMarkers ()
  710. {
  711. throw new NotImplementedException();
  712. }
  713. #endregion
  714. #region StartFigure
  715. public void StartFigure()
  716. {
  717. _isNewFigure = true;
  718. }
  719. #endregion
  720. #region Warp [TODO]
  721. public void Warp (PointF[] destPoints, RectangleF srcRect)
  722. {
  723. Warp (destPoints, srcRect, null, WarpMode.Perspective, 1.0f / 4.0f);
  724. }
  725. public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix)
  726. {
  727. Warp (destPoints, srcRect, matrix, WarpMode.Perspective, 1.0f / 4.0f);
  728. }
  729. public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode)
  730. {
  731. Warp (destPoints, srcRect, matrix, warpMode, 1.0f / 4.0f);
  732. }
  733. public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode, float flatness)
  734. {
  735. throw new NotImplementedException();
  736. }
  737. #endregion
  738. #region Widen [TODO]
  739. public void Widen (Pen pen)
  740. {
  741. Widen (pen, null, 1.0f / 4.0f);
  742. }
  743. public void Widen (Pen pen, Matrix matrix)
  744. {
  745. Widen (pen, matrix, 1.0f / 4.0f);
  746. }
  747. public void Widen (Pen pen, Matrix matrix, float flatness)
  748. {
  749. throw new NotImplementedException();
  750. }
  751. #endregion
  752. }
  753. }