view src/samer/tools/ImageTrace.java @ 8:5e3cbbf173aa tip

Reorganise some more
author samer
date Fri, 05 Apr 2019 22:41:58 +0100
parents bf79fb79ee13
children
line wrap: on
line source
/*
 *	Copyright (c) 2000, Samer Abdallah, King's College London.
 *	All rights reserved.
 *
 *	This software is provided AS iS and WITHOUT ANY WARRANTY; 
 *	without even the implied warranty of MERCHANTABILITY or 
 *	FITNESS FOR A PARTICULAR PURPOSE.
 */

package samer.tools;
import java.awt.*;
import java.util.*;

public class ImageTrace extends ImageTraceBase
{
	private	int		x=0;

	public ImageTrace( ImageSourceBase i, Observable o) { super(i,o); }

	public void next()
	{ 
		ip.sendPixels(); 

		// make room for next image
		if (scroll) while (x+sx>width) { 
			graphics.copyArea(scrollStep,0,width-scrollStep,height,-scrollStep,0);
			x-=scrollStep;
		}
		else if (x>=width) x=0; 

		if (!sc) {
			graphics.drawImage( img, x, 0, null);  
		} else {
			if (stretch) {
				graphics.drawImage( img, x, 0, sx, height, null); 
			} else {
				graphics.drawImage( img, x, 0, sx, sy, null); 
			}
		}
		getToolkit().sync();
		
		x+=sx;
	}

	public Dimension getPreferredSize() {
		return new Dimension(cx*256,cy*ip.getHeight());
	}
}