How to loop over an ArrayList using the index value of an Array (Processing)

谁说我不能喝 提交于 2019-12-12 06:21:16

问题


The second loop (for (int j = years[i].xrateValue.size ()-1; j >= 0; j--)) is retrieving all the xrate values for each Year from the array (years[i]). Please do you have any ideas of how I can only return the xrate values for each year in the array. For example, Year 1990 has Xrate 2,5,6,5.6 and Year 1991 has Xrate 3,6.7,5,8,1.4. The loop should only return the Xrate values for 1990 and then 1991 and so on.

for (int i=0; i<years.length; i++)
  {
    //code to display each year

    for (int j = years[i].xrateValue.size ()-1; j >= 0; j--)
    {
      float xrate = (float)(years[i].xrateValue.get(j));
      float barHeight = map(xrate, 0, mathMax, 0, 80); //adjust rect size
      float bX = sX+2;
      float bY = sY + 105 - barHeight;
      float bW = 105 / years.length;
      strokeWeight(0.9);
      stroke(10);
      fill(255, 8, 8);
      if (xrate >= 71)
      {
        fill(2, 152, 48);
      } else if ((xrate >= 51) && (xrate <= 70))
      {         
        fill(255, 217, 19);
      }
      rect(i+i+i+bX, bY, bW, barHeight);
    }
}

来源:https://stackoverflow.com/questions/29234996/how-to-loop-over-an-arraylist-using-the-index-value-of-an-array-processing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!