We are about to switch to a new forum software. Until then we have removed the registration on this forum.
hello! i am new to this whole forum thing, but i was wondering if i might humbly ask for some assistance? i am trying to configure a sketch that uses data plotting and my array is acting up. any/all help would be greatly appreciated. thank you so much.
//Information from: http://www.oceaneconomics.org/LMR/topTenResults.aspx?selRegions=GL&selYears=2013&selOut=display&noepID=unknown
XML FishValue;//The xml file is declared
//ArrayLists for data sets
ArrayList Fish fishes = new ArrayList Fish();
int numOfFish = 10; //number of fish
int [] position = new int [numOfFish]; // array for position of each fish's data
int [] fishValue = new int [numOfFish]; // array for fish values
String [] fishNames = new String [numOfFish];// array for fish names
PFont f;
PImage BG;
void setup() {
size(640,480);
colorMode(HSB,360,100,100,100);
textAlign(CENTER);
background(0);
BG = loadImage("GreatLakes.jpg");
//loads the xml file
FishValue = loadXML("FishValue.xml");
XML [] Fish = FishValue.getChildren("Fish"); //information is recognized with this function
for (int i = 4; i < numOfFish; i++){
//the ValuePerFish given US dollar value of each fish
//int ValuePerFish =
//the names of each fish
fishNames[i] = Fish[i].getContent();
//the spacing between fish data
position [i] = (width/numOfFish)/2;
position [i] += (i * (width/numOfFish)/1.5);
}
//elements
for (int m = 0; m position[0]-50 && xMouse < position[0]+50) {
b.movement();
b.display(70);
//}
//Points
for (int i = 1; i < numOfFish; i++) {
//This causes the points to connect
int m = i - 1;
//The x and y positions
float xPos1 = position[i]-(width/10)/1.2;
float xPos2 = position[i];
float yPos1 = height/1.1-FishValue[m]*4;
float yPos2 = height/1.1-FishValue[i]*4;
//The lines of the line graph
//strokeWeight(2);
//stroke(360,20);
//line(xPos1, yPos1, xPos2, yPos2);
//stroke(360,10);
//line(xPos1, height/1.1, xPos2, height/1.1);
}
//The names for each fish
for (int i = 0; i < numOfFish; i++) {
fill(170, 30, 90);
text(fishNames[i], position[i], height/1.05);
}
//Value of each fish in US Dollars
textSize(10);
fill(360); //text color
text("Value of each fish in U.S. Dollars", 100, 50);
}
}
Answers
http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text
thanks. how about now?
static final
:static final NUM_OF_FISH = 10;
.class
Fishand use 1 Fish[] array only:
i appreciate your input, but it still confuses me. not your fault, obviously. this class is hard for me.