java applet only runs locally
Author |
Message |
Homer_simpson
![](http://compsci.ca/v3/uploads/user_avatars/18138546704b4d2a3b2e50e.gif)
|
Posted: Tue Aug 07, 2012 1:42 am Post subject: java applet only runs locally |
|
|
hi,
I made a java applet which is a simple simulation.. it compiles ok and when i make an html file with
<applet width=800 height=600 code="cranknicjb.class" archive="jblas-1.2.0.jar,jtransforms-2.4.jar"> </applet>
locally on my computer the applet runs as it should. but when i upload the applet to my website it gives me this error : NoClassDefFoundError fft
fft is part of java.lang.math.fft which I assume is part of the java core..
I have spent hours googling the problem but with no results...
the applet is uploaded here : http://www.nimaaj.com/cn.html
any ideas?
thanks |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Ultrahex
|
Posted: Tue Aug 07, 2012 3:27 pm Post subject: Re: java applet only runs locally |
|
|
java.lang.math does not include fft. I can't get it to work at all locally, probably problem with java locally. That is the advice I can give. |
|
|
|
|
![](images/spacer.gif) |
DemonWasp
|
Posted: Tue Aug 07, 2012 4:00 pm Post subject: RE:java applet only runs locally |
|
|
There is no standard java.lang.math.fft, and if you're using a third-party library for FFTs, it shouldn't be polluting java.lang.math, it should be in com.company.fft or org.organisation.fft .
It might help if you told us more about what libraries your project uses, and showed at least the import section of your code in "cranknicjb". |
|
|
|
|
![](images/spacer.gif) |
Homer_simpson
![](http://compsci.ca/v3/uploads/user_avatars/18138546704b4d2a3b2e50e.gif)
|
Posted: Tue Aug 07, 2012 5:17 pm Post subject: Re: java applet only runs locally |
|
|
thanks for your reply...
its odd since I'm not importing any other libraries other than lapack and jblas... and the code runs fine on my computer..
here is the code Quote: import java.applet.*;
import java.awt.*;
import java.lang.Math;
import java.awt.event.*;
import java.util.*;
import org.jblas.*;
import org.netlib.lapack.Dstedc;
import org.netlib.util.*;
public class cranknicjb extends Applet implements AdjustmentListener,MouseListener, MouseMotionListener,Runnable {
/////////////GUI stuffs///////////////////
CheckboxGroup radioGroup;
// The radio buttons to be selected
Checkbox radioeditpot;
Checkbox radiosetpot;
Scrollbar sb_pot;
Scrollbar sb_psi;
Scrollbar sb_psip;
Scrollbar sb_simspd;
AdjustmentListener adjustmentListenersimspd = new AdjustmentListener() {
public void adjustmentValueChanged(AdjustmentEvent adjustmentEvent) {
System.out.println("Adjusted: " + adjustmentEvent.getValue());
simspd= adjustmentEvent.getValue();
}
};
AdjustmentListener adjustmentListener = new AdjustmentListener() {
public void adjustmentValueChanged(AdjustmentEvent adjustmentEvent) {
System.out.println("Adjusted: " + adjustmentEvent.getValue());
pmult= adjustmentEvent.getValue()*20;
}
};
AdjustmentListener adjustmentListenerpsi = new AdjustmentListener() {
public void adjustmentValueChanged(AdjustmentEvent adjustmentEvent) {
System.out.println("Adjusted: " + adjustmentEvent.getValue());
psimult= adjustmentEvent.getValue()*100;
}
};
AdjustmentListener adjustmentListenerpsip = new AdjustmentListener() {
public void adjustmentValueChanged(AdjustmentEvent adjustmentEvent) {
System.out.println("Adjusted: " + adjustmentEvent.getValue());
psipmult= adjustmentEvent.getValue()*1;
}
};
/////////////GUI stuffs///////////////////
public static final double PI = 3.141592653;
FFT fft;
int app_width, app_height,width;
int mx, my,lastmx,lastmy,tempmx,tempmy; // the mouse coordinates
boolean isButtonPressed = false;
boolean mouseclicked = false;
boolean potchanged = false;
double time;
Thread t = null;
boolean threadSuspended;
boolean statstate=true,editing_pot_flag=false,xspace_flag=false;
Image potbuffer,xspaceampbuffer,xspacebuffer,pspacebuffer;
Graphics potg,xspaceampg,xspaceg,pspaceg;
Color phasecolor[];
//double[] pot={0.16, 0.09, 0.04, 0.01, 0., 0.01, 0.04, 0.09, 0.16, 0.25};
//double[] psir={0.109085, -0.169193, -0.663612, -0.591441, 0.283662, 0.868798,0.505356, -0.0591559, -0.183954, -0.0688752};
//double[] psii={-0.16989, -0.369693, -0.0945956, 0.684783, 0.958924, 0.252826,-0.440391, -0.402243, -0.0832053, 0.044656};
double x;
int max_points;
double xlength=100;
double psi_p[], psi_pr[], psi_pi[];
ComplexDouble psi[];
ComplexDouble psistat[];
double estat;
double psi_pa[];
ComplexDouble diag[];
ComplexDouble sdiag[];
ComplexDouble zmat[];
double dispmax[];
double [] energy_values;
double eigen_vectors[][];
ComplexDouble lambda;
double pot[];
double dx=3;
double dt=0.000001;
double m=.001;
double h=1;
double emult=.00005;
double psimult=3000;
double psipmult=5;
double pmult=1000;
double simspd=100;
Button helloButton = new Button("Hello World!");
public void adjustmentValueChanged(AdjustmentEvent e)
{
}
public void drawall(){
potg.clearRect( 0, 0, 700, 200 );
xspaceg.clearRect(0,0,700,100);
xspaceampg.clearRect(0,0,700,100);
pspaceg.clearRect(0,0,700,100);
for ( double i = 0;((i < max_points-1)); ++i )
{
potg.setColor( Color.gray );
potg.drawLine(0,200-(int)(emult*pmult*energy_values[(int)i]),width,200-(int)(emult*pmult*energy_values[(int)i]));
potg.setColor( Color.green );
potg.drawLine( (int)(i/max_points*width),200-(int)(pmult*pot[(int)i]), (int)((i+1)/max_points*width) , 200-(int)(pmult*pot[(int)i+1]));
xspaceampg.setColor( phasecolor[(int)(psi[(int)i].arg()/(PI)*360)] );
xspaceampg.drawLine( (int)(i/max_points*width),100, (int)(i/max_points*width),100-(int)(2.0*psimult*psi[(int)i].abs()));
xspaceg.setColor( Color.red );
xspaceg.drawLine( (int)(i/max_points*width),50-(int)(psimult*psi[(int)i].real()), (int)((i+1)/max_points*width) , 50-(int)(psimult*psi[(int)i+1].real()));
xspaceg.setColor( Color.blue );
xspaceg.drawLine( (int)(i/max_points*width),50-(int)(psimult*psi[(int)i].imag()), (int)((i+1)/max_points*width) , 50-(int)(psimult*psi[(int)i+1].imag()));
pspaceg.setColor( Color.red );
pspaceg.drawLine( (int)(i/max_points*width),50-(int)(psipmult*psi_pr[(int)(i)]), (int)((i+1)/max_points*width) , 50-(int)(psipmult*psi_pr[(int)(i+1)]));
pspaceg.setColor( Color.blue );
pspaceg.drawLine( (int)(i/max_points*width),50-(int)(psipmult*psi_pi[(int)(i)]), (int)((i+1)/max_points*width) , 50-(int)(psipmult*psi_pi[(int)(i+1)]));
pspaceg.setColor( Color.white );
pspaceg.drawLine( (int)(i/max_points*width),50-(int)(psipmult*psi_pa[(int)(i)]), (int)((i+1)/max_points*width) , 50-(int)(psipmult*psi_pa[(int)(i+1)]));
}
for ( int i = 0; i < max_points-1; ++i )
for ( int j = 0; j < 6; ++j )
{
potg.drawLine( (int)(i/max_points*width),app_height-(int)(100*eigen_vectors[j][(int)i]+30+20*j), (int)((i+1)/max_points*width) , app_height-(int)(100*eigen_vectors[j][(int)i+1]+30+20*j));
}
potg.setColor( Color.darkGray );
potg.drawRect( 1, 1, 698, 200 );
xspaceampg.setColor( Color.darkGray );
xspaceampg.drawRect( 1, 1, 698, 99 );
xspaceg.setColor( Color.darkGray );
xspaceg.drawRect( 1, 1, 698, 99 );
pspaceg.setColor( Color.darkGray );
pspaceg.drawRect( 1, 1, 698, 98);
}
public void updatematrix() {
lambda=new ComplexDouble(0,dt*h/(2*m*dx*dx));
sdiag[0]=new ComplexDouble(0,0);
diag[0]=new ComplexDouble(0,0);
for (int i = 1; i < max_points-1; i++ ) {
diag[i]=lambda.add(1).add(new ComplexDouble(0,pot[i]/(2*h))).add(lambda.mul(.5).mul(sdiag[i-1]));
sdiag[i]=lambda.div(diag[i].mul(-2));
//System.out.println(diag[i].toString()+" "+sdiag[i].toString());
}
}
public void updatepsi() {
time+=dt;
zmat[0]=new ComplexDouble(0,0);
for (int i = 1; i < max_points-1; i++ ) {
zmat[i]=(((new ComplexDouble(1,0).sub(lambda)).mul(psi[i])).sub(
((new ComplexDouble(0,1).mul(pot[i])).div(new ComplexDouble(2*h,0))).mul(psi[i])).add(
(lambda.mul(new ComplexDouble(.5,0))).mul((psi[i+1].add(psi[i-1]).add(zmat[i-1]))))).div(diag[i]);
}
for (int i = max_points-2; i > 1; i-- ) {
psi[i]=zmat[i].sub(sdiag[i].mul(psi[i+1]));
}
}
public void updatepsi2() {
time+=dt;
for (int i = 1; i < max_points-1; i++ ) {
psi[i]=psistat[i].mul(new ComplexDouble(Math.sin(estat*time),Math.cos(estat*time)));
}
}
public void normalizepsi() {
double norm=0;
for (int i = 0; i < max_points; i++ ) {
norm +=psi[i].abs();
}
//System.out.println("norm = "+norm);
norm=1/norm;
for (int i = 0; i < max_points; i++ ) {
psi[i]=psi[i].mul(norm);
}
}
public void normalizepsistat() {
double norm=0;
for (int i = 0; i < max_points; i++ ) {
norm +=psistat[i].abs();
}
//System.out.println("norm = "+norm);
norm=1/norm;
for (int i = 0; i < max_points; i++ ) {
psistat[i]=psistat[i].mul(norm);
}
}
public void clickedonx() {
statstate=false;
for (int i = 0; i < max_points; i++ ) {
x=(double)i/(double)max_points*xlength;
psi[i]=new ComplexDouble(
Math.exp(-1*(x-((double)mx/(double)width)*xlength)*(x-((double)mx/(double)width)*xlength)),
0*Math.exp(-1*(x-((double)mx/(double)width)*xlength)*(x-((double)mx/(double)width)*xlength))
);
}
psi[0]=new ComplexDouble(0,0);
psi[max_points]=new ComplexDouble(0,0);
normalizepsi();
for (int i = 0; i != max_points; i++) {
int ii = (i <= max_points/2) ? (max_points/2-i)*2 : (max_points-(i-max_points/2))*2;
psi_p[ii] = psi[max_points-1-i].real();
psi_p[ii+1] = psi[max_points-1-i].imag();
}
fft.transform(psi_p, false);
for (int i = 0; i != max_points; i++) {
int ii = (i <= max_points/2) ? (max_points/2-i)*2 :
(max_points-(i-max_points/2))*2;
psi_pr[i] = psi_p[ii];
psi_pi[i] = psi_p[ii+1];
psi_pa[i]=Math.sqrt(psi_p[ii]*psi_p[ii]+psi_p[ii+1]*psi_p[ii+1]);
}
drawall();
}
public void calceigen()
{
double diag_ti[] = new double[max_points];
double sdiag_ti[] = new double[max_points];
double dispmax[] = new double[max_points];
double zmatrix_ti[] = new double[max_points*max_points];
double beta=h*h/(2*m*dx*dx);
///////////////////////////////////////stationary states/////////////////////////////////
int i, j;
for (i = 0; i < max_points; ++i ) {
diag_ti[i]=beta*(pot[i]+2);
sdiag_ti[i]=-beta;
int in=i*max_points;
for (j = 0; j != max_points; j++)
zmatrix_ti[in+j] = 0;
zmatrix_ti[in+i] = 1;
}
double work[] = new double[1+4*max_points+max_points*max_points];
int iwork[] = new int[3+5*max_points];
intW info = new intW(0);
// use LAPACK to find the eigenvalues and eigenvectors
Dstedc.dstedc("I", max_points,
diag_ti, 0, sdiag_ti, 0, zmatrix_ti, 0, max_points,
work, 0, work.length, iwork, 0, iwork.length,
info);
energy_values = new double[max_points];
//elevelCount = n;
// now get the eigenvalues and sort them
for (i = 0; i != max_points; i++) {
energy_values[i] = diag_ti[i];
}
eigen_vectors = new double[max_points][max_points];
for (i = 0; i != max_points; i++) {
for (j = 0; j != max_points; j++)
if (energy_values[i] == diag_ti[j])
break;
if (j == max_points) {
System.out.print("can't find elevels! " + i + " " + energy_values[i] + "\n");
continue;
}
diag_ti[j] = -1;
int k;
dispmax[i] = 0;
for (k = 0; k != max_points; k++) {
eigen_vectors[i][k] = zmatrix_ti[j*max_points+k];
if (eigen_vectors[i][k] > dispmax[i])
dispmax[i] = eigen_vectors[i][k];
else if (-eigen_vectors[i][k] > dispmax[i])
dispmax[i] = -eigen_vectors[i][k];
}
}
///////////////////////////////////////stationary states/////////////////////////////////*/
}
public void init() {
////////////////////////////////gui stuff////////////////////////////////
setLayout(null);
radioGroup = new CheckboxGroup();
radioeditpot = new Checkbox("Edit", radioGroup,false);
radiosetpot = new Checkbox("Select", radioGroup,true);
radioeditpot.setBounds(720,50,80,20);
radiosetpot.setBounds(720,70,80,20);
add(radioeditpot);
add(radiosetpot);
Scrollbar sb_simspd = new Scrollbar (Scrollbar.HORIZONTAL, 100, 1, 7, 1001);
simspd=100;
sb_simspd.setBounds(10,510,200,20);
sb_simspd.addAdjustmentListener(adjustmentListenersimspd);
add(sb_simspd);
Scrollbar sb_pot = new Scrollbar (Scrollbar.VERTICAL, 50, 1, 80, 120);
pmult=1600;
sb_pot.setBounds(700,1,20,200);
sb_pot.addAdjustmentListener(adjustmentListener);
add(sb_pot);
Scrollbar sb_psi = new Scrollbar (Scrollbar.VERTICAL, 9, 1, 7, 201);
psimult=900;
sb_psi.setBounds(700,200,20,200);
sb_psi.addAdjustmentListener(adjustmentListenerpsi);
add(sb_psi);
Scrollbar sb_psip = new Scrollbar (Scrollbar.VERTICAL, 27, 1, 7, 300);
psipmult=27;
sb_psip.setBounds(700,400,20,100);
sb_psip.addAdjustmentListener(adjustmentListenerpsip);
add(sb_psip);
////////////////////////////////gui stuff////////////////////////////////
////////////////////////////////phase colors////////////////////////////////
phasecolor= new Color[361];
for (float j = 0; j < 361; j++ )
phasecolor[(int)j]=new Color(j/360,(float) 0.2, (360-j)/360);
app_width = getSize().width;
////////////////////////////////phase colors////////////////////////////////
////////////////////////////////init values////////////////////////////////
width=app_width-100;
max_points=1024;
dx=xlength/max_points;
app_height = getSize().height;
setBackground( Color.black );
mx = app_width/2;
my = app_height/2;
lastmx = -1;
lastmy = -1;
time=0;
////////////////////////////////init values////////////////////////////////
////////////////////////////////allocate memory////////////////////////////////
psi= new ComplexDouble[max_points+1];
psistat= new ComplexDouble[max_points+1];
psi_pa= new double[max_points];
diag= new ComplexDouble[max_points+1];
sdiag= new ComplexDouble[max_points+1];
zmat= new ComplexDouble[max_points+1];
pot= new double[max_points+1];
psi_p = new double[max_points*2];
psi_pr = new double[max_points+1];
psi_pi = new double[max_points+1];
fft = new FFT(max_points);
////////////////////////////////allocate memory////////////////////////////////
////////////////////////////////init pot////////////////////////////////
for (int i = 0; i < max_points; i++ ) {
x=(double)i/(double)max_points*xlength;
pot[i]=.5*((x-xlength/2)*(x-xlength/2)/(xlength*xlength)+
0*Math.exp(-1*(x-.5*xlength)*(x-.5*xlength))+
0*Math.exp(-1*(x-.4*xlength)*(x-.4*xlength))+
0*Math.exp(-1*(x-.6*xlength)*(x-.6*xlength)));
psi[i]=new ComplexDouble(
2000*Math.exp(-.01*(x-.5*xlength)*(x-.5*xlength))*Math.cos(5*x),
2000*Math.exp(-.01*(x-.5*xlength)*(x-.5*xlength))*Math.sin(5*x)
);
////////////////////////////////init pot////////////////////////////////
}
//for (int i = 500; i < 540; i++ )
//pot[i]=.2;
//pot[10]=100;
//pot[max_points-10]=100;
//pot[0]=100;
//pot[max_points]=100;
////////////////////////////////init calc////////////////////////////////
psi[0]=new ComplexDouble(0,0);
psi[max_points]=new ComplexDouble(0,0);
normalizepsi();
updatematrix();//crank-nicholson matrix
calceigen();//calculate stationary states
////////////////////////////////init calc////////////////////////////////
////////////////////////////////init psi////////////////////////////////
for (int i = 0; i < max_points; ++i ) {
psistat[i]=new ComplexDouble(
eigen_vectors[0][i],
0
);
psi[i]=new ComplexDouble(
eigen_vectors[0][i],
0
);
}
estat=energy_values[0];
normalizepsi();
normalizepsistat();
////////////////////////////////init psi////////////////////////////////
////////////////////////////////window buffer and mouse////////////////////////////////
addMouseListener( this );
addMouseMotionListener( this );
potbuffer = createImage( 700, 201 );
xspaceampbuffer = createImage( 700, 100 );
xspacebuffer = createImage( 700, 100 );
pspacebuffer = createImage( 700, 100 );
potg = potbuffer.getGraphics();
xspaceampg=xspaceampbuffer.getGraphics();
xspaceg=xspacebuffer.getGraphics();
pspaceg=pspacebuffer.getGraphics();
potg.setColor( Color.black );
xspaceampg.setColor( Color.black );
xspaceg.setColor( Color.black );
pspaceg.setColor( Color.black );
//helloButton.setBounds(20,20,100,30);
//add(helloButton);
////////////////////////////////window buffer and mouse////////////////////////////////
}
/////////////////////////////////////////////////////////thread stuffs/////////////////////////////////////////////////////////
// Executed when the applet is destroyed.
public void destroy() {
System.out.println("destroy()");
}
// Executed after the applet is created; and also whenever
// the browser returns to the page containing the applet.
public void start() {
if ( t == null ) {
t = new Thread( this );
threadSuspended = false;
t.start();
}
else {
if ( threadSuspended ) {
threadSuspended = false;
synchronized( this ) {
notify();
}
}
}
}
// Executed whenever the browser leaves the page containing the applet.
public void stop() {
threadSuspended = true;
}
// Executed within the thread that this applet created.
public void run() {
try {
while (true) {
// Here's where the thread does some work
//int val = sb.getValue();
//System.out.println(val+" ");
showStatus( "time is " + time );
// Now the thread checks to see if it should suspend itself
if ( threadSuspended ) {
synchronized( this ) {
while ( threadSuspended ) {
wait();
}
}
}
////////////////////////////////update psi////////////////////////////////
for (int k =0;((k<simspd)&&(!isButtonPressed));k++)
{
if(!statstate)
updatepsi();
else
updatepsi2();
}
////////////////////////////////update psi////////////////////////////////
////////////////////////////////calculate momentum space psi(FFT)////////////////////////////////
for (int i = 0;(( i != max_points)); i++) {
int ii = (i <= max_points/2) ? (max_points/2-i)*2 : (max_points-(i-max_points/2))*2;
psi_p[ii] = psi[max_points-1-i].real();
psi_p[ii+1] = psi[max_points-1-i].imag();
}
fft.transform(psi_p, false);
for (int i = 0; (( i != max_points)); i++) {
int ii = (i <= max_points/2) ? (max_points/2-i)*2 :
(max_points-(i-max_points/2))*2;
psi_pr[i] = psi_p[ii];
psi_pi[i] = psi_p[ii+1];
psi_pa[i]=Math.sqrt(psi_p[ii]*psi_p[ii]+psi_p[ii+1]*psi_p[ii+1]);
}
////////////////////////////////calculate momentum space psi(FFT)////////////////////////////////
////////////////////////////////draw everything to buffer////////////////////////////////
drawall();
////////////////////////////////draw everything to buffer////////////////////////////////
////////////////////////////////process mouse////////////////////////////////
potg.drawString( "das pooooooooooop! "+mx+","+my+" "+isButtonPressed+",lastmx :"+lastmx, mx, my );
if(isButtonPressed)////////////////////////////////mouse pressed////////////////////////////////
{
if(((my>200)&&(my<400)&&(!editing_pot_flag))||(xspace_flag))////////////////////////////////clicked on xspace and not editing pot flag////////////////////////////////
{
if (mouseclicked)
{
isButtonPressed = false;
mouseclicked=false;
}
clickedonx();
xspace_flag=true;
repaint();
}////////////////////////////////clicked on xspace and not editing pot flag////////////////////////////////
if(((my<200)&&(!xspace_flag))||(editing_pot_flag))////////////////////////////////(clicked on pot and not xspace flag) or edit pot flag////////////////////////////////
{
if(radiosetpot.getState())////////////////////////////////set pot////////////////////////////////
{
if ((
(my>200-(int)(.5*(emult*pmult*energy_values[(int)0]+emult*pmult*energy_values[(int)1])))
&&
(my<200-(int)(.5*(emult*pmult*energy_values[(int)0])))
)||(my==200-(int)(emult*pmult*energy_values[(int)0])))
{////////////////////////////////clicked on or halfway betweem grnd and first excited////////////////////////////////
potg.setColor( Color.white );
potg.drawLine(0,200-(int)(emult*pmult*energy_values[(int)0]),width,200-(int)(emult*pmult*energy_values[(int)0]));
for (int i = 0; i < max_points; ++i ) {
psistat[i]=new ComplexDouble(
eigen_vectors[0][i],
0
);
}
estat=energy_values[0];
normalizepsistat();
statstate=true;
}////////////////////////////////clicked on or halfway betweem grnd and first excited////////////////////////////////
for ( int j = 1; j < max_points-2; ++j )////////////////////////////////start from first excited through all energies////////////////////////////////
{
if ((
(my>200-(int)(.5*(emult*pmult*energy_values[(int)j]+emult*pmult*energy_values[(int)j+1])))
&&
(my<200-(int)(.5*(emult*pmult*energy_values[(int)j]+emult*pmult*energy_values[(int)j-1])))
)|| (my==200-(int)(emult*pmult*energy_values[(int)j])))
{////////////////////////////////clicked around(halfway points) or on energy level////////////////////////////////
potg.setColor( Color.white );
potg.drawLine(0,200-(int)(emult*pmult*energy_values[(int)j]),width,200-(int)(emult*pmult*energy_values[(int)j]));
for (int i = 0; i < max_points; ++i ) {
psistat[i]=new ComplexDouble(
eigen_vectors[j][i],
0
);
}
estat=energy_values[j];
normalizepsistat();
statstate=true;
}////////////////////////////////clicked around(halfway points) or on energy level////////////////////////////////
}////////////////////////////////start from first excited through all energies////////////////////////////////
isButtonPressed = false;
mouseclicked=false;
}////////////////////////////////set pot////////////////////////////////
if((radioeditpot.getState())||(editing_pot_flag))////////////////////////////////edit pot or edit pot flag////////////////////////////////
{
editing_pot_flag=true;
if (mouseclicked)
{
isButtonPressed = false;
mouseclicked=false;
editing_pot_flag=false;
}
if(mx>0)
tempmx=mx;
else
tempmx=1;
tempmy=my;
if(my<200)
tempmy=my;
else
tempmy=200;
if(tempmx<width)
{
if(lastmx==-1)
{
lastmx=tempmx;
lastmy=tempmy;
pot[(int)(mx/(double)width*(double)max_points)]=(200-tempmy)/pmult;
}
if (tempmx<lastmx){
for(double mxi=tempmx;mxi<lastmx;mxi+=dx)
{
pot[(int)(mxi/(double)width*(double)max_points)]=(200-tempmy)/pmult;
}
}else
{
for(double mxi=tempmx;mxi>lastmx;mxi-=dx)
{
pot[(int)(mxi/(double)width*(double)max_points)]=(200-tempmy)/pmult;
}
}
drawall();
lastmx=tempmx;
lastmy=tempmy;
potchanged=true;
repaint();
}
}////////////////////////////////edit pot or edit pot flag////////////////////////////////
}////////////////////////////////(clicked on pot and not xspace flag) or edit pot flag////////////////////////////////
}////////////////////////////////mouse pressed////////////////////////////////
else
{////////////////////////////////mouse not pressed////////////////////////////////
xspace_flag=false;
if(potchanged)////////////////////////////////potential recalc////////////////////////////////
{
potg.setColor( Color.gray );
potg.fillRect( width/2-50, app_height/2-30, 200, 60);
potg.setColor( Color.darkGray );
potg.fillRect( width/2-45, app_height/2-25, 190, 50);
potg.setColor( Color.white );
potg.drawString("Calculating Eigenstates...", width/2-40, app_height/2 );
repaint();
editing_pot_flag=false;
calceigen();
updatematrix();
for (int i = 0; i < max_points; ++i ) {
psistat[i]=new ComplexDouble(
eigen_vectors[0][i],
0
);
psi[i]=new ComplexDouble(
eigen_vectors[0][i],
0
);
}
estat=energy_values[0];
normalizepsi();
normalizepsistat();
potchanged=false;
lastmx = -1;
lastmy = -1;
}////////////////////////////////potential recalc////////////////////////////////
if((my<200)&&(radiosetpot.getState()))
{////////////////////////////////draw floating stationary state psi////////////////////////////////
if ((
(my>200-(int)(.5*(emult*pmult*energy_values[(int)0]+emult*pmult*energy_values[(int)1])))
&&
(my<200-(int)(.5*(emult*pmult*energy_values[(int)0])))
)||(my==200-(int)(emult*pmult*energy_values[(int)0])))
{////////////////////////////////clicked on or halfway betweem grnd and first excited////////////////////////////////
potg.setColor( Color.white );
xspaceg.setColor( Color.white );
potg.drawLine(0,200-(int)(emult*pmult*energy_values[(int)0]),width,200-(int)(emult*pmult*energy_values[(int)0]));
for ( double i = 0; i < max_points-1; ++i )
{
xspaceg.drawLine( (int)(i/max_points*width),50-(int)(100*eigen_vectors[0][(int)i]), (int)((i+1)/max_points*width) , 50-(int)(100*eigen_vectors[0][(int)i+1]));
}
}////////////////////////////////clicked on or halfway betweem grnd and first excited////////////////////////////////
for ( int j = 1; j < max_points-2; ++j )
{
if ((
(my>200-(int)(.5*(emult*pmult*energy_values[(int)j]+emult*pmult*energy_values[(int)j+1])))
&&
(my<200-(int)(.5*(emult*pmult*energy_values[(int)j]+emult*pmult*energy_values[(int)j-1])))
)|| (my==200-(int)(emult*pmult*energy_values[(int)j])))
{////////////////////////////////clicked around(halfway points) or on energy level////////////////////////////////
potg.setColor( Color.white );
xspaceg.setColor( Color.white );
potg.drawLine(0,200-(int)(emult*pmult*energy_values[(int)j]),width,200-(int)(emult*pmult*energy_values[(int)j]));
for ( double i = 0; i < max_points-1; ++i )
{
xspaceg.drawLine( (int)(i/max_points*width),50-(int)(100*eigen_vectors[j][(int)i]), (int)((i+1)/max_points*width) , 50-(int)(100*eigen_vectors[j][(int)i+1]));
}
}////////////////////////////////clicked around(halfway points) or on energy level////////////////////////////////
}
}////////////////////////////////draw floating stationary state psi////////////////////////////////
repaint();
}////////////////////////////////mouse not pressed////////////////////////////////
////////////////////////////////process mouse////////////////////////////////
t.sleep( 10 ); // interval given in milliseconds
}
}
catch (InterruptedException e) { }
}
/////////////////////////////////////////////////////////thread stuffs/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////mouse stuffs/////////////////////////////////////////////////////////
public void mouseEntered( MouseEvent e ) {
// called when the pointer enters the applet's rectangular area
}
public void mouseExited( MouseEvent e ) {
// called when the pointer leaves the applet's rectangular area
}
public void mouseClicked( MouseEvent e ) {
// called after a press and release of a mouse button
// with no motion in between
// (If the user presses, drags, and then releases, there will be
// no click event generated.)
isButtonPressed = true;
mouseclicked=true;
}
public void mousePressed( MouseEvent e ) { // called after a button is pressed down
isButtonPressed = true;
}
//setBackground( Color.gray );
//repaint();
// "Consume" the event so it won't be processed in the
// default manner by the source which generated it.
//e.consume();
public void mouseReleased( MouseEvent e ) { // called after a button is released
isButtonPressed = false;
//setBackground( Color.black );
//repaint();
//e.consume();
}
public void mouseMoved( MouseEvent e ) { // called during motion when no buttons are down
mx = e.getX();
my = e.getY();
//showStatus( "Mouse at (" + mx + "," + my + ")" );
//repaint();
//e.consume();
}
public void mouseDragged( MouseEvent e ) { // called during motion with buttons down
mx = e.getX();
my = e.getY();
isButtonPressed = true;
//showStatus( "Mouse at (" + mx + "," + my + ")" );
//repaint();
//e.consume();
}
/////////////////////////////////////////////////////////mouse stuffs/////////////////////////////////////////////////////////
public void update( Graphics g ) {
g.drawImage( potbuffer, 0, 0, this );
g.drawImage( xspaceampbuffer, 0, 201, this );
g.drawImage( xspacebuffer, 0, 301, this );
g.drawImage( pspacebuffer, 0, 401, this );
//g.drawImage (potbuffer,0, potbuffer.getHeight(this), potbuffer.getWidth(this), 0,0, 0, potbuffer.getWidth(this), potbuffer.getHeight(this),this);
}
public void paint( Graphics g ) {
update( g );
getToolkit().sync();
}
} |
|
|
|
|
![](images/spacer.gif) |
Homer_simpson
![](http://compsci.ca/v3/uploads/user_avatars/18138546704b4d2a3b2e50e.gif)
|
|
|
|
![](images/spacer.gif) |
chrisbrown
![](http://compsci.ca/v3/uploads/user_avatars/18814724584bcbb8192aae8.png)
|
Posted: Tue Aug 07, 2012 8:50 pm Post subject: Re: java applet only runs locally |
|
|
The Apache Commons math library doesn't abbreviate FFT as a class name so it's probably not using that one, and none of your jars contain a class named FFT so it must be finding it on your local classpath.
What's the output of code: | FFT.class.getName(); |
|
|
|
|
|
![](images/spacer.gif) |
Homer_simpson
![](http://compsci.ca/v3/uploads/user_avatars/18138546704b4d2a3b2e50e.gif)
|
Posted: Tue Aug 07, 2012 10:50 pm Post subject: Re: java applet only runs locally |
|
|
that command returns "FFT"
my local class path is:
C:\Program Files (x86)\Java\jre7\lib\jlapack-0.8\netlib-java-0.9.3.jar;C:\Program Files (x86)\Java\jre7\lib\jlapack-0.8\arpack_combined_all.jar;C:\Users\4dmin\Documents\java works\Jama-1.0.2.jar;C:\Users\4dmin\Documents\java works\jblas-1.2.0.jar;C:\Users\4dmin\Documents\java works\jtransforms-2.4.jar;
I'm stumped ![Sad Sad](images/smiles/icon_sad.gif) |
|
|
|
|
![](images/spacer.gif) |
Homer_simpson
![](http://compsci.ca/v3/uploads/user_avatars/18138546704b4d2a3b2e50e.gif)
|
Posted: Tue Aug 07, 2012 11:05 pm Post subject: Re: java applet only runs locally |
|
|
Oh i figured it out i simply had not uploaded all the class files to the server... now its running well: http://nimaaj.com/schsim.html
thanks for ur help guys |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
chrisbrown
![](http://compsci.ca/v3/uploads/user_avatars/18814724584bcbb8192aae8.png)
|
Posted: Wed Aug 08, 2012 12:22 am Post subject: Re: java applet only runs locally |
|
|
Don't forget to add netlib and arpack to the archive parameter. As it is now, it throws a NoClassDefFound on netlib's initW. And unless there's something hiding in there, I don't think you need jtransform either. As far as I can tell, it works fine for me when I use code: | archive="jblas-1.2.0.jar,netlib-java-0.9.3.jar,arpack_combined_all.jar" |
That aside, it looks like a neat tool. What's it going to be used for? |
|
|
|
|
![](images/spacer.gif) |
Homer_simpson
![](http://compsci.ca/v3/uploads/user_avatars/18138546704b4d2a3b2e50e.gif)
|
Posted: Wed Aug 08, 2012 12:45 pm Post subject: Re: java applet only runs locally |
|
|
Thanks, I wrote it to help demonstrate the behavior of Schrodinger's equation for students taking third year quantum mechanics course at YorkU. |
|
|
|
|
![](images/spacer.gif) |
|
|