fix typo
[mcs.git] / class / System.Drawing / System.Drawing / Region.jvm.cs
blob18e1e37829da238cc3b3576b635ffb72cc603c8d
2 using System;
3 using System.Drawing.Drawing2D;
4 using System.Runtime.InteropServices;
6 using awt = java.awt;
7 using geom = java.awt.geom;
9 namespace System.Drawing
11 [ComVisible (false)]
12 public sealed class Region : BasicShape
14 #region Member Vars
15 internal static readonly Region InfiniteRegion = new Region(new Rectangle(-0x400000, -0x400000, 0x800000, 0x800000));
16 #endregion
18 #region Internals
19 internal geom.Area NativeObject
21 get
23 return (geom.Area)Shape;
26 #endregion
28 #region Ctors. and Dtor
31 public Region ()
32 : this ((geom.Area) InfiniteRegion.NativeObject.clone ())
36 internal Region(geom.Area native) : base(native)
41 public Region (GraphicsPath path) : this(new geom.Area(path.NativeObject))
45 public Region (Rectangle rect) : this(new geom.Area(rect.NativeObject))
49 public Region (RectangleF rect) : this(new geom.Area(rect.NativeObject))
53 [MonoTODO]
54 public Region (RegionData region_data) : this((geom.Area)null)
56 throw new NotImplementedException ();
58 #endregion
60 #region Union
61 public void Union (GraphicsPath path)
63 if (path == null)
64 throw new ArgumentNullException("path");
65 NativeObject.add(new geom.Area(path.NativeObject));
69 public void Union (Rectangle rect)
71 NativeObject.add(new geom.Area(rect.NativeObject));
74 public void Union (RectangleF rect)
76 NativeObject.add(new geom.Area(rect.NativeObject));
79 public void Union (Region region)
81 if (region == null)
82 throw new ArgumentNullException("region");
83 NativeObject.add(region.NativeObject);
85 #endregion
87 #region Intersect
89 public void Intersect (GraphicsPath path)
91 if (path == null)
92 throw new ArgumentNullException("path");
93 NativeObject.intersect(new geom.Area(path.NativeObject));
96 public void Intersect (Rectangle rect)
98 NativeObject.intersect(new geom.Area(rect.NativeObject));
101 public void Intersect (RectangleF rect)
103 NativeObject.intersect(new geom.Area(rect.NativeObject));
106 public void Intersect (Region region)
108 if (region == null)
109 throw new ArgumentNullException("region");
110 NativeObject.intersect(region.NativeObject);
112 #endregion
114 #region Complement
116 public void Complement (GraphicsPath path)
118 if (path == null)
119 throw new ArgumentNullException("path");
120 geom.Area a = new geom.Area(path.NativeObject);
121 a.subtract(NativeObject);
122 Shape = a;
125 public void Complement (Rectangle rect)
127 geom.Area a = new geom.Area(rect.NativeObject);
128 a.subtract(NativeObject);
129 Shape = a;
132 public void Complement (RectangleF rect)
134 geom.Area a = new geom.Area(rect.NativeObject);
135 a.subtract(NativeObject);
136 Shape = a;
139 public void Complement (Region region)
141 if (region == null)
142 throw new ArgumentNullException("region");
143 geom.Area a = (geom.Area) region.NativeObject.clone ();
144 a.subtract(NativeObject);
145 Shape = a;
147 #endregion
149 #region Exclude
151 public void Exclude (GraphicsPath path)
153 if (path == null)
154 throw new ArgumentNullException("path");
155 NativeObject.subtract(new geom.Area(path.NativeObject));
158 public void Exclude (Rectangle rect)
160 NativeObject.subtract(new geom.Area(rect.NativeObject));
163 public void Exclude (RectangleF rect)
165 NativeObject.subtract(new geom.Area(rect.NativeObject));
168 public void Exclude (Region region)
170 if (region == null)
171 throw new ArgumentNullException("region");
172 NativeObject.subtract(region.NativeObject);
174 #endregion
176 #region Xor
178 public void Xor (GraphicsPath path)
180 if (path == null)
181 throw new ArgumentNullException("path");
182 NativeObject.exclusiveOr(new geom.Area(path.NativeObject));
185 public void Xor (Rectangle rect)
187 NativeObject.exclusiveOr(new geom.Area(rect.NativeObject));
190 public void Xor (RectangleF rect)
192 NativeObject.exclusiveOr(new geom.Area(rect.NativeObject));
195 public void Xor (Region region)
197 if (region == null)
198 throw new ArgumentNullException("region");
199 NativeObject.exclusiveOr(region.NativeObject);
201 #endregion
203 #region GetBounds
205 public RectangleF GetBounds (Graphics graphics)
207 if (graphics == null)
208 throw new ArgumentNullException("graphics");
209 return new RectangleF(NativeObject.getBounds2D());
211 #endregion
213 #region Translate
215 public void Translate (int dx, int dy)
217 Translate((float)dx, (float)dy);
220 public void Translate (float dx, float dy)
222 if (NativeObject.equals(InfiniteRegion.NativeObject))
223 return;
224 NativeObject.transform(geom.AffineTransform.getTranslateInstance(
226 dy));
228 #endregion
230 #region IsVisible [TODO]
232 public bool IsVisible (int x, int y, Graphics g)
234 return IsVisible((float)x, (float)y, g);
237 public bool IsVisible (int x, int y, int width, int height)
239 return IsVisible((float)x, (float)y, (float)width, (float)height);
242 public bool IsVisible (int x, int y, int width, int height, Graphics g)
244 return IsVisible((float)x, (float)y, (float)width, (float)height, g);
247 public bool IsVisible (Point point)
249 return IsVisible(point.X, point.Y);
252 public bool IsVisible (PointF point)
254 return IsVisible(point.X, point.Y);
257 public bool IsVisible (Point point, Graphics g)
259 return IsVisible(point.X, point.Y, g);
262 public bool IsVisible (PointF point, Graphics g)
264 return IsVisible(point.X, point.Y, g);
267 public bool IsVisible (Rectangle rect)
269 return IsVisible(rect.X, rect.Y, rect.Width, rect.Height);
272 public bool IsVisible (RectangleF rect)
274 return IsVisible(rect.X, rect.Y, rect.Width, rect.Height);
277 public bool IsVisible (Rectangle rect, Graphics g)
279 return IsVisible(rect.X, rect.Y, rect.Width, rect.Height, g);
282 public bool IsVisible (RectangleF rect, Graphics g)
284 return IsVisible(rect.X, rect.Y, rect.Width, rect.Height, g);
287 public bool IsVisible (float x, float y)
289 return NativeObject.contains(x,y);
292 public bool IsVisible (float x, float y, Graphics g)
294 if (g == null)
295 throw new ArgumentNullException("graphics");
296 return NativeObject.contains(x,y);
299 public bool IsVisible (float x, float y, float width, float height)
301 return NativeObject.intersects(x,y,width,height);
304 public bool IsVisible (float x, float y, float width, float height, Graphics g)
306 if (g == null)
307 throw new ArgumentNullException("graphics");
308 return NativeObject.intersects(x,y,width,height);
310 #endregion
312 #region IsEmpty
313 public bool IsEmpty(Graphics g)
315 if (g == null)
316 throw new ArgumentNullException("graphics");
317 return NativeObject.isEmpty();
319 #endregion
321 #region IsInfinite
322 public bool IsInfinite(Graphics g)
324 if (g == null)
325 throw new ArgumentNullException("graphics");
326 //probably too naive.
327 return NativeObject.equals(InfiniteRegion.NativeObject);
329 #endregion
331 #region MakeEmpty
332 public void MakeEmpty()
334 NativeObject.reset();
336 #endregion
338 #region MakeInfinite
339 public void MakeInfinite()
341 Shape = (geom.Area) InfiniteRegion.NativeObject.clone ();
343 #endregion
345 #region Equals
346 public bool Equals(Region region, Graphics g)
348 if (g == null)
349 throw new ArgumentNullException("graphics");
350 return NativeObject.equals(region.NativeObject);
352 #endregion
354 [MonoTODO]
355 public RegionData GetRegionData()
357 throw new NotImplementedException();
360 [MonoTODO]
361 public IntPtr GetHrgn(Graphics g) {
362 throw new NotImplementedException();
366 public RectangleF[] GetRegionScans(Matrix matrix)
368 throw new NotImplementedException();
371 #region Transform
372 public void Transform(Matrix matrix)
374 if (matrix == null)
375 throw new ArgumentNullException("matrix");
376 if (NativeObject.equals(InfiniteRegion.NativeObject))
377 return;
378 NativeObject.transform(matrix.NativeObject);
380 #endregion
382 #region Clone
383 public Region Clone()
385 return new Region ((geom.Area) NativeObject.clone ());
387 #endregion