gpt4 book ai didi

java - 从 Eclipse 运行处理时如何解决 java.lang.RuntimeException : The P3D renderer is not in the class path.?

转载 作者:行者123 更新时间:2023-12-01 17:29:27 25 4
gpt4 key购买 nike

我将发布整个代码:

import controlP5.ControlP5;
import processing.core.*;
import processing.core.PApplet;
import processing.core.PFont;
import processing.core.PImage;
import processing.core.PShape;
import processing.event.MouseEvent;

import processing.data.*;
import processing.event.*;
import processing.opengl.*;

public class Two_Maps_Texture extends PApplet {

PFont title;
PFont label;
PImage worldMap;
PImage skyBackground;
PShape box;
Table table, table2;
int rowCount;
float x1, y1, z1, x2, y2, z2;

//Interaction Zoom and Pan Variables:
float zoom = 600;
float panLeft = 0;
float panTop = 0;


DestinationToTrip fromUSA;
DestinationToTrip toUSA;

ControlP5 button1;
ControlP5 button2;
boolean isFromUSAVisible = false;
boolean isToUSAVisible = false;


public void setup() {

table = new Table("From_USA_Coordinates.tsv");
table2 = new Table("To_USA.tsv");
rowCount = table.getRowCount();

worldMap = loadImage("world.topo.bathy.200406.3x5400x2700.jpg");
//skyBackground = loadImage("Screen-Shot-2018-04-28-at-7.46.41-PM");
//skyBackground.resize(1400, 800);
worldMap.resize(500, 300);
textureMode(NORMAL);
fill(255);
//stroke(color(44,48,32));
box = createShape(BOX, -650, 300, 0);
box.beginShape(BOX);
box.endShape();
box.setTexture(worldMap);

fromUSA = new DestinationToTrip(table);
toUSA = new DestinationToTrip(table2);

title = loadFont("Tahoma-Bold-48.vlw");
label = loadFont("Tahoma-48.vlw");

fill(150);

//pushMatrix();
camera();
button1 = new ControlP5(this);
button1.addButton("From_USA_to_Other_Countries").setValue(1).setPosition((100), (height-150)).setSize(200, 100).setColorBackground(color(76,112,170)).setVisible(true);

button2 = new ControlP5(this);
button2.addButton("From_Other_Countries_to_USA").setValue(0).setPosition((350), (height-150)).setSize(200, 100).setColorBackground(color(76,112,170));
//popMatrix();
}

public void draw() {
background(0xff181c70);
fill(0);
titlesAndLegends();
boxSetup();

if(isFromUSAVisible == true) {
fromUSA.displayCurves(table, 0xff4185bf);
}

if(isToUSAVisible == true){
pushMatrix();
toUSA.displayCurves(table2, 0xffdfb34a);
popMatrix();
}
}

public void boxSetup(){
camera(panLeft, zoom , zoom, panLeft, -190, panTop, 0, 1, 0); // eye(0, 600, 600) center(0, 0, 0) up(0, 1, 0)

pushMatrix();
translate(-350, 0, 0);
shape(box);
popMatrix();

pushMatrix();
translate(350, 0, 0);
shape(box);
popMatrix();
}

public void titlesAndLegends() {
pushMatrix();
camera();
textAlign(CENTER);
textSize(40);
fill(0xff91cd83);
textFont(title);
text("Flights Involving USA - 2019", width/2, 90);
textFont(label);
if(isFromUSAVisible == true) {
textSize(20);
fill(0xff4185bf);
text("USA to Other Country", width/2, 150);
} if(isToUSAVisible == true) {
textSize(20);
fill(0xffdfb34a);
text("Other Countries to USA", width/2, 180);
}
popMatrix();
}

public void mouseDragged() {
if((mouseX- pmouseX) > 0){
panLeft -= 5;
} else {
panLeft += 5;
}
}

public void mouseWheel(MouseEvent event) {
float e = event.getCount();
if(e == 1) {
zoom += 30;
}else {
zoom -= 30;
}
}

public void From_USA_to_Other_Countries() {
if(!isFromUSAVisible) {
isFromUSAVisible = true;
}else {
isFromUSAVisible = false;
}
}

public void From_Other_Countries_to_USA() {
if(!isToUSAVisible) {
isToUSAVisible = true;
}else {
isToUSAVisible = false;
}
}
class DestinationToTrip {

Table table;
int rowCount;
float x1, y1, z1, x2, y2, z2;

int stroke = 0xffF05252;



DestinationToTrip(Table table) {
this.table = table;
}

public void displayCurves(Table table, int stroke) {
rowCount = table.getRowCount();
table = new Table("From_USA_Coordinates.tsv");

pushMatrix();
// To use the center of the left box as center coordinates
translate(-350, 0, 0);
textSize(15);

for(int row = 1; row < rowCount; row++) {

float USALatitude = table.getFloat(row, 3);
float USALongitude = table.getFloat(row, 4);
String countryName = table.getString(row,1);

//Mapped Within X-axis of the left side map box

float mappedLatitude = map(USALatitude,-90, 90, 150, -150); // Latitude is in Y axis
float mappedLongitude = map(USALongitude, -180, 180, -325, 325); // Longitude in X Axis
x1 = mappedLongitude;
y1 = mappedLatitude;
z1 = 0;

float tripCountryLatitude = table.getFloat(row, 5);
float tripCountryLongitude = table.getFloat(row, 6);
float tripLatitude = map(tripCountryLatitude, -90, 90, 150, -150); // In Y, same mapping
float tripLongitude = map(tripCountryLongitude, -180, 180, 375, 1025);

// In X, having the position of the right box depending on the coordinates center
x2 = tripLongitude;
y2 = tripLatitude;
z2 = 0;

float zOff = map(0, 0, height, 300, 0); // Move mouse up and down

float a = (x2-x1)/3;
float b = (y2-y1)/3;

stroke(stroke);
noFill();

bezier(x1, y1, z1, // First point
x1 + a, y1 + b, z1 + zOff, // First intermediate point
x2 - a, y2 - b, z2 + zOff, // Second intermediate point
x2, y2, z2);

//rotate(PI);
stroke(255);
fill(255);
text(countryName, x2-10, y2+10, z2+20);
}

popMatrix();

}

}
class Table {
int rowCount;
String[][] data;


Table(String filename) {
String[] rows = loadStrings(filename);
data = new String[rows.length][];

for (int i = 0; i < rows.length; i++) {
if (trim(rows[i]).length() == 0) {
continue; // skip empty rows
}
if (rows[i].startsWith("#")) {
continue; // skip comment lines
}

// split the row on the tabs
String[] pieces = split(rows[i], TAB);
// copy to the table array
data[rowCount] = pieces;
rowCount++;

// this could be done in one fell swoop via:
//data[rowCount++] = split(rows[i], TAB);
}
// resize the 'data' array as necessary
data = (String[][]) subset(data, 0, rowCount);
}


public int getRowCount() {
return rowCount;
}


// find a row by its name, returns -1 if no row found
public int getRowIndex(String name) {
for (int i = 0; i < rowCount; i++) {
if (data[i][0].equals(name)) {
return i;
}
}
println("No row named '" + name + "' was found");
return -1;
}


public String getRowName(int row) {
return getString(row, 0);
}


public String getString(int rowIndex, int column) {
return data[rowIndex][column];
}


public String getString(String rowName, int column) {
return getString(getRowIndex(rowName), column);
}


public int getInt(String rowName, int column) {
return parseInt(getString(rowName, column));
}


public int getInt(int rowIndex, int column) {
return parseInt(getString(rowIndex, column));
}


public float getFloat(String rowName, int column) {
return parseFloat(getString(rowName, column));
}


public float getFloat(int rowIndex, int column) {
return parseFloat(getString(rowIndex, column));
}


public void setRowName(int row, String what) {
data[row][0] = what;
}


public void setString(int rowIndex, int column, String what) {
data[rowIndex][column] = what;
}


public void setString(String rowName, int column, String what) {
int rowIndex = getRowIndex(rowName);
data[rowIndex][column] = what;
}


public void setInt(int rowIndex, int column, int what) {
data[rowIndex][column] = str(what);
}


public void setInt(String rowName, int column, int what) {
int rowIndex = getRowIndex(rowName);
data[rowIndex][column] = str(what);
}


public void setFloat(int rowIndex, int column, float what) {
data[rowIndex][column] = str(what);
}


public void setFloat(String rowName, int column, float what) {
int rowIndex = getRowIndex(rowName);
data[rowIndex][column] = str(what);
}
}
public void settings() { size(1400, 800, "P3D"); }
static public void main(String[] passedArgs) {
String[] appletArgs = new String[] { "Two_Maps_Texture" };
if (passedArgs != null) {
PApplet.main(concat(appletArgs, passedArgs));
} else {
PApplet.main(appletArgs);
}
}
}

java.lang.RuntimeException: The P3D renderer is not in the class path. at processing.core.PApplet.makeGraphics(PApplet.java:2311) at processing.core.PApplet.createPrimaryGraphics(PApplet.java:2345) at processing.core.PApplet.initSurface(PApplet.java:10983) at processing.core.PApplet.runSketch(PApplet.java:10922) at processing.core.PApplet.main(PApplet.java:10620) at Two_Maps_Texture.main(Two_Maps_Texture.java:355)

我已经像资源告诉我的那样导入了所有 jar 文件,但仍然收到错误。

最佳答案

确保将 jogl 和gluegen 库添加到构建路径中,以支持 P3D(OpenGL) 渲染器。

这是 OSX 上的示例:使用 jar files特定于您的平台(操作系统和 CPU 架构)

gluegen-rt and jogl jar libraries location in in the eclipse project

它们应该位于Java/core/library内的Processing安装文件夹中。

将相关的 jogl 和gluegen-rt jar 文件添加到项目并将它们添加到构建路径后,您应该能够正确编译

关于java - 从 Eclipse 运行处理时如何解决 java.lang.RuntimeException : The P3D renderer is not in the class path.?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61152015/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com