annotate yetilab/plot/plot.yeti @ 115:30c790d2789e

plot -> plotMatrix
author Chris Cannam
date Thu, 18 Apr 2013 08:47:26 +0100
parents f73923903ba4
children 098b4efde5b1
rev   line source
Chris@108 1 module yetilab.plot.plot;
Chris@108 2
Chris@108 3 import org.jzy3d.plot3d.builder: Mapper;
Chris@108 4 import org.jzy3d.maths: Range;
Chris@108 5 import org.jzy3d.plot3d.primitives: Shape;
Chris@108 6 import org.jzy3d.chart: Chart, ChartLauncher;
Chris@108 7 import org.jzy3d.plot3d.builder: Builder;
Chris@108 8 import org.jzy3d.plot3d.builder.concrete: OrthonormalGrid;
Chris@108 9 import org.jzy3d.colors.colormaps: ColorMapRainbow;
Chris@108 10 import org.jzy3d.colors: ColorMapper;
Chris@108 11 import org.jzy3d.colors: Color;
Chris@108 12 import org.jzy3d.plot3d.rendering.canvas: Quality;
Chris@108 13
Chris@108 14 newMatrixMapper matrix =
Chris@108 15 (class MMapper extends Mapper
Chris@108 16 double f(double x, double y)
Chris@108 17 matrix.getAt y x
Chris@108 18 end;
Chris@108 19 new MMapper());
Chris@108 20
Chris@108 21 newMatrixLogMapper matrix =
Chris@108 22 (class MMapper extends Mapper
Chris@108 23 double f(double x, double y)
Chris@108 24 ln (matrix.getAt y x)
Chris@108 25 end;
Chris@108 26 new MMapper());
Chris@108 27
Chris@108 28 newMapper mapFunction =
Chris@108 29 (class FMapper extends Mapper
Chris@108 30 double f(double x, double y)
Chris@108 31 mapFunction x y
Chris@108 32 end;
Chris@108 33 new FMapper());
Chris@108 34
Chris@115 35 plotMatrix matrix =
Chris@108 36 (mapper = newMatrixLogMapper matrix;
Chris@108 37 size = matrix.size;
Chris@108 38 xrange = new Range(1, size.columns - 1);
Chris@108 39 yrange = new Range(1, size.rows - 1);
Chris@108 40 grid = new OrthonormalGrid(xrange, size.columns, yrange, size.rows);
Chris@112 41 println "Matrix size: \(size)";
Chris@110 42 surface = Builder#buildOrthonormalBig(grid, mapper); //??? big?
Chris@111 43 surface#setFaceDisplayed(false);
Chris@108 44 surface#setWireframeDisplayed(true);
Chris@108 45 surface#setWireframeColor(Color#BLACK);
Chris@112 46 // chart = new Chart(Quality#Fastest, "swing");
Chris@112 47 chart = new Chart(Quality#Nicest);
Chris@108 48 chart#getScene()#getGraph()#add(surface);
Chris@115 49 ChartLauncher#openChart(chart);
Chris@115 50 ());
Chris@108 51
Chris@110 52 plotStructure structure =
Chris@110 53 case structure of
Chris@110 54 Grid matrix:
Chris@115 55 plotMatrix matrix;
Chris@110 56 //!!!
Chris@110 57 _: failWith "Cannot plot this structure (only grids implemented so far)";
Chris@110 58 esac;
Chris@108 59
Chris@115 60 {
Chris@115 61 plotMatrix,
Chris@115 62 plotStructure
Chris@115 63 }
Chris@110 64