public virtual void line(SaxAttributesSupport attributes) { StraightEdgeRecord straightEdge = new StraightEdgeRecord(); if (hasAttribute(attributes, "dx")) { straightEdge.deltaX = parseInt(getAttribute(attributes, "dx")); } if (hasAttribute(attributes, "dy")) { straightEdge.deltaY = parseInt(getAttribute(attributes, "dy")); } DefineShape defineShape = (DefineShape) stack[stack.Count - 1]; defineShape.shapeWithStyle.shapeRecords.Add(straightEdge); }
private int calcBits(StraightEdgeRecord edge) { return SwfEncoder.minBits(SwfEncoder.maxNum(edge.deltaX, edge.deltaY, 0, 0), 1); }
private void encodeStraightEdgeRecord(StraightEdgeRecord line, SwfEncoder w, int nbits) { if (line.deltaX == 0) { w.writeUBits(1, 2); // vertical line w.writeSBits(line.deltaY, nbits); } else if (line.deltaY == 0) { w.writeUBits(0, 2); // horizontal line w.writeSBits(line.deltaX, nbits); } else { w.writeBit(true); // general line w.writeSBits(line.deltaX, nbits); w.writeSBits(line.deltaY, nbits); } }
/// <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)); } }