ArrayList problem !
in
Programming Questions
•
7 months ago
Hello there,
I am novice programmer in processing. I am trying to develop a time series program. In my program i am having trouble to to read data of arraylist. I am want to compare this data in for loop with a value of i so that i can replace the value where it matches with i.
The program is something like that..
ArrayList intervals = new ArrayList();
ArrayList read_intervals(String path) {
BufferedReader reader = createReader(path);
//String line;
while (true) {
try {
line = reader.readLine();
}
catch (IOException e) {
e.printStackTrace();
line = null;
}
if (line == null) break;
String[] pieces = split(line, ',');
int rel_num = -1;
for (int i = 0; i < dpc_single_relations.length; i++) {
if (pieces[0].equals(dpc_single_relations[i]))
{
rel_num = i;
break;
}
}
if (rel_num == -1) rel_num = 0;
// intervals.add(new MotionInterval(int(pieces[1]), int(pieces[2]), rel_num));
// intervals.add(line);
ArrayList tmpArray = new ArrayList();
tmpArray.add(int(pieces[1]));
tmpArray.add(int(pieces[2]));
intervals.add(tmpArray);
//System.out.println(intervals);
}
return intervals;
}
void draw() {
background(0);
strokeWeight(20);
stroke(100);
line(0, height/2, width, height/2);
mX = constrain(mX, width/2 - 200*zoomLevel, -width/2 + 200*zoomLevel);
translate(mX, mY);
for (int i = 500; i < timeEnd - timeBegin; i++) {
float yearTick = map(i, 0, timeEnd - timeBegin, width/2 - 200*zoomLevel, width/2 + 200*zoomLevel);
int upTick;
/*
if (zoomLevel < 15) yearModulate = 100;
else if (zoomLevel < 50) yearModulate = 10;
else if(zoomLevel < 120) yearModulate = 5;
*/
if (i%yearModulate == 0) {//Every tenth year make bold
upTick = 60;
fill(100);
textAlign(RIGHT);
textFont(font);
pushMatrix();
rotate(HALF_PI);
text(i, height/2 + 60, -yearTick);
popMatrix();
strokeWeight(1);
}
else {
strokeWeight(.5);
upTick = 50;
}
noFill();
line(yearTick, height/2 - upTick, yearTick, height/2 + upTick);
/////csv//////////
}
}
What should I do in this case in draw function if i want change value of i with interval which is a arraylist ?
1