Ejemplo n.º 1
0
 /**
  * Constructs a new <code>AdvancedStroke</code> with the specified
  * attributes.
  * @param width the width of this <code>AdvancedStroke</code>.  The
  *         width must be greater than or equal to 0.0f.  If width is
  *         set to 0.0f, the stroke is rendered as the thinnest
  *         possible line for the target device and the antialias
  *         hint setting.
  * @param cap the decoration of the ends of a <code>AdvancedStroke</code>
  * @param join the decoration applied where path segments meet
  * @param miterlimit the limit to trim the miter join.  The miterlimit
  *        must be greater than or equal to 1.0f.
  * @param dash the array representing the dashing pattern
  * @param dash_phase the offset to start the dashing pattern
  * @throws IllegalArgumentException if <code>width</code> is negative
  * @throws IllegalArgumentException if <code>cap</code> is not either
  *         CAP_BUTT, CAP_ROUND or CAP_SQUARE
  * @throws IllegalArgumentException if <code>miterlimit</code> is less
  *         than 1 and <code>join</code> is JOIN_MITER
  * @throws IllegalArgumentException if <code>join</code> is not
  *         either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER
  * @throws IllegalArgumentException if <code>dash_phase</code>
  *         is negative and <code>dash</code> is not <code>null</code>
  * @throws IllegalArgumentException if the length of
  *         <code>dash</code> is zero
  * @throws IllegalArgumentException if dash lengths are all zero.
  */
 public AdvancedStroke(float width, int cap, int join, float miterlimit,
                       float[] dash, float dash_phase, AffineTransform penTransform,
                       AffineTransform outputTransform, PenFit penFit)
 {
     if (width < 0.0f)
     {
         throw new IllegalArgumentException("negative width");
     }
     if (cap != CAP_BUTT && cap != CAP_ROUND && cap != CAP_SQUARE)
     {
         throw new IllegalArgumentException("illegal end cap value");
     }
     if (join == JOIN_MITER)
     {
         if (miterlimit < 1.0f)
         {
             throw new IllegalArgumentException("miter limit < 1");
         }
     }
     else if (join != JOIN_ROUND && join != JOIN_BEVEL)
     {
         throw new IllegalArgumentException("illegal line join value");
     }
     if (dash != null)
     {
         if (dash_phase < 0.0f)
         {
             throw new IllegalArgumentException("negative dash phase");
         }
         bool allzero = true;
         for (int i = 0; i < dash.Length; i++)
         {
             float d = dash[i];
             if (d > 0.0)
             {
                 allzero = false;
             }
             else if (d < 0.0)
             {
                 throw new IllegalArgumentException("negative dash length");
             }
         }
         if (allzero)
         {
             throw new IllegalArgumentException("dash lengths all zero");
         }
     }
     this.width      = width;
     this.cap        = cap;
     this.join       = join;
     this.miterlimit = miterlimit;
     if (dash != null)
     {
         this.dash = (float [])dash.Clone();
     }
     this.dash_phase       = dash_phase;
     this._penTransform    = penTransform;
     this._outputTransform = outputTransform;
     this._penFit          = penFit;
 }
Ejemplo n.º 2
0
			public awt.Stroke Create(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase, geom.AffineTransform penTransform,
				geom.AffineTransform outputTransform, PenFit penFit) {
				if ((penFit == PenFit.NotThin) &&
					(outputTransform == null || outputTransform.isIdentity()) &&
					(penTransform == null || penTransform.isIdentity()))
					return new awt.BasicStroke(width, cap, join, miterlimit, dash, dash_phase);
				return new System.Drawing.AdvancedStroke(width, cap, join, miterlimit, dash, dash_phase, penTransform, outputTransform, penFit);
			}
Ejemplo n.º 3
0
 public awt.Stroke Create(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase, geom.AffineTransform penTransform,
                          geom.AffineTransform outputTransform, PenFit penFit)
 {
     if ((penFit == PenFit.NotThin) &&
         (outputTransform == null || outputTransform.isIdentity()) &&
         (penTransform == null || penTransform.isIdentity()))
     {
         return(new awt.BasicStroke(width, cap, join, miterlimit, dash, dash_phase));
     }
     return(new System.Drawing.AdvancedStroke(width, cap, join, miterlimit, dash, dash_phase, penTransform, outputTransform, penFit));
 }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="outputTransform">transform which will be applied on the final shape</param>
        /// <param name="fitPen">ensure the shape will wide enough to be visible</param>
        /// <returns></returns>
        internal awt.Stroke GetNativeObject(geom.AffineTransform penTransform, geom.AffineTransform outputTransform, PenFit penFit)
        {
            float[] dashPattern = null;

            switch (DashStyle)
            {
            case DashStyle.Custom:
                if (_dashPattern != null)
                {
                    dashPattern = new float[_dashPattern.Length];
                    for (int i = 0; i < _dashPattern.Length; i++)
                    {
                        if (EndCap == LineCap.Flat)
                        {
                            dashPattern[i] = _dashPattern[i] * Width;
                        }
                        else
                        {
                            if ((i & 1) == 0)
                            {
                                // remove the size of caps from the opaque parts
                                dashPattern[i] = (_dashPattern[i] * Width) - Width;
                                if (_dashPattern[i] < 0)
                                {
                                    dashPattern[i] = 0;
                                }
                            }
                            else
                            {
                                // add the size of caps to the transparent parts
                                dashPattern[i] = (_dashPattern[i] * Width) + Width;
                            }
                        }
                    }
                }
                break;

            case DashStyle.Dash:
                dashPattern = DASH_ARRAY;
                break;

            case DashStyle.DashDot:
                dashPattern = DASHDOT_ARRAY;
                break;

            case DashStyle.DashDotDot:
                dashPattern = DASHDOTDOT_ARRAY;
                break;

                //				default:
                //				case DashStyle.Solid:
                //					break;
            }

            int join;

            switch (LineJoin)
            {
            case LineJoin.Bevel:
                join = java.awt.BasicStroke.JOIN_BEVEL;
                break;

            default:
            case LineJoin.Miter:
            case LineJoin.MiterClipped:
                join = java.awt.BasicStroke.JOIN_MITER;
                break;

            case LineJoin.Round:
                join = java.awt.BasicStroke.JOIN_ROUND;
                break;
            }

            // We go by End cap for now.
            int cap;

            switch (EndCap)
            {
            default:
            case LineCap.Square:
            case LineCap.SquareAnchor:
                cap = awt.BasicStroke.CAP_SQUARE;
                break;

            case LineCap.Round:
            case LineCap.RoundAnchor:
                cap = awt.BasicStroke.CAP_ROUND;
                break;

            case LineCap.Flat:
                cap = awt.BasicStroke.CAP_BUTT;
                break;
            }

            geom.AffineTransform penT = _transform.NativeObject;
            if (penTransform != null && !penTransform.isIdentity())
            {
                penT = (geom.AffineTransform)penT.clone();
                penT.concatenate(penTransform);
            }

            return(StrokeFactory.CreateStroke(Width, cap,
                                              join, MiterLimit, dashPattern, DashOffset,
                                              penT, outputTransform, penFit));
        }
Ejemplo n.º 5
0
 internal awt.Stroke GetNativeObject(geom.AffineTransform outputTransform, PenFit penFit)
 {
     return(GetNativeObject(null, outputTransform, penFit));
 }
Ejemplo n.º 6
0
 static public awt.Stroke CreateStroke(float width, int cap, int join, float miterlimit,
                                       float[] dash, float dash_phase, geom.AffineTransform penTransform,
                                       geom.AffineTransform outputTransform, PenFit penFit)
 {
     return(Creator.Create(width, cap, join, miterlimit, dash, dash_phase, penTransform, outputTransform, penFit));
 }
Ejemplo n.º 7
0
		/**
		 * Constructs a new <code>AdvancedStroke</code> with the specified
		 * attributes.
		 * @param width the width of this <code>AdvancedStroke</code>.  The
		 *         width must be greater than or equal to 0.0f.  If width is
		 *         set to 0.0f, the stroke is rendered as the thinnest
		 *         possible line for the target device and the antialias
		 *         hint setting.
		 * @param cap the decoration of the ends of a <code>AdvancedStroke</code>
		 * @param join the decoration applied where path segments meet
		 * @param miterlimit the limit to trim the miter join.  The miterlimit
		 *        must be greater than or equal to 1.0f.
		 * @param dash the array representing the dashing pattern
		 * @param dash_phase the offset to start the dashing pattern
		 * @throws IllegalArgumentException if <code>width</code> is negative
		 * @throws IllegalArgumentException if <code>cap</code> is not either
		 *         CAP_BUTT, CAP_ROUND or CAP_SQUARE
		 * @throws IllegalArgumentException if <code>miterlimit</code> is less
		 *         than 1 and <code>join</code> is JOIN_MITER
		 * @throws IllegalArgumentException if <code>join</code> is not
		 *         either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER
		 * @throws IllegalArgumentException if <code>dash_phase</code>
		 *         is negative and <code>dash</code> is not <code>null</code>
		 * @throws IllegalArgumentException if the length of
		 *         <code>dash</code> is zero
		 * @throws IllegalArgumentException if dash lengths are all zero.
		 */
		public AdvancedStroke(float width, int cap, int join, float miterlimit,
			float[] dash, float dash_phase, AffineTransform penTransform,
			AffineTransform outputTransform, PenFit penFit) {
			if (width < 0.0f) {
				throw new IllegalArgumentException("negative width");
			}
			if (cap != CAP_BUTT && cap != CAP_ROUND && cap != CAP_SQUARE) {
				throw new IllegalArgumentException("illegal end cap value");
			}
			if (join == JOIN_MITER) {
				if (miterlimit < 1.0f) {
					throw new IllegalArgumentException("miter limit < 1");
				}
			} else if (join != JOIN_ROUND && join != JOIN_BEVEL) {
				throw new IllegalArgumentException("illegal line join value");
			}
			if (dash != null) {
				if (dash_phase < 0.0f) {
					throw new IllegalArgumentException("negative dash phase");
				}
				bool allzero = true;
				for (int i = 0; i < dash.Length; i++) {
					float d = dash[i];
					if (d > 0.0) {
						allzero = false;
					} else if (d < 0.0) {
						throw new IllegalArgumentException("negative dash length");
					}
				}
				if (allzero) {
					throw new IllegalArgumentException("dash lengths all zero");
				}
			}
			this.width	= width;
			this.cap	= cap;
			this.join	= join;
			this.miterlimit	= miterlimit;
			if (dash != null) {
				this.dash = (float []) dash.Clone();
			}
			this.dash_phase	= dash_phase;
			this._penTransform = penTransform;
			this._outputTransform = outputTransform;
			this._penFit = penFit;
		}
Ejemplo n.º 8
0
		static public awt.Stroke CreateStroke(float width, int cap, int join, float miterlimit,
			float[] dash, float dash_phase, geom.AffineTransform penTransform,
			geom.AffineTransform outputTransform, PenFit penFit) {

			return Creator.Create(width, cap, join, miterlimit, dash, dash_phase, penTransform, outputTransform, penFit);
		}
Ejemplo n.º 9
0
			public awt.Stroke Create(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase, geom.AffineTransform penTransform,
				geom.AffineTransform outputTransform, PenFit penFit) {
				return new awt.BasicStroke(width, cap, join, miterlimit, dash, dash_phase);
			}
Ejemplo n.º 10
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="outputTransform">transform which will be applied on the final shape</param>
		/// <param name="fitPen">ensure the shape will wide enough to be visible</param>
		/// <returns></returns>
		internal awt.Stroke GetNativeObject(geom.AffineTransform penTransform, geom.AffineTransform outputTransform, PenFit penFit) {
			float[] dashPattern = null;

			switch (DashStyle) {
				case DashStyle.Custom:
					if (_dashPattern != null) {
						dashPattern = new float[_dashPattern.Length];
						for(int i = 0; i < _dashPattern.Length; i++) {

							if (EndCap == LineCap.Flat)
								dashPattern[i] = _dashPattern[i] * Width;
							else {
								if ((i & 1) == 0) {
									// remove the size of caps from the opaque parts
									dashPattern[i] = (_dashPattern[i] * Width) - Width;
									if (_dashPattern[i] < 0)
										dashPattern[i] = 0;
								}
								else
									// add the size of caps to the transparent parts
									dashPattern[i] = (_dashPattern[i] * Width) + Width;
							}
						}
					}
					break;
				case DashStyle.Dash:
					dashPattern = DASH_ARRAY;
					break;
				case DashStyle.DashDot:
					dashPattern = DASHDOT_ARRAY;
					break;
				case DashStyle.DashDotDot:
					dashPattern = DASHDOTDOT_ARRAY;
					break;
				
					//				default:
					//				case DashStyle.Solid:
					//					break;
			}

			int join;
			switch (LineJoin) {
				case LineJoin.Bevel:
					join = java.awt.BasicStroke.JOIN_BEVEL;
					break;
				default:
				case LineJoin.Miter:
				case LineJoin.MiterClipped:
					join = java.awt.BasicStroke.JOIN_MITER;
					break;
				case LineJoin.Round:
					join = java.awt.BasicStroke.JOIN_ROUND;
					break;
			}

			// We go by End cap for now.
			int cap;
			switch (EndCap) {
				default:
				case LineCap.Square:
				case LineCap.SquareAnchor:
					cap = awt.BasicStroke.CAP_SQUARE;
					break;
				case LineCap.Round: 
				case LineCap.RoundAnchor:
					cap = awt.BasicStroke.CAP_ROUND;
					break;
				case LineCap.Flat:
					cap = awt.BasicStroke.CAP_BUTT;
					break;
			}

			geom.AffineTransform penT = _transform.NativeObject;
			if (penTransform != null && !penTransform.isIdentity()) {
				penT = (geom.AffineTransform) penT.clone();
				penT.concatenate(penTransform);
			}

			return StrokeFactory.CreateStroke(Width, cap, 
				join, MiterLimit, dashPattern, DashOffset,
				penT, outputTransform, penFit);
		}
Ejemplo n.º 11
0
		internal awt.Stroke GetNativeObject(geom.AffineTransform outputTransform, PenFit penFit) {
			return GetNativeObject(null, outputTransform, penFit);
		}