import java.awt.*; import chart.*; // This class serves as an intermediary between Newton and the Chart // package (which was downloaded from http://www.ve.com/javachart/) // Its main purpose is to prove that Newton and Interpolator don't use // anything from Chart to cheat (since Chart doesn't really have an // API). Other tools were used to find the API for LineChart, since it // was provided in a binary-only form. public class Graph extends Frame { public Graph() { super("Graph window"); // Set the title setResizable(false); // Resizing could do BAD things. setLayout(null); // No layout addNotify(); // Make the peer newSize(340, 440); // Setup the size } // Draw myself onto the graphic. Not very exciting, to be sure. public synchronized void paint(Graphics g) { super.paint(g); LineChart lc = new LineChart("Graph of p"); lc.addDataSet("p(x)", x, y); lc.resize(width, height); lc.lineVisible(true); lc.drawGraph(g); } // Handle destruction public boolean handleEvent(Event event) { if (event.id == Event.WINDOW_DESTROY) { hide(); return true; } return super.handleEvent(event); } // Change my size public void newSize(int h, int w) { height = h; width = w; resize(insets().left + insets().right + w, insets().top + insets().bottom + h); } public double x[]; public double y[]; private int height; private int width; }