Mercurial > hg > jslab
view src/samer/maths/MatrixImage.java @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
children |
line wrap: on
line source
/* * MatrixImage.java * * 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.maths; import samer.core.*; import samer.tools.*; import java.awt.Color; public class MatrixImage extends ImageViewer { Matrix M; Node n; public MatrixImage( Matrix M) { // should make an intelligent choice of // image source depending on shape of matrix super(new MatrixImageSource( M, true),M.observable()); this.n=Shell.env().node(); this.M=M; } public void scale() { double max, min, x; int n=M.getRowDimension(); int m=M.getColumnDimension(); min=max=M.get(0,0); for (int i=0; i<n; i++) { for (int j=0; j<m; j++) { x=M.get(i,j); if (x>max) max=x; if (x<min) min=x; } } getVMap().setDomain(min,max); getVMap().changed(this); } public static Viewer getViewerFor(Matrix M) { Shell.push(new Node("image",M.getNode())); Viewer vwr = new MatrixImage(M); Shell.pop(); return vwr; } }