private void curveRecord(int[] delta) { CurvedEdgeRecord cer = new CurvedEdgeRecord(); cer.setControlDeltaX(delta[0]); cer.setControlDeltaY(delta[1]); cer.setAnchorDeltaX(delta[2]); cer.setAnchorDeltaY(delta[3]); shape.addShapeRecord(cer); }
/** * @see SWFReader#readCurvedEdgeRecord */ private void writeCurvedEdgeRecord(CurvedEdgeRecord shape) { tagBuffer.writeBit(true); // This is an edge. Always 1. tagBuffer.writeBit(false); // StraightFlag is always false. int numBits = shape.getNumBits(); tagBuffer.writeUB(numBits, 4); tagBuffer.writeSB(shape.getControlDeltaX(), numBits + 2); tagBuffer.writeSB(shape.getControlDeltaY(), numBits + 2); tagBuffer.writeSB(shape.getAnchorDeltaX(), numBits + 2); tagBuffer.writeSB(shape.getAnchorDeltaY(), numBits + 2); }
private static boolean curveControlPointInsideCurrentRect(int x0, int y0, CurvedEdgeRecord curve, Rect currRect) { int x = x0 + curve.getControlDeltaX(); int y = y0 + curve.getControlDeltaY(); //initialize xmin, ymin, xmax, ymax to the control points of curve int xmin = x0, xmax = x0; int ymin = y0, ymax = y0; if (x < xmin) xmin = x; if (y < ymin) ymin = y; if (x > xmax) xmax = x; if (y > ymax) ymax = y; if ((currRect.xMin() < xmin) && (currRect.xMax() > xmax) && (currRect.yMin() < ymin) && (currRect.yMax() > ymax)) return true; else return false; }
private static boolean curveControlPointInsideCurrentRect(int x0, int y0, CurvedEdgeRecord curve, Rect currRect) { int x = x0 + curve.getControlDeltaX(); int y = y0 + curve.getControlDeltaY(); //initialize xmin, ymin, xmax, ymax to the control points of curve int xmin = x0, xmax = x0; int ymin = y0, ymax = y0; if (x < xmin) xmin = x; if (y < ymin) ymin = y; if (x > xmax) xmax = x; if (y > ymax) ymax = y; if ((currRect.xMin() < xmin) && (currRect.xMax() > xmax) && (currRect.yMin() < ymin) && (currRect.yMax() > ymax)) return true; else return false; }
/** * @see SWFReader#readCurvedEdgeRecord */ private void writeCurvedEdgeRecord(CurvedEdgeRecord shape) { tagBuffer.writeBit(true); // This is an edge. Always 1. tagBuffer.writeBit(false); // StraightFlag is always false. int numBits = shape.getNumBits(); tagBuffer.writeUB(numBits, 4); tagBuffer.writeSB(shape.getControlDeltaX(), numBits + 2); tagBuffer.writeSB(shape.getControlDeltaY(), numBits + 2); tagBuffer.writeSB(shape.getAnchorDeltaX(), numBits + 2); tagBuffer.writeSB(shape.getAnchorDeltaY(), numBits + 2); }
private void curveRecord(int[] delta) { CurvedEdgeRecord cer = new CurvedEdgeRecord(); cer.setControlDeltaX(delta[0]); cer.setControlDeltaY(delta[1]); cer.setAnchorDeltaX(delta[2]); cer.setAnchorDeltaY(delta[3]); shape.addShapeRecord(cer); }
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; }
int day = (int)anchorY - (int)controlY; CurvedEdgeRecord cer = new CurvedEdgeRecord(); cer.setControlDeltaX(dcx); cer.setControlDeltaY(dcy); cer.setAnchorDeltaX(dax); cer.setAnchorDeltaY(day); return cer;
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; }
int day = (int)anchorY - (int)controlY; CurvedEdgeRecord cer = new CurvedEdgeRecord(); cer.setControlDeltaX(dcx); cer.setControlDeltaY(dcy); cer.setAnchorDeltaX(dax); cer.setAnchorDeltaY(day); return cer;
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 CurvedEdgeRecord readCurvedEdgeRecord() throws IOException { final CurvedEdgeRecord curvedEdgeRecord = new CurvedEdgeRecord(); final int nbits = 2 + bitStream.readUB(4); curvedEdgeRecord.setControlDeltaX(bitStream.readSB(nbits)); curvedEdgeRecord.setControlDeltaY(bitStream.readSB(nbits)); curvedEdgeRecord.setAnchorDeltaX(bitStream.readSB(nbits)); curvedEdgeRecord.setAnchorDeltaY(bitStream.readSB(nbits)); return curvedEdgeRecord; }
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 CurvedEdgeRecord readCurvedEdgeRecord() throws IOException { final CurvedEdgeRecord curvedEdgeRecord = new CurvedEdgeRecord(); final int nbits = 2 + bitStream.readUB(4); curvedEdgeRecord.setControlDeltaX(bitStream.readSB(nbits)); curvedEdgeRecord.setControlDeltaY(bitStream.readSB(nbits)); curvedEdgeRecord.setAnchorDeltaX(bitStream.readSB(nbits)); curvedEdgeRecord.setAnchorDeltaY(bitStream.readSB(nbits)); return curvedEdgeRecord; }
out.print(curvedEdge.getControlDeltaX() + "\t" + curvedEdge.getControlDeltaY() + "\t"); out.print(curvedEdge.getAnchorDeltaX() + "\t" + curvedEdge.getAnchorDeltaY()); x += (curvedEdge.getControlDeltaX() + curvedEdge.getAnchorDeltaX()); y += (curvedEdge.getControlDeltaY() + curvedEdge.getAnchorDeltaY());
out.print(curvedEdge.getControlDeltaX() + "\t" + curvedEdge.getControlDeltaY() + "\t"); out.print(curvedEdge.getAnchorDeltaX() + "\t" + curvedEdge.getAnchorDeltaY()); x += (curvedEdge.getControlDeltaX() + curvedEdge.getAnchorDeltaX()); y += (curvedEdge.getControlDeltaY() + curvedEdge.getAnchorDeltaY());
private static Rect computeCurveBounds(int x0, int y0, CurvedEdgeRecord curve) int x1 = x0 + curve.getControlDeltaX(); int y1 = y0 + curve.getControlDeltaY(); int x2 = x1 + curve.getAnchorDeltaX(); int y2 = y1 + curve.getAnchorDeltaY();
private static Rect computeCurveBounds(int x0, int y0, CurvedEdgeRecord curve) int x1 = x0 + curve.getControlDeltaX(); int y1 = y0 + curve.getControlDeltaY(); int x2 = x1 + curve.getAnchorDeltaX(); int y2 = y1 + curve.getAnchorDeltaY();
out.print("cdx=\"" + curvedEdge.getControlDeltaX() + "\" cdy=\"" + curvedEdge.getControlDeltaY() + "\" "); out.print("dx=\"" + curvedEdge.getAnchorDeltaX() + "\" dy=\"" + curvedEdge.getAnchorDeltaY() + "\" "); out.println("/>");
out.print("cdx=\"" + curvedEdge.getControlDeltaX() + "\" cdy=\"" + curvedEdge.getControlDeltaY() + "\" "); out.print("dx=\"" + curvedEdge.getAnchorDeltaX() + "\" dy=\"" + curvedEdge.getAnchorDeltaY() + "\" "); out.println("/>");