comparison src/samer/tools/SignalTrace.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 * DoubleAgent.java
3 *
4 * Copyright (c) 2000, Samer Abdallah, King's College London.
5 * All rights reserved.
6 *
7 * This software is provided AS IS and WITHOUT ANY WARRANTY;
8 * without even the implied warranty of MERCHANTABILITY or
9 * FITNESS FOR A PARTICULAR PURPOSE.
10 */
11
12 package samer.tools;
13 import samer.core.*;
14 import samer.core.types.*;
15 import java.util.*;
16 import java.awt.*;
17
18 public class SignalTrace extends Trace
19 {
20 VDouble x;
21 Color col;
22 Renderer R;
23 int oldj;
24
25 public SignalTrace(VDouble x) {
26 this.x=x;
27 col=Shell.getColor("color",getForeground());
28 R=(Renderer)Shell.get("renderer",Renderer.LINE);
29 oldj=-1;
30 }
31
32 public void run() {
33 super.run();
34 int j=height-map.toInt(x.value);
35 if (oldj<0) oldj=j;
36 graphics.setColor(col);
37 R.draw(graphics,x1,x2,oldj,j,j0);
38 oldj=j;
39 }
40 public void detach() { x.deleteObserver(this); }
41 public void update(Observable obs, Object arg) {
42 if (arg==Viewable.DISPOSING) { detach(); getParent().remove(this); }
43 else if (x==obs) run();
44 else super.update(obs,arg);
45 }
46
47 public void getCommands(Registry r) { super.getCommands(r); r.add("renderer"); }
48 public void execute(String cmd, Environment env) throws Exception {
49 if (cmd.equals("renderer")) R=(Renderer)Shell.get("renderer",Renderer.LINE);
50 else super.execute(cmd,env);
51 }
52 }
53