Chris@108: module yetilab.plot.plot; Chris@108: Chris@108: import org.jzy3d.plot3d.builder: Mapper; Chris@119: import org.jzy3d.maths: Range, Coord3d; Chris@108: import org.jzy3d.chart: Chart, ChartLauncher; Chris@108: import org.jzy3d.plot3d.builder: Builder; Chris@108: import org.jzy3d.plot3d.builder.concrete: OrthonormalGrid; Chris@108: import org.jzy3d.colors.colormaps: ColorMapRainbow; Chris@119: import org.jzy3d.colors: ColorMapper, Color; Chris@108: import org.jzy3d.plot3d.rendering.canvas: Quality; Chris@119: import org.jzy3d.plot3d.rendering.view.modes: ViewPositionMode; Chris@148: import org.jzy3d.plot3d.primitives: FlatLine2d, Point; Chris@108: Chris@108: newMatrixMapper matrix = Chris@108: (class MMapper extends Mapper Chris@108: double f(double x, double y) Chris@117: result = matrix.getAt y x; Chris@117: println "f(\(x),\(y)) -> \(result)"; Chris@117: result Chris@108: end; Chris@108: new MMapper()); Chris@108: Chris@108: newMatrixLogMapper matrix = Chris@108: (class MMapper extends Mapper Chris@108: double f(double x, double y) Chris@108: ln (matrix.getAt y x) Chris@108: end; Chris@108: new MMapper()); Chris@108: Chris@108: newMapper mapFunction = Chris@108: (class FMapper extends Mapper Chris@108: double f(double x, double y) Chris@108: mapFunction x y Chris@108: end; Chris@108: new FMapper()); Chris@108: Chris@115: plotMatrix matrix = Chris@117: (mapper = newMatrixMapper matrix; Chris@108: size = matrix.size; Chris@119: xrange = new Range(0, size.columns - 1); Chris@119: yrange = new Range(0, size.rows - 1); Chris@108: grid = new OrthonormalGrid(xrange, size.columns, yrange, size.rows); Chris@112: println "Matrix size: \(size)"; Chris@117: surface = Builder#buildOrthonormal(grid, mapper); //??? big? Chris@117: println "Z Bounds: \(surface#getBounds()#getZmin()) -> \(surface#getBounds()#getZmax())"; Chris@121: surface#setFaceDisplayed(true); Chris@108: surface#setWireframeDisplayed(true); Chris@108: surface#setWireframeColor(Color#BLACK); Chris@112: // chart = new Chart(Quality#Fastest, "swing"); Chris@112: chart = new Chart(Quality#Nicest); Chris@108: chart#getScene()#getGraph()#add(surface); Chris@115: ChartLauncher#openChart(chart); Chris@115: ()); Chris@108: Chris@148: plotCurve values is list? -> () = Chris@148: (chart = new Chart(Quality#Nicest); Chris@148: scene = chart#getScene(); Chris@148: n = length values; Chris@148: line = new FlatLine2d([0..n-1] as ~float[], values as ~float[], 0); Chris@148: line#setWireframeDisplayed(true); Chris@148: line#setWireframeColor(Color#BLACK); Chris@148: line#setWireframeWidth(2); Chris@148: line#setFaceDisplayed(false); Chris@148: scene#add(line); Chris@148: chart#getView()#setViewPoint(new Coord3d(0, 0, 0)); Chris@148: axes = chart#getAxeLayout(); Chris@148: axes#setXAxeLabelDisplayed(false); Chris@148: axes#setYAxeLabelDisplayed(false); Chris@148: axes#setZAxeLabelDisplayed(true); Chris@148: axes#setZAxeLabel("unit goes here"); //!!! Chris@148: axes#setYTickLabelDisplayed(false); Chris@148: ChartLauncher#openChart(chart); Chris@148: ()); Chris@148: Chris@110: plotStructure structure = Chris@110: case structure of Chris@110: Grid matrix: Chris@115: plotMatrix matrix; Chris@148: Curve curve: Chris@148: plotCurve (map (.value) curve); //!!! this is wrong, but just to see Chris@110: _: failWith "Cannot plot this structure (only grids implemented so far)"; Chris@110: esac; Chris@108: Chris@115: { Chris@119: newMatrixMapper, Chris@119: newMatrixLogMapper, Chris@119: newMapper, Chris@115: plotMatrix, Chris@119: plotStructure, Chris@115: } Chris@110: