Huge Java Resource

I have been working on some numerical problems in the last few weeks.  Mostly related to curve fitting and interpolation.  I am slowly sliding back to Java bit-by-bit though I am not sure if I will give up Python as the syntax is so tight and it is actually very fast.

Anyway, I was looking around for some curve fitting and interpolation code on the Net and found Michael Flannigan’s website which has a great resource of math, stats, optimization and some other  more subtle items.  His Java code is here.

I can’t even do it justice by showing the list of packages as it is about twice as long as the screen capture shown to the right.

Java Application or Applet

There is a neat way that an application/applet can be written such that it can run as a GUI in a web page or as a GUI application. Create the Test.java code as:
[cc lang="java"]
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;

public class Test extends JFrame {

public Test() {
}

public static void main(String args[])
{
JFrame jf = new JFrame();
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
TestApplet app = new TestApplet();
app.init();
jf.getContentPane().add(“Center”, app);
jf.setSize(600,600);
jf.setVisible(true);
jf.repaint();

}
}
[/cc]
and create the TestApplet.java code as:
[cc lang="java"]
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.GridLayout;
import java.awt.event.*;
import java.awt.Font;

public class TestApplet extends JApplet implements ActionListener, DocumentListener
{
JPanel main_panel = null;

public TestApplet()
{
createTestApplet();

}

public void init()
{
}

private void createTestApplet()
{
// Create the two panels, one for input and the other for gradient
// table output
main_panel = new JPanel(new GridLayout(1,2));
add( main_panel );

}

public void insertUpdate(DocumentEvent e )
{ changedUpdate(e); }

public void removeUpdate(DocumentEvent e )
{ changedUpdate(e); }

public void changedUpdate(DocumentEvent e)
{
}

public void actionPerformed(ActionEvent e)
{

}
}
[/cc]
And then to compile it, just do:
[cc lang="bash"]
$ javac Test.java
[/cc]

And now to run it

You can either run it from the command line:
[cc lang="bash"]
$ java Test
[/cc]
or create a web page:
[cc lang="html"]





[/cc]