Changing stroke color on an imported .csv file
in
Programming Questions
•
4 months ago
A little background on project.
Creating a 3d globe with a line pin pointing a location on the globe to where myself and a fellow military person as deployed to. (me = army, him = air force). Right now we have the data being imported via a .csv file. Currently I can get all the points mapped on the globe via long and lat coordinates. My issue is the for loop to recognize the different. Right now a field is called ID, if ID = 1 then stroke color = blue, and if ID = 2, then stroke color is green. Currently the code colors all the lines as one color and doesn't recognize the other. Below are some snippits of the code to hopefully make things clear.
- Table t;
- DataHolder[] data;
- DataHolder (int i) {
- INDEX = i+1;
- LOCATION = t.getString (i+1, 0);
- OPERATION = t.getString (i+1, 1);
- VALUE = t.getInt (i+1, 2);
- LATITUDE = parseCoord (t.getString(i+1, 3));
- LONGITUDE = parseCoord (t.getString(i+1, 4));
- START = polarToCartesian (LATITUDE, LONGITUDE, -1);
- END = polarToCartesian (LATITUDE, LONGITUDE, VALUE*SCALE_F);
- YEAR = t.getInt (i+1, 5);
- WEEKS = t.getInt (i+1, 6);
- ID = t.getInt (i+1, 7);
- }
- void render(PGraphics canvas, boolean buffered) {
- for (int i=0; i< data.length; i++) {
- canvas.strokeWeight(LINES_WEIGHT);
- if (buffered) {
- canvas.strokeWeight(BUFF_LINES_W);
- canvas.stroke(INDEX);
- canvas.line(START.x, START.y, START.z, END.x, END.y, END.z);
- } else
- if (hovered) {
- canvas.stroke(HOVER_COL);
- canvas.line(START.x, START.y, START.z, END.x, END.y, END.z);
- } // end if hovered
- if (data[i].ID == 1) {
- canvas.stroke(BLUE_COLOR);
- canvas.line(START.x, START.y, START.z, END.x, END.y, END.z);
- } else {
- canvas.stroke(GREEN_COLOR);
- canvas.line(START.x, START.y, START.z, END.x, END.y, END.z);
- } // end if ID = 2
- }// end for statement
- } //end void render ()
If need more code to clarify things, can post. Currently its 4 files in my project folder, so didn't want to make this post too long.
1