/// <summary> /// Returns the location of the destination point given a /// point in the source. If dstPt is non-null, it will /// be used to hold the return value. Since this is not a geometric /// operation, the srcPt will equal the dstPt. </summary> /// <param name="srcPt"> a point in the source image </param> /// <param name="dstPt"> the destination point or <code>null</code> </param> /// <returns> the location of the destination point. </returns> public Point2D GetPoint2D(Point2D srcPt, Point2D dstPt) { if (dstPt == null) { dstPt = new Point2D.Float(); } dstPt.SetLocation(srcPt.X, srcPt.Y); return(dstPt); }
public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) { if (dstPt == null) { dstPt = new Point2D.Float(); } dstPt.setLocation(srcPt.getX(), srcPt.getY()); return(dstPt); }
/** * Appends a straight line segment from the current point to the point <CODE>(x, y)</CODE>. */ public virtual void LineTo(float x, float y) { if (currentPoint == null) { throw new Exception(START_PATH_ERR_MSG); } Point2D targetPoint = new Point2D.Float(x, y); this.LastSubpath.AddSegment(new Line(currentPoint, targetPoint)); currentPoint = targetPoint; }
/// <summary> /// Constructs a simple acyclic <code>GradientPaint</code> object. </summary> /// <param name="pt1"> the first specified <code>Point</code> in user space </param> /// <param name="color1"> <code>Color</code> at the first specified /// <code>Point</code> </param> /// <param name="pt2"> the second specified <code>Point</code> in user space </param> /// <param name="color2"> <code>Color</code> at the second specified /// <code>Point</code> </param> /// <exception cref="NullPointerException"> if either one of colors or points /// is null </exception> public GradientPaint(Point2D pt1, Color color1, Point2D pt2, Color color2) { if ((color1 == null) || (color2 == null) || (pt1 == null) || (pt2 == null)) { throw new NullPointerException("Colors and points should be non-null"); } P1 = new Point2D.Float((float)pt1.X, (float)pt1.Y); P2 = new Point2D.Float((float)pt2.X, (float)pt2.Y); this.Color1_Renamed = color1; this.Color2_Renamed = color2; }
/// <summary> /// Constructs a simple acyclic <code>GradientPaint</code> object. </summary> /// <param name="x1"> x coordinate of the first specified /// <code>Point</code> in user space </param> /// <param name="y1"> y coordinate of the first specified /// <code>Point</code> in user space </param> /// <param name="color1"> <code>Color</code> at the first specified /// <code>Point</code> </param> /// <param name="x2"> x coordinate of the second specified /// <code>Point</code> in user space </param> /// <param name="y2"> y coordinate of the second specified /// <code>Point</code> in user space </param> /// <param name="color2"> <code>Color</code> at the second specified /// <code>Point</code> </param> /// <exception cref="NullPointerException"> if either one of colors is null </exception> public GradientPaint(float x1, float y1, Color color1, float x2, float y2, Color color2) { if ((color1 == null) || (color2 == null)) { throw new NullPointerException("Colors cannot be null"); } P1 = new Point2D.Float(x1, y1); P2 = new Point2D.Float(x2, y2); this.Color1_Renamed = color1; this.Color2_Renamed = color2; }
/** * Appends a cubic Bezier curve to the current path. The curve shall extend from * the current point to the point <CODE>(x3, y3)</CODE>. */ public virtual void CurveTo(float x1, float y1, float x2, float y2, float x3, float y3) { if (currentPoint == null) { throw new Exception(START_PATH_ERR_MSG); } // Numbered in natural order Point2D secondPoint = new Point2D.Float(x1, y1); Point2D thirdPoint = new Point2D.Float(x2, y2); Point2D fourthPoint = new Point2D.Float(x3, y3); IList <Point2D> controlPoints = new List <Point2D>(new Point2D[] { currentPoint, secondPoint, thirdPoint, fourthPoint }); this.LastSubpath.AddSegment(new BezierCurve(controlPoints)); currentPoint = fourthPoint; }
/// <summary> /// Applies Affine transformation to point /// </summary> /// <param name="point"></param> /// <param name="transormationMatrix"></param> /// <returns></returns> private Point Transform(Point point, Matrix transormationMatrix) { var transformMatrix = new AffineTransform(transormationMatrix[Matrix.I11], transormationMatrix[Matrix.I12], transormationMatrix[Matrix.I21], transormationMatrix[Matrix.I22], transormationMatrix[Matrix.I31], transormationMatrix[Matrix.I32]); var dst = new Point2D.Float(); transformMatrix.Transform(new Point2D.Float(point.X, point.Y), dst); if (_pageRotation == 0) { return(new Point(dst.x, _pageHeight - dst.y)); } if (_pageRotation == 90) { return(new Point(dst.x, dst.y)); } throw new Exception("Current page rotation is not handled"); }
public void transform(Point2D[] src, int srcOff, Point2D[] dst, int dstOff, int length) { while (--length >= 0) { Point2D srcPoint = src[srcOff++]; double x = srcPoint.getX(); double y = srcPoint.getY(); Point2D dstPoint = dst[dstOff]; if (dstPoint == null) { if (srcPoint is Point2D.Double) { dstPoint = new Point2D.Double(); } else { dstPoint = new Point2D.Float(); } } dstPoint.setLocation(x * m00 + y * m01 + m02, x * m10 + y * m11 + m12); dst[dstOff++] = dstPoint; } }
public Point2D transform(Point2D src, Point2D dst) { if (dst == null) { if (src is Point2D.Double) { dst = new Point2D.Double(); } else { dst = new Point2D.Float(); } } double x = src.getX(); double y = src.getY(); dst.setLocation(x * m00 + y * m01 + m02, x * m10 + y * m11 + m12); return dst; }
public Point2D inverseTransform(Point2D src, Point2D dst) { //throws NoninvertibleTransformException { double det = getDeterminant(); if (java.lang.Math.abs(det) < ZERO) { // awt.204=Determinant is zero throw new NoninvertibleTransformException("Determinant is zero"); //$NON-NLS-1$ } if (dst == null) { if (src is Point2D.Double) { dst = new Point2D.Double(); } else { dst = new Point2D.Float(); } } double x = src.getX() - m02; double y = src.getY() - m12; dst.setLocation((x * m11 - y * m01) / det, (y * m00 - x * m10) / det); return dst; }