Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package hu.kazocsaba.imageviewer;
 
Utility methods for image viewers.

Author(s):
Kazó Csaba
 
public class ImageViewerUtil {
Private constructor.
	private ImageViewerUtil() {}
A property change listener that synchronizes the display-related properties of two image viewers.
	private static class PropertySynchronizer implements PropertyChangeListener {
		private final ImageViewer v1,v2;
			this. = v1;
			this. = v2;
		}
		public void propertyChange(PropertyChangeEvent evt) {
			ImageViewer target=source== ?  : ;
			if ("statusBarVisible".equals(evt.getPropertyName())) {
else if ("resizeStrategy".equals(evt.getPropertyName())) {
else if ("zoomFactor".equals(evt.getPropertyName())) {
				target.setZoomFactor(source.getZoomFactor());
else if ("pixelatedZoom".equals(evt.getPropertyName())) {
			}
		}
	}
Synchronizes the view state of multiple image viewers with respect to scroll position and resize strategy, and other properties affecting display. For this to work correctly, the viewers should always have the same size.

Parameters:
first the first viewer
others the other viewers
	public static void synchronizeViewers(ImageViewer firstImageViewer... others) {
		for (ImageViewer otherothers) {
			if (other!=first) {
				other.trackSizeIfEmpty(first);
				new PropertySynchronizer(firstother);
			}
		}
	}
New to GrepCode? Check out our FAQ X