@Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);


            if(Analysis.imageA == null || Analysis.imageB == null) return;

            Graphics2D g2d = (Graphics2D)g;

            Image A = Analysis.imageA;
            Image B = Analysis.imageB;

            double w = getWidth();
            double h = getHeight();

            double wCoeffIm1 = w / (2 * A.source.getWidth(null));
            double hCoeffIm1 = h / A.source.getHeight(null);
            double ratio1 = (wCoeffIm1 < hCoeffIm1) ? wCoeffIm1 : hCoeffIm1;
            double x1 = 0, y1 = 0;
            double w1 = ratio1 * A.source.getWidth(null),
                   h1 = ratio1 * A.source.getHeight(null);

            double wCoeffIm2 = w / (2 * B.source.getWidth(null));
            double hCoeffIm2 = h / B.source.getHeight(null);
            double ratio2 = (wCoeffIm2 < hCoeffIm2) ? wCoeffIm2 : hCoeffIm2;
            double x2 = w / 2, y2 = 0;
            double w2 = ratio2 * B.source.getWidth(null),
                   h2 = ratio2 * B.source.getHeight(null);

            g2d.drawImage(A.source, (int)x1, (int)y1, (int)w1, (int)h1, Color.WHITE, null);
            g2d.drawImage(B.source, (int)x2, (int)y2, (int)w2, (int)h2, Color.WHITE, null);

            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                 RenderingHints.VALUE_ANTIALIAS_ON);

            g2d.setColor(new Color(255,0,128, 128));
            g2d.setStroke(new BasicStroke(1));
            if(showNearest && Analysis.doneNearest) {
                drawNearest(g2d, A, B, x1, y1, w1, h1, x2, y2, w2, h2);
            }


            if(showPoints) {
                drawPoints(g2d, A, x1, y1, w1, h1);
                drawPoints(g2d, B, x2, y2, w2, h2);
            }

            if(showStats) {
                g2d.setColor(new Color(198, 198, 198));
                g2d.setStroke(new BasicStroke(1));
                g2d.fillRect(0, 0, (int) w1, 30);

                g2d.setColor(new Color(0, 0, 0));
                g2d.drawString("Matched pairs: " + Analysis.matchedPairs, 0, 12);
                g2d.drawString("Similarity: " + String.format("%.2f %%", Analysis.percent), 0, 27);
            }
        }