示例#1
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));
 }
示例#2
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));
        }