Mercurial > hg > jslab
diff src/samer/tools/ImageTraceBase.java @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/samer/tools/ImageTraceBase.java Tue Jan 17 17:50:20 2012 +0000 @@ -0,0 +1,79 @@ +/* + * 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.*; +import samer.core.*; +import samer.core.util.*; + +public abstract class ImageTraceBase extends ImageViewer +{ + int sx, sy; + int scrollStep=1; + boolean sc; + boolean stretch=false; + boolean scroll=false; + + + ImageTraceBase( ImageSourceBase i, Observable o) + { + super(i,o); + + setScroll(Shell.getBoolean("scroll",false)); + setStretch(Shell.getBoolean("stretch",false)); + setScrollStep(1); + setCellSize(cx,cy); + } + + public void setScrollStep(int st) { scrollStep=st; } + public void setScroll(boolean f) { scroll=f; } + public void setStretch(boolean f) { + stretch = f; + sc = stretch || (cx!=1) || (cy!=1); + } + + public void setCellSize( int a, int b) + { + super.setCellSize(a,b); + sc = stretch || (cx!=1) || (cy!=1); + sx = cx*ip.getWidth(); + sy = cy*ip.getHeight(); + } + + public void update( Graphics g) { clear(g); } + public void paint( Graphics g) { clear(g); } + + public void getCommands(Agent.Registry r) { + super.getCommands(r); r.group(); + r.add("scroll",scroll).add("stretch",stretch).add("cell.size"); + } + + public void execute(String cmd, Environment env) throws Exception + { + if (cmd.equals("scroll")) { + setScroll(X._bool(env.datum(),!scroll)); + } else if (cmd.equals("stretch")) { + setStretch(X._bool(env.datum(),!stretch)); + } else if (cmd.equals("cell.size")) { + setCellSize( + X._int(env.datum("cell.width"),cx), + X._int(env.datum("cell.height"),cy) + ); + } else super.execute(cmd,env); + } + + public abstract void next(); + + public void update(Observable o, Object oo) { + if (o==obs && oo!=Viewable.DISPOSING) next(); + else super.update(o,oo); + } +}