p0 = a.last.last();
p0 = a.last.cp2();
  private void capEnd(Segment a, Segment b)  {    double[] p0, p1;    double dx, dy, l;    Point2D c1,c2;    switch( cap )      {      case CAP_BUTT:        a.add(new LineSegment(a.last.P2, b.P1));        break;      case CAP_SQUARE:        p0 = a.last.last();        p1 = new double[]{a.last.P2.getX(), a.last.P2.getY()};        dx = p1[0] - p0[0];        dy = p1[1] - p0[1];        l = Math.sqrt(dx * dx + dy * dy);        dx = 0.5*width*dx/l;        dy = 0.5*width*dy/l;        c1 = new Point2D.Double(p1[0] + dx, p1[1] + dy);        c2 = new Point2D.Double(b.P1.getX() + dx, b.P1.getY() + dy);        a.add(new LineSegment(a.last.P2, c1));        a.add(new LineSegment(c1, c2));        a.add(new LineSegment(c2, b.P1));        break;      case CAP_ROUND:        p0 = a.last.last();        p1 = new double[]{a.last.P2.getX(), a.last.P2.getY()};        dx = p1[0] - p0[0];        dy = p1[1] - p0[1];        l = Math.sqrt(dx * dx + dy * dy);        dx = (2.0/3.0)*width*dx/l;        dy = (2.0/3.0)*width*dy/l;        c1 = new Point2D.Double(p1[0] + dx, p1[1] + dy);        c2 = new Point2D.Double(b.P1.getX() + dx, b.P1.getY() + dy);        a.add(new CubicSegment(a.last.P2, c1, c2, b.P1));        break;      }    a.add(b);  }