Cannot make a static reference to the non static method draw() in the type myStockProject.draw

I’ve been creating a stock market and I am unable to figure a solution to the error in the title.
at the point graph.draw in the class myStockProject is where I get the error. I have uploaded that class and the graph class. any help or solutions would be appreciated.

import java.util.*;
ArrayList<String> tickers = new ArrayList();
ArrayList<Float> openingPrices = new ArrayList();
ArrayList<Float> closingPrices = new ArrayList();
ArrayList<Float> adjustedClosingPrices = new ArrayList();
ArrayList<Float> lowestPrices = new ArrayList();
ArrayList<Float> highestPrices = new ArrayList();
ArrayList<Float> volume = new ArrayList();
ArrayList<String> dates = new ArrayList();
ArrayList<Integer> days = new ArrayList();
ArrayList<Integer> months = new ArrayList();
ArrayList<Integer> years = new ArrayList();
ArrayList<Integer> range = new ArrayList();
ArrayList<Data> myData;
ArrayList<Widget> queries;
Data singularData;
Screen screenOne;
Screen screenTwo;
Screen screenThree;
Graph myGraph = new Graph();
Widget firstWidget;
ArrayList <Widget> widgetList;
ArrayList <Widget> direction ;
TextWidget focus;
PFont widgetFont;
final int EVENT_TEXT=-1;
final int EVENT_BACKWARD=-2;
final int TEXT_WIDGET = 1;
final int EVENT_NULL=0;
int event;
int qEvents;
color widgetBorder;
int events = 1;
int queriedEvents = 1;
int screen;


void setup(){
  
  size(800,500);
  background(255);
  myData = new ArrayList();
  read_in_data();
  arraySort();
  println(count());
  widgetBorder = color (0,0,0);
  
  
  
  widgetFont=loadFont("Verdana-12.vlw");
  textFont(widgetFont);
  //TextWidget textEdit=new TextWidget(100, 25, 200, 40, "Type a ticker symbol", 
  //color(255), widgetFont, TEXT_WIDGET, 10);
  //focus = null;
  widgetList = new ArrayList<Widget>();
  queries = new ArrayList<Widget>();
  direction = new ArrayList<Widget>();
  screenOne = new Screen(color(255), widgetList,null, null, null);
  screenTwo = new Screen(color(255), direction, queries, null, null);
  screenThree = new Screen (color(255), direction, null, null, null);
  screen = 1;

  int x = 100;
  int y = 100;
  String tickerText = "";
  String previousTicker = "";
  int index = 0;
  
  for(int i = 0 ; i<count(); i++){
    boolean quit = false;
    while(quit == false){
      tickerText=tickers.get(index);
      if(!tickerText.equals(previousTicker)){
        quit = true;
      }
      index++;
    }
    previousTicker=tickerText;
    firstWidget = new Widget(x, y, 60, 30 ,tickerText, color(255,0,0), widgetFont, events);
    focus = null;
    widgetList.add(firstWidget); 
    y+=100;
    if(y>=500){
      y=60;
      x+=100;
    }
    events++;
  }
  Widget openPrice = new Widget (400, 100, 100, 40, "opening price", color(255,0,0), widgetFont, queriedEvents);
  queries.add(openPrice);
  queriedEvents++;
  
   Widget closePrice = new Widget (400, 150, 100, 40, "closing price", color(255,0,0), widgetFont, queriedEvents);
  queries.add(closePrice);
  queriedEvents++;
  
   Widget adjClosePrice = new Widget (400, 200, 160, 40, "adjusted closing price", color(255,0,0), widgetFont, queriedEvents);
  queries.add(adjClosePrice);
  queriedEvents++;
  
   Widget low = new Widget (400, 250, 100, 40, "lowest price", color(255,0,0), widgetFont, queriedEvents);
  queries.add(low);
  queriedEvents++;
  
   Widget high = new Widget (400, 300, 100, 40, "highest price", color(255,0,0), widgetFont, queriedEvents);
  queries.add(high);
  queriedEvents++;
  
   Widget volume = new Widget (400, 350, 100, 40, "stock volume", color(255,0,0), widgetFont, queriedEvents);
  queries.add(volume);
  queriedEvents++;
  
   Widget previous = new Widget (50, 400, 50, 30, "back", color(255,0,0), widgetFont, EVENT_BACKWARD);
   focus = null;
   direction.add(previous);
}
void draw(){
  background(100);
  textSize(12);
  background(255);
  stroke(0);
  fill(255);
  if(screen == 1){
    screenOne.draw();
  }
  else if (screen == 2){
    screenTwo.draw();
  }
  else if (screen == 3){
    screenThree.draw();
  }
}
void mousePressed()
{
  for(int i = 0;i<widgetList.size(); i++)
  {
    Widget myWidget = (Widget)widgetList.get(i);
    event = myWidget.getEvent(mouseX, mouseY);
    
    if(screen == 1)
    {
      event = screenOne.getEvent();
      switch(event)
      {
        case EVENT_TEXT:
        println("clicked");
        focus = (TextWidget)myWidget;
        return;
        
        case 1:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 2:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 3:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 4:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 5:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 6:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 7:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 8:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 9:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 10:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 11:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 12:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 13:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 14:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 15:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 16:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 17:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 18:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 19:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 20:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 21:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 22:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 23:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 24:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 25:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 26:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 27:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 28:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 29:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 30:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 31:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 32:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 33:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 34:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 35:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 36:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 37:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 38:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 39:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 40:
        screen = 2;
        ranges();
        focus = null;
        return;
        
        case 41:
        screen = 2;
        ranges();
        focus = null;
        return;
      }
    }
    else if(screen == 2)
    {
      qEvents = screenTwo.getEvent();
      if(qEvents == EVENT_BACKWARD)
      { 
        screen = 1;
      }
      switch(qEvents){
        case 1:
        screen = 3;
        return;
        
        case 2: 
        screen=3;
        //Graph.draw();
        return;
        
        case 3: 
        screen=3;
       // Graph.draw();
        return;
        
        case 4: 
        screen=3;
      //  Graph.draw();
        return;
        
        case 5: 
        screen=3;
       // Graph.draw();
        return;
        
        case 6: 
        screen=3;
        //Graph.draw();
        return;
      }
   
    }
    else if(screen == 3){
      qEvents = screenTwo.getEvent();
      if(qEvents == EVENT_BACKWARD)
      {
        screen = 2;
      }
    }
  }
}
void keyPressed(){
  if(focus != null)
  {
    focus.append(key);
  }
}

void read_in_data(){
  String lines[] = loadStrings("daily_prices1k.csv");
  
  for(int i = 0; i<lines.length; i++) {
    singularData = new Data(lines[i]);
    myData.add(singularData);
    myNewArray(myData.get(i).myArray);
    
    
  }
}

void myNewArray(String array[]){
  tickers.add(array[0]);
  openingPrices.add(convertToString(array[1]));
  closingPrices.add(convertToString(array[2]));
  adjustedClosingPrices.add(convertToString(array[3]));
  lowestPrices.add(convertToString(array[4]));
  highestPrices.add(convertToString(array[5]));
  volume.add(convertToString(array[6]));
  dates.add(array[7]);
  breakUpDates(array[7]);
}
  
  float convertToString(String points){
    float point = float(points);
    return point;
  }
  
  Integer convertDatesToString(String points){
    int point = int (points);
    return point;
  }
  
  void breakUpDates(String date){
    String array[] = split(date, "-");
    days.add(convertDatesToString(array[0]));
    months.add(convertDatesToString(array[1]));
    years.add(convertDatesToString(array[2]));
  }

    void arraySort(){
      for(int i = 0; i<tickers.size(); i++){
        String myTickers=tickers.get(i);
       for(int index = 0; index<tickers.size(); index++){
       if(tickers.get(index).equals(myTickers)&&i!=index){
  
         
            String removeTicker = tickers.get(index);
            tickers.remove(index);
            tickers.add(i, removeTicker);
            
            float removeClose = closingPrices.get(index);
            closingPrices.remove(index);
            closingPrices.add(i, removeClose);
            
            float removeOpen = openingPrices.get(index);
            openingPrices.remove(index);
            openingPrices.add(i, removeOpen);
            
            float removeAdjusted = adjustedClosingPrices.get(index);
            adjustedClosingPrices.remove(index);
            adjustedClosingPrices.add(i, removeAdjusted);
            
            float removeLowest = lowestPrices.get(index);
            lowestPrices.remove(index);
           lowestPrices.add(i, removeLowest);
            
           float removeHighest = highestPrices.get(index);
            highestPrices.remove(index);
            highestPrices.add(i, removeHighest);
            
            float removeVolume = volume.get(index);
            volume.remove(index);
            volume.add(i, removeVolume);
            
            int removeDay = days.get(index);
           days.remove(index);
            days.add(i, removeDay);
            
            int removeMonth = months.get(index);
            days.remove(index);
            days.add(i, removeMonth);
            
           int removeYear = years.get(index);
            days.remove(index);
           days.add(i, removeYear);
            
         }
      }
      }
    }

    
 int count(){
   int count = 1;
   for(int i = 1; i< tickers.size(); i++){
     String newTicker = tickers.get(i);
     if(!tickers.get(i-1).equals(newTicker)){
       count++;
     }
   }
   return count;
 }
 
 void ranges(){
   range = new ArrayList();
   int count = 1 ;
   for(int i = 1; i<tickers.size(); i++){
     String newTicker = tickers.get(i);
          if(!tickers.get(i-1).equals(newTicker)){
       count++;
          }
          if(count == event){
            range.add(i);

          }
        }
  }

  
    
  class Graph{
  ArrayList<Integer> groupedDays;
  ArrayList<Integer> groupedMonths;
  ArrayList<Integer> groupedYears;
  ArrayList<Float> graphPosition;
  int margin, graphHeight, topOfMargin, leftOfMargin, rightOfMargin;
  PFont font;
  String fontList[] = PFont.list();
  PVector[]positions;
  float maximum;
  float minimum;
  float numberOfSpaces;
  
  Graph(){
  }
  
   void draw(){
    qEvents = screenTwo.getEvent();
    switch(qEvents){
      case 1:
      dataPicked(openingPrices);
      return;
      case 2:
      dataPicked (closingPrices);
      return;
      case 3:
      dataPicked(adjustedClosingPrices);
      return;
      case 4:
      dataPicked (lowestPrices);
      return;
      case 5:
      dataPicked(highestPrices);
      return;
      case 6:
      dataPicked (volume);
      return;
    }
    findPosition();
    drawGraph();
    fill(0);
    
    text(tickers.get(range.get(0)),600, 75);
    for(int i = 0; i<positions.length; i++)
    {
      if(mouseX > positions[i].x-5 && mouseX < positions[i].x+5)
      {
        {
          fill(#F00048);
          ellipse(positions[i].x, positions[i].y, 10, 10);
          textSize(24);
          text(groupedYears.get(i), positions[i].x-25, height - margin);
          {
            noStroke();
            fill(255);
            {
              fill(0);
              textSize(12);
              text("date:"+groupedDays.get(i),groupedMonths.get(i),groupedYears.get(i));
              text("value:"+graphPosition.get(i),  positions[i].x-30, positions[i].y+30);
            }
          }
        }
      }
      else {
        fill(200);
        ellipse(positions[i].x, positions[i].y, 15, 15);
      }
    }
  }
  void dataPicked(ArrayList<Float> dataSet){
    groupedDays = new ArrayList();
    groupedMonths = new ArrayList();
    groupedYears = new ArrayList();
    graphPosition = new ArrayList();
    
    if(range.get(0)==1){
      range.add(0, 0);
    }
    
    int lastPieceOfData = range.get(range.size()-1);
    for (int i = range.get(0); i<lastPieceOfData; i++){
      groupedDays.add(days.get(i));
      groupedMonths.add(months.get(i));
      groupedYears.add(years.get(i));
      graphPosition.add(dataSet.get(i));
    }
    int swap = 0;
    int swap2 = 0;
    float swapData = 0;
    float swapData2 = 0;
    
    for(int i = 0; i < groupedYears.size(); i++){
      for(int j = 0; j<(groupedYears.size())-1; j++){
        if(groupedYears.get(j)>groupedYears.get(j+1)){
          swap = groupedYears.get(j);
          swap2 = groupedYears.get(j+1);
          groupedYears.set(j, swap2);
          groupedYears.set(j+1, swap);
          
          swap = groupedMonths.get(j);
          swap2 = groupedMonths.get(j+1);
          groupedMonths.set(j, swap2);
          groupedMonths.set(j+1, swap);
          
          swap = groupedDays.get(j);
          swap2 = groupedDays.get(j+1);
          groupedDays.set(j, swap2);
          groupedDays.set(j+1, swap);
          
          swapData = graphPosition.get(j);
          swapData2 = graphPosition.get(j+1);
          graphPosition.set(j, swapData2);
          graphPosition.set(j+1, swapData);
        }
      }
      for(int j = 0; j<(groupedMonths.size())-1; j++){
        if(groupedMonths.get(j)>groupedMonths.get(j+1) && groupedYears.get(j)>groupedYears.get(j+1)){
          
          swap = groupedDays.get(j);
          swap2 = groupedDays.get(j+1);
          groupedDays.set(j, swap2);
          groupedDays.set(j+1, swap);
          
          swap = groupedMonths.get(j);
          swap2 = groupedMonths.get(j+1);
          groupedMonths.set(j, swap2);
          groupedMonths.set(j+1, swap);
          
          swapData = graphPosition.get(j);
          swapData2 = graphPosition.get(j+1);
          graphPosition.set(j, swapData2);
          graphPosition.set(j+1, swapData);
          
        }
      }
      for(int j = 0; j<(groupedDays.size())-1; j++){
        if(groupedMonths.get(j)>groupedMonths.get(j+1) && groupedDays.get(j)>groupedDays.get(j+1)){
           
          swap = groupedDays.get(j);
          swap2 = groupedDays.get(j+1);
          groupedDays.set(j, swap2);
          groupedDays.set(j+1, swap);
          
           swapData = graphPosition.get(j);
          swapData2 = graphPosition.get(j+1);
          graphPosition.set(j, swapData2);
          graphPosition.set(j+1, swapData);
        }
      }
    }
    }
    void findPosition(){
      positions = new PVector[graphPosition.size()];
      maximum = Collections.max(graphPosition);
      minimum = Collections.min(graphPosition);
      
      margin = 100;
      leftOfMargin = 150;
      rightOfMargin = 100;
      topOfMargin = 250;
      graphHeight = (height - margin)-topOfMargin;
      numberOfSpaces = (width - leftOfMargin - rightOfMargin)/groupedYears.size()-1;
      
      for(int i = 0; i<graphPosition.size(); i++){
        float adjust = map(graphPosition.get(i), minimum, maximum, 0, graphPosition.size());
        float ypos = height-margin-adjust;
        float xpos = margin +(numberOfSpaces *i);
        positions[i] = new PVector(xpos, ypos);
      }
    }
    void drawGraph(){
      for(int i = 0; i< positions.length; i++){
        stroke(100, 100);
        line(positions[i].x, margin, positions[i].x, height-margin);
        String year = Integer.toString(groupedYears.get(i));
        if(i>0){
          stroke(200);
          line(positions[i].x, positions[i].y, positions[i-1].x, positions[i-1].y);
        }
      }
      text(maximum, 5, margin);
      text(minimum, 5, height - margin);
    }
  }

We can’t run your code, a lot of classes are missing

The error you get is mostly cause by lines of code outside any function. This is mostly a misplaced } …

I couldn’t find any, but it can be in another tab if you have those

other classes are below

class Data{
  String [] myArray;
  String singularData;
  
  Data(String data){
    singularData = data;
    myArray = splitter(singularData);
  }
  String [] splitter (String lineOfData){
    String myArray[] = split(lineOfData, ",");
    return myArray;
  }
}



class Screen{
  ArrayList<Widget> widgets = new ArrayList();
  ArrayList<Widget> navigationButtons = new ArrayList();
  ArrayList<Widget> queryList = new ArrayList();
Graph graph;
  
  color screenColour;
  
  Screen(color screenColour, ArrayList<Widget> widgetList,ArrayList<Widget> direction,
  ArrayList<Widget> queries, Graph graph)
  {
    this.screenColour = screenColour;
    widgets = widgetList;
    navigationButtons = direction;
    queryList = queries;
    this.graph = graph;
   
  }
  
  int getEvent(){
    if(widgets != null){
      for(Widget widget: widgets)
      {
        int event = widget.getEvent(mouseX, mouseY);
        if(event!=0)
        return event;
      }
    }
      if(navigationButtons != null){
      for(Widget navigationButton: navigationButtons)
      {
        int event = navigationButton.getEvent(mouseX, mouseY);
        if(event!=0)
        return event;
      }
      }
      if(queryList != null){
      for(Widget myQueries: queryList)
      {
        int event = myQueries.getEvent(mouseX, mouseY);
        if(event!=0)
        return event;
      }
      }
      return EVENT_NULL;
      }
    
      void draw(){
        background(screenColour);
        if(widgets != null)
        {
          for(Widget widget : widgets) {
            color widgetBorder;
           if (mouseX > widget.x && mouseX < widget.x + widget.width
                && mouseY > widget.y && mouseY < widget.y + widget.height){
                    widgetBorder = color(255, 255, 255);
                }
                else{
                    widgetBorder = color(0, 0, 0);
                }
                
          
                stroke(widgetBorder);
                widget.draw();
                
            }
            if(navigationButtons!=null)
            {
            for(Widget navigationButton: navigationButtons) {
            color widgetBorder2;
           if (mouseX > navigationButton.x && mouseX < navigationButton.x + navigationButton.width*2
                && mouseY > navigationButton.y && mouseY < navigationButton.y + navigationButton.height){
                    widgetBorder2 = color(255, 255, 255);
                }
                else{
                    widgetBorder2 = color(0, 0, 0);
        }
        stroke(widgetBorder2);
        navigationButton.draw();
      }
      if(queryList!=null)
      {
        for(Widget myQueries: queryList){
        color widgetBorder3;
           if (mouseX > myQueries.x && mouseX < myQueries.x + myQueries.width
                && mouseY > myQueries.y && mouseY < myQueries.y + myQueries.height){
                    widgetBorder3 = color(255, 255, 255);
                }
                else{
                    widgetBorder3 = color(0, 0, 0);
        }
        stroke(widgetBorder3);
        myQueries.draw();
}
      }
}
}
      }
}


class Widget{
  ArrayList stockButtons = new ArrayList();
   int x, y, width, height;
  String ticker; 
  int event;
  color widgetColor, labelColor;
  PFont widgetFont;

  Widget()
  {
  }
  Widget(int x, int y, int width, int height, String ticker, 
    color widgetColor, PFont widgetFont, int event) {
    this.x=x; 
    this.y=y; 
    this.width = width; 
    this.height= height;
    this.ticker=ticker; 
    this.event=event;
    this.widgetColor=widgetColor; 
    this.widgetFont=widgetFont;
    labelColor= color(0);
  }
  void draw() {
    fill(widgetColor);
    rect(x, y, width, height);
    fill(labelColor);
    text(ticker, x+10, y+height-10);
  }
  int getEvent(int mX, int mY) {
    if (mX>x && mX < x+width && mY >y && mY <y+height) {
      return event;
    }
    return 0;
  }
}
class TextWidget extends Widget {

  int maxlen;

  TextWidget(int x, int y, int width, int height, String ticker, 
  color widgetColor, PFont widgetFont, int event, int maxlen) {
    super();
    this.x=x; 
    this.y=y; 
    this.width = width; 
    this.height= height;
    this.ticker=ticker; 
    this.event=event;
    this.widgetColor=widgetColor; 
    this.widgetFont=widgetFont;
    labelColor=color(0); 
    this.maxlen=maxlen;
  }
  void append(char s) {
    if (s==BACKSPACE) {
      if (!ticker.equals(""))
        ticker=ticker.substring(0, ticker.length()-1);
    }
    else if (ticker.length() < maxlen)
      ticker=ticker+str(s);
  }
}

I see a lot of error but that is not one of them

I can’t help you.





import java.util.*;

ArrayList tickers = new ArrayList();
ArrayList openingPrices = new ArrayList();
ArrayList closingPrices = new ArrayList();
ArrayList adjustedClosingPrices = new ArrayList();
ArrayList lowestPrices = new ArrayList();
ArrayList highestPrices = new ArrayList();
ArrayList volume = new ArrayList();
ArrayList dates = new ArrayList();
ArrayList days = new ArrayList();
ArrayList months = new ArrayList();
ArrayList years = new ArrayList();
ArrayList range = new ArrayList();
ArrayList myData;
ArrayList queries;

Data singularData;
Screen screenOne;
Screen screenTwo;
Screen screenThree;
Graph myGraph = new Graph();
Widget firstWidget;
ArrayList widgetList;
ArrayList direction ;
TextWidget focus;
PFont widgetFont;
final int EVENT_TEXT=-1;
final int EVENT_BACKWARD=-2;
final int TEXT_WIDGET = 1;
final int EVENT_NULL=0;
int event;
int qEvents;
color widgetBorder;
int events = 1;
int queriedEvents = 1;
int screen;

void setup() {

  size(800, 500);
  background(255);
  myData = new ArrayList();
  read_in_data();
  arraySort();
  println(count());
  widgetBorder = color (0, 0, 0);

  widgetFont=loadFont("Verdana-12.vlw");
  textFont(widgetFont);
  //TextWidget textEdit=new TextWidget(100, 25, 200, 40, “Type a ticker symbol”,
  //color(255), widgetFont, TEXT_WIDGET, 10);
  //focus = null;
  widgetList = new ArrayList();
  queries = new ArrayList();
  direction = new ArrayList();
  screenOne = new Screen(color(255), widgetList, null, null, null);
  screenTwo = new Screen(color(255), direction, queries, null, null);
  screenThree = new Screen (color(255), direction, null, null, null);
  screen = 1;

  int x = 100;
  int y = 100;
  String tickerText = "";
  String previousTicker = "";
  int index = 0;

  for (int i = 0; i<count(); i++) {
    boolean quit = false;
    while (quit == false) {
      // tickerText=tickers.get(index);
      if (!tickerText.equals(previousTicker)) {
        quit = true;
      }
      index++;
    }
    previousTicker=tickerText;
    firstWidget = new Widget(x, y, 60, 30, tickerText, color(255, 0, 0), widgetFont, events);
    focus = null;
    widgetList.add(firstWidget);
    y+=100;
    if (y>=500) {
      y=60;
      x+=100;
    }
    events++;
  }
  Widget openPrice = new Widget (400, 100, 100, 40, "opening price", color(255, 0, 0), widgetFont, queriedEvents);
  queries.add(openPrice);
  queriedEvents++;

  Widget closePrice = new Widget (400, 150, 100, 40, "closing price", color(255, 0, 0), widgetFont, queriedEvents);
  queries.add(closePrice);
  queriedEvents++;

  Widget adjClosePrice = new Widget (400, 200, 160, 40, "adjusted closing price", color(255, 0, 0), widgetFont, queriedEvents);
  queries.add(adjClosePrice);
  queriedEvents++;

  Widget low = new Widget (400, 250, 100, 40, "lowest price", color(255, 0, 0), widgetFont, queriedEvents);
  queries.add(low);
  queriedEvents++;

  Widget high = new Widget (400, 300, 100, 40, "highest price", color(255, 0, 0), widgetFont, queriedEvents);
  queries.add(high);
  queriedEvents++;

  Widget volume = new Widget (400, 350, 100, 40, "stock volume", color(255, 0, 0), widgetFont, queriedEvents);
  queries.add(volume);
  queriedEvents++;

  Widget previous = new Widget (50, 400, 50, 30, "back", color(255, 0, 0), widgetFont, EVENT_BACKWARD);
  focus = null;
  direction.add(previous);
}
void draw() {
  background(100);
  textSize(12);
  background(255);
  stroke(0);
  fill(255);
  if (screen == 1) {
    screenOne.draw();
  } else if (screen == 2) {
    screenTwo.draw();
  } else if (screen == 3) {
    screenThree.draw();
  }
}
void mousePressed()
{
  for (int i = 0; i<widgetList.size(); i++)
  {
    Widget myWidget = (Widget)widgetList.get(i);
    event = myWidget.getEvent(mouseX, mouseY);

    if (screen == 1)
    {
      event = screenOne.getEvent();
      switch(event)
      {
      case EVENT_TEXT:
        println("clicked");
        focus = (TextWidget)myWidget;
        return;

      case 1:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 2:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 3:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 4:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 5:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 6:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 7:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 8:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 9:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 10:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 11:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 12:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 13:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 14:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 15:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 16:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 17:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 18:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 19:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 20:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 21:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 22:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 23:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 24:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 25:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 26:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 27:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 28:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 29:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 30:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 31:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 32:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 33:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 34:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 35:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 36:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 37:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 38:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 39:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 40:
        screen = 2;
        ranges();
        focus = null;
        return;

      case 41:
        screen = 2;
        ranges();
        focus = null;
        return;
      }
    } else if (screen == 2)
    {
      qEvents = screenTwo.getEvent();
      if (qEvents == EVENT_BACKWARD)
      { 
        screen = 1;
      }
      switch(qEvents) {
      case 1:
        screen = 3;
        return;

      case 2: 
        screen=3;
        //Graph.draw();
        return;

      case 3: 
        screen=3;
        // Graph.draw();
        return;

      case 4: 
        screen=3;
        //  Graph.draw();
        return;

      case 5: 
        screen=3;
        // Graph.draw();
        return;

      case 6: 
        screen=3;
        //Graph.draw();
        return;
      }
    } else if (screen == 3) {
      qEvents = screenTwo.getEvent();
      if (qEvents == EVENT_BACKWARD)
      {
        screen = 2;
      }
    }
  }
}
void keyPressed() {
  if (focus != null)
  {
    focus.append(key);
  }
}

void read_in_data() {
  String lines[] = loadStrings("daily_prices1k.csv");

  for (int i = 0; i<lines.length; i++) {
    singularData = new Data(lines[i]);
    myData.add(singularData);
    // myNewArray(myData.get(i).myArray);
  }
}

void myNewArray(String array[]) {
  tickers.add(array[0]);
  openingPrices.add(convertToString(array[1]));
  closingPrices.add(convertToString(array[2]));
  adjustedClosingPrices.add(convertToString(array[3]));
  lowestPrices.add(convertToString(array[4]));
  highestPrices.add(convertToString(array[5]));
  volume.add(convertToString(array[6]));
  dates.add(array[7]);
  breakUpDates(array[7]);
}

float convertToString(String points) {
  float point = float(points);
  return point;
}

Integer convertDatesToString(String points) {
  int point = int (points);
  return point;
}

void breakUpDates(String date) {
  String array[] = split(date, "-");
  days.add(convertDatesToString(array[0]));
  months.add(convertDatesToString(array[1]));
  years.add(convertDatesToString(array[2]));
}

void arraySort() {
  for (int i = 0; i<tickers.size(); i++) {
    String myTickers=(String) tickers.get(i);
    for (int index = 0; index<tickers.size(); index++) {
      if (tickers.get(index).equals(myTickers)&&i!=index) {


        String removeTicker = (String) tickers.get(index);
        tickers.remove(index);
        tickers.add(i, removeTicker);

        float removeClose = (float) closingPrices.get(index);
        closingPrices.remove(index);
        closingPrices.add(i, removeClose);

        float removeOpen = (float)   openingPrices.get(index);
        openingPrices.remove(index);
        openingPrices.add(i, removeOpen);

        float removeAdjusted =  (float) adjustedClosingPrices.get(index);
        adjustedClosingPrices.remove(index);
        adjustedClosingPrices.add(i, removeAdjusted);

        float removeLowest =  (float) lowestPrices.get(index);
        lowestPrices.remove(index);
        lowestPrices.add(i, removeLowest);

        float removeHighest =  (float) highestPrices.get(index);
        highestPrices.remove(index);
        highestPrices.add(i, removeHighest);

        float removeVolume = (float)  volume.get(index);
        volume.remove(index);
        volume.add(i, removeVolume);

        int removeDay = (int)  days.get(index);
        days.remove(index);
        days.add(i, removeDay);

        int removeMonth = (int)months.get(index);
        days.remove(index);
        days.add(i, removeMonth);

        int removeYear = (int)years.get(index);
        days.remove(index);
        days.add(i, removeYear);
      }
    }
  }
}

int count() {
  int count = 1;
  for (int i = 1; i< tickers.size(); i++) {
    String newTicker = (String)tickers.get(i);
    if (!tickers.get(i-1).equals(newTicker)) {
      count++;
    }
  }
  return count;
}

void ranges() {
  range = new ArrayList();
  int count = 1 ;
  for (int i = 1; i<tickers.size(); i++) {
    String newTicker =(String) tickers.get(i);
    if (!tickers.get(i-1).equals(newTicker)) {
      count++;
    }
    if (count == event) {
      range.add(i);
    }
  }
}

class Graph {
  ArrayList groupedDays;
  ArrayList groupedMonths;
  ArrayList groupedYears;
  ArrayList graphPosition;
  int margin, graphHeight, topOfMargin, leftOfMargin, rightOfMargin;
  PFont font;
  String fontList[] = PFont.list();
  PVector[]positions;
  float maximum;
  float minimum;
  float numberOfSpaces;

  Graph() {
  }

  void draw() {
    qEvents = screenTwo.getEvent();
    switch(qEvents) {
    case 1:
      dataPicked(openingPrices);
      return;
    case 2:
      dataPicked (closingPrices);
      return;
    case 3:
      dataPicked(adjustedClosingPrices);
      return;
    case 4:
      dataPicked (lowestPrices);
      return;
    case 5:
      dataPicked(highestPrices);
      return;
    case 6:
      dataPicked (volume);
      return;
    }
    findPosition();
    drawGraph();
    fill(0);

    text((String)tickers.get((int)range.get(0)), 
      600, 75);
    for (int i = 0; i<positions.length; i++)
    {
      if (mouseX > positions[i].x-5 && mouseX < positions[i].x+5)
      {
        {
          fill(#F00048);
          ellipse(positions[i].x, positions[i].y, 10, 10);
          textSize(24);
          // text(groupedYears.get(i), positions[i].x-25, height - margin);
          {
            noStroke();
            fill(255);
            {
              fill(0);
              textSize(12);
              //              text("date:"+groupedDays.get(i), groupedMonths.get(i), groupedYears.get(i));
              //              text("value:"+graphPosition.get(i), positions[i].x-30, positions[i].y+30);
            }
          }
        }
      } else {
        fill(200);
        ellipse(positions[i].x, positions[i].y, 15, 15);
      }
    }
  }
  void dataPicked(ArrayList dataSet) {
    groupedDays = new ArrayList();
    groupedMonths = new ArrayList();
    groupedYears = new ArrayList();
    graphPosition = new ArrayList();

    if ((int)range.get(0)==1) {
      range.add(0, 0);
    }

    int lastPieceOfData = range.get(range.size()-1);
    for (int i = range.get(0); i<lastPieceOfData; i++) {
      groupedDays.add(days.get(i));
      groupedMonths.add(months.get(i));
      groupedYears.add(years.get(i));
      graphPosition.add(dataSet.get(i));
    }
    int swap = 0;
    int swap2 = 0;
    float swapData = 0;
    float swapData2 = 0;

    for (int i = 0; i < groupedYears.size(); i++) {
      for (int j = 0; j<(groupedYears.size())-1; j++) {
        if (groupedYears.get(j)>groupedYears.get(j+1)) {
          swap = groupedYears.get(j);
          swap2 = groupedYears.get(j+1);
          groupedYears.set(j, swap2);
          groupedYears.set(j+1, swap);

          swap = groupedMonths.get(j);
          swap2 = groupedMonths.get(j+1);
          groupedMonths.set(j, swap2);
          groupedMonths.set(j+1, swap);

          swap = groupedDays.get(j);
          swap2 = groupedDays.get(j+1);
          groupedDays.set(j, swap2);
          groupedDays.set(j+1, swap);

          swapData = graphPosition.get(j);
          swapData2 = graphPosition.get(j+1);
          graphPosition.set(j, swapData2);
          graphPosition.set(j+1, swapData);
        }
      }
      for (int j = 0; j<(groupedMonths.size())-1; j++) {
        if (groupedMonths.get(j)>groupedMonths.get(j+1) && groupedYears.get(j)>groupedYears.get(j+1)) {

          swap = groupedDays.get(j);
          swap2 = groupedDays.get(j+1);
          groupedDays.set(j, swap2);
          groupedDays.set(j+1, swap);

          swap = groupedMonths.get(j);
          swap2 = groupedMonths.get(j+1);
          groupedMonths.set(j, swap2);
          groupedMonths.set(j+1, swap);

          swapData = graphPosition.get(j);
          swapData2 = graphPosition.get(j+1);
          graphPosition.set(j, swapData2);
          graphPosition.set(j+1, swapData);
        }
      }
      for (int j = 0; j<(groupedDays.size())-1; j++) {
        if (groupedMonths.get(j)>groupedMonths.get(j+1) && groupedDays.get(j)>groupedDays.get(j+1)) {

          swap = groupedDays.get(j);
          swap2 = groupedDays.get(j+1);
          groupedDays.set(j, swap2);
          groupedDays.set(j+1, swap);

          swapData = graphPosition.get(j);
          swapData2 = graphPosition.get(j+1);
          graphPosition.set(j, swapData2);
          graphPosition.set(j+1, swapData);
        }
      }
    }
  }
  void findPosition() {
    positions = new PVector[graphPosition.size()];
    maximum = Collections.max(graphPosition);
    minimum = Collections.min(graphPosition);

    margin = 100;
    leftOfMargin = 150;
    rightOfMargin = 100;
    topOfMargin = 250;
    graphHeight = (height - margin)-topOfMargin;
    numberOfSpaces = (width - leftOfMargin - rightOfMargin)/groupedYears.size()-1;

    for (int i = 0; i<graphPosition.size(); i++) {
      float adjust = map(graphPosition.get(i), minimum, maximum, 0, graphPosition.size());
      float ypos = height-margin-adjust;
      float xpos = margin +(numberOfSpaces *i);
      positions[i] = new PVector(xpos, ypos);
    }
  }
  void drawGraph() {
    for (int i = 0; i< positions.length; i++) {
      stroke(100, 100);
      line(positions[i].x, margin, positions[i].x, height-margin);
      String year = Integer.toString(groupedYears.get(i));
      if (i>0) {
        stroke(200);
        line(positions[i].x, positions[i].y, positions[i-1].x, positions[i-1].y);
      }
    }
    text(maximum, 5, margin);
    text(minimum, 5, height - margin);
  }
}

// ********************************************************************************************************

class Data {
  String [] myArray;
  String singularData;

  Data(String data) {
    singularData = data;
    myArray = splitter(singularData);
  }
  String [] splitter (String lineOfData) {
    String myArray[] = split(lineOfData, ",");
    return myArray;
  }
}

class Screen {
  ArrayList widgets = new ArrayList();
  ArrayList navigationButtons = new ArrayList();
  ArrayList queryList = new ArrayList();
  Graph graph;

  color screenColour;

  Screen(color screenColour, ArrayList widgetList, ArrayList direction, 
    ArrayList queries, Graph graph)
  {
    this.screenColour = screenColour;
    widgets = widgetList;
    navigationButtons = direction;
    queryList = queries;
    this.graph = graph;
  }

  int getEvent() {
    if (widgets != null) {
      for (Widget widget : widgets)
      {
        int event = widget.getEvent(mouseX, mouseY);
        if (event!=0)
          return event;
      }
    }
    if (navigationButtons != null) {
      for (Widget navigationButton : navigationButtons)
      {
        int event = navigationButton.getEvent(mouseX, mouseY);
        if (event!=0)
          return event;
      }
    }
    if (queryList != null) {
      for (Widget myQueries : queryList)
      {
        int event = myQueries.getEvent(mouseX, mouseY);
        if (event!=0)
          return event;
      }
    }
    return EVENT_NULL;
  }

  void draw() {
    background(screenColour);
    if (widgets != null)
    {
      for (Widget widget : widgets) {
        color widgetBorder;
        if (mouseX > widget.x && mouseX < widget.x + widget.width
          && mouseY > widget.y && mouseY < widget.y + widget.height) {
          widgetBorder = color(255, 255, 255);
        } else {
          widgetBorder = color(0, 0, 0);
        }


        stroke(widgetBorder);
        widget.draw();
      }
      if (navigationButtons!=null)
      {
        for (Widget navigationButton : navigationButtons) {
          color widgetBorder2;
          if (mouseX > navigationButton.x && mouseX < navigationButton.x + navigationButton.width*2
            && mouseY > navigationButton.y && mouseY < navigationButton.y + navigationButton.height) {
            widgetBorder2 = color(255, 255, 255);
          } else {
            widgetBorder2 = color(0, 0, 0);
          }
          stroke(widgetBorder2);
          navigationButton.draw();
        }
        if (queryList!=null)
        {
          for (Widget myQueries : queryList) {
            color widgetBorder3;
            if (mouseX > myQueries.x && mouseX < myQueries.x + myQueries.width
              && mouseY > myQueries.y && mouseY < myQueries.y + myQueries.height) {
              widgetBorder3 = color(255, 255, 255);
            } else {
              widgetBorder3 = color(0, 0, 0);
            }
            stroke(widgetBorder3);
            myQueries.draw();
          }
        }
      }
    }
  }
}

class Widget {
  ArrayList stockButtons = new ArrayList();
  int x, y, width, height;
  String ticker;
  int event;
  color widgetColor, labelColor;
  PFont widgetFont;

  Widget()
  {
  }
  Widget(int x, int y, int width, int height, String ticker, 
    color widgetColor, PFont widgetFont, int event) {
    this.x=x;
    this.y=y;
    this.width = width;
    this.height= height;
    this.ticker=ticker;
    this.event=event;
    this.widgetColor=widgetColor;
    this.widgetFont=widgetFont;
    labelColor= color(0);
  }
  void draw() {
    fill(widgetColor);
    rect(x, y, width, height);
    fill(labelColor);
    text(ticker, x+10, y+height-10);
  }
  int getEvent(int mX, int mY) {
    if (mX>x && mX < x+width && mY >y && mY <y+height) {
      return event;
    }
    return 0;
  }
}
class TextWidget extends Widget {

  int maxlen;

  TextWidget(int x, int y, int width, int height, String ticker, 
    color widgetColor, PFont widgetFont, int event, int maxlen) {
    super();
    this.x=x;
    this.y=y;
    this.width = width;
    this.height= height;
    this.ticker=ticker;
    this.event=event;
    this.widgetColor=widgetColor;
    this.widgetFont=widgetFont;
    labelColor=color(0);
    this.maxlen=maxlen;
  }
  void append(char s) {
    if (s==BACKSPACE) {
      if (!ticker.equals(""))
        ticker=ticker.substring(0, ticker.length()-1);
    } else if (ticker.length() < maxlen)
      ticker=ticker+str(s);
  }
}
//

Hello,

I always take an interest but your code is not formatted (difficult to read and can’t cut and paste) so have to pass on this one.

Try doing a Google search; there are many discussions on this topic and you may glean some insight from them.

:)

I was wrong with my assessment

Forget about it