Ejemplo n.º 1
0
        /// <summary> Moves the current pen position to a new location without drawing. In SWF, this requires a
        /// style change record and a delta is calculated between the current position and the
        /// new position.
        /// <p/>
        /// If fill or line style information has changed since the last move command, the new style
        /// information is also included in the record.
        ///
        /// </summary>
        /// <param name="x">
        /// </param>
        /// <param name="y">
        /// </param>
        public void  move(double x, double y)
        {
            double dx = x - start.x;             //dx is delta from origin-x to final-x
            double dy = y - start.y;             //dy is delta from origin-y to final-y

            if (convertToTwips)
            {
                dx *= flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL;
                dy *= flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL;
            }

            StyleChangeRecord scr = new StyleChangeRecord();

            //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
            scr.setMove((int)System.Math.Round((double)dx), (int)System.Math.Round((double)dy));

            //Reset rounding counters, as this info is only useful per sub-shape/fill closure
            dxSumTwips = 0;
            dySumTwips = 0;

            //Check styles
            if (lineStyleHasChanged)
            {
                scr.Linestyle       = lineStyle;
                lineStyleHasChanged = false;
            }

            if (fillStyle0HasChanged && useFillStyle0)
            {
                scr.FillStyle0       = fillStyle0;
                fillStyle0HasChanged = false;
            }

            if (fillStyle1HasChanged && useFillStyle1)
            {
                scr.FillStyle1       = fillStyle1;
                fillStyle1HasChanged = false;
            }

            lastMoveTo.x = x;
            lastMoveTo.y = y;
            pen.x        = x;
            pen.y        = y;

            shape.shapeRecords.Add(scr);
        }
Ejemplo n.º 2
0
		public virtual void  styleChange(SaxAttributesSupport attributes)
		{
			StyleChangeRecord styleChange = new StyleChangeRecord();
			if (hasAttribute(attributes, "dx") || hasAttribute(attributes, "dy"))
			{
				styleChange.stateMoveTo = true;
				styleChange.moveDeltaX = parseInt(getAttribute(attributes, "dx"));
				styleChange.moveDeltaY = parseInt(getAttribute(attributes, "dy"));
			}
			if (hasAttribute(attributes, "fillStyle0"))
			{
				styleChange.stateFillStyle0 = true;
				styleChange.fillstyle0 = parseInt(getAttribute(attributes, "fillStyle0"));
			}
			if (hasAttribute(attributes, "fillStyle1"))
			{
				styleChange.stateFillStyle1 = true;
				styleChange.fillstyle1 = parseInt(getAttribute(attributes, "fillStyle1"));
			}
			if (hasAttribute(attributes, "lineStyle"))
			{
				styleChange.stateLineStyle = true;
				styleChange.linestyle = parseInt(getAttribute(attributes, "lineStyle"));
			}
			styleChange.fillstyles = new System.Collections.ArrayList();
			styleChange.linestyles = new System.Collections.ArrayList();
			fillstyles = styleChange.fillstyles;
			linestyles = styleChange.linestyles;
			stack.Add(styleChange);
		}
Ejemplo n.º 3
0
		private void  encodeStyleChangeRecord(SwfEncoder w, StyleChangeRecord s, int[] numFillBits, int[] numLineBits, int shape)
		{
			w.writeBit(s.stateNewStyles);
			w.writeBit(s.stateLineStyle);
			w.writeBit(s.stateFillStyle1);
			w.writeBit(s.stateFillStyle0);
			w.writeBit(s.stateMoveTo);
			
			if (s.stateMoveTo)
			{
				int moveBits = s.nMoveBits();
				w.writeUBits(moveBits, 5);
				w.writeSBits(s.moveDeltaX, moveBits);
				w.writeSBits(s.moveDeltaY, moveBits);
			}
			
			if (s.stateFillStyle0)
			{
				w.writeUBits(s.fillstyle0, numFillBits[0]);
			}
			
			if (s.stateFillStyle1)
			{
				w.writeUBits(s.fillstyle1, numFillBits[0]);
			}
			
			if (s.stateLineStyle)
			{
				w.writeUBits(s.linestyle, numLineBits[0]);
			}
			
			if (s.stateNewStyles)
			{
				w.flushBits();
				
				encodeFillstyles(s.fillstyles, w, shape);
				encodeLinestyles(s.linestyles, w, shape);
				
				numFillBits[0] = SwfEncoder.minBits(s.fillstyles.Count, 0);
				numLineBits[0] = SwfEncoder.minBits(s.linestyles.Count, 0);
				w.writeUBits(numFillBits[0], 4);
				w.writeUBits(numLineBits[0], 4);
			}
		}
        /// <summary> Utility method that calculates the minimum bounding rectangle that encloses a list
        /// of ShapeRecords, taking into account the possible maximum stroke width of any of the
        /// supplied linestyles.
        /// </summary>
        /// <param name="records">
        /// </param>
        /// <param name="lineStyles">
        /// </param>
        /// <returns>
        /// </returns>
        public static Rect getBounds(System.Collections.IList records, System.Collections.IList lineStyles)
        {
            if (records == null || records.Count == 0)
            {
                return(new Rect());
            }
            else
            {
                int  x1        = 0;
                int  y1        = 0;
                int  x2        = 0;
                int  y2        = 0;
                int  x         = 0;
                int  y         = 0;
                bool firstMove = true;

                System.Collections.IEnumerator it = records.GetEnumerator();
                //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
                while (it.MoveNext())
                {
                    //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
                    ShapeRecord r = (ShapeRecord)it.Current;
                    if (r == null)
                    {
                        continue;
                    }

                    if (r is StyleChangeRecord)
                    {
                        StyleChangeRecord scr = (StyleChangeRecord)r;
                        x = scr.moveDeltaX;
                        y = scr.moveDeltaY;
                        if (firstMove)
                        {
                            x1        = x;
                            y1        = y;
                            x2        = x;
                            y2        = y;
                            firstMove = false;
                        }
                    }
                    else if (r is StraightEdgeRecord)
                    {
                        StraightEdgeRecord ser = (StraightEdgeRecord)r;
                        x = x + ser.deltaX;
                        y = y + ser.deltaY;
                    }
                    else if (r is CurvedEdgeRecord)
                    {
                        CurvedEdgeRecord cer = (CurvedEdgeRecord)r;
                        x = x + cer.controlDeltaX + cer.anchorDeltaX;
                        y = y + cer.controlDeltaY + cer.anchorDeltaY;
                    }

                    if (x < x1)
                    {
                        x1 = x;
                    }
                    if (y < y1)
                    {
                        y1 = y;
                    }
                    if (x > x2)
                    {
                        x2 = x;
                    }
                    if (y > y2)
                    {
                        y2 = y;
                    }
                }

                if (lineStyles != null && lineStyles.Count > 0)
                {
                    it = lineStyles.GetEnumerator();
                    int width = flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL;
                    //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
                    while (it.MoveNext())
                    {
                        //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
                        LineStyle ls = (LineStyle)it.Current;
                        if (ls == null)
                        {
                            continue;
                        }
                        else
                        {
                            if (width < ls.width)
                            {
                                width = ls.width;
                            }
                        }
                    }

                    //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                    double stroke = (int)System.Math.Round((double)(width * 0.5));
                    //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                    x1 = (int)System.Math.Round((double)(x1 - stroke));
                    //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                    y1 = (int)System.Math.Round((double)(y1 - stroke));
                    //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                    x2 = (int)System.Math.Round((double)(x2 + stroke));
                    //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                    y2 = (int)System.Math.Round((double)(y2 + stroke));
                }

                return(new Rect(x1, x2, y1, y2));
            }
        }
Ejemplo n.º 5
0
		/// <summary> Moves the current pen position to a new location without drawing. In SWF, this requires a
		/// style change record and a delta is calculated between the current position and the
		/// new position.
		/// <p/>
		/// If fill or line style information has changed since the last move command, the new style
		/// information is also included in the record.
		/// 
		/// </summary>
		/// <param name="x">
		/// </param>
		/// <param name="y">
		/// </param>
		public void  move(double x, double y)
		{
			double dx = x - start.x; //dx is delta from origin-x to final-x
			double dy = y - start.y; //dy is delta from origin-y to final-y
			
			if (convertToTwips)
			{
				dx *= flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL;
				dy *= flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL;
			}
			
			StyleChangeRecord scr = new StyleChangeRecord();
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			scr.setMove((int) System.Math.Round((double) dx), (int) System.Math.Round((double) dy));
			
			//Reset rounding counters, as this info is only useful per sub-shape/fill closure
			dxSumTwips = 0;
			dySumTwips = 0;
			
			//Check styles
			if (lineStyleHasChanged)
			{
				scr.Linestyle = lineStyle;
				lineStyleHasChanged = false;
			}
			
			if (fillStyle0HasChanged && useFillStyle0)
			{
				scr.FillStyle0 = fillStyle0;
				fillStyle0HasChanged = false;
			}
			
			if (fillStyle1HasChanged && useFillStyle1)
			{
				scr.FillStyle1 = fillStyle1;
				fillStyle1HasChanged = false;
			}
			
			lastMoveTo.x = x;
			lastMoveTo.y = y;
			pen.x = x;
			pen.y = y;
			
			shape.shapeRecords.Add(scr);
		}