no need to extends anything, in fact PlotXDPanel classes are JPanels, so you can use it directly in your applets.
Of course the I/O features like export to png file will be unavailable except if the applet security policy is configured to allow local writing (which is not a secured solution at all...)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"3DExample.class" wasn't actually the name of the class, but something I had just stuck in there for clarity.
i have included the class that generates the 3D plot, which was lifted off the example on your webpage, along with a simple, but messy, class that creates an array of circle coordinates. the html tag is basically the as the link but with "OneMoreTime" substituted. Thanks a lot for any help you can give.
// First Program
package plot;
import org.jmathplot.gui.*;
public class OneMoreTime {
public static void main(String[] args) {
//build a data set
GenerateCircle datas = new GenerateCircle();
Plot3DPanel plot3d = new Plot3DPanel(datas.getData(),"datas","LINE");
new FrameView(plot3d);
plot3d.addPlot(datas.getData(),"datas","SCATTER");
}
}
//circle coordinates program
package plot;
public class GenerateCircle {
public double[][] datas = new double[84][3];
public GenerateCircle(){
int x = 0;
double r = 400;
for (x = 0; x < 21; x++) {
datas[x][0] = x;//x = x
datas[x][1] = Math.sqrt(r - Math.pow(x,2));//y
datas[x][2] = x;//z
}
for (int a = 20; a >= 0; a--) {
datas[x][0] = a;//x = x
datas[x][1] = -Math.sqrt(r - Math.pow(a,2));//y
datas[x][2] = a;//z
x++;
}
for (int a = 0; a < 21; a++) {
datas[x][0] = -a;//x = x
datas[x][1] = -Math.sqrt(r - Math.pow(a,2));//y
datas[x][2] = -a;//z
x++;
}
for (int a = 20; a >= 0; a--) {
datas[x][0] = -a;//x = x
datas[x][1] = Math.sqrt(r - Math.pow(a,2));//y
datas[x][2] = -a;//z
x++;
}
}
public double[][]getData(){
return datas;
}
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thanks. let me try to work through your example and see if I can get that working. seems like you use the "extends Applet" statement and I don't. So that might have something to do with it, although I tried that earlier and it didn't work. Secondly, you have the ".jar" file in your HTML code, which I am not sure what it does in this instance, but is missing from my example too.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
was able to compile a few programs that use the 3D plot. awesome. is there simple way to extend these classes to be applet enabled?
no need to extends anything, in fact PlotXDPanel classes are JPanels, so you can use it directly in your applets.
Of course the I/O features like export to png file will be unavailable except if the applet security policy is configured to allow local writing (which is not a secured solution at all...)
thanks. i tried compiling the example given on the webpage that uses the Plot3DPanel class and then using an html tag like
<APPLET CODE="3DExample.class" WIDTH=300 HEIGHT=300>
</APPLET>
to put it in to enable on a webpage, but had no luck - both extending as an applet or as a stand-alone. is there something I am doing wrong?
It seems to me you need to begin the name of your classes not with numbers (I'm not sure).
Can you give me the source code of your class ?
thanks.
"3DExample.class" wasn't actually the name of the class, but something I had just stuck in there for clarity.
i have included the class that generates the 3D plot, which was lifted off the example on your webpage, along with a simple, but messy, class that creates an array of circle coordinates. the html tag is basically the as the link but with "OneMoreTime" substituted. Thanks a lot for any help you can give.
// First Program
package plot;
import org.jmathplot.gui.*;
public class OneMoreTime {
public static void main(String[] args) {
//build a data set
GenerateCircle datas = new GenerateCircle();
Plot3DPanel plot3d = new Plot3DPanel(datas.getData(),"datas","LINE");
new FrameView(plot3d);
plot3d.addPlot(datas.getData(),"datas","SCATTER");
}
}
//circle coordinates program
package plot;
public class GenerateCircle {
public double[][] datas = new double[84][3];
public GenerateCircle(){
int x = 0;
double r = 400;
for (x = 0; x < 21; x++) {
datas[x][0] = x;//x = x
datas[x][1] = Math.sqrt(r - Math.pow(x,2));//y
datas[x][2] = x;//z
}
for (int a = 20; a >= 0; a--) {
datas[x][0] = a;//x = x
datas[x][1] = -Math.sqrt(r - Math.pow(a,2));//y
datas[x][2] = a;//z
x++;
}
for (int a = 0; a < 21; a++) {
datas[x][0] = -a;//x = x
datas[x][1] = -Math.sqrt(r - Math.pow(a,2));//y
datas[x][2] = -a;//z
x++;
}
for (int a = 20; a >= 0; a--) {
datas[x][0] = -a;//x = x
datas[x][1] = Math.sqrt(r - Math.pow(a,2));//y
datas[x][2] = -a;//z
x++;
}
}
public double[][]getData(){
return datas;
}
}
Here is an example of what an applet could be :
package org.jmathplot.examples;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import org.jmathplot.gui.*;
import org.jmathplot.util.*;
/**
* <p>Copyright : BSD License</p>
* @author Yann RICHET
* @version 1.0
*/
public class SimpleApplet
extends Applet {
public void init() {
double[][] datas = DoubleArray.random(10, 3);
PlotPanel plotpanel = new Plot3DPanel(datas, "datas", PlotPanel.SCATTER);
plotpanel.setSize(600, 600);
plotpanel.setPreferredSize(new Dimension(600, 600));
this.add(plotpanel);
}
}
and the html source :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-15">
<title>Page de test HTML</title>
</head>
<body>
<applet archive="jmathplot_examples.jar" codebase="."
code="org/jmathplot/examples/SimpleApplet.class" name="AppletTest"
width="600" height="600" hspace="0" vspace="0" align="middle">
</applet>
</body>
</html>
the java source code you posted seems to work too.
thanks. let me try to work through your example and see if I can get that working. seems like you use the "extends Applet" statement and I don't. So that might have something to do with it, although I tried that earlier and it didn't work. Secondly, you have the ".jar" file in your HTML code, which I am not sure what it does in this instance, but is missing from my example too.