gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/doc/pegboard/1020 PEG_1020.rst


From: Matti Katila
Subject: [Gzz-commits] gzz/doc/pegboard/1020 PEG_1020.rst
Date: Thu, 24 Oct 2002 10:42:30 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Matti Katila <address@hidden>   02/10/24 10:42:29

Modified files:
        doc/pegboard/1020: PEG_1020.rst 

Log message:
        added textprototype and got lost with coordinates

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/doc/pegboard/1020/PEG_1020.rst.diff?tr1=1.3&tr2=1.4&r1=text&r2=text

Patches:
Index: gzz/doc/pegboard/1020/PEG_1020.rst
diff -u gzz/doc/pegboard/1020/PEG_1020.rst:1.3 
gzz/doc/pegboard/1020/PEG_1020.rst:1.4
--- gzz/doc/pegboard/1020/PEG_1020.rst:1.3      Tue Oct 22 03:05:47 2002
+++ gzz/doc/pegboard/1020/PEG_1020.rst  Thu Oct 24 10:42:29 2002
@@ -3,8 +3,8 @@
 =============================================================
 
 :Authors:  Matti Katila
-:Date:     $Date: 2002/10/22 07:05:47 $
-:Revision: $Revision: 1.3 $
+:Date:     $Date: 2002/10/24 14:42:29 $
+:Revision: $Revision: 1.4 $
 :Status:   Incomplete
 
 
@@ -88,6 +88,7 @@
          |_|_|_|_|_|_|_|   |
          |_|_|_________|  \|/
 
+            -also days per month is needed
 
 
 Prototypes etc.
@@ -96,6 +97,184 @@
     Open for comments.
 
 
-    # example from gfx.librenderable.renderable
-    "Name": "CalendarPaper",
-    "Data": "float x0, y0, x1, y1; Calendar::Calendar* calendar; float 
scale;float dicefactor; int flags;",
+TextPrototype
+-------------
+
+
+import java.util.*;
+
+public class TextCalendar {
+    static void p(String s) { System.out.print(s); } 
+    static void pln(String s) { System.out.println(s); }
+
+    // notice common factor, 12
+    private int weeks_in_month[] = new int[12];
+    private int empty_before_first_day[] = new int[12];
+    private int days_in_month[] = new int[12];
+
+    
+    public TextCalendar() {
+
+       // get the supported ids for GMT-08:00 (Pacific Standard Time)
+       String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
+
+       // if no ids were returned, something is wrong. get out.
+       if (ids.length == 0)
+           System.exit(0);
+
+       // create a Pacific Standard Time time zone
+       SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
+
+       // set up rules for daylight savings time
+       pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 
1000);
+       pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 
1000);
+       Calendar calendar = new GregorianCalendar(pdt);
+       calendar.setFirstDayOfWeek(Calendar.MONDAY);
+
+       Date date = new Date();
+       date.setYear(calendar.YEAR);
+
+       pln(" * Year: " + calendar.get(calendar.YEAR));
+
+       for (int month = 0; month < 12; month++) {
+
+           // set first day of month
+           date.setDate(1);
+           date.setMonth(month);
+           calendar.setTime(date);
+
+           // print month
+           p("\n" + 
+             monthStr(calendar.get(Calendar.MONTH)) +
+             " " + (calendar.get(Calendar.MONTH)+1) +
+             "\n   ");
+           
+           // count empty day at the beginning of the month.
+           if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
+               empty_before_first_day[month] = 6;
+           } else {
+               empty_before_first_day[month] =
+                   calendar.get(Calendar.DAY_OF_WEEK) - 2;
+           }
+
+           // print empty spaces at the beginning of month if needed..
+           for (int i=0; i< empty_before_first_day[month]; i++) {
+               p("      ");
+           }
+
+
+           // generate one month a day by day
+           for (int day=1; day<33; day++) {
+               date.setDate(day);
+               calendar.setTime(date);
+
+               // over-month checking
+               if (date.getDate() < day) {
+                   days_in_month[month] = day - 1;
+                   break; 
+               }
+
+               // print weekday and date
+               p(dayStr(calendar.get(Calendar.DAY_OF_WEEK))+ 
+                 " " +
+                 calendar.get(Calendar.DATE) + ", "
+                 );
+
+               // if sunday, print "\n" and increment weeks
+               if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
+                   p("\n   ");
+                   weeks_in_month[month] += 1;
+               }
+           }
+           pln("\n **  Weeks: " + weeks_in_month[month] + 
+               ", " + empty_before_first_day[month] +
+               " - empty days at the beginning of the month, " +
+               days_in_month[month] +" days in month");
+       }
+
+    }
+
+
+    private String dayStr(int day) {
+
+       if ( day < Calendar.SUNDAY || day > Calendar.SATURDAY ) return "ERROR";
+
+       switch(day) {
+       case Calendar.MONDAY: return "Ma";
+       case Calendar.TUESDAY: return "Ti";
+       case Calendar.WEDNESDAY: return "Ke";
+       case Calendar.THURSDAY: return "To";
+       case Calendar.FRIDAY: return "Pe";
+       case Calendar.SATURDAY: return "La";
+       case Calendar.SUNDAY: return "Su";
+       } 
+       return "Error";
+    }
+
+    private String monthStr(int month) { 
+       if ( month < 0 || month > 11) return "ERROR";
+       
+       String ret ="";
+
+       switch(month) {
+       case 0: ret = "Tammi"; break;
+       case 1: ret = "Helmi"; break;
+       case 2: ret = "Maalis"; break;
+       case 3: ret = "Huhti"; break;
+       case 4: ret = "Touko"; break;
+       case 5: ret = "Kesä";  break;
+       case 6: ret = "Heinä"; break;
+       case 7: ret = "Elo"; break;
+       case 8: ret = "Syys"; break;
+       case 9: ret = "Loka"; break;
+       case 10: ret = "Marras"; break;
+       case 11: ret = "Joulu"; break;
+       }
+       return ret + "kuu";
+    }
+
+
+    public static void main(String [] arg) {
+       TextCalendar c = new TextCalendar();
+    }
+}
+
+
+
+Still Very Problematic
+----------------------
+
+  _Coordinating system._
+
+
+What is really needed with calendar?
+
+
+   while (yearHasMonthsLeft):
+
+      // draw month skeleton
+      draw skeleton( height[month] )
+      // height(weeks) is one of the arguments
+
+
+      // put text in correct places 
+      move to non empty day from beginning
+
+      while ( monthHasDaysLeft):
+         putText ( date)
+
+         etc..
+
+
+ * So, where is scaling done?
+ * Is calendar fixed size? 
+
+How it is used?
+
+   -Someone needs a piece of calendar(x0,y0, x1,y1)
+      -Calculate what part needs rendering
+      -Render
+      -Put on screen with right coordinates.
+      
+
+  ** Talk to Tjl about coordinate systems. **




reply via email to

[Prev in Thread] Current Thread [Next in Thread]