Graphics2D g2D = (Graphics2D) g;
    public void draw(Graphics g, Point2D[] points, boolean complete) {        Graphics2D g2D = (Graphics2D) g;        setGraphics(g);        int nbpts = points.length;        int xcoord[] = new int[nbpts + 6];        int ycoord[] = new int[nbpts + 6];        for (int i = 0; i < nbpts; i++) {            xcoord[i] = (int) points[i].getX();            ycoord[i] = (int) points[i].getY();        }        if (complete) {            int orient = getOrientation() == LEFT ? -1 : 1;            // Compute cosinus and sinus of rotation angle            double dx = points[nbpts - 1].getX() - points[0].getX();            double dy = points[nbpts - 1].getY() - points[0].getY();            double norm = Math.sqrt(dx * dx + dy * dy);            double rcos = dx / norm;            double rsin = dy / norm;            // Compute vertices (6 lines to approximate)            double ll = getLength(); // en x avant rotation            double ww = orient * getWidth(); // en y avant rotation            double l, w;            l = 0.9330127 * ll; // i.e. (2 + sqrt(3))/4            w = 0.5 * ww;            xcoord[nbpts] = (int) (points[0].getX() + l * rcos - w * rsin);            ycoord[nbpts++] = (int) (points[0].getY() + l * rsin + w * rcos);            l = 0.85355339 * ll; // i.e. (2 + sqrt(2))/4            w = 0.70710678 * ww;            xcoord[nbpts] = (int) (points[0].getX() + l * rcos - w * rsin);            ycoord[nbpts++] = (int) (points[0].getY() + l * rsin + w * rcos);            l = 0.5 * ll;            w = ww;            xcoord[nbpts] = (int) (points[0].getX() + l * rcos - w * rsin);            ycoord[nbpts++] = (int) (points[0].getY() + l * rsin + w * rcos);            l = 0.14644661 * ll; // i.e. (2 - sqrt(2))/4            w = 0.70710678 * ww;            xcoord[nbpts] = (int) (points[0].getX() + l * rcos - w * rsin);            ycoord[nbpts++] = (int) (points[0].getY() + l * rsin + w * rcos);            l = 0.066987298 * ll; // i.e. (2 - sqrt(3))/4            w = 0.5 * ww;            xcoord[nbpts] = (int) (points[0].getX() + l * rcos - w * rsin);            ycoord[nbpts++] = (int) (points[0].getY() + l * rsin + w * rcos);            // link to start            xcoord[nbpts] = (int) points[0].getX();            ycoord[nbpts++] = (int) points[0].getY();            if (filled)                g.fillPolygon(xcoord, ycoord, nbpts);        }        g.drawPolyline(xcoord, ycoord, nbpts);        restoreGraphics(g);    }