• fullscreen
  • Matrix.pde
  • Season.pde
  • Setup.pde
  • UKWeather.pde
  • circle.pde
  • public class Matrix 
    {
    	private Integer r;
    	private Integer c;
            private double[][] value;
            private double theMin = Integer.MAX_VALUE;
            private double theMax = Integer.MIN_VALUE;
      
            Matrix(Integer rows, Integer cols)
    	{
                r = rows;
                c = cols;
                value = new double[r][c];
                for (int i = 0; i < this.r; i++)
                {
                    for (int j = 0; j < this.c; j++)
                    {
                        value[i][j] = -1.0;
                    }
                }
            }
    
            public void update(int row, int col, double value)
            {
                if ((row <= this.r && row >= 0) && (col <= this.c && col >= 0 ))
                {
                    if (value < theMin)
                        theMin = value;
                    if (value > theMax)
                        theMax = value;
                        
                    this.value[row][col] = value;
                }
            }
            public int getRows()
            {
               return r;
            }
            public int getCols()
            {
                return c;
            }
            public double getMin()
            {
                return theMin; 
            }
            public double getMax()
            {
                return theMax; 
            }
            
            public double getValue(int a, int b)
            {
                double ret = -1;
                if (a <= r && b <= c)
                {
                    for (int i = 0; i < r; i++)
                    {
                        if (i == a)
                        {
                            for (int j = 0; j < c; j++)
                            {
                                if (b == j)
                                {
                                     ret = value[i][j];
                                }
                            }
                        }
                    }
                }
                return ret;
            }    
            public double[] getRow(int row)
            {
                double[] b = new double[this.c];
                for (int j = 0; j < this.c; j++)
                {
                    b[j] = this.value[row][j];
                }
            
                return b;
            }
    
    	public double[] getColumn(int col)
    	{
                    double[] a = new double[1];
                    a[0] = 0.0;
                    return a;
    	}
            public Matrix transpose()
            {
               Matrix temp = new Matrix(this.r, this.c);
               double[] b = new double[this.c];
               for (int i = 0; i < this.c; i++)
               {
                  b = this.getColumn(i);
                
                  for (int j = 0; j < this.r; j++)
                  {
                      temp.update(i, j, b[j]);
                  }
               }
            
            return temp;
            }
            public void display()
            {
                for (int i = 0; i < this.r; i++)
                {
                    for (int j = 0; j < this.c; j++)
                    {
                        System.out.print("row "+i+", col "+j+" = "+value[i][j]+" ");
                    }
                    System.out.println();
                }
            }
    }
    
    
    public class Season 
    {
        private double seasonsWeather = 0.0;
        private Matrix Aseason;
        
        public Season(String season, Setup NN)
        {
            Aseason = new Matrix(NN.getRows(), 1);
            double[] a = new double[12];
            for (int i = 0; i < NN.getRows(); i++ )
            {
                a = NN.getRow((i+1914));
                
                if (season.toUpperCase().equals("WINTER"))
                {
                    
                    if (i > 0)
                    {
                        double b = NN.getValue((i-1),11);
                        a[1] = a[1] + b;
                    }
                    for (int j = 0; j < 2; j++)
                    {
                        seasonsWeather = seasonsWeather + a[j];
                    }
                }
                else if (season.toUpperCase().equals("SPRING"))
                {
                    for (int j = 2; j < 5; j++)
                    {
                        seasonsWeather = seasonsWeather + a[j];
                    }
                }
                else if (season.toUpperCase().equals("SUMMER"))
                {
                    for (int j = 5; j < 8; j++)
                    {
                        seasonsWeather = seasonsWeather + a[j];
                    }   
                }
                else if (season.toUpperCase().equals("AUTUMN"))
                {
                    for (int j = 8; j < 11; j++)
                    {
                        seasonsWeather = seasonsWeather + a[j];
                    }
                }
                        
                Aseason.update(i, 0, seasonsWeather);
                seasonsWeather = 0;  
            }
        }
        public double getTotalSeasonsWeather(int year)
        {
            if (year >=1914 && year <= (Aseason.getRows()+1914))
            {
                return Aseason.getValue((year-1914),0);
            }
            else return -1;
        }
        public double getAvgSeasonsWeather(int year)
        {
            if (year >=1914) // && year <= (Aseason.getRows()+1914))
            {
                  return Aseason.getValue((year-1914),0)/3;
            }
            else return -1;
        }
    
        public double getTheMin()
        {
           return Aseason.getMin(); 
        }
        public double getTheMax()
        {
           return Aseason.getMax(); 
        }
    
    }
    
    
    import java.io.*;
    import java.net.URL;
    import java.util.Vector;
    
    public class Setup 
    {
        private int rows = 0;
        private int cols = 0;
        private int minYear = Integer.MAX_VALUE;
        private int maxYear = Integer.MIN_VALUE;
        private double theMin = Integer.MAX_VALUE;
        private double theMax = Integer.MIN_VALUE;
        private double yearsRain = 0;
        private double yearsTemp = 0;
        private double yearsSun = 0;
        
        private Vector rainfall = new Vector();
        private double[] averageRain;
        private double[] averageTemperature;
        private double[] averageSunLight;
        private int year;
        private int month;
        private String strLine;
        private InputStream is = null;
        private BufferedReader bis = null;
        private Object content = null;
        
        private Matrix nn;
        
        public Setup(String filename)
        {
        	try
            {		
                int line = 0;
                System.out.println("Filename is "+filename);
    
                URL myUrl = new URL(filename);
    
                is = myUrl.openStream();
        
                bis = new BufferedReader(new InputStreamReader(is));
                    
    	    strLine = bis.readLine();
            
                boolean end = false;
                        
                for (int i = 0; strLine != null && !end; i++)
                {
                    if (i > 7)
                    {
                        int startpos = 0, endpos = 0, month = 0;
                           
                        for (int j = 0; j < strLine.length()-30 && !end; j++)
                        {
                            if (strLine.charAt(j) == 32 )
                            {
                                if (startpos != endpos)
                                {
                                    if (startpos == 0)
                                    {
                                        if (!(strLine.substring(startpos,endpos+1).trim().equals("MIN")))
                                        {
                                            year = Integer.parseInt(strLine.substring(startpos,endpos+1).trim());
                                            if (year < minYear)
                                                minYear = year;
                                            if (year > maxYear)
                                                maxYear = year;
                                            rows++;
                                        }
                                        else end = true;
                                    }
                                    else
                                    {
                                        rainfall.add(strLine.substring(startpos,endpos+1));
                                        if (month > cols) cols = month;
                                        month++;
                                    }
                                 }
                                 startpos = j;
                                 endpos = j;
                             }
                             else
                             {
                                 endpos++;
                             }
                        }
                        month = 0;
                    }
                             
                    strLine = bis.readLine();
                    line++;
                }
                        
                is.close();
                
                    nn = new Matrix(this.getRows(),this.getCols()+1);
                    int a = 0;
                    Vector b = this.getValues();
                    if (nn != null)
                    {
                        for (int i = 0; i < this.getRows(); i++)
                        {
                            for (int j = 0; j < this.getCols()+1; j++)
                            {
                                double c = Double.parseDouble((String)b.get(a));
                                if (c > theMin)
                                  theMin = c;
                                if (c < theMax)
                                  theMax = c;
                                  
                                nn.update(i, j, c);
                                a++;
                            }
                        }
                    }
                    else System.out.print("Matrix object is empty");
            
                }
                catch (FileNotFoundException e) 
                {
                    System.out.println("File not found!!!!");
    		e.printStackTrace();
                }
                catch (IOException e) 
                {
                    e.printStackTrace();
                }
                
        }
        public double getTheMin()
        {
           return nn.getMin(); 
        }
        public double getTheMax()
        {
           return nn.getMax(); 
        }
        public double getMin()
        {
             double p = 0.0;
             double[] a = new double[nn.getCols()];
             theMin = Integer.MAX_VALUE;
             for (int i = 0; i < nn.getRows(); i++)
             {
                 p = getRainfall(i+1914);
                      
                 if (p < theMin)
                   theMin = p;
             }
             return theMin; 
        }
        public double getMax()
        {
             double p = 0.0;
             double[] a = new double[nn.getCols()];
             theMax = Integer.MIN_VALUE;
             for (int i = 0; i < nn.getRows(); i++)
             {
                 p = getRainfall(i+1914);
                      
                 if (p > theMax)
                   theMax = p;
             }
             return theMax; 
        }
        public int getRows()
        {
            return rows;
        }
        public int getCols()
        {
            return cols;
        }
        public int getMinYear()
        {
            return minYear;
        }
        public int getMaxYear()
        {
            return maxYear;
        }
        public Vector getValues()
        {
            return rainfall;
        }
        public Object getContent()
        {
            return content;
        }
        public double getRainfall(int year)
        {
            if (nn == null)
                System.out.println("nn is null!!!");
                
            double[] a = new double[nn.getCols()];
            a = nn.getRow(year-1914);
            yearsRain = 0;
            for (int i = 0; i < (nn.getCols()); i++)
                yearsRain = yearsRain + a[i];
                
            return yearsRain;
        }
        public double getAvgTemperature(int year)
        {
            double[] a = new double[nn.getCols()];
            a = nn.getRow(year-1914);
            yearsTemp = 0;
            for (int i = 0; i < (nn.getCols()); i++)
                yearsTemp = yearsTemp + a[i];
            return yearsTemp/nn.getCols();
        }
        public double getAvgSunshine(int year)
        {
            if (year > minYear && year < maxYear)
            {
                double[] a = new double[nn.getCols()];
                a = nn.getRow(year-1914);
                yearsSun = 0;
                for (int i = 0; i < (nn.getCols()); i++)
                    yearsSun = yearsSun + a[i];
                return yearsSun/nn.getCols();
            }
            else return 0;
        }
        public double[] getRow(int year)
        {
            return nn.getRow(year-1914);
        }
        public double getValue(int year, int month)
        {
            return nn.getValue(year, month);
        }
    }
    
    
    PImage Play, Pause;
    boolean go = false;
    PFont font;
    circle Summer, Winter, Autumn, Spring, Weather;
    Setup R, T, S;
    Season WinterR, WinterT, SpringR, SpringT, SummerR, SummerT, AutumnR, AutumnT, WinterS, SpringS, SummerS, AutumnS;
    double temp = 0, rain = 0, diameter = 0;
    int theRainYear = 0, theTempYear = 0, theSunYear = 0, movingYear = 1914, currentPos = 0;
    
    Random generator = new Random();
    
    void setup()
    {
        font = createFont("Georgia", 10);
        textFont(font);
        size(800,600);
        background(0);
    
        Play = loadImage("play.jpg");
        Pause = loadImage("pause.jpg");
        colorMode(RGB,255);
        
        R = new Setup("http://www.metoffice.gov.uk/climate/uk/seriesstatistics/ukrain.txt");
        T = new Setup("http://www.metoffice.gov.uk/climate/uk/seriesstatistics/uktemp.txt");
        S = new Setup("http://www.metoffice.gov.uk/climate/uk/seriesstatistics/uksun.txt");
    
        WinterR = new Season("Winter",R);
        WinterT = new Season("Winter",T);
        WinterS = new Season("Winter",S);
        SpringR = new Season("Spring",R);
        SpringT = new Season("Spring",T);
        SpringS = new Season("Spring",S);
        SummerR = new Season("Summer",R);
        SummerT = new Season("Summer",T);
        SummerS = new Season("Summer",S);
        AutumnR = new Season("Autumn",R);
        AutumnT = new Season("Autumn",T);
        AutumnS = new Season("Autumn",S);
    
        theRainYear = R.getMinYear();
        theTempYear = T.getMinYear();
        theSunYear = S.getMinYear();
        temp = T.getAvgTemperature(theTempYear);
        rain = R.getRainfall(theRainYear);
        
        Summer = new circle((float)(11.02+(1.02*(SummerR.getTotalSeasonsWeather(theRainYear)-1))), (float)(431.76-((500/17)*(SummerT.getAvgSeasonsWeather(theRainYear)-1))),50,"FFFFE600", SummerS);
        Spring = new circle((float)(11.02+(1.02*(SpringR.getTotalSeasonsWeather(theRainYear)-1))), (float)(431.76-((500/17)*(SpringT.getAvgSeasonsWeather(theRainYear)-1))),50,"FFC8F526", SpringS);
        Autumn = new circle((float)(11.02+(1.02*(AutumnR.getTotalSeasonsWeather(theRainYear)-1))), (float)(431.76-((500/17)*(AutumnT.getAvgSeasonsWeather(theRainYear)-1))),50,"FFE3701A", AutumnS);
        Winter = new circle((float)(11.02+(1.02*(WinterR.getTotalSeasonsWeather(theRainYear)-1))), (float)(431.76-((500/17)*(WinterT.getAvgSeasonsWeather(theRainYear)-1))),50,"FF0EBFE9", WinterS);    
    
        ProcessSunshine(Summer);
        ProcessSunshine(Spring);
        ProcessSunshine(Autumn);  
        ProcessSunshine(Winter);
    }
    
    void draw()
    {
        background(0);
        smooth();
     
        font = createFont("Georgia", 28);
        textFont(font);
        fill(225);
        text(theRainYear,670,20);
        font = createFont("Georgia", 10);
        textFont(font);
    
        drawVerticalLine(30,20,3,128,500);      
        drawHorizontalLine(30,520,3,128,500);
        addXLegend("Temperature", 12, 180, 3, 128);
        addYLegend("Rain fall", 250, 535, 3, 128);
       
        drawTemperatureChart(24,450,5,72,50);
        drawRainChart(30,522,72,5);
      
        drawLegend();
        drawSlider();
        startButton();
        
        Summer.display();
        Spring.display();
        Autumn.display();
        Winter.display();
        
        ProcessRainfall();
        ProcessTemperature();
    
        Summer.move((int)(11.02+(1.02*(SummerR.getTotalSeasonsWeather(theRainYear)-1))), (int)(431.76-((500/17)*(SummerT.getAvgSeasonsWeather(theRainYear)-1))));
        Spring.move((int)(11.02+(1.02*(SpringR.getTotalSeasonsWeather(theRainYear)-1))), (int)(431.76-((500/17)*(SpringT.getAvgSeasonsWeather(theRainYear)-1))));
        Autumn.move((int)(11.02+(1.02*(AutumnR.getTotalSeasonsWeather(theRainYear)-1))), (int)(431.76-((500/17)*(AutumnT.getAvgSeasonsWeather(theRainYear)-1))));
        Winter.move((int)(11.02+(1.02*(WinterR.getTotalSeasonsWeather(theRainYear)-1))), (int)(431.76-((500/17)*(WinterT.getAvgSeasonsWeather(theRainYear)-1))));
    
        if ((go) &&  Winter.move((int)(11.02+(1.02*(WinterR.getTotalSeasonsWeather(theRainYear)-1))), (int)(453.32-(16.67*(WinterT.getAvgSeasonsWeather(theRainYear)-1)))) && Spring.move((int)(11.02+(1.02*(SpringR.getTotalSeasonsWeather(theRainYear)-1))), (int)(453.32-(16.67*(SpringT.getAvgSeasonsWeather(theRainYear)-1)))) && Summer.move((int)(11.02+(1.02*(SummerR.getTotalSeasonsWeather(theRainYear)-1))), (int)(453.32-(16.67*(SummerT.getAvgSeasonsWeather(theRainYear)-1)))) && Autumn.move((int)(11.02+(1.02*(AutumnR.getTotalSeasonsWeather(theRainYear)-1))), (int)(453.32-(16.67*(AutumnT.getAvgSeasonsWeather(theRainYear)-1)))))
        {
             theRainYear++;
             theTempYear++; 
             
             ProcessSunshine(Summer);
             ProcessSunshine(Spring);
             ProcessSunshine(Autumn);  
             ProcessSunshine(Winter);  
             
             if ((theRainYear >= R.getMaxYear()) || (theTempYear >= T.getMaxYear()))
               go = !go;
        }
    }
    
    void ProcessSunshine(circle T)
    {
          T.setDiameter(theRainYear);
    }
    void ProcessRainfall()
    {
        if (theRainYear < R.getMaxYear())
        {
           rain = R.getRainfall(theRainYear);
        }
    }
    
    void ProcessTemperature()
    {
        if (theTempYear < T.getMaxYear())
        {
           temp = T.getAvgTemperature(theTempYear);
        }
    }
    void drawVerticalLine(int xpos, int ypos, int weight, int shade, int len)
    {
       strokeWeight(weight);
       stroke(shade);
       line(xpos,ypos, xpos, ypos+len);  
    }
    
    void drawHorizontalLine(int xpos, int ypos, int weight, int shade, int len)
    {
       strokeWeight(weight);
       stroke(shade);
       line(xpos,ypos, xpos+len, ypos);
    }
    
    void addXLegend(String legend, int xpos, int ypos, int weight, int shade)
    {
        char a;
        strokeWeight(weight);
        stroke(shade);
        fill(shade);	
        font = createFont("Georgia", 10);
        textFont(font);
        textAlign(LEFT, CENTER);
        
        for (int i = 0; i < legend.length(); i++)
        {
            text(legend.charAt(i),xpos,ypos+(i*10)); 
        }
    }
    
    void addYLegend(String legend, int xpos, int ypos, int weight, int shade)
    {
        strokeWeight(weight);
        stroke(shade);
        fill(shade);	
        font = createFont("Georgia", 10);
        textFont(font);
        textAlign(LEFT, CENTER);
        text(legend,xpos,ypos);
    }
    
    void drawLegend()
    {
        font = createFont("Georgia", 10);
        textFont(font);
        noStroke();
        fill(#7CFC00);
        text("Total",625,60);
        text("Rainfall",620,75);
        text("Average",680,60);
        text("Temperature",670,75);
        text("Average",740,60);
        text("Sunshine",740,75);
        fill(245);
        text((int)(WinterR.getTotalSeasonsWeather(theRainYear)),630,100);
        text((int)(WinterT.getAvgSeasonsWeather(theRainYear)),700,100);
        text((int)Winter.getDiameter(theRainYear),750,100);
        text((int)(SpringR.getTotalSeasonsWeather(theRainYear)),630,150);
        text((int)(SpringT.getAvgSeasonsWeather(theRainYear)),700,150);
        text((int)Spring.getDiameter(theRainYear),750,150);
        text((int)(SummerR.getTotalSeasonsWeather(theRainYear)),630,200);
        text((int)(SummerT.getAvgSeasonsWeather(theRainYear)),700,200);
        text((int)Summer.getDiameter(theRainYear),750,200);
        text((int)(AutumnR.getTotalSeasonsWeather(theRainYear)),630,250);
        text((int)(AutumnT.getAvgSeasonsWeather(theRainYear)),700,250);
        text((int)Autumn.getDiameter(theRainYear),750,250);
        fill(#0EBFE9);
        ellipse(560,100,20,20);
        text("Winter",580,100);
        fill(#C8F526);
        ellipse(560,150,20,20);
        text("Spring",580,150);
        fill(#FFE600);
        ellipse(560,200,20,20);
        text("Summer",580,200);
        fill(#E3701A);
        ellipse(560,250,20,20);
        text("Autumn",580,250);
    }
    void startButton()
    {
    
       if (!go)
         image(Play,550,500);
       else image(Pause,550,500);
    
    }
    
    void drawSlider()
    {
       strokeWeight(3);
       stroke(128);
       int s = R.getMaxYear() - R.getMinYear();
       for (int i = 0; i <= s; i++)
       {
           line(20+(i*7),550,20+(i*7),560);
           
       }
       drawButton();   
    }
    
    void drawButton()
    {     
       currentPos = (20+((theRainYear-R.getMinYear())*7));
    
       strokeWeight(1);
       stroke(255);
       fill(#9E0508);
       ellipse(20+((theRainYear-R.getMinYear())*7),555,10,10);
       strokeWeight(3);
       stroke(#7CFC00);
       fill(#7CFC00);
       font = createFont("Georgia", 14);
       textFont(font);
       text(theRainYear,5+((theRainYear-R.getMinYear())*7),570);
       fill(128);
    }
    
    void drawTemperatureChart(int xpos, int ypos, int w, int h, int gap)
    {
       noStroke();
       fill(unhex("FF74BBFB"));
       rect(xpos,ypos,w,h);
       ypos = ypos - h;
       fill(unhex("FF36DBCA"));
       rect(xpos,ypos,w,h);
       ypos = ypos - h;
       fill(unhex("FF6EFF70"));
       rect(xpos,ypos,w,h);
       ypos = ypos - h;	
       fill(unhex("FF33FF33"));
       rect(xpos,ypos,w,h);
       ypos = ypos - h;   
       fill(unhex("FFFFE303"));
       rect(xpos,ypos,w,h);
       ypos = ypos - h;   
       fill(unhex("FFEE4000"));
       rect(xpos,ypos,w,h);
       ypos = ypos - h;   
       fill(unhex("FFEE0000"));
       rect(xpos,ypos,w,h);   
    }
    
    void drawRainChart(int xpos, int ypos, int w, int h)
    {
       noStroke();
       fill(unhex("FFF0F8FF"));
       rect(xpos,ypos,w,h);
       xpos = xpos + w;   
       fill(unhex("FFC6E2FF"));
       rect(xpos,ypos,w,h);
       xpos = xpos + w;   
       fill(unhex("FF88ACE0"));
       rect(xpos,ypos,w,h);
       xpos = xpos + w;   
       fill(unhex("FF3A5894"));
       rect(xpos,ypos,w,h);
       xpos = xpos + w;      
       fill(unhex("FF22316C"));
       rect(xpos,ypos,w,h);
       xpos = xpos + w;   
       fill(unhex("FF120A8F"));
       rect(xpos,ypos,w,h);
       xpos = xpos + w;      
       fill(unhex("FF000033"));
       rect(xpos,ypos,w,h);
    }
    
    void mousePressed()
    {
      if ((mouseX >= 550 && mouseX <= 650) && (mouseY >= 495 && mouseY <= 525))
      {
          go = !go;
      }
    }
    
    void keyPressed()
    {
       if (key == CODED)
       {
          if (keyCode == LEFT)
          {
              movingYear = 1914+(((currentPos-7)-20)/7);
              if (movingYear > 1914)
              {  
                if (1914+(((currentPos-7)-20)/7) <= 2008)
                  movingYear = 1914+(((currentPos-7)-20)/7);
              }
              else movingYear = 1914;
          }
          else if (keyCode == RIGHT)
          {
              if ((1914+(((currentPos+7)-20)/7)) <= 2008)
                movingYear = 1914+(((currentPos+7)-20)/7);
          }
          
          theRainYear = movingYear;
          theTempYear = movingYear;
     
       }
    }
    
    void mouseDragged()
    {
      if (currentPos < mouseX)
      {
        if ((mouseX >= 20 && mouseX <= 680) && (mouseY >= 550 && mouseY <= 560))
        {
            movingYear = 1914+((mouseX-20)/7);        
        }
      }
      else
      {
          if ((mouseX >= 20 && mouseX <= 680) && (mouseY >= 550 && mouseY <= 560))
          {
            movingYear = 1914+((currentPos-20)/7);
            movingYear = movingYear - ((currentPos-mouseX)/7);
          }
      }
    
      theRainYear = movingYear;
      theTempYear = movingYear;  
    }
    
    class circle
    {
      private int xpos, ypos;
      private int dimension, weight;
      private final int radix = 16;
      private String colour;
      private Season T;
    
      public circle(float x, float y, int d, String c)
      {
        this.xpos = (int)x;
        this.ypos = (int)y;
        this.dimension = d;
        this.colour = c;
      }
    
      public circle(float x, float y, int d, String c, Season w)
      {
        this.xpos = (int)x;
        this.ypos = (int)y;
        this.dimension = d;
        this.colour = c;
        this.T = w;
      }
    
      public void changeColour(String c)
      {
        this.colour = c;
      }
      public void display()
      {
        noStroke();
        smooth();
        int c = unhex(this.colour);
        fill(c);
        ellipse(this.xpos,this.ypos,this.dimension,this.dimension);
      }
      public void move(float new_x, float new_y)
      {
        if ((int)new_x == (int)this.xpos && (int)new_y == (int)this.ypos)
        {
          return;
        }
        else
        {
          clear();
          if ((int)new_x > this.xpos)
          {
            this.xpos++; 
          }
          else if ((int)new_x < this.xpos)
          {
            this.xpos--;
          }
    
          if ((int)new_y > this.ypos)
          {
            this.ypos++; 
          }
          else if ((int)new_y < this.ypos)
          {
            this.ypos--;
          }
    
          display();
    
          move(new_x,new_y);
        }
      }
    
      public boolean move(int new_x, int new_y)
      {
        if (new_x > (int)this.xpos)
        {
          if ((new_x - (int)this.xpos) > 25)
          {
            this.xpos = (int)(this.xpos + ((new_x - this.xpos) / 10));
          }
          else this.xpos = new_x;
        }
        else if (new_x < (int)this.xpos)
        {
          if (((int)this.xpos - new_x) > 25)
          {
            this.xpos = (int)(this.xpos - ((this.xpos - new_x) / 10));
          }
          else this.xpos = new_x;
        }
        if (new_y > (int)this.ypos)
        {
          if ((new_y - (int)this.ypos) > 25)
          {
            this.ypos = (int)(this.ypos + ((new_y + this.ypos) / 10));
          }
          else this.ypos = new_y;
        }
        else if (new_y < (int)this.ypos)
        {
          if (((int)this.ypos - new_y) > 25)
          {
            this.ypos = (int)(this.ypos - ((this.ypos - new_y) / 10));
          }
          else this.ypos = new_y;
        }
        return (new_x == (int)this.xpos && new_y == (int)this.ypos);  
      }
    
      public void setDiameter(int year)
      {
        if (year < 1929)
        {
          this.dimension = (int)generator.nextDouble() * 50 + 50;
        }
        else
        {
    //        System.out.println("Looking up the postion of "+(year-15)+" for sunshine because year = "+year);
          this.dimension = (int)T.getAvgSeasonsWeather(year-15); //-(2008 - 1929));               
        }
      }
    
      public int getDiameter(int year)
      {
          return this.dimension;
      }
    
      public float getX()
      {
        return xpos; 
      }
    
      public float getY()
      {
        return ypos; 
      }
    
      private void clear()
      {
        noStroke();
        smooth();
        fill(0);
        ellipse(this.xpos,this.ypos,this.dimension,this.dimension); 
      }
    }
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    Anthony Smee

    UK Weather since 1914

    Add to Faves Me Likey@! 5
    You must login/register to add this sketch to your favorites.

    I have tried to visualise the data from: http://www.metoffice.gov.uk/climate/uk/seriesstatistics/ukrain.txt (British Met Office)

    I wanted an easy way to read this data (Rain, temp, and amount of sunshine). I also hoped to see some interesting results (i.e. something like the hockey stick...), this isn't the case. You can drag the year to your interest. Also the left and right arrows allow you to look at future and previous years.Interested in getting some feedback. It is a little slow, apologies. You can use left and right arrows.

    How excellent!
    The results make you wonder about this climate change business - rainfall and temps don't seem to be incrementally increasing..
    Well done on a great app!
    You need to login/register to comment.