import java.applet.*; import java.awt.*; import GrapherGUI.*; public class Web extends Applet { public void init() { SliderMatrix sm = new SliderMatrix(3); sm.add(-10.0, 10.0, 0.0, 4, "param_h.jpg", "h"); sm.add(5.0, 15.0, 5.0, 4, "param_g.jpg", "g"); MyFunc1 f1 = new MyFunc1(); MyFunc2 f2 = new MyFunc2(); GUI gui = new GUI(sm, null, -2.0, 2.0, -3.0, 10.0); gui.addFunction(f1); gui.addFunction(f2); gui.setAxesIcons("axis_x.jpg", "axis_y.jpg"); add(gui); } } class MyFunc1 extends Function { public short type() { return Function.FCNTYPE_SINGLEVAL; } public String name() { return "Test"; } public double f(double x, SliderMatrix p) { double g, h; try { g = p.val("g"); h = p.val("h"); } catch (Error e) { return 0.0; } return x * x * x * h / g; } public void farray( double minx, double maxx, int density, double[] a, double[] b, SliderMatrix p) {} } class MyFunc2 extends Function { public short type() { return Function.FCNTYPE_ARRAY; } public String name() { return "Using a whole array"; } public double f(double x, SliderMatrix p) { return 4.0; } public void farray( double minx, double maxx, int density, double[] X, double[] Y, SliderMatrix p) { double dx = Math.abs(maxx - minx) / (double) density; double x, y, g, h; int i; try { g = p.val("g"); h = p.val("h"); } catch (Error e) { g = 0.0; h = 0.0; } x = minx; i = 0; while (x < maxx && i < density) { y = x * g; X[i] = x; Y[i] = y; x += dx; i++; } } }