import com.imsl.chart3d.*; import com.imsl.chart.Colormap; public class SampleShadedSurface extends JFrameChart3D implements Surface.ZFunction, ColorFunction { private Colormap colormap = Colormap.GREEN_RED_BLUE_WHITE; public SampleShadedSurface() { Chart3D chart = getChart3D(); AxisXYZ axis = new AxisXYZ(chart); Surface surface = new Surface(axis, this, -1.0, 1.0, -1.0, 1.0); surface.setColorFunction(this); surface.setSurfaceType(Surface.SURFACE_TYPE_NICEST); double maxColor = Math.pow(1.8,4); ColormapLegend colormapLegend = new ColormapLegend(chart, colormap, 0., maxColor); colormapLegend.setTitle("Color"); colormapLegend.setPosition(-5, 5); render(); } public double f(double x, double y) { return 2*Math.sin(x+y) - Math.cos(2*x-3*y); } public java.awt.Color color(double x, double y, double z) { double t = x*x + y*y + z*z ; double s = Math.pow(t, 0.25) / 1.8; return colormap.color(s); } public static void main(String args[]) { new SampleShadedSurface().setVisible(true); } }