@Override
    public void paint(Graphics g) {
        g.setColor(Color.WHITE);
        g.fillRect(0, 0, getWidthGraph(), getHeightGraph());
        g.setColor(Color.GRAY);

        try {
            double xfactor = getWidthGraph() / (xdh - xdl), yfactor = getHeightGraph() / (ydh - ydl); //a normalization factor. always do xposition*xfactor + xmid
            double xmid = getWidthGraph() - (xdh) * xfactor, ymid = getHeightGraph() - (ydh) * yfactor; //y axis is xmid, x axis is ymid. yeah...

            //drawing the lines.
            for (double xline = 0; xline < xdh; xline += xlineint) {
                g.drawLine((int)(xmid + xline * xfactor), 0, (int)(xmid + xline * xfactor), getHeightGraph());
            }

            for (double xline = 0; xline > xdl; xline -= xlineint) {
                g.drawLine((int)(xmid + xline * xfactor), 0, (int)(xmid + xline * xfactor), getHeightGraph());
            }

            for (double yline = 0; yline < ydh; yline += ylineint) {
                g.drawLine(0, (int)(ymid + yline * yfactor), getWidthGraph(), (int)(ymid + yline * yfactor));
            }

            for (double yline = 0; yline > ydl; yline -= ylineint) {
                g.drawLine(0, (int)(ymid + yline * yfactor), getWidthGraph(), (int)(ymid + yline * yfactor));
            }

            Graphics2D g2d = (Graphics2D) g;
            Stroke oldstroke = g2d.getStroke();
            g2d.setStroke(new BasicStroke(2));
            g.drawLine(0, (int)(ymid), getWidthGraph(), (int)(ymid));
            g.drawLine((int)(xmid), 0, (int)(xmid), getHeightGraph());
            Color oldcolor = g.getColor();

            
            g.setColor(Color.RED);
            paintSlopeField(g, xmid, xfactor, ymid, yfactor);

            g2d.setStroke(oldstroke);
            g2d.setColor(oldcolor);
        } catch (UnresolvedNameException nave) {
            System.out.println(nave);
            return;
        }
    }