Esempio n. 1
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 13JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Sets the location, size, angular extents, and closure type of
  * this arc to the specified values.
  *
  * @param loc The <CODE>Point</CODE> representing the coordinates of
  * the upper-left corner of the arc.
  * @param size The <CODE>Dimension</CODE> representing the width
  * and height of the full ellipse of which this arc is
  * a partial section.
  * @param angSt The starting angle of the arc in degrees.
  * @param angExt The angular extent of the arc in degrees.
  * @param closure The closure type for the arc:
  * {@link #OPEN}, {@link #CHORD}, or {@link #PIE}.
  */
 public void SetArc(Point loc, Dimension size,
            double angSt, double angExt, int closure)
 {
     SetArc(loc.GetX(), loc.GetY(), size.GetWidth(), size.GetHeight(),
            angSt, angExt, closure);
 }
Esempio n. 2
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 13JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Sets the position, bounds, and angular extents of this arc to the
  * specified Value. The starting angle of the arc is tangent to the
  * line specified by points (p1, p2), the ending angle is tangent to
  * the line specified by points (p2, p3), and the arc has the
  * specified radius.
  *
  * @param p1 The first point that defines the arc. The starting
  * angle of the arc is tangent to the line specified by points (p1, p2).
  * @param p2 The second point that defines the arc. The starting
  * angle of the arc is tangent to the line specified by points (p1, p2).
  * The ending angle of the arc is tangent to the line specified by
  * points (p2, p3).
  * @param p3 The third point that defines the arc. The ending angle
  * of the arc is tangent to the line specified by points (p2, p3).
  * @param radius The radius of the arc.
  */
 public void SetArcByTangent(Point p1, Point p2, Point p3,
             double radius)
 {
     double ang1 = MathEx.Atan2(p1.GetY() - p2.GetY(),
                  p1.GetX() - p2.GetX());
     double ang2 = MathEx.Atan2(p3.GetY() - p2.GetY(),
                  p3.GetX() - p2.GetX());
     double diff = ang2 - ang1;
     if (diff > MathEx.PI)
     {
         ang2 -= MathEx.PI * 2.0;
     }
     else if (diff < -MathEx.PI)
     {
         ang2 += MathEx.PI * 2.0;
     }
     double bisect = (ang1 + ang2) / 2.0;
     double theta = MathEx.Abs(ang2 - bisect);
     double dist = radius / MathEx.Sin(theta);
     double xp = p2.GetX() + dist * MathEx.Cos(bisect);
     double yp = p2.GetY() + dist * MathEx.Sin(bisect);
     // REMIND: This needs some work...
     if (ang1 < ang2)
     {
         ang1 -= MathEx.PI / 2.0;
         ang2 += MathEx.PI / 2.0;
     }
     else
     {
         ang1 += MathEx.PI / 2.0;
         ang2 -= MathEx.PI / 2.0;
     }
     ang1 = MathEx.ToDegrees(-ang1);
     ang2 = MathEx.ToDegrees(-ang2);
     diff = ang2 - ang1;
     if (diff < 0)
     {
         diff += 360;
     }
     else
     {
         diff -= 360;
     }
     SetArcByCenter(xp, yp, radius, ang1, diff, _type);
 }
Esempio n. 3
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 13JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * {@inheritDoc}
  */
 public bool Contains(Point p)
 {
     return Contains(p.GetX(), p.GetY());
 }
Esempio n. 4
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * {@inheritDoc}
         */
        public bool Contains(Point p)
        {
            return(Contains(p.GetX(), p.GetY()));
        }
Esempio n. 5
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 13JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Returns the distance from this <code>Point</code> to a
  * specified <code>Point</code>.
  *
  * @param pt the specified point to be measured
  *           against this <code>Point</code>
  * @return the distance between this <code>Point</code> and
  * the specified <code>Point</code>.
  */
 public int Distance(Point pt)
 {
     int px = pt.GetX() - GetX();
     int py = pt.GetY() - GetY();
     long disSq = px * px + py * py;
     long dis = MathFP.Sqrt(disSq << MathFP.DEFAULT_PRECISION);
     return MathFP.ToInt(dis);
 }
Esempio n. 6
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 13JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Sets the location of the end points and control point of this
  * <code>QuadCurve</code> to the specified <code>Point</code>
  * coordinates.
  * @param p1 the start point
  * @param cp the control point
  * @param p2 the end point
  */
 public void SetCurve(Point p1, Point cp, Point p2)
 {
     SetCurve(p1.GetX(), p1.GetY(),
             cp.GetX(), cp.GetY(),
             p2.GetX(), p2.GetY());
 }
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 02NOV2008  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Sets the location and size of the framing rectangle of this
  * <code>IShape</code> to the specified {@link Point} and
  * {@link Dimension}, respectively.  The framing rectangle is used
  * by the subclasses of <code>RectangularShape</code> to define
  * their geometry.
  * @param loc the specified <code>Point</code>
  * @param size the specified <code>Dimension</code>
  */
 public void SetFrame(Point loc, Dimension size)
 {
     SetFrame(loc.GetX(), loc.GetY(), size.GetWidth(), size.GetHeight());
 }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * Inverse transforms the specified <code>ptSrc</code> and stores the
         * result in <code>ptDst</code>.
         * If <code>ptDst</code> is <code>null</code>, a new
         * <code>Point</code> object is allocated and then the result of the
         * transform is stored in this object.
         * In either case, <code>ptDst</code>, which contains the transformed
         * point, is returned for convenience.
         * If <code>ptSrc</code> and <code>ptDst</code> are the same
         * object, the input point is correctly overwritten with the
         * transformed point.
         * @param ptSrc the point to be inverse transformed
         * @param ptDst the resulting transformed point
         * @return <code>ptDst</code>, which contains the result of the
         * inverse transform.
         * @exception NoninvertibleTransformException  if the matrix cannot be
         *                                         inverted.
         */
        public Point InverseTransform(Point ptSrc, Point ptDst)
        {
            if (ptDst == null)
            {
                ptDst = new Point();
            }
            // Copy source coords into local variables in case src == dst
            double x = ptSrc.GetX();
            double y = ptSrc.GetY();
            switch (_state)
            {
                default:
                    StateError();
                    return ptDst;
                case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
                    {
                        x -= _m02;
                        y -= _m12;
                        double det = _m00 * _m11 - _m01 * _m10;
                        if (Math.Abs(det) <= double.MinValue)
                        {
                            throw new NoninvertibleTransformException("Determinant is " +
                                                                      det);
                        }
                        ptDst.SetLocation(Round((x * _m11 - y * _m01) / det),
                                          Round((y * _m00 - x * _m10) / det));
                        return ptDst;
                    }
                case (APPLY_SHEAR | APPLY_SCALE):
                    {
                        double det = _m00 * _m11 - _m01 * _m10;
                        if (Math.Abs(det) <= double.MinValue)
                        {
                            throw new NoninvertibleTransformException("Determinant is " +
                                                                      det);
                        }
                        ptDst.SetLocation(Round((x * _m11 - y * _m01) / det),
                                          Round((y * _m00 - x * _m10) / det));
                        return ptDst;
                    }
                case (APPLY_SHEAR | APPLY_TRANSLATE):
                    x -= _m02;
                    y -= _m12;
                    if (_m01 == 0.0 || _m10 == 0.0)
                    {
                        throw new NoninvertibleTransformException("Determinant is 0");
                    }
                    ptDst.SetLocation(Round(y / _m10),
                                Round(x / _m01));
                    return ptDst;
                case (APPLY_SHEAR):
                    if (_m01 == 0.0 || _m10 == 0.0)
                    {
                        throw new NoninvertibleTransformException("Determinant is 0");
                    }
                    ptDst.SetLocation(Round(y / _m10),
                                Round(x / _m01));
                    return ptDst;
                case (APPLY_SCALE | APPLY_TRANSLATE):
                    x -= _m02;
                    y -= _m12;
                    if (_m00 == 0.0 || _m11 == 0.0)
                    {
                        throw new NoninvertibleTransformException("Determinant is 0");
                    }
                    ptDst.SetLocation(Round(x / _m00),
                                Round(y / _m11));
                    return ptDst;
                case (APPLY_SCALE):
                    if (_m00 == 0.0 || _m11 == 0.0)
                    {
                        throw new NoninvertibleTransformException("Determinant is 0");
                    }
                    ptDst.SetLocation(Round(x / _m00),
                                Round(y / _m11));
                    return ptDst;
                case (APPLY_TRANSLATE):
                    ptDst.SetLocation(Round(x - _m02), Round(y - _m12));
                    return ptDst;
                case (APPLY_IDENTITY):
                    ptDst.SetLocation(Round(x), Round(y));
                    return ptDst;
            }

            /* NOTREACHED */
        }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 02NOV2008  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Sets the framing rectangle of this <code>IShape</code> based on a
         * specified center <code>Point</code> and corner
         * <code>Point</code>.  The framing rectangle is used by the subclasses
         * of <code>RectangularShape</code> to define their geometry.
         * @param center the specified center <code>Point</code>
         * @param corner the specified corner <code>Point</code>
         */
        public void SetFrameFromCenter(Point center, Point corner)
        {
            SetFrameFromCenter(center.GetX(), center.GetY(),
                               corner.GetX(), corner.GetY());
        }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 15JUN2009  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * Constructs a {@code LinearGradientBrush}.
         *
         * @param start the gradient axis start {@code Point} in user space
         * @param end the gradient axis end {@code Point} in user space
         * @param fractions numbers ranging from 0 to 255 specifying the
         *                  distribution of colors along the gradient
         * @param colors array of colors corresponding to each fractional Value
         * @param fillType either {@code NO_CYCLE}, {@code REFLECT},
         *                    or {@code REPEAT}
         * @param gradientTransform transform to apply to the gradient
         *
         * @throws NullPointerException
         * if one of the points is null,
         * or {@code fractions} array is null,
         * or {@code colors} array is null,
         * or {@code cycleMethod} is null,
         * or {@code colorSpace} is null,
         * or {@code gradientTransform} is null
         * @throws IllegalArgumentException
         * if start and end points are the same points,
         * or {@code fractions.length != colors.length},
         * or {@code colors} is less than 2 in size,
         * or a {@code fractions} Value is less than 0.0 or greater than 1.0,
         * or the {@code fractions} are not provided in strictly increasing order
         */
        public LinearGradientBrush(Point start, Point end,
                int[] fractions, Color[] colors,
                AffineTransform gradientTransform, int fillType)
        {
            if (fractions == null)
            {
                throw new NullReferenceException("Fractions array cannot be null");
            }

            if (colors == null)
            {
                throw new NullReferenceException("Colors array cannot be null");
            }

            if (gradientTransform == null)
            {
                throw new NullReferenceException("Gradient transform cannot be " +
                        "null");
            }

            if (fractions.Length != colors.Length)
            {
                throw new ArgumentException("Colors and fractions must " +
                        "have equal size");
            }

            if (colors.Length < 2)
            {
                throw new ArgumentException("User must specify at least " +
                        "2 colors");
            }

            // check that values are in the proper range and progress
            // in increasing order from 0 to 1
            int previousFraction = -255;
            for (int i = 0; i < fractions.Length; i++)
            {
                int currentFraction = fractions[i];
                if (currentFraction < 0 || currentFraction > 255)
                {
                    throw new ArgumentException("Fraction values must " +
                            "be in the range 0 to 255: " +
                            currentFraction);
                }

                if (currentFraction <= previousFraction)
                {
                    throw new ArgumentException("Keyframe fractions " +
                            "must be increasing: " +
                            currentFraction);
                }

                previousFraction = currentFraction;
            }

            // We have to deal with the cases where the first gradient stop is not
            // equal to 0 and/or the last gradient stop is not equal to 1.
            // In both cases, create a new point and replicate the previous
            // extreme point's color.
            bool fixFirst = false;
            bool fixLast = false;
            int len = fractions.Length;
            int off = 0;

            if (fractions[0] != 0)
            {
                // first stop is not equal to zero, fix this condition
                fixFirst = true;
                len++;
                off++;
            }
            if (fractions[fractions.Length - 1] != 255)
            {
                // last stop is not equal to one, fix this condition
                fixLast = true;
                len++;
            }

            this._fractions = new int[len];
            Array.Copy(fractions, 0, this._fractions, off, fractions.Length);
            this._colors = new Color[len];
            Array.Copy(colors, 0, this._colors, off, colors.Length);

            if (fixFirst)
            {
                this._fractions[0] = 0;
                this._colors[0] = colors[0];
            }
            if (fixLast)
            {
                this._fractions[len - 1] = 255;
                this._colors[len - 1] = colors[colors.Length - 1];
            }

            // copy the gradient transform
            this._gradientTransform = new AffineTransform(gradientTransform);

            // determine transparency
            bool opaque = true;
            for (int i = 0; i < colors.Length; i++)
            {
                opaque = opaque && (colors[i].GetAlpha() == 0xff);
            }
            _transparency = opaque ? Color.OPAQUE : Color.TRANSLUCENT;

            // check input parameters
            if (start == null || end == null)
            {
                throw new NullReferenceException("Start and end points must be" +
                        "non-null");
            }

            if (start.Equals(end))
            {
                throw new ArgumentException("Start point cannot equal" +
                        "endpoint");
            }

            // copy the points...
            this._start = new Point(start.GetX(), start.GetY());
            this._end = new Point(end.GetX(), end.GetY());

            Rectangle rectangle = new Rectangle(start, end);
            float dx = start.X - end.X;
            float dy = start.Y - end.Y;
            double angle = MathEx.Atan2(dy, dx);
            int intAngle = SingleFP.FromDouble(angle);
            RectangleFP r = Utils.ToRectangleFP(rectangle);
            _wrappedBrushFP = new LinearGradientBrushFP(r.GetLeft(), r.GetTop(),
                    r.GetRight(), r.GetBottom(),
                    intAngle);
            for (int i = 0; i < colors.Length; i++)
            {
                ((LinearGradientBrushFP)_wrappedBrushFP).SetGradientColor
                        (SingleFP.FromFloat(fractions[i] / 100.0f),
                        colors[i]._value);
            }
            ((LinearGradientBrushFP)_wrappedBrushFP).UpdateGradientTable();
            _wrappedBrushFP.SetMatrix(Utils.ToMatrixFP(gradientTransform));
            _wrappedBrushFP.FillMode = fillType;
        }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 02NOV2008  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Sets the diagonal of the framing rectangle of this <code>IShape</code>
         * based on two specified <code>Point</code> objects.  The framing
         * rectangle is used by the subclasses of <code>RectangularShape</code>
         * to define their geometry.
         *
         * @param p1 the start <code>Point</code> of the specified diagonal
         * @param p2 the end <code>Point</code> of the specified diagonal
         */
        public void SetFrameFromDiagonal(Point p1, Point p2)
        {
            SetFrameFromDiagonal(p1.GetX(), p1.GetY(), p2.GetX(), p2.GetY());
        }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 02NOV2008  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Sets the location and size of the framing rectangle of this
         * <code>IShape</code> to the specified {@link Point} and
         * {@link Dimension}, respectively.  The framing rectangle is used
         * by the subclasses of <code>RectangularShape</code> to define
         * their geometry.
         * @param loc the specified <code>Point</code>
         * @param size the specified <code>Dimension</code>
         */
        public void SetFrame(Point loc, Dimension size)
        {
            SetFrame(loc.GetX(), loc.GetY(), size.GetWidth(), size.GetHeight());
        }
Esempio n. 13
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 13JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Returns the square of the distance from this
  * <code>Point</code> to a specified <code>Point</code>.
  *
  * @param pt the specified point to be measured
  *           against this <code>Point</code>
  * @return the square of the distance between this
  * <code>Point</code> to a specified <code>Point</code>.
  */
 public int DistanceSq(Point pt)
 {
     int px = pt.GetX() - GetX();
     int py = pt.GetY() - GetY();
     return (px * px + py * py);
 }
Esempio n. 14
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 13JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Sets the starting angle and angular extent of this arc using
  * two points. The first point is used to determine the angle of
  * the starting point relative to the arc's center.
  * The second point is used to determine the angle of the end point
  * relative to the arc's center.
  * The arc will always be non-empty and extend counterclockwise
  * from the first point around to the second point.
  *
  * @param p1 The <CODE>Point</CODE> that defines the arc's
  * starting point.
  * @param p2 The <CODE>Point</CODE> that defines the arc's
  * ending point.
  */
 public void SetAngles(Point p1, Point p2)
 {
     SetAngles(p1.GetX(), p1.GetY(), p2.GetX(), p2.GetY());
 }
Esempio n. 15
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 02NOV2008  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Sets the framing rectangle of this <code>IShape</code> based on a
  * specified center <code>Point</code> and corner
  * <code>Point</code>.  The framing rectangle is used by the subclasses
  * of <code>RectangularShape</code> to define their geometry.
  * @param center the specified center <code>Point</code>
  * @param corner the specified corner <code>Point</code>
  */
 public void SetFrameFromCenter(Point center, Point corner)
 {
     SetFrameFromCenter(center.GetX(), center.GetY(),
                corner.GetX(), corner.GetY());
 }
Esempio n. 16
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 13JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Sets the starting angle of this arc to the angle that the
  * specified point defines relative to the center of this arc.
  * The angular extent of the arc will remain the same.
  *
  * @param p The <CODE>Point</CODE> that defines the starting angle.
  */
 public void SetAngleStart(Point p)
 {
     // Bias the dx and dy by the height and width of the oval.
     double dx = GetHeight() * (p.GetX() - GetCenterX());
     double dy = GetWidth() * (p.GetY() - GetCenterY());
     SetAngleStart(-MathEx.ToDegrees(MathEx.Atan2(dy, dx)));
 }
Esempio n. 17
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 02NOV2008  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Sets the diagonal of the framing rectangle of this <code>IShape</code>
  * based on two specified <code>Point</code> objects.  The framing
  * rectangle is used by the subclasses of <code>RectangularShape</code>
  * to define their geometry.
  *
  * @param p1 the start <code>Point</code> of the specified diagonal
  * @param p2 the end <code>Point</code> of the specified diagonal
  */
 public void SetFrameFromDiagonal(Point p1, Point p2)
 {
     SetFrameFromDiagonal(p1.GetX(), p1.GetY(), p2.GetX(), p2.GetY());
 }
Esempio n. 18
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * Transforms the specified <code>ptSrc</code> and stores the result
         * in <code>ptDst</code>.
         * If <code>ptDst</code> is <code>null</code>, a new Point
         * object is allocated and then the result of the transformation is
         * stored in this object.
         * In either case, <code>ptDst</code>, which contains the
         * transformed point, is returned for convenience.
         * If <code>ptSrc</code> and <code>ptDst</code> are the same
         * object, the input point is correctly overwritten with
         * the transformed point.
         * @param ptSrc the specified <code>Point</code> to be transformed
         * @param ptDst the specified <code>Point</code> that stores the
         * result of transforming <code>ptSrc</code>
         * @return the <code>ptDst</code> after transforming
         * <code>ptSrc</code> and stroring the result in <code>ptDst</code>.
         */
        public Point Transform(Point ptSrc, Point ptDst)
        {
            if (ptDst == null)
            {
                ptDst = new Point();
            }
            // Copy source coords into local variables in case src == dst
            double x = ptSrc.GetX();
            double y = ptSrc.GetY();
            switch (_state)
            {
                default:
                    StateError();
                    return ptDst;
                case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
                    ptDst.SetLocation(Round(x * _m00 + y * _m01 + _m02),
                              Round(x * _m10 + y * _m11 + _m12));
                    return ptDst;
                case (APPLY_SHEAR | APPLY_SCALE):
                    ptDst.SetLocation(Round(x * _m00 + y * _m01),
                                Round(x * _m10 + y * _m11));
                    return ptDst;
                case (APPLY_SHEAR | APPLY_TRANSLATE):
                    ptDst.SetLocation(Round(y * _m01 + _m02),
                                Round(x * _m10 + _m12));
                    return ptDst;
                case (APPLY_SHEAR):
                    ptDst.SetLocation(Round(y * _m01),
                                Round(x * _m10));
                    return ptDst;
                case (APPLY_SCALE | APPLY_TRANSLATE):
                    ptDst.SetLocation(Round(x * _m00 + _m02),
                                Round(y * _m11 + _m12));
                    return ptDst;
                case (APPLY_SCALE):
                    ptDst.SetLocation(Round(x * _m00),
                                Round(y * _m11));
                    return ptDst;
                case (APPLY_TRANSLATE):
                    ptDst.SetLocation(Round(x + _m02),
                                Round(y + _m12));
                    return ptDst;
                case (APPLY_IDENTITY):
                    ptDst.SetLocation(Round(x), Round(y));
                    return ptDst;
            }

            /* NOTREACHED */
        }
Esempio n. 19
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 13JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Determines where the specified {@link Point} lies with
  * respect to this <code>Rectangle</code>.
  * This method computes a binary OR of the appropriate mask values
  * indicating, for each side of this <code>Rectangle</code>,
  * whether or not the specified <code>Point</code> is on the same
  * side of the edge as the rest of this <code>Rectangle</code>.
  * @param p the specified <code>Point</code>
  * @return the logical OR of all appropriate out codes.
  */
 public int Outcode(Point p)
 {
     return Outcode(p.GetX(), p.GetY());
 }