Mega Code Archive
Draw Math Function In Coordinate
import java.awt.*;
import java.applet.*;
import java.net.URL;
import graph.*;
/*************************************************************************
**
** Applet example1
** Version 1.0 January 1996
**
**************************************************************************
** Copyright (C) 1996 Leigh Brookshaw
**
** 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.
**************************************************************************
**
** This is a simple applet that demonstrates how to use the basic features
** of the Plotting Class library. The data is calculated locally by
** the applet
**
*************************************************************************/
public class example1 extends Applet {
Graph2D graph;
DataSet data1;
DataSet data2;
Axis xaxis;
Axis yaxis_left;
Axis yaxis_right;
double data[];
int np = 100;
URL markerURL;
public void init() {
int i;
int j;
double data[] = new double[2*np];
/*
** Get the passed parameters
*/
String mfile = "marker.txt";
/*
** Create the Graph instance and modify the default behaviour
*/
graph = new Graph2D();
graph.drawzero = false;
graph.drawgrid = false;
graph.borderTop = 50;
/*
** Load a file containing Marker definitions
*/
try {
//markerURL = this.getClass().(mfile);
markerURL = this.getClass().getResource(mfile);
graph.setMarkers(new Markers(markerURL));
} catch(Exception e) {
System.out.println("Failed to create Marker URL!");
}
setLayout( new BorderLayout() );
add("Center", graph);
/*
** Calculate the first data Set.
*/
for(i=j=0; i