void scaleImages(String nameOfChangedImage) {

		if (SnapshotGallery.sharedInstance().isEmpty()) {
			return;
		}

		if (EventQueue.isDispatchThread())
			setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
		float w = 0, h = 0;
		Insets insets = getInsets();
		int w1 = insets.left + insets.right;
		int h1 = insets.top + insets.bottom + IMAGE_HEIGHT;
		int n = SnapshotGallery.sharedInstance().size();
		String name = null;
		ImageIcon icon = null;
		Image image = null;
		float r = 1;
		for (int i = n - 1; i >= 0; i--) {
			name = SnapshotGallery.sharedInstance().getImageName(i);
			image = SnapshotGallery.sharedInstance().getThumbnail(i);
			if (image == null || name.equals(nameOfChangedImage)) {
				icon = SnapshotGallery.sharedInstance().loadAnnotatedImage(i);
				w = icon.getIconWidth();
				h = icon.getIconHeight();
				r = IMAGE_HEIGHT / h;
				w *= r;
				// This scaling method causes out-of-memory error:
				// icon.getImage().getScaledInstance((int) w, IMAGE_HEIGHT, Image.SCALE_SMOOTH);
				image = ModelerUtilities.scale((BufferedImage) icon.getImage(), r, r);
				SnapshotGallery.sharedInstance().putThumbnail(icon.getDescription(), image);
				image.flush();
				icon.getImage().flush();
			}
			else {
				w = image.getWidth(this);
				h = image.getHeight(this);
			}
			if (getLayout() instanceof FlowLayout) {
				w1 += (int) w + ((FlowLayout) getLayout()).getHgap();
			}
			else {
				w1 += (int) w + IMAGE_GAP;
			}
		}
		setPreferredSize(new Dimension(w1, h1));
		if (EventQueue.isDispatchThread())
			setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

	}