Thoughts on my calendar application?
in
Share your Work
•
1 month ago
So, obviously it needs a lot of work for it to be a fully functioning calendar app, but what are your initial thoughts? I just made this for fun, I guess its my first real application. To add an event just add a line in the setEvent() function at the top as I haven't added the 'add event' portion to the gui yet. You will probably have to add a new event as we are most likely in different time zones. I know there are a lot but if you spot an error just let me know :D.
Anyway, here it is.
- int[] dateArray = new int[100000];
- int[] dayArray = new int[100000];
- float[] startTimeArray = new float[100000];
- float[] endTimeArray = new float[100000];
- String[] eventNameArray = new String[100000];
- String[] calendarNameArray = new String[100000];
- void setEvent()
- {
- addEvent(20130901,01,3.00,5.00,"Piano","Music");
- addEvent(20130901,01,14.00,24.00,"Sleep","Sleep");
- addEvent(20130901,01,9.00,22.00,"Calculus","School");
- addEvent(20130901,01,9.00,22.00,"Gym","Exercise");
- //addEvent(YYYYMMDD,DD,(start)H.MM,(end)H.MM,event name, Calendar name)
- }
- void setup()
- {
- background(255);
- size(700,800);
- smooth();
- textAlign(CENTER,CENTER);
- rectMode(CENTER);
- textSize(10);
- frameRate(30);
- setEvent();
- }
- void draw()
- {
- displayCalendar();
- }
- void displayCalendar()
- {
- //refresh screen
- background(255);
- noStroke();
- calendarPanels();
- calendarCurrentDateAndTime();
- displayEvent();
- }
- void displayEvent()
- {
- int currentDate = (year()*100+month())*100+day();
- int currentEventsCounter=100;
- for (int z = 0; z<=dateArray.length-1;z++)
- {
- if (dateArray[z]==currentDate)
- {
- int eventNumberInArray = z;
- if (startTimeArray[eventNumberInArray]<=hour()+(minute()*pow(10,-2))&&endTimeArray[eventNumberInArray]>hour()+(minute()*pow(10,-2)))
- {
- currentEventsCounter-=20;
- fill(0);
- int endPositionVal = round(((float)((float)((int(endTimeArray[eventNumberInArray])+((float)((endTimeArray[eventNumberInArray]-int(endTimeArray[eventNumberInArray]))*pow(10,2))/60))-(hour()+((float)minute()/60)))*60)/60)*100);
- noStroke();
- if (calendarNameArray[eventNumberInArray] == "Music")
- {
- color eventCol = color(100,0,150,75);
- fill(eventCol);
- }
- else if (calendarNameArray[eventNumberInArray] == "Exercise")
- {
- color eventCol = color(255,0,0,75);
- fill(eventCol);
- }
- else if (calendarNameArray[eventNumberInArray] == "School")
- {
- color eventCol = color(0,150,150,75);
- fill(eventCol);
- }
- else if (calendarNameArray[eventNumberInArray] == "Sleep")
- {
- color eventCol = color(0,0,0,75);
- fill(eventCol);
- }
- else if (calendarNameArray[eventNumberInArray] == "Meal")
- {
- color eventCol = color(200,0,150,75);
- fill(eventCol);
- }
- rect(width/2-(currentEventsCounter/5),(height/10)+(endPositionVal/2),width/3+(currentEventsCounter/5),endPositionVal);
- }
- else
- {
- if (endTimeArray[eventNumberInArray]>hour()+(minute()*pow(10,-2)))
- {
- currentEventsCounter-=20;
- float midEventPix = ((float)(((((((startTimeArray[eventNumberInArray]-int(startTimeArray[eventNumberInArray]))*100)/60)*100)+int(startTimeArray[eventNumberInArray]))-(hour()+((float)minute()/60)))+((((((((endTimeArray[eventNumberInArray]-int(endTimeArray[eventNumberInArray]))*100)/60)*100)+int(endTimeArray[eventNumberInArray]))-(hour()+((float)minute()/60)))-((((((startTimeArray[eventNumberInArray]-int(startTimeArray[eventNumberInArray]))*100)/60)*100)+int(startTimeArray[eventNumberInArray]))-(hour()+((float)minute()/60))))/2)))*100;
- float eventLengthPix = (((((((endTimeArray[eventNumberInArray]-int(endTimeArray[eventNumberInArray]))*100)/60)*100)+int(endTimeArray[eventNumberInArray]))-(hour()+((float)minute()/60)))-((((((startTimeArray[eventNumberInArray]-int(startTimeArray[eventNumberInArray]))*100)/60)*100)+int(startTimeArray[eventNumberInArray]))-(hour()+((float)minute()/60))))*100;
- if (calendarNameArray[eventNumberInArray] == "Music")
- {
- color eventCol = color(100,0,150,75);
- fill(eventCol);
- }
- else if (calendarNameArray[eventNumberInArray] == "Exercise")
- {
- color eventCol = color(255,0,0,75);
- fill(eventCol);
- }
- else if (calendarNameArray[eventNumberInArray] == "School")
- {
- color eventCol = color(0,150,150,75);
- fill(eventCol);
- }
- else if (calendarNameArray[eventNumberInArray] == "Sleep")
- {
- color eventCol = color(0,0,0,75);
- fill(eventCol);
- }
- else if (calendarNameArray[eventNumberInArray] == "Meal")
- {
- color eventCol = color(200,0,150,75);
- fill(eventCol);
- }
- rect(width/2-(currentEventsCounter/5),(height/10)+midEventPix,width/3+(currentEventsCounter/5),eventLengthPix);
- }
- }
- }
- }
- }
- void addEvent(int eventDate,int eventDay,float eventStartTime,float eventEndTime,String eventName,String calendarName)
- {
- int nextEventPos = 0;
- //Check next position in the array
- for (int a =0;a<=dateArray.length-1;a++)
- {
- if (eventNameArray[a]==null)
- {
- nextEventPos = a;
- break;
- }
- }
- //Once next position is found enter event details into each array
- dayArray[nextEventPos] = eventDay;
- dateArray[nextEventPos] = eventDate;
- startTimeArray[nextEventPos] = eventStartTime;
- endTimeArray[nextEventPos] = eventEndTime;
- eventNameArray[nextEventPos] = eventName;
- calendarNameArray[nextEventPos] = calendarName;
- }
- void calendarPanels()
- {
- //main panel
- fill(200);
- rect(width/2,height/2,width/2,height);
- //top panel
- textSize(width/40);
- fill(0);
- rect(width/2,20,width,40);
- fill(255,0,0);
- rect(width/2,20,width/3,40);
- fill(255);
- text("Click to add new event",width/2,17);
- }
- void calendarCurrentDateAndTime()
- {
- //Today cursor date and time
- textSize(width/40);
- fill(255,0,0);
- text(day()+"/"+month()+"/"+year(),width/10,17);
- textSize(10);
- if (minute()<10)
- {
- text(hour()+":"+"0"+minute(),50,height/10);
- }
- else
- {
- text(hour()+":"+minute(),50,height/10);
- }
- stroke(255,0,0);
- line(75,height/10,width,height/10);
- ellipse(75,height/10,15,15);
- //Display subsequent hours
- int time = minute();
- stroke(0);
- fill(0);
- for(int testHours = 1;testHours<=23;testHours++)
- {
- if (hour()+testHours<=24)
- {
- text(hour()+testHours+":00",15,(height/10)+((testHours*100)-(((float)time/60)*100)));
- line(75,(height/10)+((testHours*100)-(((float)time/60)*100)),width,(height/10)+((testHours*100)-(((float)time/60)*100)));
- }
- }
- }