public void drawPolygon (double[] x, double[] y, JGColor[] col, int len,
                             boolean filled, boolean pf_relative) {
        if (buf_gfx == null) return;
        int[] xpos = new int[3];
        int[] ypos = new int[3];
        xpos[0] = el.scaleXPos(x[0], pf_relative);
        ypos[0] = el.scaleYPos(y[0], pf_relative);
        xpos[1] = el.scaleXPos(x[1], pf_relative);
        ypos[1] = el.scaleYPos(y[1], pf_relative);
        xpos[2] = el.scaleXPos(x[len - 1], pf_relative);
        ypos[2] = el.scaleYPos(y[len - 1], pf_relative);
        if (!filled) {
            // draw first and last line segment
            if (col != null) setColor(buf_gfx, col[1]);
            buf_gfx.drawLine(xpos[0], ypos[0], xpos[1], ypos[1]);
            if (col != null) setColor(buf_gfx, col[0]);
            buf_gfx.drawLine(xpos[2], ypos[2], xpos[0], ypos[0]);
        }
        for (int i = 2; i < len; i++) {
            xpos[2] = el.scaleXPos(x[i], pf_relative);
            ypos[2] = el.scaleYPos(y[i], pf_relative);
            if (col != null) setColor(buf_gfx, col[i]);
            if (filled) {
                buf_gfx.fillPolygon(xpos, ypos, 3);
            }
            else {
                buf_gfx.drawLine(xpos[1], ypos[1], xpos[2], ypos[2]);
            }
            xpos[1] = xpos[2];
            ypos[1] = ypos[2];
        }
    }