2 using System.Drawing.Drawing2D;
3 using System.Drawing.Imaging;
4 using System.Drawing.Text;
5 using System.ComponentModel;
6 using System.Collections;
7 using System.Runtime.InteropServices;
10 using geom = java.awt.geom;
12 namespace System.Drawing {
14 public sealed class Graphics : MarshalByRefObject, IDisposable {
15 sealed class DummyStroke : awt.Stroke {
16 #region Stroke Members
18 awt.Shape awt.Stroke.createStrokedShape(awt.Shape arg_0) {
19 throw new NotImplementedException("DummyStroke");
25 sealed class NormalizingPathIterator : geom.PathIterator {
29 readonly geom.PathIterator _iter;
31 const float norm = 0.5f;
32 const float rnd = (1.0f - norm);
40 public NormalizingPathIterator(geom.PathIterator iter) {
48 static int GetIndex(int type) {
50 switch ((GraphicsPath.JPI)type) {
51 case GraphicsPath.JPI.SEG_CUBICTO:
54 case GraphicsPath.JPI.SEG_QUADTO:
57 case GraphicsPath.JPI.SEG_MOVETO:
58 case GraphicsPath.JPI.SEG_LINETO:
61 case GraphicsPath.JPI.SEG_CLOSE:
72 #region PathIterator Members
74 void geom.PathIterator.next() {
78 bool geom.PathIterator.isDone() {
79 return _iter.isDone();
82 int geom.PathIterator.currentSegment(float[] point) {
83 int type = _iter.currentSegment(point);
85 int index = GetIndex(type);
88 float ox = point[index];
89 float oy = point[index+1];
90 float newax = (float) java.lang.Math.floor(ox + rnd) + norm;
91 float neway = (float) java.lang.Math.floor(oy + rnd) + norm;
93 point[index+1] = neway;
96 switch ((GraphicsPath.JPI)type) {
97 case GraphicsPath.JPI.SEG_CUBICTO:
103 case GraphicsPath.JPI.SEG_QUADTO:
104 point[0] += (newax + ax) / 2;
105 point[1] += (neway + ay) / 2;
107 // case GraphicsPath.JPI.SEG_MOVETO:
108 // case GraphicsPath.JPI.SEG_LINETO:
109 // case GraphicsPath.JPI.SEG_CLOSE:
119 int geom.PathIterator.currentSegment(double[] point) {
120 int type = _iter.currentSegment(point);
122 int index = GetIndex(type);
125 float ox = (float)point[index];
126 float oy = (float)point[index+1];
127 float newax = (float)java.lang.Math.floor(ox + rnd) + norm;
128 float neway = (float)java.lang.Math.floor(oy + rnd) + norm;
129 point[index] = newax;
130 point[index+1] = neway;
133 switch ((GraphicsPath.JPI)type) {
134 case GraphicsPath.JPI.SEG_CUBICTO:
140 case GraphicsPath.JPI.SEG_QUADTO:
141 point[0] += (newax + ax) / 2;
142 point[1] += (neway + ay) / 2;
144 // case GraphicsPath.JPI.SEG_MOVETO:
145 // case GraphicsPath.JPI.SEG_LINETO:
146 // case GraphicsPath.JPI.SEG_CLOSE:
156 int geom.PathIterator.getWindingRule() {
157 return _iter.getWindingRule();
167 readonly awt.Graphics2D _nativeObject;
168 PixelOffsetMode _pixelOffsetMode = PixelOffsetMode.Default;
169 int _textContrast = 4;
170 TextRenderingHint _textRenderingHint;
171 readonly Image _image;
173 readonly Matrix _transform;
174 GraphicsUnit _pageUnit = GraphicsUnit.Display;
175 float _pageScale = 1.0f;
177 readonly Region _clip;
178 readonly awt.Rectangle _windowRect;
180 GraphicsState _nextGraphicsState = null;
182 static readonly float [] _unitConversion = {
186 DefaultScreenResolution / 72.0f, // Point
187 DefaultScreenResolution, // Inch
188 DefaultScreenResolution / 300.0f,// Document
189 DefaultScreenResolution / 25.4f // Millimeter
192 static int _isHeadless;
193 static internal bool IsHeadless {
195 if (_isHeadless == 0) {
196 bool isHeadless = awt.GraphicsEnvironment.isHeadless();
199 awt.Toolkit.getDefaultToolkit();
206 _isHeadless = isHeadless ? 2 : 1;
209 return _isHeadless > 1;
217 public delegate bool EnumerateMetafileProc (EmfPlusRecordType recordType,
221 PlayRecordCallback callbackData);
223 public delegate bool DrawImageAbort (IntPtr callbackData);
226 #region Constr. and Destr.
227 private Graphics (Image image) {
228 _nativeObject = (awt.Graphics2D)image.NativeObject.CurrentImage.NativeImage.getGraphics();
230 _transform = new Matrix ();
232 NativeObject.setStroke(new DummyStroke());
233 NativeObject.setRenderingHint(awt.RenderingHints.KEY_COLOR_RENDERING, awt.RenderingHints.VALUE_COLOR_RENDER_QUALITY);
235 InterpolationMode = InterpolationMode.Bilinear;
236 TextRenderingHint = TextRenderingHint.SystemDefault;
238 _windowRect = new awt.Rectangle(_image.Width, _image.Height);
239 _clip = new Region();
244 #region Internal Accessors
246 static internal float [] UnitConversion {
248 return _unitConversion;
252 static internal int DefaultScreenResolution {
254 return IsHeadless ? 96 :
255 awt.Toolkit.getDefaultToolkit().getScreenResolution();
259 internal java.awt.Graphics2D NativeObject {
261 return _nativeObject;
266 #region FromImage (static accessor)
267 public static Graphics FromImage (Image image) {
268 return new Graphics(image);
273 #region Workers [INTERNAL]
274 void DrawShape(Pen pen, awt.Shape shape) {
276 throw new ArgumentNullException("pen");
278 if (StrokeFactory.CanCreateAdvancedStroke &&
279 (!pen.CanCreateBasicStroke || !NeedsNormalization)) {
280 geom.AffineTransform oldT = NativeObject.getTransform();
281 NativeObject.setTransform(Matrix.IdentityTransform.NativeObject);
284 geom.AffineTransform t = GetFinalTransform();
285 if (!oldT.isIdentity()) {
286 t = (geom.AffineTransform)t.clone();
287 t.preConcatenate(oldT);
290 double widthsquared = pen.GetSquaredTransformedWidth(t);
292 bool antiAlias = (SmoothingMode == SmoothingMode.AntiAlias);
294 bool thin = (widthsquared <= (antiAlias ?
295 AdvancedStroke.MinPenSizeAASquared :
296 AdvancedStroke.MinPenSizeSquared));
298 PenFit penFit = thin ? (antiAlias ? PenFit.ThinAntiAlias : PenFit.Thin) : PenFit.NotThin;
300 if (NeedsNormalization) {
303 widthsquared <= AdvancedStroke.MinPenSizeSquaredNorm;
306 shape = GetNormalizedShape(shape, t);
307 shape = pen.GetNativeObject(
308 t, null, penFit).createStrokedShape(shape);
311 shape = pen.GetNativeObject(t, penFit).createStrokedShape(shape);
312 shape = GetNormalizedShape(shape, null);
316 shape = pen.GetNativeObject(t, penFit).createStrokedShape(shape);
319 FillScaledShape(pen.Brush, shape);
322 NativeObject.setTransform(oldT);
326 awt.Stroke oldStroke = NativeObject.getStroke();
327 NativeObject.setStroke(pen.GetNativeObject(null, PenFit.NotThin));
330 NativeObject.setPaint(pen.Brush);
332 geom.AffineTransform oldT = NativeObject.getTransform();
333 NativeObject.transform(GetFinalTransform());
335 NativeObject.draw(shape);
338 NativeObject.setTransform(oldT);
342 NativeObject.setStroke(oldStroke);
346 void FillShape(Brush paint, awt.Shape shape) {
348 throw new ArgumentNullException("brush");
350 geom.AffineTransform oldT = null;
351 if (NeedsNormalization) {
352 oldT = NativeObject.getTransform();
353 geom.AffineTransform t = GetFinalTransform();
354 if (!oldT.isIdentity()) {
355 t = (geom.AffineTransform) t.clone ();
356 t.preConcatenate(oldT);
358 shape = GetNormalizedShape(shape, t);
361 geom.AffineTransform t = GetFinalTransform();
363 shape = t.createTransformedShape(shape);
367 NativeObject.setTransform(Matrix.IdentityTransform.NativeObject);
370 FillScaledShape(paint, shape);
374 NativeObject.setTransform(oldT);
378 bool NeedsNormalization {
380 return PixelOffsetMode != PixelOffsetMode.Half &&
381 PixelOffsetMode != PixelOffsetMode.HighQuality;
385 static awt.Shape GetNormalizedShape(awt.Shape shape, geom.AffineTransform t) {
386 geom.PathIterator iter = new NormalizingPathIterator(shape.getPathIterator(t));
388 geom.GeneralPath path = new geom.GeneralPath(iter.getWindingRule());
389 path.append(iter, false);
393 void FillScaledShape(Brush paint, awt.Shape shape) {
395 if (!(paint is SolidBrush || paint is HatchBrush) && !_transform.IsIdentity) {
396 m = paint.BrushTransform;
397 paint.BrushMultiplyTransform( _transform );
401 NativeObject.setPaint(paint);
402 NativeObject.fill(shape);
406 paint.BrushTransform = m;
413 public void Dispose() {
414 NativeObject.dispose();
419 public void Clear (Color color) {
420 FillScaledShape(new SolidBrush( color ), _clip.NativeObject);
425 public void DrawArc (Pen pen, Rectangle rect, float startAngle, float sweepAngle) {
436 public void DrawArc (Pen pen, RectangleF rect, float startAngle, float sweepAngle) {
446 public void DrawArc (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle) {
456 public void DrawArc (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle) {
457 GraphicsPath path = new GraphicsPath();
458 path.AddArc(x, y, width, height, startAngle, sweepAngle);
463 #region DrawBezier(s)
464 public void DrawBezier (Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4) {
465 DrawBezier(pen, pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
468 public void DrawBezier (Pen pen, Point pt1, Point pt2, Point pt3, Point pt4) {
469 DrawBezier(pen, pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
472 public void DrawBezier (Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) {
473 geom.GeneralPath path = new geom.GeneralPath();
475 path.curveTo(x2,y2,x3,y3,x4,y4);
476 DrawShape(pen, path);
479 public void DrawBeziers (Pen pen, Point [] points) {
480 GraphicsPath path = new GraphicsPath();
481 path.AddBeziers(points);
485 public void DrawBeziers (Pen pen, PointF [] points) {
486 GraphicsPath path = new GraphicsPath();
487 path.AddBeziers(points);
492 #region DrawClosedCurve
493 public void DrawClosedCurve (Pen pen, PointF [] points) {
494 DrawClosedCurve(pen, points, 0.5f, FillMode.Alternate);
497 public void DrawClosedCurve (Pen pen, Point [] points) {
498 DrawClosedCurve(pen, points, 0.5f, FillMode.Alternate);
501 public void DrawClosedCurve (Pen pen, Point [] points, float tension, FillMode fillmode) {
502 GraphicsPath path = new GraphicsPath(fillmode);
503 path.AddClosedCurve(points, tension);
507 public void DrawClosedCurve (Pen pen, PointF [] points, float tension, FillMode fillmode) {
508 GraphicsPath path = new GraphicsPath(fillmode);
509 path.AddClosedCurve(points, tension);
515 public void DrawCurve (Pen pen, Point [] points) {
516 DrawCurve(pen, points, 0.5f);
519 public void DrawCurve (Pen pen, PointF [] points) {
520 DrawCurve(pen, points, 0.5f);
523 public void DrawCurve (Pen pen, PointF [] points, float tension) {
524 DrawCurve(pen, points, 0, points.Length-1, tension);
527 public void DrawCurve (Pen pen, Point [] points, float tension) {
528 DrawCurve(pen, points, 0, points.Length-1, tension);
532 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments) {
533 DrawCurve(pen, points, offset, numberOfSegments, 0.5f);
536 public void DrawCurve (Pen pen, Point [] points, int offset, int numberOfSegments, float tension) {
537 GraphicsPath path = new GraphicsPath();
538 path.AddCurve(points, offset, numberOfSegments, tension);
543 public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments, float tension) {
544 GraphicsPath path = new GraphicsPath();
545 path.AddCurve(points, offset, numberOfSegments, tension);
551 public void DrawEllipse (Pen pen, Rectangle rect) {
552 DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
555 public void DrawEllipse (Pen pen, RectangleF rect) {
556 DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
559 public void DrawEllipse (Pen pen, int x, int y, int width, int height) {
560 DrawEllipse(pen,(float)x,(float)y,(float)width,(float)height);
563 public void DrawEllipse (Pen pen, float x, float y, float width, float height) {
564 DrawShape(pen, new geom.Ellipse2D.Float(x,y,width,height));
569 public void DrawIcon (Icon icon, Rectangle targetRect) {
570 Bitmap b = icon.ToBitmap ();
571 this.DrawImage (b, targetRect);
574 public void DrawIcon (Icon icon, int x, int y) {
575 Bitmap b = icon.ToBitmap ();
576 this.DrawImage (b, x, y);
579 public void DrawIconUnstretched (Icon icon, Rectangle targetRect) {
580 Bitmap b = icon.ToBitmap ();
581 this.DrawImageUnscaled (b, targetRect);
587 public void DrawImage (Image image, Point point) {
588 DrawImage(image, point.X, point.Y);
591 public void DrawImage (Image image, PointF point) {
592 DrawImage(image, point.X, point.Y);
596 public void DrawImage (Image image, Point [] destPoints) {
597 Matrix m = new Matrix(new Rectangle(0, 0, image.Width, image.Height), destPoints);
601 public void DrawImage (Image image, PointF [] destPoints) {
602 Matrix m = new Matrix(new RectangleF(0, 0, image.Width, image.Height), destPoints);
607 public void DrawImage (Image image, Rectangle rect) {
608 DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
611 public void DrawImage (Image image, RectangleF rect) {
612 DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
616 public void DrawImage (Image image, int x, int y) {
617 DrawImage(image, (float)x, (float)y);
620 public void DrawImage (Image image, float x, float y) {
621 if ((image.HorizontalResolution != DpiX) || (image.VerticalResolution != DpiY))
622 DrawImage( image, x, y,
623 (float)image.Width * (DpiX / image.HorizontalResolution) / _unitConversion[(int)PageUnit],
624 (float)image.Height * (DpiY / image.VerticalResolution) / _unitConversion[(int)PageUnit]) ;
626 DrawImage( image, x, y,
627 (float)image.Width / _unitConversion[(int)PageUnit],
628 (float)image.Height / _unitConversion[(int)PageUnit] );
632 public void DrawImage (Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit) {
636 new Point( destRect.X, destRect.Y),
637 new Point( destRect.X + destRect.Width, destRect.Y),
638 new Point( destRect.X, destRect.Y + destRect.Height)},
643 public void DrawImage (Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit) {
647 new PointF( destRect.X, destRect.Y),
648 new PointF( destRect.X + destRect.Width, destRect.Y),
649 new PointF( destRect.X, destRect.Y + destRect.Height)},
655 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit) {
656 DrawImage(image, destPoints, srcRect, srcUnit, null);
659 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit) {
660 DrawImage(image, destPoints, srcRect, srcUnit, null);
663 [MonoLimitation("ImageAttributes parameter is ignored.")]
664 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr) {
665 //TBD: ImageAttributes
666 if (srcUnit != GraphicsUnit.Pixel)
667 throw new NotImplementedException();
668 // Like in .NET http://dotnet247.com/247reference/msgs/45/227979.aspx
670 Matrix mx = new Matrix(srcRect, destPoints);
672 Region region = new Region(srcRect);
673 DrawImage(image, mx, region);
676 [MonoLimitation ("ImageAttributes parameter is ignored.")]
677 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr) {
678 //TBD: ImageAttributes
679 if (srcUnit != GraphicsUnit.Pixel)
680 throw new NotImplementedException();
681 // Like in .NET http://dotnet247.com/247reference/msgs/45/227979.aspx
683 Matrix mx = new Matrix(srcRect, destPoints);
685 Region region = new Region(srcRect);
686 DrawImage(image, mx, region);
690 public void DrawImage (Image image, int x, int y, int width, int height) {
691 DrawImage(image, (float)x, (float)y, (float)width, (float)height);
694 public void DrawImage (Image image, float x, float y, float width, float height) {
695 Matrix mx = new Matrix();
696 mx.Translate((float)x, (float)y);
697 mx.Scale(width / (float)image.Width, height / (float)image.Height);
699 DrawImage( image, mx );
703 public void DrawImage (Image image, int x, int y, Rectangle srcRect, GraphicsUnit srcUnit) {
704 DrawImage(image, new Rectangle(x, y, srcRect.Width, srcRect.Height), srcRect, srcUnit);
707 public void DrawImage (Image image, float x, float y, RectangleF srcRect, GraphicsUnit srcUnit) {
708 DrawImage(image, new RectangleF(x, y, srcRect.Width, srcRect.Height), srcRect, srcUnit);
712 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit) {
713 DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, null);
716 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit) {
717 DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, null);
720 [MonoLimitation ("ImageAttributes parameter is ignored.")]
721 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr) {
726 new Rectangle(srcX, srcY, srcWidth, srcHeight),
730 [MonoLimitation ("ImageAttributes parameter is ignored.")]
731 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs) {
736 new RectangleF(srcX, srcY, srcWidth, srcHeight),
741 public delegate bool DrawImageAbort (IntPtr callbackdata);
743 [MonoNotSupported ("")]
744 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
746 throw new NotImplementedException ();
749 [MonoNotSupported ("")]
750 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
752 throw new NotImplementedException ();
755 [MonoNotSupported ("")]
756 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
758 throw new NotImplementedException ();
761 [MonoNotSupported ("")]
762 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
764 throw new NotImplementedException ();
767 [MonoNotSupported ("")]
768 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
770 throw new NotImplementedException ();
773 [MonoNotSupported ("")]
774 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback)
776 throw new NotImplementedException ();
779 [MonoNotSupported ("")]
780 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData)
782 throw new NotImplementedException ();
785 [MonoNotSupported ("")]
786 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData)
788 throw new NotImplementedException ();
791 internal void DrawImage (Image image, Matrix m) {
792 DrawImage(image, m, null);
795 internal void DrawImage (Image image, Matrix m, Region clip) {
797 clip = new Region( new RectangleF( 0, 0, image.Width, image.Height ) );
800 geom.AffineTransform t = GetFinalTransform(_transform.NativeObject, PageUnit, 1.0f);
802 m.NativeObject.preConcatenate(t);
806 if (NeedsNormalization) {
807 Matrix normMatrix = ComputeClipNormalization(clip.GetBounds(this));
808 clip.Transform(normMatrix);
811 awt.Shape oldClip = NativeObject.getClip();
812 IntersectScaledClipWithBase(clip);
815 Matrix mm = ComputeImageNormalization(image, m);
816 NativeObject.drawImage(image.NativeObject.CurrentImage.NativeImage, mm.NativeObject, null);
819 NativeObject.setClip( oldClip );
823 private static Matrix ComputeImageNormalization(Image img, Matrix m) {
827 //m.Translate( -(m.Elements[0] + m.Elements[2]) / 2.0f, -(m.Elements[3] + m.Elements[1]) / 2.0f, MatrixOrder.Append);
829 -(float)(m.NativeObject.getScaleX() + m.NativeObject.getShearX()) / 2.0f,
830 -(float)(m.NativeObject.getScaleY() + m.NativeObject.getShearY()) / 2.0f, MatrixOrder.Append);
832 PointF [] p = new PointF[] {
834 new PointF( img.Width, 0 ),
835 new PointF( 0, img.Height )};
837 m.TransformPoints(p);
838 for (int i=0; i < p.Length; i++) {
839 p[i].X = (float)( p[i].X + 0.5f );
840 p[i].Y = (float)( p[i].Y + 0.5f );
843 return new Matrix( new Rectangle(0, 0, img.Width, img.Height), p );
845 private static Matrix ComputeClipNormalization(RectangleF rect) {
846 PointF [] p = new PointF[] {
847 new PointF( rect.X, rect.Y ),
848 new PointF( rect.X + rect.Width, rect.Y ),
849 new PointF( rect.X, rect.Y + rect.Height )};
851 for (int i=0; i < p.Length; i++) {
852 p[i].X = (float)Math.Round( p[i].X + 0.5f ) + 0.5f;
853 p[i].Y = (float)Math.Round( p[i].Y + 0.5f ) + 0.5f;
856 return new Matrix( rect, p );
862 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
864 throw new NotImplementedException();
868 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
871 throw new NotImplementedException();
875 public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
877 throw new NotImplementedException();
883 public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
885 throw new NotImplementedException();
890 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
892 //TBD:units,attributes, callback
893 java.awt.Graphics2D g = (java.awt.Graphics2D)nativeObject;
894 g.drawImage(image.NativeObject,destRect.X,destRect.Y,destRect.Width,destRect.Height,srcX,srcY,srcWidth,srcHeight,null);
897 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
899 //TBD:units,attributes, callback
900 java.awt.Graphics2D g = (java.awt.Graphics2D)nativeObject;
901 g.drawImage(image.NativeObject,
905 (int)destRect.Height,
909 (int)srcHeight,null);
912 public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
914 //TBD:units,attributes, callback
915 java.awt.Graphics2D g = (java.awt.Graphics2D)nativeObject;
916 g.drawImage(image.NativeObject,
920 (int)destRect.Height,
924 (int)srcHeight,null);
927 public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
929 //TBD:units,attributes, callback
930 java.awt.Graphics2D g = (java.awt.Graphics2D)nativeObject;
931 g.drawImage(image.NativeObject,
943 public void DrawImageUnscaled (Image image, Point point)
945 DrawImageUnscaled (image, point.X, point.Y);
948 public void DrawImageUnscaled (Image image, Rectangle rect) {
949 DrawImageUnscaled (image, rect.X, rect.Y, rect.Width, rect.Height);
952 public void DrawImageUnscaled (Image image, int x, int y) {
953 DrawImage (image, x, y, image.Width, image.Height);
956 public void DrawImageUnscaled (Image image, int x, int y, int width, int height) {
957 Image tmpImg = new Bitmap (width, height);
958 Graphics g = FromImage (tmpImg);
959 g.DrawImage (image, 0, 0, image.Width, image.Height);
960 this.DrawImage (tmpImg, x, y, width, height);
966 [MonoNotSupported ("")]
967 public void DrawImageUnscaledAndClipped (Image image, Rectangle rect)
969 throw new NotImplementedException ();
976 public void DrawLine (Pen pen, PointF pt1, PointF pt2) {
977 DrawLine(pen,pt1.X,pt1.Y,pt2.X,pt2.Y);
980 public void DrawLine (Pen pen, Point pt1, Point pt2) {
981 DrawLine(pen,(float)pt1.X,(float)pt1.Y,(float)pt2.X,(float)pt2.Y);
984 public void DrawLine (Pen pen, int x1, int y1, int x2, int y2) {
985 DrawLine(pen,(float)x1,(float)y1,(float)x2,(float)y2);
988 public void DrawLine (Pen pen, float x1, float y1, float x2, float y2) {
989 DrawShape(pen, new geom.Line2D.Float(x1,y1,x2,y2));
992 public void DrawLines (Pen pen, PointF [] points) {
993 GraphicsPath path = new GraphicsPath();
994 path.AddLines(points);
995 DrawShape(pen, path);
998 public void DrawLines (Pen pen, Point [] points) {
999 GraphicsPath path = new GraphicsPath();
1000 path.AddLines(points);
1001 DrawShape(pen, path);
1006 public void DrawPath (Pen pen, GraphicsPath path) {
1007 DrawShape(pen, path);
1012 public void DrawPie (Pen pen, Rectangle rect, float startAngle, float sweepAngle) {
1013 DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1016 public void DrawPie (Pen pen, RectangleF rect, float startAngle, float sweepAngle) {
1017 DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
1020 public void DrawPie (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle) {
1021 GraphicsPath path = new GraphicsPath();
1022 path.AddPie(x, y, width, height, startAngle, sweepAngle);
1023 DrawPath(pen, path);
1026 public void DrawPie (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle) {
1027 DrawPie(pen,(float)x,(float)y,(float)width,(float)height,(float)startAngle,(float)sweepAngle);
1032 public void DrawPolygon (Pen pen, Point [] points) {
1033 GraphicsPath path = new GraphicsPath();
1034 path.AddPolygon(points);
1035 DrawPath(pen, path);
1038 public void DrawPolygon (Pen pen, PointF [] points) {
1039 GraphicsPath path = new GraphicsPath();
1040 path.AddPolygon(points);
1041 DrawPath(pen, path);
1045 #region DrawRectangle(s)
1046 internal void DrawRectangle (Pen pen, RectangleF rect) {
1047 DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
1050 public void DrawRectangle (Pen pen, Rectangle rect) {
1051 DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
1054 public void DrawRectangle (Pen pen, float x, float y, float width, float height) {
1055 DrawShape(pen, new geom.Rectangle2D.Float(x,y,width,height));
1058 public void DrawRectangle (Pen pen, int x, int y, int width, int height) {
1059 DrawRectangle (pen,(float) x,(float) y,(float) width,(float) height);
1062 public void DrawRectangles (Pen pen, RectangleF [] rects) {
1063 foreach(RectangleF r in rects)
1064 DrawRectangle (pen, r.Left, r.Top, r.Width, r.Height);
1067 public void DrawRectangles (Pen pen, Rectangle [] rects) {
1068 foreach(Rectangle r in rects)
1069 DrawRectangle (pen, r.Left, r.Top, r.Width, r.Height);
1074 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle) {
1075 DrawString(s, font, brush, layoutRectangle.X, layoutRectangle.Y, layoutRectangle.Width, layoutRectangle.Height, null);
1078 public void DrawString (string s, Font font, Brush brush, PointF point) {
1079 DrawString(s, font, brush, point.X, point.Y, float.PositiveInfinity, float.PositiveInfinity, null);
1082 public void DrawString (string s, Font font, Brush brush, PointF point, StringFormat format) {
1083 DrawString(s, font, brush, point.X, point.Y, float.PositiveInfinity, float.PositiveInfinity, format);
1086 public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format) {
1087 DrawString(s, font, brush, layoutRectangle.X, layoutRectangle.Y, layoutRectangle.Width, layoutRectangle.Height, format);
1090 public void DrawString (string s, Font font, Brush brush, float x, float y) {
1091 DrawString(s, font, brush, x, y, float.PositiveInfinity, float.PositiveInfinity, null);
1094 public void DrawString (string s, Font font, Brush brush, float x, float y, StringFormat format) {
1095 DrawString(s, font, brush, x, y, float.PositiveInfinity, float.PositiveInfinity, format);
1098 void DrawString (string s, Font font, Brush brush,
1099 float x, float y, float width, float height,
1100 StringFormat format) {
1102 throw new ArgumentNullException("brush");
1105 throw new ArgumentNullException("font");
1107 if (format != null && format.LineAlignment != StringAlignment.Near) {
1109 SizeF sizeF = MeasureString(s, font, format, width, height, null);
1111 float lineAWidth = width;
1112 float lineAHeight = height;
1114 if (float.IsPositiveInfinity(width))
1115 lineAWidth = lineAHeight = 0;
1117 float wdelta = format.IsVertical ? lineAWidth - sizeF.Width : lineAHeight - sizeF.Height;
1118 float pdelta = format.LineAlignment == StringAlignment.Center ? wdelta/2 : wdelta;
1119 if (format.IsVertical) {
1120 if (!(format.IsRightToLeft && format.LineAlignment == StringAlignment.Far))
1122 if (!float.IsPositiveInfinity(width))
1127 if (!float.IsPositiveInfinity(width))
1132 awt.Paint oldP = NativeObject.getPaint();
1133 NativeObject.setPaint(brush);
1135 geom.AffineTransform oldT = NativeObject.getTransform();
1138 bool noclip = float.IsPositiveInfinity(width) || (format != null && format.NoClip);
1140 awt.Shape oldClip = null;
1142 oldClip = NativeObject.getClip();
1143 NativeObject.clip(new geom.Rectangle2D.Float(x, y, width, height));
1146 TextLineIterator iter = new TextLineIterator(s, font, NativeObject.getFontRenderContext(), format, width, height);
1147 NativeObject.transform(iter.Transform);
1148 for (LineLayout layout = iter.NextLine(); layout != null; layout = iter.NextLine()) {
1149 layout.Draw (NativeObject, x * UnitConversion [(int) PageUnit], y * UnitConversion [(int) PageUnit]);
1154 NativeObject.setClip(oldClip);
1158 NativeObject.setTransform(oldT);
1162 NativeObject.setPaint(oldP);
1169 void PushGraphicsState(GraphicsState state) {
1170 state.Next = _nextGraphicsState;
1171 _nextGraphicsState = state;
1174 GraphicsState PopGraphicsState() {
1175 GraphicsState state = _nextGraphicsState;
1176 _nextGraphicsState = _nextGraphicsState.Next;
1180 bool ContainsGraphicsState(GraphicsState state) {
1181 GraphicsState gs = _nextGraphicsState;
1193 public void EndContainer (GraphicsContainer container) {
1194 Restore(container.StateObject);
1197 public GraphicsContainer BeginContainer () {
1198 return new GraphicsContainer(Save(Matrix.IdentityTransform, true));
1201 public GraphicsContainer BeginContainer (Rectangle dstrect, Rectangle srcrect, GraphicsUnit unit) {
1202 Matrix containerTransfrom =
1203 new Matrix( srcrect,
1204 new Point [] { new Point (dstrect.X, dstrect.Y),
1205 new Point (dstrect.X + dstrect.Width, dstrect.Y),
1206 new Point (dstrect.X, dstrect.Y + dstrect.Height) });
1208 float scale = _unitConversion[ (int)PageUnit ] / _unitConversion[ (int)unit ];
1209 containerTransfrom.Scale(scale, scale);
1211 return new GraphicsContainer(Save(containerTransfrom, true));
1215 public GraphicsContainer BeginContainer (RectangleF dstrect, RectangleF srcrect, GraphicsUnit unit) {
1216 Matrix containerTransfrom =
1217 new Matrix( srcrect,
1218 new PointF [] { new PointF (dstrect.X, dstrect.Y),
1219 new PointF (dstrect.X + dstrect.Width, dstrect.Y),
1220 new PointF (dstrect.X, dstrect.Y + dstrect.Height) });
1222 float scale = _unitConversion[ (int)PageUnit ] / _unitConversion[ (int)unit ];
1223 containerTransfrom.Scale(scale, scale);
1225 return new GraphicsContainer(Save(containerTransfrom, true));
1228 GraphicsState Save(Matrix matrix, bool resetState) {
1229 GraphicsState graphicsState = new GraphicsState(this, matrix, resetState);
1231 PushGraphicsState( graphicsState );
1232 return graphicsState;
1235 public GraphicsState Save () {
1236 return Save(Matrix.IdentityTransform, false);
1239 public void Restore (GraphicsState graphicsState) {
1240 if (ContainsGraphicsState(graphicsState)) {
1241 GraphicsState gs = PopGraphicsState();
1242 while ( gs != graphicsState )
1243 gs = PopGraphicsState();
1245 graphicsState.RestoreState(this);
1251 #region Metafiles Staff
1253 public void AddMetafileComment (byte [] data) {
1254 throw new NotImplementedException ();
1259 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback)
1261 throw new NotImplementedException ();
1265 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback)
1267 throw new NotImplementedException ();
1271 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback)
1273 throw new NotImplementedException ();
1277 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback)
1279 throw new NotImplementedException ();
1283 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback)
1285 throw new NotImplementedException ();
1289 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback)
1291 throw new NotImplementedException ();
1295 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
1297 throw new NotImplementedException ();
1301 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData)
1303 throw new NotImplementedException ();
1307 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
1309 throw new NotImplementedException ();
1313 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
1315 throw new NotImplementedException ();
1319 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
1321 throw new NotImplementedException ();
1325 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData)
1327 throw new NotImplementedException ();
1331 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1333 throw new NotImplementedException ();
1337 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1339 throw new NotImplementedException ();
1343 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1345 throw new NotImplementedException ();
1349 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1351 throw new NotImplementedException ();
1355 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1357 throw new NotImplementedException ();
1361 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
1363 throw new NotImplementedException ();
1367 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1369 throw new NotImplementedException ();
1373 public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1375 throw new NotImplementedException ();
1379 public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1381 throw new NotImplementedException ();
1385 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1387 throw new NotImplementedException ();
1391 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1393 throw new NotImplementedException ();
1397 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1399 throw new NotImplementedException ();
1403 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1405 throw new NotImplementedException ();
1409 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1411 throw new NotImplementedException ();
1415 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1417 throw new NotImplementedException ();
1421 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1423 throw new NotImplementedException ();
1427 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1429 throw new NotImplementedException ();
1433 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
1435 throw new NotImplementedException ();
1439 public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1441 throw new NotImplementedException ();
1445 public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1447 throw new NotImplementedException ();
1451 public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1453 throw new NotImplementedException ();
1457 public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1459 throw new NotImplementedException ();
1463 public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1465 throw new NotImplementedException ();
1469 public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
1471 throw new NotImplementedException ();
1477 void ExcludeClip(geom.Area area) {
1479 geom.AffineTransform t = GetFinalTransform();
1480 if (!t.isIdentity()) {
1481 area = (geom.Area) area.clone ();
1485 _clip.NativeObject.subtract(area);
1487 NativeObject.clip(_clip);
1490 public void ExcludeClip (Rectangle rect) {
1491 ExcludeClip(new geom.Area(rect.NativeObject));
1494 public void ExcludeClip (Region region) {
1496 throw new ArgumentNullException("region");
1497 ExcludeClip(region.NativeObject);
1501 #region FillClosedCurve
1502 public void FillClosedCurve (Brush brush, PointF [] points) {
1503 FillClosedCurve (brush, points, FillMode.Alternate);
1507 public void FillClosedCurve (Brush brush, Point [] points) {
1508 FillClosedCurve (brush, points, FillMode.Alternate);
1512 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode) {
1513 FillClosedCurve (brush, points, fillmode, 0.5f);
1516 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode) {
1517 FillClosedCurve (brush, points, fillmode, 0.5f);
1520 public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode, float tension) {
1521 GraphicsPath path = new GraphicsPath(fillmode);
1522 path.AddClosedCurve(points, tension);
1523 FillPath(brush, path);
1526 public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode, float tension) {
1527 GraphicsPath path = new GraphicsPath(fillmode);
1528 path.AddClosedCurve(points, tension);
1529 FillPath(brush, path);
1534 public void FillEllipse (Brush brush, Rectangle rect) {
1535 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1538 public void FillEllipse (Brush brush, RectangleF rect) {
1539 FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
1542 public void FillEllipse (Brush brush, float x, float y, float width, float height) {
1543 FillShape(brush,new java.awt.geom.Ellipse2D.Float(x,y,width,height));
1546 public void FillEllipse (Brush brush, int x, int y, int width, int height) {
1547 FillEllipse (brush,(float)x,(float)y,(float)width,(float)height);
1552 public void FillPath (Brush brush, GraphicsPath path) {
1554 throw new ArgumentNullException("path");
1556 FillShape(brush,path);
1561 public void FillPie (Brush brush, Rectangle rect, float startAngle, float sweepAngle) {
1562 FillPie(brush,(float)rect.X,(float)rect.Y,(float)rect.Width,(float)rect.Height,(float)startAngle,(float)sweepAngle);
1565 public void FillPie (Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle) {
1566 FillPie(brush,(float)x,(float)y,(float)width,(float)height,(float)startAngle,(float)sweepAngle);
1569 public void FillPie (Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle) {
1570 GraphicsPath path = new GraphicsPath();
1571 path.AddPie(x, y, width, height, startAngle, sweepAngle);
1572 FillPath(brush, path);
1577 public void FillPolygon (Brush brush, PointF [] points) {
1578 FillPolygon(brush, points, FillMode.Alternate);
1581 public void FillPolygon (Brush brush, Point [] points) {
1582 FillPolygon(brush, points, FillMode.Alternate);
1585 public void FillPolygon (Brush brush, Point [] points, FillMode fillMode) {
1586 GraphicsPath path = new GraphicsPath(fillMode);
1587 path.AddPolygon(points);
1588 FillPath(brush,path);
1591 public void FillPolygon (Brush brush, PointF [] points, FillMode fillMode) {
1592 GraphicsPath path = new GraphicsPath(fillMode);
1593 path.AddPolygon(points);
1594 FillPath(brush,path);
1598 #region FillRectangle
1599 public void FillRectangle (Brush brush, RectangleF rect) {
1600 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1603 public void FillRectangle (Brush brush, Rectangle rect) {
1604 FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
1607 public void FillRectangle (Brush brush, int x, int y, int width, int height) {
1608 FillRectangle(brush,(float)x,(float)y,(float)width,(float)height);
1611 public void FillRectangle (Brush brush, float x, float y, float width, float height) {
1612 FillShape(brush,new java.awt.geom.Rectangle2D.Float(x,y,width,height));
1615 public void FillRectangles (Brush brush, Rectangle [] rects) {
1616 GraphicsPath path = new GraphicsPath();
1617 path.AddRectangles(rects);
1618 FillPath(brush,path);
1621 public void FillRectangles (Brush brush, RectangleF [] rects) {
1622 GraphicsPath path = new GraphicsPath();
1623 path.AddRectangles(rects);
1624 FillPath(brush,path);
1629 public void FillRegion (Brush brush, Region region) {
1630 FillShape(brush,region);
1635 public void Flush () {
1636 Flush (FlushIntention.Flush);
1640 public void Flush (FlushIntention intention) {
1642 _image.NativeObject.CurrentImage.NativeImage.flush();
1645 #if INTPTR_SUPPORTED
1646 [EditorBrowsable (EditorBrowsableState.Advanced)]
1648 public void ReleaseHdc (IntPtr hdc)
1650 throw new NotImplementedException();
1653 [EditorBrowsable (EditorBrowsableState.Advanced)]
1655 public void ReleaseHdcInternal (IntPtr hdc)
1657 throw new NotImplementedException ();
1660 [EditorBrowsable (EditorBrowsableState.Advanced)]
1662 public static Graphics FromHdc (IntPtr hdc)
1664 throw new NotImplementedException();
1667 [EditorBrowsable (EditorBrowsableState.Advanced)]
1669 public static Graphics FromHdc (IntPtr hdc, IntPtr hdevice)
1671 throw new NotImplementedException ();
1674 [EditorBrowsable (EditorBrowsableState.Advanced)]
1676 public static Graphics FromHdcInternal (IntPtr hdc)
1678 throw new NotImplementedException ();
1681 [EditorBrowsable (EditorBrowsableState.Advanced)]
1683 public static Graphics FromHwnd (IntPtr hwnd)
1685 throw new NotImplementedException();
1688 [EditorBrowsable (EditorBrowsableState.Advanced)]
1690 public static Graphics FromHwndInternal (IntPtr hwnd)
1692 throw new NotImplementedException ();
1696 internal static Graphics FromXDrawable (IntPtr drawable, IntPtr display)
1698 throw new NotImplementedException();
1702 public static IntPtr GetHalftonePalette ()
1704 throw new NotImplementedException ();
1707 [EditorBrowsable (EditorBrowsableState.Advanced)]
1709 public IntPtr GetHdc ()
1711 throw new NotImplementedException();
1715 #region GetNearestColor
1717 public Color GetNearestColor (Color color) {
1718 throw new NotImplementedException();
1722 #region IntersectClip
1723 void IntersectClip (geom.Area area) {
1725 geom.AffineTransform t = GetFinalTransform();
1726 if (!t.isIdentity()) {
1727 area = (geom.Area) area.clone ();
1731 _clip.NativeObject.intersect(area);
1733 NativeObject.clip(_clip);
1736 public void IntersectClip (Region region) {
1738 throw new ArgumentNullException("region");
1740 IntersectClip(region.NativeObject);
1743 public void IntersectClip (RectangleF rect) {
1744 IntersectClip(new geom.Area(rect.NativeObject));
1747 public void IntersectClip (Rectangle rect) {
1748 IntersectClip(new geom.Area(rect.NativeObject));
1753 public bool IsVisible (Point point) {
1754 return IsVisible(point.X,point.Y);
1758 public bool IsVisible (RectangleF rect) {
1759 return IsVisible ((float)rect.X,(float)rect.Y,(float)rect.Width,(float)rect.Height);
1762 public bool IsVisible (PointF point) {
1763 return IsVisible(point.X,point.Y);
1766 public bool IsVisible (Rectangle rect) {
1767 return IsVisible ((float)rect.X,(float)rect.Y,(float)rect.Width,(float)rect.Height);
1770 public bool IsVisible (float x, float y) {
1773 geom.AffineTransform t = GetFinalTransform();
1774 if (!t.isIdentity()) {
1775 double[] p = new double[] {dx, dy};
1776 t.transform(p, 0, p, 0, 1);
1781 if (!_clip.NativeObject.contains(dx, dy))
1784 awt.Shape clip = NativeObject.getClip();
1788 return clip.contains(dx, dy);
1791 public bool IsVisible (int x, int y) {
1792 return IsVisible ((float)x,(float)y);
1795 public bool IsVisible (float x, float y, float width, float height) {
1797 geom.AffineTransform t = GetFinalTransform();
1798 geom.Rectangle2D r = new geom.Rectangle2D.Float(x, y, width, height);
1800 if (!t.isIdentity())
1801 r = t.createTransformedShape(r).getBounds2D();
1803 return NativeObject.hitClip(
1804 (int)(r.getX()+0.5), (int)(r.getY()+0.5),
1805 (int)(r.getWidth()+0.5), (int)(r.getHeight()+0.5))
1806 && _clip.NativeObject.intersects(r);
1810 public bool IsVisible (int x, int y, int width, int height) {
1811 return IsVisible ((float)x,(float)y,(float)width,(float)height);
1815 #region MeasureCharacterRanges
1816 public Region [] MeasureCharacterRanges (string text, Font font, RectangleF layoutRect, StringFormat stringFormat) {
1817 if (stringFormat == null)
1818 throw new ArgumentException("stringFormat");
1820 CharacterRange[] ranges = stringFormat.CharRanges;
1821 if (ranges == null || ranges.Length == 0)
1822 return new Region[0];
1824 GraphicsPath[] pathes = new GraphicsPath[ranges.Length];
1825 for (int i = 0; i < pathes.Length; i++)
1826 pathes[i] = new GraphicsPath();
1828 TextLineIterator iter = new TextLineIterator(text, font, NativeObject.getFontRenderContext(),
1829 stringFormat, layoutRect.Width, layoutRect.Height);
1831 for (LineLayout layout = iter.NextLine(); layout != null; layout = iter.NextLine()) {
1833 for (int i = 0; i < ranges.Length; i++) {
1834 int start = ranges[i].First;
1835 int length = ranges[i].Length;
1836 start -= iter.CharsConsumed;
1837 int limit = start + length;
1838 int layoutStart = iter.CurrentPosition - layout.CharacterCount;
1839 if (start < iter.CurrentPosition && limit > layoutStart) {
1842 if (start > layoutStart)
1843 layoutOffset = iter.GetAdvanceBetween(layoutStart, start);
1846 start = layoutStart;
1849 float width = (limit < iter.CurrentPosition) ?
1850 iter.GetAdvanceBetween(start, limit) :
1851 layout.Width - layoutOffset;
1853 float height = layout.Ascent + layout.Descent;
1855 float x = layout.NativeX;
1856 float y = layout.NativeY;
1858 if (stringFormat.IsVertical) {
1860 x -= layout.Descent;
1867 if (layout.AccumulatedHeight + height > iter.WrapHeight) {
1868 float diff = iter.WrapHeight - layout.AccumulatedHeight;
1869 if (stringFormat.IsVertical && stringFormat.IsRightToLeft) {
1877 if (stringFormat.IsVertical)
1878 pathes[i].AddRectangle(x + layoutRect.X, y + layoutRect.Y, height, width);
1880 pathes[i].AddRectangle(x + layoutRect.X, y + layoutRect.Y, width, height);
1885 geom.AffineTransform lineAlignT = iter.CalcLineAlignmentTransform();
1886 if (lineAlignT != null) {
1887 for (int i = 0; i < pathes.Length; i++)
1888 pathes[i].NativeObject.transform(lineAlignT);
1891 Region[] regions = new Region[ranges.Length];
1892 for (int i = 0; i < regions.Length; i++)
1893 regions[i] = new Region(pathes[i]);
1899 #region MeasureString
1900 public SizeF MeasureString (string text, Font font) {
1901 return MeasureString(text, font, null, float.PositiveInfinity, float.PositiveInfinity, null);
1905 public SizeF MeasureString (string text, Font font, SizeF layoutArea) {
1906 return MeasureString(text, font, layoutArea, null);
1910 public SizeF MeasureString (string text, Font font, int width) {
1911 return MeasureString(text, font, width, null);
1915 public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat format) {
1916 return MeasureString(text, font, format, layoutArea.Width, layoutArea.Height, null);
1920 public SizeF MeasureString (string text, Font font, int width, StringFormat format) {
1921 return MeasureString(text, font, format, width, float.PositiveInfinity, null);
1925 public SizeF MeasureString (string text, Font font, PointF origin, StringFormat format) {
1926 return MeasureString(text, font, format, float.PositiveInfinity, float.PositiveInfinity, null);
1929 SizeF MeasureString (string text, Font font, StringFormat format, float width, float height, int[] statistics) {
1931 if (statistics != null) {
1936 TextLineIterator iter = new TextLineIterator(text, font, NativeObject.getFontRenderContext(), format, width, height);
1939 int linesFilled = 0;
1940 for (LineLayout layout = iter.NextLine(); layout != null; layout = iter.NextLine()) {
1943 float w = layout.MeasureWidth;
1949 if (linesFilled == 0)
1952 float mheight = iter.AccumulatedHeight;
1954 if (format != null) {
1955 if (format.IsVertical) {
1956 float temp = mheight;
1962 if (!(format != null && format.NoClip)) {
1965 if (mheight > height)
1969 if (statistics != null) {
1970 statistics[0] = linesFilled;
1971 statistics[1] = iter.CharsConsumed;
1974 return new SizeF (mwidth / UnitConversion [(int) _pageUnit], mheight / UnitConversion [(int) _pageUnit]);
1978 public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat, out int charactersFitted, out int linesFilled) {
1980 charactersFitted = 0;
1982 int[] statistics = new int[2];
1983 SizeF sz = MeasureString(text, font, stringFormat, layoutArea.Width, layoutArea.Height, statistics);
1984 linesFilled = statistics[0];
1985 charactersFitted = statistics[1];
1990 #region MultiplyTransform
1991 public void MultiplyTransform (Matrix matrix) {
1992 MultiplyTransform (matrix, MatrixOrder.Prepend);
1995 public void MultiplyTransform (Matrix matrix, MatrixOrder order) {
1996 ConcatenateTransform(matrix.NativeObject, order);
2000 #region Reset (Clip and Transform)
2001 public void ResetClip () {
2002 _clip.MakeInfinite();
2004 NativeObject.clip(_clip);
2007 public void ResetTransform () {
2012 #region RotateTransform
2013 public void RotateTransform (float angle) {
2014 RotateTransform (angle, MatrixOrder.Prepend);
2017 public void RotateTransform (float angle, MatrixOrder order) {
2018 ConcatenateTransform(
2019 geom.AffineTransform.getRotateInstance(java.lang.Math.toRadians(angle)),
2024 #region ScaleTransform
2025 public void ScaleTransform (float sx, float sy) {
2026 ScaleTransform (sx, sy, MatrixOrder.Prepend);
2029 public void ScaleTransform (float sx, float sy, MatrixOrder order) {
2030 ConcatenateTransform(
2031 geom.AffineTransform.getScaleInstance(sx, sy),
2036 #region SetClip [Must be reviewed - more abstraction needed]
2037 public void SetClip (RectangleF rect) {
2038 SetClip (rect, CombineMode.Replace);
2041 public void SetClip (GraphicsPath path) {
2042 SetClip (path, CombineMode.Replace);
2045 public void SetClip (Rectangle rect) {
2046 SetClip (rect, CombineMode.Replace);
2049 public void SetClip (Graphics g) {
2050 SetClip (g, CombineMode.Replace);
2053 public void SetClip (Graphics g, CombineMode combineMode) {
2055 throw new NullReferenceException();
2057 CombineClipArea(g._clip.NativeObject, combineMode);
2060 public void SetClip (Rectangle rect, CombineMode combineMode) {
2061 SetClip(rect.X,rect.Y,rect.Width,rect.Height,combineMode);
2063 public void SetClip (RectangleF rect, CombineMode combineMode) {
2064 SetClip(rect.X,rect.Y,rect.Width,rect.Height,combineMode);
2067 public void SetClip (Region region, CombineMode combineMode) {
2069 throw new ArgumentNullException("region");
2071 CombineClipArea ((geom.Area) region.NativeObject.clone (), combineMode);
2074 public void SetClip (GraphicsPath path, CombineMode combineMode) {
2076 throw new ArgumentNullException("path");
2078 CombineClipArea(new geom.Area(path.NativeObject), combineMode);
2082 #region Clipping Staff [INTERNAL]
2083 internal Region ScaledClip {
2085 return _clip.Clone();
2088 _clip.NativeObject.reset();
2089 _clip.NativeObject.add(value.NativeObject);
2092 internal void SetClip(float x,float y,float width,float height,CombineMode combineMode) {
2093 CombineClipArea(new geom.Area(
2094 new geom.Rectangle2D.Float(x,y,width,height)),combineMode);
2097 void CombineClipArea(geom.Area area, CombineMode combineMode) {
2098 geom.AffineTransform t = GetFinalTransform();
2099 if (!t.isIdentity())
2101 if (combineMode == CombineMode.Replace) {
2102 _clip.NativeObject.reset();
2103 _clip.NativeObject.add(area);
2106 geom.Area curClip = _clip.NativeObject;
2107 switch(combineMode) {
2108 case CombineMode.Complement:
2111 case CombineMode.Exclude:
2112 curClip.subtract(area);
2114 case CombineMode.Intersect:
2115 curClip.intersect(area);
2117 case CombineMode.Union:
2120 case CombineMode.Xor:
2121 curClip.exclusiveOr(area);
2124 throw new ArgumentOutOfRangeException();
2129 NativeObject.clip(_clip);
2132 internal void IntersectScaledClipWithBase(awt.Shape clip) {
2133 NativeObject.clip(clip);
2136 void RestoreBaseClip() {
2137 if (_nextGraphicsState == null) {
2138 NativeObject.setClip(_windowRect);
2142 _nextGraphicsState.RestoreBaseClip(this);
2147 #region TransformPoints
2149 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts) {
2150 //TBD:CoordinateSpace
2151 java.awt.geom.AffineTransform tr = this.Transform.NativeObject;
2152 float[] fpts = new float[2];
2153 for(int i = 0; i< pts.Length; i++) {
2156 tr.transform(fpts, 0, fpts, 0, 1);
2163 public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts) {
2164 //TBD:CoordinateSpace
2165 java.awt.geom.AffineTransform tr = this.Transform.NativeObject;
2166 float[] fpts = new float[2];
2167 for(int i = 0; i< pts.Length; i++) {
2170 tr.transform(fpts, 0, fpts, 0, 1);
2171 pts[i].X = (int)fpts[0];
2172 pts[i].Y = (int)fpts[1];
2177 #region TranslateClip
2178 public void TranslateClip (int dx, int dy) {
2179 TranslateClip((float)dx, (float)dy);
2183 public void TranslateClip (float dx, float dy) {
2186 geom.AffineTransform f = GetFinalTransform();
2188 if (!f.isIdentity()) {
2189 double[] p = new double[] {x, y};
2190 f.deltaTransform(p, 0, p, 0, 1);
2196 // It seems .Net does exactly this...
2197 x = Math.Floor(x+0.96875);
2198 y = Math.Floor(y+0.96875);
2200 geom.AffineTransform t = geom.AffineTransform.getTranslateInstance(x, y);
2202 _clip.NativeObject.transform(t);
2204 NativeObject.clip(_clip);
2208 #region TranslateTransform
2209 public void TranslateTransform (float dx, float dy) {
2210 TranslateTransform (dx, dy, MatrixOrder.Prepend);
2214 public void TranslateTransform (float dx, float dy, MatrixOrder order) {
2215 ConcatenateTransform(
2216 geom.AffineTransform.getTranslateInstance(dx, dy),
2221 #region Properties [Partial TODO]
2222 public Region Clip {
2224 Region r = _clip.Clone();
2225 geom.AffineTransform t = GetFinalTransform();
2226 if (!t.isIdentity())
2227 r.NativeObject.transform(t.createInverse());
2232 SetClip (value, CombineMode.Replace);
2236 public RectangleF ClipBounds {
2238 awt.Shape shape = _clip.NativeObject;
2240 shape = Region.InfiniteRegion.NativeObject;
2242 geom.RectangularShape r = shape.getBounds2D();
2243 geom.AffineTransform t = GetFinalTransform();
2244 if (!t.isIdentity()) {
2245 geom.AffineTransform it = t.createInverse();
2246 r = it.createTransformedShape(r).getBounds2D();
2249 return new RectangleF (r);
2253 public CompositingMode CompositingMode {
2254 //TBD:check this carefully
2256 return (NativeObject.getComposite() == awt.AlphaComposite.SrcOver) ?
2257 CompositingMode.SourceOver : CompositingMode.SourceCopy;
2260 NativeObject.setComposite(
2261 (value == CompositingMode.SourceOver) ?
2262 awt.AlphaComposite.SrcOver : awt.AlphaComposite.Src);
2267 public CompositingQuality CompositingQuality {
2269 awt.RenderingHints hints = NativeObject.getRenderingHints();
2270 if(hints.containsKey(awt.RenderingHints.KEY_ALPHA_INTERPOLATION)) {
2271 object value_ai = hints.get(awt.RenderingHints.KEY_ALPHA_INTERPOLATION);
2273 if (value_ai == awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED)
2274 return CompositingQuality.HighSpeed;
2275 if (value_ai == awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY)
2276 return CompositingQuality.HighQuality;
2277 if (value_ai == awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT)
2278 return CompositingQuality.Default;
2281 return CompositingQuality.Default;
2285 awt.RenderingHints hints = NativeObject.getRenderingHints();
2287 case CompositingQuality.AssumeLinear:
2288 case CompositingQuality.Default:
2289 case CompositingQuality.GammaCorrected:
2290 hints.put(awt.RenderingHints.KEY_ALPHA_INTERPOLATION,
2291 awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT);
2293 case CompositingQuality.HighQuality:
2294 hints.put(awt.RenderingHints.KEY_ALPHA_INTERPOLATION,
2295 awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
2297 case CompositingQuality.HighSpeed:
2298 hints.put(awt.RenderingHints.KEY_ALPHA_INTERPOLATION,
2299 awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED);
2301 // case CompositingQuality.Invalid:
2302 // if(hints.containsKey(awt.RenderingHints.KEY_ALPHA_INTERPOLATION))
2303 // hints.remove(awt.RenderingHints.KEY_ALPHA_INTERPOLATION);
2306 NativeObject.setRenderingHints(hints);
2313 return _image.HorizontalResolution;
2315 return DefaultScreenResolution;
2322 return _image.VerticalResolution;
2324 return DefaultScreenResolution;
2328 public InterpolationMode InterpolationMode {
2330 awt.RenderingHints hints = NativeObject.getRenderingHints();
2331 if(hints.containsKey(awt.RenderingHints.KEY_INTERPOLATION)) {
2332 object value_i = hints.get(awt.RenderingHints.KEY_INTERPOLATION);
2334 if (value_i == awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR)
2335 return InterpolationMode.Bilinear;
2336 if (value_i == awt.RenderingHints.VALUE_INTERPOLATION_BICUBIC)
2337 return InterpolationMode.Bicubic;
2338 if (value_i == awt.RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR)
2339 return InterpolationMode.NearestNeighbor;
2342 return InterpolationMode.Default;
2345 awt.RenderingHints hints = NativeObject.getRenderingHints();
2348 case InterpolationMode.Bicubic:
2349 case InterpolationMode.HighQualityBicubic:
2350 case InterpolationMode.Low:
2351 hints.put(awt.RenderingHints.KEY_INTERPOLATION, awt.RenderingHints.VALUE_INTERPOLATION_BICUBIC);
2353 case InterpolationMode.High:
2354 case InterpolationMode.Bilinear:
2355 case InterpolationMode.HighQualityBilinear:
2356 hints.put(awt.RenderingHints.KEY_INTERPOLATION, awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR);
2358 case InterpolationMode.Default:
2359 if (hints.containsKey(awt.RenderingHints.KEY_INTERPOLATION))
2360 hints.remove(awt.RenderingHints.KEY_INTERPOLATION);
2362 case InterpolationMode.NearestNeighbor:
2363 hints.put(awt.RenderingHints.KEY_INTERPOLATION, awt.RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
2365 case InterpolationMode.Invalid:
2366 throw new ArgumentException();
2368 throw new ArgumentOutOfRangeException();
2371 NativeObject.setRenderingHints(hints);
2375 public bool IsClipEmpty {
2377 return _clip.IsEmpty(this);
2381 public bool IsVisibleClipEmpty {
2383 if (_clip.IsEmpty(this))
2386 return VisibleClipBounds.IsEmpty;
2390 public float PageScale {
2399 public GraphicsUnit PageUnit {
2408 static internal geom.AffineTransform GetFinalTransform(
2409 geom.AffineTransform transform, GraphicsUnit pageUnit, float pageScale) {
2410 geom.AffineTransform t = null;
2411 if (pageUnit != GraphicsUnit.Display) {
2412 float scale = pageScale * _unitConversion[ (int)pageUnit ];
2413 if (Math.Abs(scale-1f) > float.Epsilon)
2414 t = geom.AffineTransform.getScaleInstance(scale, scale);
2418 t.concatenate(transform);
2425 internal geom.AffineTransform GetFinalTransform() {
2426 return GetFinalTransform(_transform.NativeObject, PageUnit, PageScale);
2429 public PixelOffsetMode PixelOffsetMode {
2431 return _pixelOffsetMode;
2434 _pixelOffsetMode = value;
2439 public Point RenderingOrigin {
2441 throw new NotImplementedException();
2444 throw new NotImplementedException();
2448 public SmoothingMode SmoothingMode {
2450 awt.RenderingHints hints = NativeObject.getRenderingHints();
2451 if(hints.containsKey(awt.RenderingHints.KEY_ANTIALIASING)) {
2452 object value_aa = hints.get(awt.RenderingHints.KEY_ANTIALIASING);
2453 if (value_aa == awt.RenderingHints.VALUE_ANTIALIAS_ON) {
2454 if(hints.containsKey(awt.RenderingHints.KEY_RENDERING)) {
2455 object value_render = hints.get(awt.RenderingHints.KEY_RENDERING);
2456 if (value_render == awt.RenderingHints.VALUE_RENDER_QUALITY)
2457 return SmoothingMode.HighQuality;
2458 if (value_render == awt.RenderingHints.VALUE_RENDER_SPEED)
2459 return SmoothingMode.HighSpeed;
2462 return SmoothingMode.AntiAlias;
2465 if (value_aa == awt.RenderingHints.VALUE_ANTIALIAS_DEFAULT)
2466 return SmoothingMode.Default;
2468 return SmoothingMode.None;
2473 awt.RenderingHints hints = NativeObject.getRenderingHints();
2476 case SmoothingMode.None:
2477 if(hints.containsKey(awt.RenderingHints.KEY_ANTIALIASING))
2478 hints.remove(awt.RenderingHints.KEY_ANTIALIASING);
2479 if(hints.containsKey(awt.RenderingHints.KEY_RENDERING))
2480 hints.remove(awt.RenderingHints.KEY_RENDERING);
2482 case SmoothingMode.AntiAlias:
2483 hints.put(awt.RenderingHints.KEY_ANTIALIASING, awt.RenderingHints.VALUE_ANTIALIAS_ON);
2485 case SmoothingMode.HighQuality:
2486 hints.put(awt.RenderingHints.KEY_RENDERING, awt.RenderingHints.VALUE_RENDER_QUALITY);
2487 goto case SmoothingMode.AntiAlias;
2488 case SmoothingMode.HighSpeed:
2489 hints.put(awt.RenderingHints.KEY_RENDERING, awt.RenderingHints.VALUE_RENDER_SPEED);
2490 goto case SmoothingMode.None;
2491 case SmoothingMode.Default:
2492 hints.put(awt.RenderingHints.KEY_RENDERING, awt.RenderingHints.VALUE_RENDER_DEFAULT);
2493 goto case SmoothingMode.AntiAlias;
2494 case SmoothingMode.Invalid:
2495 throw new ArgumentException("Invalid parameter used.");
2498 NativeObject.setRenderingHints(hints);
2503 /// Java does not have similar functionality
2505 public int TextContrast {
2507 return _textContrast;
2511 _textContrast = value;
2515 public TextRenderingHint TextRenderingHint {
2517 return _textRenderingHint;
2518 // awt.RenderingHints hints = NativeObject.getRenderingHints();
2519 // if(hints.containsKey(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING)) {
2520 // if(hints.get(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING) ==
2521 // java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON)
2522 // return TextRenderingHint.AntiAlias;
2523 // if(hints.get(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING) ==
2524 // java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_OFF)
2525 // return TextRenderingHint.SingleBitPerPixel;
2527 // //return TextRenderingHint.SystemDefault;
2528 // return TextRenderingHint.SingleBitPerPixelGridFit;
2532 _textRenderingHint = value;
2533 awt.RenderingHints hints = NativeObject.getRenderingHints();
2535 case TextRenderingHint.AntiAlias:
2536 case TextRenderingHint.AntiAliasGridFit:
2537 case TextRenderingHint.ClearTypeGridFit:
2538 // case TextRenderingHint.SystemDefault:
2539 hints.put(awt.RenderingHints.KEY_TEXT_ANTIALIASING,
2540 awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
2543 case TextRenderingHint.SingleBitPerPixelGridFit:
2544 hints.put(awt.RenderingHints.KEY_TEXT_ANTIALIASING,
2545 awt.RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
2548 case TextRenderingHint.SingleBitPerPixel:
2549 hints.put(awt.RenderingHints.KEY_TEXT_ANTIALIASING,
2550 awt.RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
2553 case TextRenderingHint.SystemDefault:
2554 hints.put(awt.RenderingHints.KEY_TEXT_ANTIALIASING,
2555 awt.RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
2559 NativeObject.setRenderingHints(hints);
2563 public Matrix Transform {
2565 return _transform.Clone();
2569 throw new ArgumentNullException("matrix");
2571 if (!value.IsInvertible)
2572 throw new ArgumentException("Invalid parameter used.");
2574 value.CopyTo(_transform);
2578 internal Matrix BaseTransform {
2580 return new Matrix(NativeObject.getTransform());
2583 NativeObject.setTransform(value.NativeObject);
2587 internal void PrependBaseTransform(geom.AffineTransform t) {
2588 NativeObject.transform(t);
2591 internal awt.Shape VisibleShape {
2597 public RectangleF VisibleClipBounds {
2599 if (_clip.IsEmpty(this))
2600 return RectangleF.Empty;
2602 geom.Rectangle2D r = _clip.NativeObject.getBounds2D();
2603 awt.Shape clip = NativeObject.getClip();
2604 geom.Rectangle2D clipBounds = (clip != null) ? clip.getBounds2D() : _windowRect;
2605 geom.Rectangle2D.intersect(r, clipBounds, r);
2606 if ((r.getWidth() <= 0) || (r.getHeight() <= 0))
2607 return RectangleF.Empty;
2609 geom.AffineTransform t = GetFinalTransform();
2610 if (!t.isIdentity()) {
2611 geom.AffineTransform it = t.createInverse();
2612 r = it.createTransformedShape(r).getBounds2D();
2615 return new RectangleF (r);
2619 void ConcatenateTransform(geom.AffineTransform transform, MatrixOrder order) {
2620 geom.AffineTransform at = _transform.NativeObject;
2621 Matrix.Multiply(at, transform, order);