added Jacob as author of waterfall chart elements

This commit is contained in:
Martin Pernollet 2017-06-12 20:55:53 +02:00
parent 8943d46aed
commit 3d8e163b13
3 changed files with 39 additions and 30 deletions

View File

@ -9,6 +9,11 @@ import org.jzy3d.plot3d.primitives.Shape;
import org.jzy3d.plot3d.primitives.TesselatedPolygon; import org.jzy3d.plot3d.primitives.TesselatedPolygon;
import org.jzy3d.plot3d.primitives.WaterfallComposite; import org.jzy3d.plot3d.primitives.WaterfallComposite;
/**
* Build a drawable Waterfall using <a href="">Matlab style</a>
*
* @author Jacob Filik
*/
public class WaterfallTessellator extends Tessellator { public class WaterfallTessellator extends Tessellator {
@Override @Override

View File

@ -5,6 +5,13 @@ import java.util.List;
import org.jzy3d.colors.Color; import org.jzy3d.colors.Color;
import org.jzy3d.colors.ColorMapper; import org.jzy3d.colors.ColorMapper;
/**
* A drawable Waterfall using <a href="">Matlab style</a>
*
* @see WaterfallTessellator
*
* @author Jacob Filik
*/
public class WaterfallComposite extends Shape { public class WaterfallComposite extends Shape {
public void add(ColoredWireframePolygon outline, Shape fill) { public void add(ColoredWireframePolygon outline, Shape fill) {

View File

@ -18,46 +18,43 @@ public class WaterfallDemo extends AbstractAnalysis {
@Override @Override
public void init() { public void init() {
float[] x = new float[80]; float[] x = new float[80];
for (int i = 0; i < x.length; i++) { for (int i = 0; i < x.length; i++) {
x[i] = -3f + 6f*((float)i/(x.length-1)); x[i] = -3f + 6f * ((float) i / (x.length - 1));
} }
float[] y = new float[40]; float[] y = new float[40];
for (int i = 0; i < y.length; i++) { for (int i = 0; i < y.length; i++) {
y[i] = -3f + 2f*((float)i/(y.length-1)); y[i] = -3f + 2f * ((float) i / (y.length - 1));
} }
float[] z = getZ(x,y); float[] z = getZ(x, y);
WaterfallTessellator waterfall = new WaterfallTessellator();
Shape build = waterfall.build(x, y, z);
build.setColorMapper(new ColorMapper(new ColorMapRainbow(), build.getBounds().getZmin(), build.getBounds().getZmax(), new Color(1, 1, 1, .5f)));
WaterfallTessellator waterfall = new WaterfallTessellator();
Shape build =waterfall.build(x, y, z);
build.setColorMapper(new ColorMapper(new ColorMapRainbow(), build.getBounds().getZmin(), build.getBounds().getZmax(), new Color(1, 1, 1, .5f)));
// build.setColor(Color.BLACK);
// Create a chart // Create a chart
chart = AWTChartComponentFactory.chart(Quality.Intermediate, getCanvasType()); chart = AWTChartComponentFactory.chart(Quality.Intermediate, getCanvasType());
chart.getScene().getGraph().add(build); chart.getScene().getGraph().add(build);
chart.getView(); chart.getView();
} }
private float[] getZ(float[] x, float[] y) { private float[] getZ(float[] x, float[] y) {
float[] z = new float[x.length * y.length];
float[] z = new float[x.length*y.length]; for (int i = 0; i < y.length; i++) {
for (int j = 0; j < x.length; j++) {
for (int i = 0; i < y.length; i++) { z[j + (x.length * i)] = (float) f((double) x[j], (double) y[i]);
for (int j = 0; j < x.length; j++) { }
z[j + (x.length*i)] = (float)f((double)x[j],(double)y[i]); }
} return z;
}
return z;
} }
private double f(double x, double y) { private double f(double x, double y) {
return x * Math.sin(x * y); return x * Math.sin(x * y);
} }
} }