Graphics2D g2D = (Graphics2D) g;
    public void draw(Graphics g, Point2D[] points, boolean complete) {        Graphics2D g2D = (Graphics2D) g;        setGraphics(g);        int nbpts = points.length;        double xcoord1 = points[0].getX();        double ycoord1 = points[0].getY();        double xcoord2 = points[nbpts - 1].getX();        double ycoord2 = points[nbpts - 1].getY();        if (complete) {            // Compute cosinus and sinus of rotation angle            double dx = xcoord2 - xcoord1;            double dy = ycoord2 - ycoord1;            double norm = Math.sqrt(dx * dx + dy * dy);            double rcos = dx / norm;            double rsin = dy / norm;            // Compute vertices            double r = getLength() / 2.0; // x radius before rotation            double w = getWidth();            // rotate            int x = (int) (xcoord1 + r * rcos);            int y = (int) (ycoord1 + r * rsin);            if (filled) {                g.fillOval((int) (x - w / 2),                        (int) (y - w / 2),                        (int) (w),                        (int) (w));            } else {                g.drawOval((int) (x - w / 2),                        (int) (y - w / 2),                        (int) (w),                        (int) (w));            }        }        restoreGraphics(g);    }