samer@0: package samer.mds; samer@0: samer@0: import samer.core.*; samer@0: import samer.core.types.*; samer@0: import samer.core.util.*; samer@0: import samer.maths.*; samer@0: import samer.tools.*; samer@0: import java.util.*; samer@0: import java.awt.*; samer@0: samer@0: public class MatrixPointViewer2 extends samer.core.util.swing.VCanvas implements Task, Observer, Agent samer@0: { samer@0: Matrix P; // point positions samer@0: Vec x; // point activities samer@0: int N; samer@0: int k1, k2; samer@0: Color[] clut; samer@0: VMap xmap, ymap, cmap; samer@0: VInteger markerSize; samer@0: int[] ix, iy; samer@0: samer@0: public MatrixPointViewer2(Matrix P, Vec x) { samer@0: this.P=P; samer@0: this.x=x; samer@0: N=P.getRowDimension(); samer@0: k1=0; k2=1; samer@0: samer@0: // ColorRamp cramp=new ColorRamp(256); samer@0: // cramp.set(0,Color.black); samer@0: // cramp.gradientTo(255,Color.white); samer@0: clut=new Color[256]; samer@0: for (int i=0; i<256; i++) clut[i]=new Color(255,255,255,i); samer@0: samer@0: ix = new int[N]; samer@0: iy = new int[N]; samer@0: samer@0: markerSize=new VInteger("markerSize",4); samer@0: cmap=new VMap(new LinearMap(256),new Node("cmap")); samer@0: xmap=new VMap(new LinearMap(256),new Node("xmap")); samer@0: ymap=new VMap(new LinearMap(256),new Node("ymap")); samer@0: exposeCommands(this); samer@0: samer@0: P.viewable().addObserver(this); samer@0: xmap.addObserver(this); samer@0: ymap.addObserver(this); samer@0: } samer@0: samer@0: public void sized() { samer@0: xmap.getMap().setIntRange(width); samer@0: ymap.getMap().setIntRange(height); samer@0: update(null,null); samer@0: } samer@0: samer@0: public void attach() { P.viewable().addObserver(this); } samer@0: public void detach() { samer@0: P.viewable().deleteObserver(this); samer@0: xmap.dispose(); samer@0: ymap.dispose(); samer@0: cmap.dispose(); samer@0: markerSize.dispose(); samer@0: } samer@0: samer@0: public void rotate() { samer@0: k2++; samer@0: if (k2>=P.getColumnDimension()) { samer@0: k2=0; k1++; samer@0: if (k1>=P.getColumnDimension()) k1=0; samer@0: } samer@0: if (k2==k1) rotate(); samer@0: } samer@0: samer@0: public void starting() {} samer@0: public void stopping() {} samer@0: public void run() { repaint(); } samer@0: public void dispose() { detach(); } samer@0: samer@0: public void update(Observable o, Object a) samer@0: { samer@0: double [][] p=P.getArray(); samer@0: IMap xm=xmap.getMap(); samer@0: IMap ym=ymap.getMap(); samer@0: samer@0: for (int i=0; i