GeneralPathIterator.jvm.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using java.awt.geom;
  3. namespace System.Drawing.Drawing2D
  4. {
  5. internal class GeneralPathIterator : PathIterator
  6. {
  7. #region Fields
  8. int typeIdx = 0;
  9. int pointIdx = 0;
  10. ExtendedGeneralPath _path;
  11. AffineTransform _affine;
  12. private static readonly int [] curvesize = {2, 2, 4, 6, 0};
  13. #endregion // Fileds
  14. #region Constructors
  15. public GeneralPathIterator(ExtendedGeneralPath _path) : this (_path, null)
  16. {
  17. }
  18. public GeneralPathIterator(ExtendedGeneralPath _path, AffineTransform at)
  19. {
  20. this._path = _path;
  21. this._affine = at;
  22. }
  23. #endregion // Constructors
  24. #region Methods
  25. public int getWindingRule()
  26. {
  27. return _path.getWindingRule ();
  28. }
  29. public bool isDone()
  30. {
  31. return (typeIdx >= _path.TypesCount);
  32. }
  33. public void next()
  34. {
  35. int type = _path.Types [typeIdx++] & ExtendedGeneralPath.SEG_MASK;
  36. pointIdx += curvesize [type];
  37. }
  38. public int currentSegment(float [] coords) {
  39. int type = _path.Types [typeIdx] & ExtendedGeneralPath.SEG_MASK;
  40. int numCoords = curvesize [type];
  41. if (numCoords > 0 && _affine != null)
  42. _affine.transform (_path.Coords, pointIdx, coords, 0, numCoords/2);
  43. else
  44. Array.Copy (_path.Coords, pointIdx, coords, 0, numCoords);
  45. return type;
  46. }
  47. public int currentSegment(double [] coords)
  48. {
  49. int type = _path.Types [typeIdx] & ExtendedGeneralPath.SEG_MASK;
  50. int numCoords = curvesize [type];
  51. if (numCoords > 0 && _affine != null)
  52. _affine.transform (_path.Coords, pointIdx, coords, 0, numCoords/2);
  53. else
  54. for (int i=0; i < numCoords; i++)
  55. coords [i] = _path.Coords [pointIdx + i];
  56. return type;
  57. }
  58. #endregion // Methods
  59. }
  60. }