[System.Net] Add support for .pac proxy config scripts on mac
[mono.git] / mcs / class / System.Drawing / System.Drawing.Drawing2D / GeneralPathIterator.jvm.cs
1 //
2 // System.Drawing.Drawing2D.GeneralPathIterator.cs
3 //
4 // Author:
5 // Bors Kirzner <boris@mainsoft.com>    
6 //
7 // Copyright (C) 2005 Mainsoft Corporation, (http://www.mainsoft.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 // 
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 // 
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 \r
29 using System;\r
30 \r
31 using java.awt.geom;\r
32 \r
33 namespace System.Drawing.Drawing2D\r
34 {\r
35         internal class GeneralPathIterator : PathIterator\r
36         {\r
37                 #region Fields\r
38 \r
39                 int typeIdx = 0;\r
40                 int pointIdx   = 0;\r
41                 ExtendedGeneralPath _path;\r
42                 AffineTransform _affine;\r
43 \r
44                 private static readonly int [] curvesize = {2, 2, 4, 6, 0};\r
45 \r
46                 #endregion // Fileds\r
47 \r
48                 #region Constructors\r
49 \r
50                 public GeneralPathIterator(ExtendedGeneralPath _path) : this (_path, null)\r
51                 {\r
52                 }\r
53 \r
54                 public GeneralPathIterator(ExtendedGeneralPath _path, AffineTransform at) \r
55                 {\r
56                         this._path = _path;\r
57                         this._affine = at;\r
58                 }\r
59 \r
60                 #endregion // Constructors\r
61 \r
62                 #region Methods\r
63 \r
64                 public int getWindingRule() \r
65                 {\r
66                         return _path.getWindingRule ();\r
67                 }\r
68 \r
69                 public bool isDone() \r
70                 {\r
71                         return (typeIdx >= _path.TypesCount);\r
72                 }\r
73 \r
74                 public void next() \r
75                 {\r
76                         int type = _path.Types [typeIdx++] & ExtendedGeneralPath.SEG_MASK;\r
77                         pointIdx += curvesize [type];\r
78                 }\r
79 \r
80                 public int currentSegment(float [] coords) {\r
81                         int type = _path.Types [typeIdx] & ExtendedGeneralPath.SEG_MASK;\r
82                         int numCoords = curvesize [type];\r
83                         if (numCoords > 0 && _affine != null)\r
84                                 _affine.transform (_path.Coords, pointIdx, coords, 0, numCoords/2);\r
85                         else\r
86                                 Array.Copy (_path.Coords, pointIdx, coords, 0, numCoords);\r
87                         return type;\r
88                 }\r
89 \r
90                 public int currentSegment(double [] coords) \r
91                 {\r
92                         int type = _path.Types [typeIdx] & ExtendedGeneralPath.SEG_MASK;\r
93                         int numCoords = curvesize [type];\r
94                         if (numCoords > 0 && _affine != null)\r
95                                 _affine.transform (_path.Coords, pointIdx, coords, 0, numCoords/2);\r
96                         else \r
97                                 for (int i=0; i < numCoords; i++)\r
98                                         coords [i] = _path.Coords [pointIdx + i];\r
99                 \r
100                         return type;\r
101                 }\r
102 \r
103                 #endregion // Methods\r
104         }  \r
105 }\r