/* (non-Javadoc) * @see org.apache.batik.parser.PathHandler#curvetoCubicSmoothAbs(float, float, float, float) */ public void curvetoCubicSmoothAbs(float x2, float y2, float x, float y) throws ParseException { if (verbose) System.out.println("curvetoCubicSmoothAbs x2:" + x2 + " y2:" + y2 + " x:" + x + " y:" + y); Vertex lastPoint = pathPoints.getLast(); if (lastPoint instanceof BezierVertex) { BezierVertex lastBez = (BezierVertex) lastPoint; Vertex lastConPointCopy = (Vertex) lastBez.getSecondCtrlPoint().getCopy(); // reflect the last controlpoint at the current point lastConPointCopy.rotateZ(lastPoint, 180); BezierVertex b = new BezierVertex(lastConPointCopy.getX(), lastConPointCopy.getY(), 0, x2, y2, 0, x, y, 0); pathPoints.add(b); currentSubPath.add(b); } else { if (verbose) System.out.println( "Couldnt get last controlpoint at: curvetoCubicSmoothAbs - using last point as first controlpoint"); Vertex lastEndPoint = new Vertex(lastPoint.getX(), lastPoint.getY(), 0); BezierVertex b = new BezierVertex(lastEndPoint.getX(), lastEndPoint.getY(), 0, x2, y2, 0, x, y, 0); pathPoints.add(b); currentSubPath.add(b); } }
/* (non-Javadoc) * @see org.apache.batik.parser.PathHandler#curvetoQuadraticSmoothRel(float, float) */ public void curvetoQuadraticSmoothRel(float x, float y) throws ParseException { if (verbose) System.out.println("curvetoQuadraticSmoothRel: " + x + "," + y); Vertex lastPoint = pathPoints.getLast(); if (lastPoint instanceof BezierVertex && cubicBezVertTOQuadricControlPoint.get(lastPoint) != null) { Vertex lastEndPoint = new Vertex( pathPoints.getLast().getX(), pathPoints.getLast().getY(), pathPoints.getLast().getZ()); // Get control point of last QuadTo Vertex lastQuadControlPoint = cubicBezVertTOQuadricControlPoint.get(lastPoint); cubicBezVertTOQuadricControlPoint.remove(lastPoint); // Rotate that controlpoint around the end point of the last QuadTo lastQuadControlPoint.rotateZ(lastEndPoint, 180); // Put in startPoint = last QuadTo Endpoint of this smoothQuadTo, the calculated control // point, and the endpoint of smoothQuadTo BezierVertex b5 = Tools3D.getCubicFromQuadraticCurve( lastEndPoint, lastQuadControlPoint, new Vertex(lastPoint.getX() + x, lastPoint.getY() + y, 0)); // Save last quad control point cubicBezVertTOQuadricControlPoint.put(b5, lastQuadControlPoint); pathPoints.add(b5); currentSubPath.add(b5); } else { if (verbose) System.out.println( "couldnt get last control point at curvetoQuadraticSmoothRel - using last point as the control point"); Vertex lastEndPoint = new Vertex(lastPoint.getX(), lastPoint.getY(), 0); Vertex quadControlPoint = new Vertex(lastPoint.getX(), lastPoint.getY(), 0); BezierVertex b5 = Tools3D.getCubicFromQuadraticCurve( lastEndPoint, quadControlPoint, new Vertex(lastPoint.getX() + x, lastPoint.getY() + y, 0)); cubicBezVertTOQuadricControlPoint.put(b5, quadControlPoint); pathPoints.add(b5); currentSubPath.add(b5); } }