@Override
    public void draw(Object obj, Component comp, Graphics2D g2) {
        Image finalImage;
        if (isConnected) {
            finalImage = this.conectedTexture.connectedImage((ConectedTexture) obj);
        } else {
            finalImage = this.image;
        }
        int width = finalImage.getWidth(null);
        int height = finalImage.getHeight(null);
        int size = Math.max(width, height);

        // Scale to shrink or enlarge the image to fit the size 1x1 cell.
        g2.scale(1.0 / size, 1.0 / size);
        g2.clip(new Rectangle(-width / 2, -height / 2, width, height));
        g2.drawImage(finalImage, -width / 2, -height / 2, null);
    }