import java.awt.*; import java.util.*; import java.applet.*; import graph.*; /************************************************************************* ** ** Applet datainc ** T. W. Shattuck Colby College Version 1.0 July 2003 ** ************************************************************************** ** Based on example1.java and the 2D graph ** Java classes by Leigh Brookshaw (1996) ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ************************************************************************** ** ** The first data set is loaded from the PARAM tag DATA of the calling html, ** the second data set is loaded form the PARAM tag FUNCTION with the ** starting x value = minimum and then in equal increments. ** The first data set is given as a comma delimited string of x and y ** data pairs. The second data set, the "function", is given as a ** comma delimited string of y values only. ** *************************************************************************/ public class datainc extends Applet { Graph2D graph; DataSet data1; DataSet data2; Axis xaxis; Axis yaxis; Markers markers; double data[]; int np = 500; int npd ; public void init() { double xf ; int count = 0; boolean error = false; double data[] = new double[2*np]; /* ** Get the passed parameters */ String datastr = getParameter("data") ; String fcnstr = getParameter("function") ; double minimum = Float.parseFloat(getParameter("minimum")); double increment = Float.parseFloat(getParameter("increment")); String xlabel = getParameter("xlabel") ; String ylabel = getParameter("ylabel") ; /* ** Create the Graph instance and modify the default behaviour */ graph = new Graph2D(); graph.drawzero = false; graph.drawgrid = false; graph.setGraphBackground(new Color(255,255,255)); /* ** Marker definitions */ markers = new Markers(); /* ** add square marker to the marker list */ int x[] = new int[5]; int y[] = new int[5]; boolean d[] = new boolean[5]; x[0]=-2; y[0]= 2; d[0]=false; x[1]= 2; y[1]= 2; d[1]=true; x[2]= 2; y[2]= -2; d[2]=true; x[3]= -2; y[3]=-2; d[3]=true; x[4]=-2; y[4]= 2; d[4]=true; markers.AddMarker(1,5,d,x,y); graph.setMarkers(markers); setLayout( new BorderLayout() ); add("Center", graph); /* ** Get the first data Set. */ StringTokenizer en_str = new StringTokenizer(datastr, ",") ; npd = en_str.countTokens() ; for(int j=0; j