@Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        
        int h = PLOT_FRAME_HEIGHT - 25;
        int w = PLOT_FRAME_WIDTH;
        
        // Draw plot axes
        g.drawLine(0, h/2, w, h/2); // x
        g.drawLine(w/2, 0, w/2, h); // y
        
        double max_d = (double) max;
        double min_d = (double) min;
        double w_d = (double) w;
        double h_d = (double) h;
        
        double c_x = w_d / (max_d - min_d);
        double c_y = h_d / (max_d - min_d);
        
        /* Draw the plot. */
        g.setColor(Color.RED);
        
        for (int i = min; i < max; i++) {
            int valueOfx1 = i;
            int valueOfy1 = formula.calculate(valueOfx1);
            
            int valueOfx2 = i+1;
            int valueOfy2 = formula.calculate(valueOfx2);
            
            int x1 = (w/2) + ((int) (valueOfx1*c_x));
            int y1 = (h/2) - ((int) (valueOfy1*c_y));
            
            int x2 = (w/2) + ((int) (valueOfx2*c_x));
            int y2 = (h/2) - ((int) (valueOfy2*c_y));
            
            g.drawLine(x1, y1, x2, y2);
        }
        
        /* Draw labels on both axes. */
        g.setColor(Color.BLACK);
        int amountOfLabels_x = 10;
        int amountOfLabels_y = 10;
        
        int max_y = getMaxY();
        int labelIncrement_x = (max - min) / amountOfLabels_x;
        int labelIncrement_y = (max_y) / amountOfLabels_y;
        
        /* Draw labels on x-axis. */
        for (int i = min; i < max; i += labelIncrement_x) {
            int x = (w/2) + ((int) (i*c_x));
            int y = (h/2);
            
            /* Don't draw zero. */
            if (i == 0)
                continue;
            
            g.drawLine(x, y - 5, x, y +5);
            g.drawString(Integer.toString(i), x - 5, y - 15);
        }
        
        /* Draw labels on y-axis. */
        int x = (w/2);
        for (int i = -max_y; i <= max_y; i += labelIncrement_y) {
            int y = (h/2) - ((int) (i*c_y));
            
            /* Don't draw zero. */
            if (i == 0)
                continue;
            
            g.drawLine(x - 5, y, x + 5, y);
            g.drawString(Integer.toString(i), x - 30, y + 7);
        }
    }