StraightEdgeRecord ser = new StraightEdgeRecord(dx, dy); shapeRecords.add(ser); return shapeRecords; StraightEdgeRecord ser = new StraightEdgeRecord(lastx, lasty); shapeRecords.add(ser); StraightEdgeRecord ser = new StraightEdgeRecord(xSeg, ySeg); shapeRecords.add(ser);
public StraightEdgeRecord(int deltaX, int deltaY) { this(); setDelta(deltaX, deltaY); }
private static int[][] getCoordinates(List<ShapeRecord> records) { int[][] coordinates = new int[records.size()][2]; ShapeRecord record; for(int i=0; i<records.size(); i++) { record = records.get(i); if (record instanceof StyleChangeRecord) { StyleChangeRecord scr = (StyleChangeRecord)record; coordinates[i][0] = scr.getMoveDeltaX(); coordinates[i][1] = scr.getMoveDeltaY(); } else if (record instanceof StraightEdgeRecord) { StraightEdgeRecord ser = (StraightEdgeRecord)record; coordinates[i][0] = coordinates[i-1][0] + ser.getDeltaX(); coordinates[i][1] = coordinates[i-1][1] + ser.getDeltaY(); } else if (record instanceof CurvedEdgeRecord) { CurvedEdgeRecord cer = (CurvedEdgeRecord)record; coordinates[i][0] = coordinates[i-1][0] + cer.getControlDeltaX() + cer.getAnchorDeltaX(); coordinates[i][1] = coordinates[i-1][1] + cer.getControlDeltaY() + cer.getAnchorDeltaY(); } } return coordinates; }
/** * @see SWFReader#readStraightEdgeRecord */ private void writeStraightEdgeRecord(StraightEdgeRecord shape) { tagBuffer.writeBit(true); // This is an edge. Always 1. tagBuffer.writeBit(true); // StraightFlag is always true. int numBits = shape.getNumBits(); tagBuffer.writeUB(numBits, 4); switch (shape.getLineType()) { case GENERAL: tagBuffer.writeBit(true); tagBuffer.writeSB(shape.getDeltaX(), numBits + 2); tagBuffer.writeSB(shape.getDeltaY(), numBits + 2); break; case VERTICAL: tagBuffer.writeBit(false); tagBuffer.writeBit(true); tagBuffer.writeSB(shape.getDeltaY(), numBits + 2); break; case HORIZONTAL: tagBuffer.writeBit(false); tagBuffer.writeBit(false); tagBuffer.writeSB(shape.getDeltaX(), numBits + 2); break; } }
private static int[][] getCoordinates(List<ShapeRecord> records) { int[][] coordinates = new int[records.size()][2]; ShapeRecord record; for(int i=0; i<records.size(); i++) { record = records.get(i); if (record instanceof StyleChangeRecord) { StyleChangeRecord scr = (StyleChangeRecord)record; coordinates[i][0] = scr.getMoveDeltaX(); coordinates[i][1] = scr.getMoveDeltaY(); } else if (record instanceof StraightEdgeRecord) { StraightEdgeRecord ser = (StraightEdgeRecord)record; coordinates[i][0] = coordinates[i-1][0] + ser.getDeltaX(); coordinates[i][1] = coordinates[i-1][1] + ser.getDeltaY(); } else if (record instanceof CurvedEdgeRecord) { CurvedEdgeRecord cer = (CurvedEdgeRecord)record; coordinates[i][0] = coordinates[i-1][0] + cer.getControlDeltaX() + cer.getAnchorDeltaX(); coordinates[i][1] = coordinates[i-1][1] + cer.getControlDeltaY() + cer.getAnchorDeltaY(); } } return coordinates; }
/** * @see SWFReader#readStraightEdgeRecord */ private void writeStraightEdgeRecord(StraightEdgeRecord shape) { tagBuffer.writeBit(true); // This is an edge. Always 1. tagBuffer.writeBit(true); // StraightFlag is always true. int numBits = shape.getNumBits(); tagBuffer.writeUB(numBits, 4); switch (shape.getLineType()) { case GENERAL: tagBuffer.writeBit(true); tagBuffer.writeSB(shape.getDeltaX(), numBits + 2); tagBuffer.writeSB(shape.getDeltaY(), numBits + 2); break; case VERTICAL: tagBuffer.writeBit(false); tagBuffer.writeBit(true); tagBuffer.writeSB(shape.getDeltaY(), numBits + 2); break; case HORIZONTAL: tagBuffer.writeBit(false); tagBuffer.writeBit(false); tagBuffer.writeSB(shape.getDeltaX(), numBits + 2); break; } }
StraightEdgeRecord ser = new StraightEdgeRecord(dx, dy); shapeRecords.add(ser); return shapeRecords; StraightEdgeRecord ser = new StraightEdgeRecord(lastx, lasty); shapeRecords.add(ser); StraightEdgeRecord ser = new StraightEdgeRecord(xSeg, ySeg); shapeRecords.add(ser);
public StraightEdgeRecord(int deltaX, int deltaY) { this(); setDelta(deltaX, deltaY); }
private void addLineSubdivideAware(int x, int y) { int limit = EdgeRecord.MAX_DELTA_IN_TWIPS; if (Math.abs(x) > limit || Math.abs(y) > limit) { int midXLeft = (int)Math.rint(Math.floor(x / 2.0)); int midYLeft = (int)Math.rint(Math.floor(y / 2.0)); int midXRight = (int)Math.rint(Math.ceil(x / 2.0)); int midYRight = (int)Math.rint(Math.ceil(y / 2.0)); if (Math.abs(midXLeft) > limit || Math.abs(midYLeft) > limit) addLineSubdivideAware(midXLeft, midYLeft); else shape.addShapeRecord(new StraightEdgeRecord(midXLeft, midYLeft)); if (Math.abs(midXRight) > limit || Math.abs(midYRight) > limit) addLineSubdivideAware(midXRight, midYRight); else shape.addShapeRecord(new StraightEdgeRecord(midXRight, midYRight)); } else { shape.addShapeRecord(new StraightEdgeRecord(x, y)); } }
private static Point getTangent(ShapeRecord curSegment, boolean start, int x, int y) { Point tangentPoint = new Point(); Point pt0 = new Point(x, y); if (curSegment instanceof StraightEdgeRecord) { Point pt1 = new Point(x+((StraightEdgeRecord)curSegment).getDeltaX(), y+((StraightEdgeRecord)curSegment).getDeltaY()); tangentPoint.x = pt1.x - pt0.x; tangentPoint.y = pt1.y - pt0.y; } else if (curSegment instanceof CurvedEdgeRecord) { Point pt1 = new Point(x+((CurvedEdgeRecord)curSegment).getControlDeltaX(), y+((CurvedEdgeRecord)curSegment).getControlDeltaY()); Point pt2 = new Point(pt1.x+((CurvedEdgeRecord)curSegment).getAnchorDeltaX(), pt1.y+((CurvedEdgeRecord)curSegment).getAnchorDeltaY()); tangentPoint = getQTangent(pt0.x, pt0.y, pt1.x, pt1.y, pt2.x, pt2.y, start); } return tangentPoint; }
private void addLineSubdivideAware(int x, int y) { int limit = EdgeRecord.MAX_DELTA_IN_TWIPS; if (Math.abs(x) > limit || Math.abs(y) > limit) { int midXLeft = (int)Math.rint(Math.floor(x / 2.0)); int midYLeft = (int)Math.rint(Math.floor(y / 2.0)); int midXRight = (int)Math.rint(Math.ceil(x / 2.0)); int midYRight = (int)Math.rint(Math.ceil(y / 2.0)); if (Math.abs(midXLeft) > limit || Math.abs(midYLeft) > limit) addLineSubdivideAware(midXLeft, midYLeft); else shape.addShapeRecord(new StraightEdgeRecord(midXLeft, midYLeft)); if (Math.abs(midXRight) > limit || Math.abs(midYRight) > limit) addLineSubdivideAware(midXRight, midYRight); else shape.addShapeRecord(new StraightEdgeRecord(midXRight, midYRight)); } else { shape.addShapeRecord(new StraightEdgeRecord(x, y)); } }
private static Point getTangent(ShapeRecord curSegment, boolean start, int x, int y) { Point tangentPoint = new Point(); Point pt0 = new Point(x, y); if (curSegment instanceof StraightEdgeRecord) { Point pt1 = new Point(x+((StraightEdgeRecord)curSegment).getDeltaX(), y+((StraightEdgeRecord)curSegment).getDeltaY()); tangentPoint.x = pt1.x - pt0.x; tangentPoint.y = pt1.y - pt0.y; } else if (curSegment instanceof CurvedEdgeRecord) { Point pt1 = new Point(x+((CurvedEdgeRecord)curSegment).getControlDeltaX(), y+((CurvedEdgeRecord)curSegment).getControlDeltaY()); Point pt2 = new Point(pt1.x+((CurvedEdgeRecord)curSegment).getAnchorDeltaX(), pt1.y+((CurvedEdgeRecord)curSegment).getAnchorDeltaY()); tangentPoint = getQTangent(pt0.x, pt0.y, pt1.x, pt1.y, pt2.x, pt2.y, start); } return tangentPoint; }
private StraightEdgeRecord readStraightEdgeRecord() throws IOException { StraightEdgeRecord straightEdgeRecord = null; final int nbits = 2 + bitStream.readUB(4); final boolean isGeneralLine = bitStream.readBit(); if (isGeneralLine) { final int dx = bitStream.readSB(nbits); final int dy = bitStream.readSB(nbits); straightEdgeRecord = new StraightEdgeRecord(dx, dy); } else { final boolean isVertLine = bitStream.readBit(); if (isVertLine) { final int dy = bitStream.readSB(nbits); straightEdgeRecord = new StraightEdgeRecord(0, dy); } else { final int dx = bitStream.readSB(nbits); straightEdgeRecord = new StraightEdgeRecord(dx, 0); } } return straightEdgeRecord; }
private StraightEdgeRecord readStraightEdgeRecord() throws IOException { StraightEdgeRecord straightEdgeRecord = null; final int nbits = 2 + bitStream.readUB(4); final boolean isGeneralLine = bitStream.readBit(); if (isGeneralLine) { final int dx = bitStream.readSB(nbits); final int dy = bitStream.readSB(nbits); straightEdgeRecord = new StraightEdgeRecord(dx, dy); } else { final boolean isVertLine = bitStream.readBit(); if (isVertLine) { final int dy = bitStream.readSB(nbits); straightEdgeRecord = new StraightEdgeRecord(0, dy); } else { final int dx = bitStream.readSB(nbits); straightEdgeRecord = new StraightEdgeRecord(dx, 0); } } return straightEdgeRecord; }
shapeRecords.add(new StraightEdgeRecord(0, -dya)); shapeRecords.add(new StraightEdgeRecord(dxa, 0)); shapeRecords.add(new StraightEdgeRecord(dxb, 0)); shapeRecords.add(new StraightEdgeRecord(dxc, 0)); shapeRecords.add(new StraightEdgeRecord(0, dya)); shapeRecords.add(new StraightEdgeRecord(0, dyb)); shapeRecords.add(new StraightEdgeRecord(0, dyc)); shapeRecords.add(new StraightEdgeRecord(-dxc, 0)); shapeRecords.add(new StraightEdgeRecord(-dxb, 0)); shapeRecords.add(new StraightEdgeRecord(-dxa, 0)); shapeRecords.add(new StraightEdgeRecord(0, -dyc)); shapeRecords.add(new StraightEdgeRecord(0, -dyb)); shapeRecords.add(new StraightEdgeRecord(0, dya)); shapeRecords.add(new StraightEdgeRecord(0, dyb)); shapeRecords.add(new StraightEdgeRecord(0, dyc)); shapeRecords.add(new StraightEdgeRecord(0, dya)); shapeRecords.add(new StraightEdgeRecord(0, dyb));