Mercurial > hg > jslab
comparison src/samer/tools/ImageTraceBase.java @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bf79fb79ee13 |
---|---|
1 /* | |
2 * Copyright (c) 2000, Samer Abdallah, King's College London. | |
3 * All rights reserved. | |
4 * | |
5 * This software is provided AS iS and WITHOUT ANY WARRANTY; | |
6 * without even the implied warranty of MERCHANTABILITY or | |
7 * FITNESS FOR A PARTICULAR PURPOSE. | |
8 */ | |
9 | |
10 package samer.tools; | |
11 | |
12 import java.awt.*; | |
13 import java.util.*; | |
14 import samer.core.*; | |
15 import samer.core.util.*; | |
16 | |
17 public abstract class ImageTraceBase extends ImageViewer | |
18 { | |
19 int sx, sy; | |
20 int scrollStep=1; | |
21 boolean sc; | |
22 boolean stretch=false; | |
23 boolean scroll=false; | |
24 | |
25 | |
26 ImageTraceBase( ImageSourceBase i, Observable o) | |
27 { | |
28 super(i,o); | |
29 | |
30 setScroll(Shell.getBoolean("scroll",false)); | |
31 setStretch(Shell.getBoolean("stretch",false)); | |
32 setScrollStep(1); | |
33 setCellSize(cx,cy); | |
34 } | |
35 | |
36 public void setScrollStep(int st) { scrollStep=st; } | |
37 public void setScroll(boolean f) { scroll=f; } | |
38 public void setStretch(boolean f) { | |
39 stretch = f; | |
40 sc = stretch || (cx!=1) || (cy!=1); | |
41 } | |
42 | |
43 public void setCellSize( int a, int b) | |
44 { | |
45 super.setCellSize(a,b); | |
46 sc = stretch || (cx!=1) || (cy!=1); | |
47 sx = cx*ip.getWidth(); | |
48 sy = cy*ip.getHeight(); | |
49 } | |
50 | |
51 public void update( Graphics g) { clear(g); } | |
52 public void paint( Graphics g) { clear(g); } | |
53 | |
54 public void getCommands(Agent.Registry r) { | |
55 super.getCommands(r); r.group(); | |
56 r.add("scroll",scroll).add("stretch",stretch).add("cell.size"); | |
57 } | |
58 | |
59 public void execute(String cmd, Environment env) throws Exception | |
60 { | |
61 if (cmd.equals("scroll")) { | |
62 setScroll(X._bool(env.datum(),!scroll)); | |
63 } else if (cmd.equals("stretch")) { | |
64 setStretch(X._bool(env.datum(),!stretch)); | |
65 } else if (cmd.equals("cell.size")) { | |
66 setCellSize( | |
67 X._int(env.datum("cell.width"),cx), | |
68 X._int(env.datum("cell.height"),cy) | |
69 ); | |
70 } else super.execute(cmd,env); | |
71 } | |
72 | |
73 public abstract void next(); | |
74 | |
75 public void update(Observable o, Object oo) { | |
76 if (o==obs && oo!=Viewable.DISPOSING) next(); | |
77 else super.update(o,oo); | |
78 } | |
79 } |