私の他の記事で述べたように、私はJavaの初心者です。私はProcessingからコードを実行しようとしています。売上データに基づいて球を作成し、Eclipse IDEを使用してJavaに変換し、コード実行後に以下のエラーが発生しました。私はカーソルが「ローカル変数m2の値が使用されていません」と表示置くと、それはフロートメートルとフロート平方メートル(メッセージを表示する行でも処理コードがEclipseエラーを使用してJavaに変換されました
。私は任意のヘルプをお願い申し上げます。
import java.awt.Color;
import processing.core.*;
import processing.core.PVector;
import processing.data.Table;
import processing.data.TableRow;
public class UsingProcessing extends PApplet {
Table table;
int ballcount = 11;
//int ballcount = table.getRowCount(); //NullPoint Exception error happening here
PVector[] orgin = new PVector[ballcount];
float[]radii = new float[ballcount];
Balls[]balls;
Color[]cols = new Color[ballcount];
public void setup(){
background(255, 127, 245);
noStroke();
ortho();
table = loadTable("HW 1 Data.csv", "header");
println(table.getRowCount() + " total rows in table");
balls = new Balls[table.getRowCount()];
for (int i = 0; i<table.getRowCount(); i++){
TableRow row = table.getRow(i);
int product = row.getInt("Product");
int sales = row.getInt("Sales");
int category = row.getInt("Category");
//Add to Arrays
orgin[i]= new PVector(width/2, height/2);
balls[i] = new Balls(product,sales,category);
radii[i] = (sales/30000);
if (category == 1) {
cols[i]= new Color(255, 30, 50);
} else if (category == 2){
cols[i]= new Color(100,255,50);
} else {
cols[i]= new Color(100,50,255);
}
//cols[i]= color(150,100,150,200);
}
}
public void draw() {
background(50);
shininess(45);
lightSpecular(255, 255, 255);
directionalLight(254, 254, 254, 1, 1, -1);
specular(225, 225, 225);
ambientLight(90, 90, 90);
ambient(90, 90, 90);
// orb-orb collision
for (int i=0; i<orgin.length; i++) {
for (int j=1+1; j<orgin.length; j++) {
float r2 = radii[i] + radii[j];
float d = dist(orgin[i].x, orgin[i].y, orgin[j].x, orgin[j].y);
if (d < r2) {
if (d==0) { // avoid dist of 0
orgin[i].add(new PVector(random(-.1, .1), random(-.1, .1)));
}
PVector axis = PVector.sub(orgin[i], orgin[j]);
float m = axis.mag();
float m2 = radii[i] + radii[j] - m;
axis.normalize();
PVector temp = new PVector();
temp.set(orgin[i]);
orgin[i].x = orgin[j].x + axis.x*r2;
orgin[i].y = orgin[j].y + axis.y*r2;
orgin[j].x = temp.x - axis.x*r2;
orgin[j].y = temp.y - axis.y*r2;
}
}
}
for (int i=0; i<orgin.length; i++) {
fill(cols[i].getRGB());
pushMatrix();
translate(orgin[i].x, orgin[i].y);
sphere(radii[i]);
popMatrix();
// boundary collison
if (orgin[i].x > width-radii[i]) {
orgin[i].x = width-radii[i];
} else if (orgin[i].x < radii[i]) {
orgin[i].x = radii[i];
}
if (orgin[i].y > height-radii[i]) {
orgin[i].y = height-radii[i];
} else if (orgin[i].y < radii[i]) {
orgin[i].y = radii[i];
}
}
}
private float random(double d, double e) {
// TODO Auto-generated method stub
return 0;
}
class Balls {
int product;
int sales;
int category;;
int radius;
boolean over = false;
Balls(){
}
Balls(int product, int sales, int category){
this.product = product;
this.sales = sales;
this.category = category;
}
}
public static void main(String[] args) {
PApplet.main("UsingProcessing");
}
public void settings(){
size(1200, 700, P3D);
}
}
エラー:
java.lang.NoClassDefFoundError: com/jogamp/opengl/GLException
at processing.opengl.PGraphicsOpenGL.createPGL(PGraphicsOpenGL.java:668)
at processing.opengl.PGraphicsOpenGL.<init>(PGraphicsOpenGL.java:532)
at processing.opengl.PGraphics3D.<init>(PGraphics3D.java:35)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at processing.core.PApplet.makeGraphics(PApplet.java:2227)
at processing.core.PApplet.createPrimaryGraphics(PApplet.java:2306)
at processing.core.PApplet.initSurface(PApplet.java:10399)
at processing.core.PApplet.runSketch(PApplet.java:10338)
at processing.core.PApplet.main(PApplet.java:10094)
at processing.core.PApplet.main(PApplet.java:10076)
at UsingProcessing.main(UsingProcessing.java:126)
Caused by: java.lang.ClassNotFoundException: com.jogamp.opengl.GLException
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 14 more
java.lang.RuntimeException: com/jogamp/opengl/GLException
at processing.core.PApplet.makeGraphics(PApplet.java:2260)
at processing.core.PApplet.createPrimaryGraphics(PApplet.java:2306)
at processing.core.PApplet.initSurface(PApplet.java:10399)
at processing.core.PApplet.runSketch(PApplet.java:10338)
at processing.core.PApplet.main(PApplet.java:10094)
at processing.core.PApplet.main(PApplet.java:10076)
at UsingProcessing.main(UsingProcessing.java:126)
よりks @KevinWorkman。すべてのライブラリを適切なクラスパスに追加することで修正されました。再度、感謝します。 – DP8