/* (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);
    }
  }
  /* (non-Javadoc)
   * @see org.apache.batik.parser.PathHandler#curvetoCubicRel(float, float, float, float, float, float)
   */
  public void curvetoCubicRel(float x1, float y1, float x2, float y2, float x, float y)
      throws ParseException {
    if (verbose)
      System.out.println(
          "curvetoCubicSmoothRel: " + x1 + "," + y1 + "  " + x2 + "," + y2 + "  " + x + "," + y);

    Vertex lastPoint = pathPoints.getLast();
    BezierVertex b =
        new BezierVertex(
            lastPoint.getX() + x1,
            lastPoint.getY() + y1,
            0,
            lastPoint.getX() + x2,
            lastPoint.getY() + y2,
            0,
            lastPoint.getX() + x,
            lastPoint.getY() + y,
            0);
    pathPoints.add(b);
    currentSubPath.add(b);
  }
  /* (non-Javadoc)
   * @see org.apache.batik.parser.PathHandler#curvetoQuadraticRel(float, float, float, float)
   */
  public void curvetoQuadraticRel(float x1, float y1, float x, float y) throws ParseException {
    if (verbose) System.out.println("curvetoQuadraticRel: " + x1 + "," + y1 + "  " + x + "," + y);

    if (!pathPoints.isEmpty() && pathPoints.getLast() != null) {
      Vertex lastPoint = pathPoints.getLast();

      Vertex lastEndPoint = new Vertex(lastPoint.getX(), lastPoint.getY(), lastPoint.getZ());
      Vertex quadControlPoint = new Vertex(lastPoint.getX() + x1, lastPoint.getY() + y1, 0);

      // Put in startPoint = last QuadTo Endpoint of this smoothQuadTo, the calculated control
      // point, and the endpoint of smoothQuadTo
      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);
    } else {
      System.out.println("last point null at curvetoQuadraticRel");
    }
  }