WindowImage.java

package ac.essex.ooechs.imaging.commons.window.data; 
 
import ac.essex.ooechs.imaging.commons.PixelLoader; 
 
import java.util.Vector; 
import java.io.Serializable; 
import java.io.File; 
 
/** 
 * Consists of an image (filename) and a series of window objects. 
 * 
 * @author Olly Oechsle, University of Essex, Date: 19-Mar-2008 
 * @version 1.0 
 */ 
public class WindowImage implements Serializable { 
 
    public Vector<Window> windows; 
 
    public File file; 
 
    public transient PixelLoader image; 
 
    public WindowImage(File file) { 
        this.file = new File(file.getAbsolutePath()); 
        this.windows = new Vector<Window>(); 
    } 
 
    public void addWindow(Window w)  { 
        this.windows.add(w); 
    } 
 
    public int clearWindows() { 
        int windowCount = windows.size(); 
         this.windows.clear(); 
        return windowCount; 
    } 
 
    public Vector<Window> getWindows() { 
        return windows; 
    } 
 
    public int countWindows() { 
        return windows.size(); 
    } 
 
    public File getFile() { 
        return file; 
    } 
 
    public PixelLoader getPixelLoader() throws Exception { 
        if (image == null) { 
            image =  new PixelLoader(file); 
        } 
        return image; 
    } 
 
    public boolean equals(Object o) { 
        if (this == o) return true; 
        if (o == null || getClass() != o.getClass()) return false; 
 
        WindowImage that = (WindowImage) o; 
 
        if (file != null ? !file.equals(that.file) : that.file != null) return false; 
 
        return true; 
    } 
 
    public int hashCode() { 
        return (file != null ? file.hashCode() : 0); 
    } 
 
}