samer@0: /* samer@0: * MatrixTrace.java samer@0: * samer@0: * Copyright (c) 2000, Samer Abdallah, King's College London. samer@0: * All rights reserved. samer@0: * samer@0: * This software is provided AS iS and WITHOUT ANY WARRANTY; samer@0: * without even the implied warranty of MERCHANTABILITY or samer@0: * FITNESS FOR A PARTICULAR PURPOSE. samer@0: */ samer@0: samer@0: package samer.maths; samer@0: import samer.core.*; samer@0: import samer.tools.*; samer@0: import java.util.*; samer@0: samer@0: /** samer@0: This viewer outputs all the elements of a row or column samer@0: to a trace (graph of value against time step). All elements samer@0: of the row are column are consecutively output at each time samer@0: step. samer@0: */ samer@0: samer@0: public class LineTrace extends Trace implements Observer samer@0: { samer@0: Observable obs; samer@0: Vec src; samer@0: samer@0: public LineTrace( Observable o, Vec v) { obs=o; src=v; } samer@0: samer@0: public void attach() { obs.addObserver(this); } samer@0: public void detach() { obs.deleteObserver(this); super.detach(); } samer@0: samer@0: public void update(Observable o, Object s) samer@0: { samer@0: if (s==Viewable.DISPOSING) { samer@0: Shell.releaseViewer(this); samer@0: } else if (obs==o) { samer@0: Vec.Iterator i=src.iterator(); samer@0: while (i.more()) next(i.next()); samer@0: } samer@0: } samer@0: protected void next(double x) {} // !! fix this samer@0: protected void realized() { super.realized(); attach(); } samer@0: }