Show ellipses in a chronological order

edited April 2016 in How To...

Hi all,

I've got a map view which displays a number of ellipses representing natural disasters. I would like to be able to make them appear in the chronological order based on the year the natural disaster happened.

Could you guide me what would be the best approach to make it happen?

I've attached a screenshot of the current view.Screen Shot 2016-04-09 at 14.20.36

This might be a very basic thing to do, however, I'm very new to processing and would appreciate your support.

Thank you Sim

Tagged:

Answers

  • what does the data look like?

  • edited April 2016

    Basically show your code.

    Remark

    When you work with background(0); in draw () or when you draw the map anew every loop of draw(): good.

    add a variable currentYearForDisplay or so to your code - set it to the first year you have data of (or 10 years before the first disaster)

    Now increase the year every frame or every 10th frame or every 2 seconds currentYearForDisplay++; or so

    now compare currentYearForDisplay to all disasters (assuming they have a date) and display only those disasters that match currentYearForDisplay

    Chrisir ;-)

  • edited April 2016

    Thanks guys. I think I managed to make it work, not sure if this is the most optimal way though.

  • (just ctrl-t in the processing editor to indent the code nicely, cut it and paste it here, highlight it and press ctrl-o. don't 'copy as html'. i have fixed the above)

  • volcano = loadStrings("VolcanoesInput.csv");

    but without these files, or a sample of their contents, that code is useless...

  • edited April 2016 Answer ✓

    first remark: you use < year

    I see a

      if (int(tsunamiData[i][0])<year) {
    

    why not say abs(tsunami.....-year) < 8 or so to make the disasters disappear after the year has passed?

    (remark: you increase year by 5 --- why not by 1? Then you could say if (int(tsunamiData[i][0]) == year) { - then the disasters would disappear instantly)

    Second remark

    you use a 2D array for the data. But since all data are similar why not make only one 2D array "disasterArray" with one more column typeOfDisaster? The column typeOfDisaster could hold an int where 0 signifies volcano, 1 earthquake and so on.

    Third remark: OOP

    When you look into objects (see tutorials) you could beautify your code by using a class btw...

    class Disaster {
    
    int year=0; // or from to date 
    int typeOfDisaster = -1; // undefined / non-existent 
    // etc. 
    
    }
    
Sign In or Register to comment.