text transform, headless session
[mono.git] / mcs / class / System.Drawing / System.Drawing / RectangleF.cs
index dd1505fbc09f83ce0d561ee627973df34fa91904..3d34b67efdc7060f886c10fd535e1c87fa0966d3 100644 (file)
@@ -51,6 +51,13 @@ namespace System.Drawing
                
                public static readonly RectangleF Empty;
 
+#if TARGET_JVM
+               internal java.awt.geom.Rectangle2D NativeObject {
+                       get {
+                               return new java.awt.geom.Rectangle2D.Float(X,Y,Width,Height);
+                       }
+               }
+#endif
 
                /// <summary>
                ///     FromLTRB Shared Method
@@ -94,10 +101,7 @@ namespace System.Drawing
                
                public void Inflate (float width, float height)
                {
-                        x -= width;
-                        y -= height;
-                        width += width * 2;
-                        height += height * 2;                        
+                       Inflate (new SizeF (width, height));
                }
 
                /// <summary>
@@ -110,7 +114,10 @@ namespace System.Drawing
                
                public void Inflate (SizeF sz)
                {
-                       Inflate (sz.Width, sz.Height);
+                        x -= sz.Width;
+                        y -= sz.Height;
+                        width += sz.Width * 2;
+                        height += sz.Height * 2;                        
                }
 
                /// <summary>
@@ -125,9 +132,14 @@ namespace System.Drawing
                public static RectangleF Intersect (RectangleF r1, 
                                                    RectangleF r2)
                {
-                       RectangleF r = new RectangleF (r1.X, r1.Y, r1.Width, r1.Height);
-                       r.Intersect (r2);
-                       return r;
+                       if (!r1.IntersectsWith (r2)) 
+                               return Empty;
+
+                       return FromLTRB (
+                               Math.Max (r1.Left, r2.Left),
+                               Math.Max (r1.Top, r2.Top),
+                               Math.Min (r1.Right, r2.Right),
+                               Math.Min (r1.Bottom, r2.Bottom));
                }
 
                /// <summary>
@@ -141,17 +153,7 @@ namespace System.Drawing
                
                public void Intersect (RectangleF r)
                {
-                       if (!IntersectsWith (r)) {
-                                x = 0;
-                                y = 0;
-                                width = 0;
-                                height = 0;
-                       }
-
-                       x = Math.Max (Left, r.Left);
-                       y = Math.Max (Top, r.Top);
-                       width = Math.Min (Right, r.Right) - X;
-                       height = Math.Min (Bottom, r.Bottom) - Y;
+                       this = RectangleF.Intersect (this, r);
                }
 
                /// <summary>
@@ -255,6 +257,14 @@ namespace System.Drawing
                }
 
 
+#if TARGET_JVM
+               internal RectangleF (java.awt.geom.RectangularShape r2d) {
+                       this.x = (float) r2d.getX ();
+                       this.y = (float) r2d.getY ();
+                       this.width = (float) r2d.getWidth ();
+                       this.height = (float) r2d.getHeight ();
+               }
+#endif
 
                /// <summary>
                ///     Bottom Property
@@ -296,16 +306,11 @@ namespace System.Drawing
                /// <remarks>
                ///     Indicates if the width or height are zero. Read only.
                /// </remarks>
-               //
-               // LAMESPEC: Documentation says "This property returns true if 
-               // the Width, Height, X, and Y properties of this RectangleF all 
-               // have values of zero; otherwise, false.". Reality returns TRUE if
-               // width or height are equal 0          
-               
+               //              
                [Browsable (false)]
                public bool IsEmpty {
                        get {
-                               return ((width == 0) || (height == 0));
+                               return (width == 0 || height == 0);
                        }
                }
 
@@ -456,8 +461,8 @@ namespace System.Drawing
                
                public bool Contains (float x, float y)
                {
-                       return ((x >= Left) && (x <= Right) && 
-                               (y >= Top) && (y <= Bottom));
+                       return ((x >= Left) && (x < Right) && 
+                               (y >= Top) && (y < Bottom));
                }
 
                /// <summary>
@@ -526,8 +531,8 @@ namespace System.Drawing
 
                public bool IntersectsWith (RectangleF r)
                {
-                       return !((Left > r.Right) || (Right < r.Left) ||
-                           (Top > r.Bottom) || (Bottom < r.Top));
+                       return !((Left >= r.Right) || (Right <= r.Left) ||
+                           (Top >= r.Bottom) || (Bottom <= r.Top));
                }
 
                /// <summary>