[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz gzz/vob/CalendarVob.java gfx/librenderables...
From: |
Matti Katila |
Subject: |
[Gzz-commits] gzz gzz/vob/CalendarVob.java gfx/librenderables... |
Date: |
Thu, 31 Oct 2002 12:34:07 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Matti Katila <address@hidden> 02/10/31 12:34:07
Modified files:
gzz/vob : CalendarVob.java
gfx/librenderables: renderables.py
gfx/demo : calendarvobtest.py
Log message:
fix Date.setYear(), several small fixes, added MORE arguments, yrgh..
I *hope* CalendarPaper has enought static variables already.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/CalendarVob.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.118&tr2=1.119&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/calendarvobtest.py.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
Patches:
Index: gzz/gfx/demo/calendarvobtest.py
diff -u gzz/gfx/demo/calendarvobtest.py:1.6 gzz/gfx/demo/calendarvobtest.py:1.7
--- gzz/gfx/demo/calendarvobtest.py:1.6 Thu Oct 31 07:27:03 2002
+++ gzz/gfx/demo/calendarvobtest.py Thu Oct 31 12:34:07 2002
@@ -27,27 +27,37 @@
# these don't efect
- gzz.vob.CalendarVob.setStatics(style_date, style_n, 3)
+ gzz.vob.CalendarVob.setStatics(style_date, style_n, 2)
# week number width, weekday height, month name height
- gzz.vob.CalendarVob.setBounds(0.9, 0.9, 1.5)
+ gzz.vob.CalendarVob.setBounds(0.6, 0.5, 1.0)
+ # scales: date, weeknum, weekday, month
+ gzz.vob.CalendarVob.setScales(1.1, 0.55, 0.24, 1.3)
+
+ # shift(something(x,y)): date, weeknum, weekday, month
+ gzz.vob.CalendarVob.setShifting(0.075, 0.55, 0.20, 1.1)
+
+
+
# annual calendar
for i in range(1, 13):
cs_cal = vs.coords.affineCoordsys(cs_home , 0, 0 , i*9, 1,0,0,1)
vs.matcher.add(cs_cal, "cs_cal"+str(i))
- cs_text = vs.coords.affineCoordsys(cs_home, 0, 0, i*9, 1.0, 0, 0,
1.0)
+
+ cs_text = vs.coords.affineCoordsys(cs_home, 0, 0, 0, 1.0, 0, 0,
1.0)
vs.matcher.add(cs_text, "cs_text"+str(i))
+
vs.map.put(gzz.vob.CalendarVob(2002, i), cs_cal, cs_text)
- # one test vob
- #cs_cal = vs.coords.affineCoordsys(0, 0, w/2 - ((w/3 + self.tx) *
(self.scale -1) ) ,
- # h/2 - ((h/3.5 + self.ty)
*(self.scale-1)),
- # w/6 * self.scale, 0, 0, h/5 *
self.scale)
- #vs.matcher.add(cs_cal, "cs_cal")
- #gzz.vob.CalendarVob.setBounds(0.9, 1.1, 0.8)
- #vs.map.put(gzz.vob.CalendarVob(2002, 12), cs_cal)
+ if 0:
+ cs_cal = vs.coords.affineCoordsys(0, 0, w/2 - ((w/3 + self.tx) *
(self.scale -1) ) ,
+ h/2 - ((h/3.5 + self.ty)
*(self.scale-1)),
+ w/6 * self.scale, 0, 0, h/5 *
self.scale)
+ vs.matcher.add(cs_cal, "cs_cal")
+ gzz.vob.CalendarVob.setBounds(0.9, 1.1, 0.8)
+ vs.map.put(gzz.vob.CalendarVob(2002, 12), cs_cal)
Index: gzz/gfx/librenderables/renderables.py
diff -u gzz/gfx/librenderables/renderables.py:1.118
gzz/gfx/librenderables/renderables.py:1.119
--- gzz/gfx/librenderables/renderables.py:1.118 Thu Oct 31 07:27:03 2002
+++ gzz/gfx/librenderables/renderables.py Thu Oct 31 12:34:07 2002
@@ -1107,6 +1107,9 @@
unicodecharvector d_txt[7];
unicodecharvector m_txt;
+ float scales[4];
+ float shifts[4];
+
float week_num_w;
float weekday_h;
float month_name_h;
@@ -1129,6 +1132,16 @@
String t6,
String t7,
String t8,
+
+ float sc0,
+ float sc1,
+ float sc2,
+ float sc3,
+
+ float sh0,
+ float sh1,
+ float sh2,
+ float sh3,
float week_num_w,
float weekday_h,
@@ -1148,6 +1161,16 @@
d_txt[6] = t7;
m_txt = t8;
+
+ this->scales[0] = sc0;
+ this->scales[1] = sc1;
+ this->scales[2] = sc2;
+ this->scales[3] = sc3;
+
+ this->shifts[0] = sh0;
+ this->shifts[1] = sh1;
+ this->shifts[2] = sh2;
+ this->shifts[3] = sh3;
this->linewidth = linewidth;
@@ -1164,23 +1187,14 @@
"ExtraClass" : """
template<class Coords> struct Vertexer {
const Coords &c;
-
float scale;
- float orig_y;
-
- Vertexer(Coords &c, float scale, float orig_y):c(c), scale(scale),
orig_y(orig_y) { }
+
+ Vertexer(Coords &c, float scale) : c(c), scale(scale) { }
template<class T> void operator()(const T &x, const T &y) {
- /*
- ZVec tmp(x, y, 0);
- c.vertex(tmp);
- */
-
- ZPt tmp(x + 1, y - orig_y + 1, 0);
+ ZPt tmp(x, y, 0);
tmp.x *= scale; tmp.y *= scale;
- tmp.x -= 1; tmp.y += orig_y - 1;
c.vertex(tmp);
-
}
};
""",
@@ -1249,7 +1263,10 @@
glEnable(GL_TEXTURE_2D);
- Vertexer<Coords> v(coords1, 1.0, 1.0);
+ float date_shift = shifts[0];
+ float date_scale = scales[0];
+
+ Vertexer<Coords> v_date(coords1, date_scale);
for (int i=1; i<=days; i++) {
int column = (empty_days + i -1) % 7;
@@ -1264,64 +1281,69 @@
frow = weekday_h + month_name_h;
if (i<10) {
- fcol += column + 0.30;
- frow += row - 0.25;
+ fcol += column + date_shift + 0.20;
+ frow += row - date_shift - 0.15;
} else {
- fcol += column + 0.10;
- frow += row - 0.25;
+ fcol += column + date_shift;
+ frow += row - date_shift - 0.15;
}
glColor3f(1.0, 1.0, 1.0);
Text::renderIter(*r_date, buffer, buffer+strlen(buffer),
- fcol , frow, v
+ fcol*(1/date_scale) , frow*(1/date_scale), v_date
);
if (column == 6) glColor3f(1.0, 0.0, 0.0);
else glColor3f(0.0, 0.0, 0.0);
Text::renderIter(*r_date, buffer, buffer+strlen(buffer),
- fcol + 0.03 , frow + 0.03, v
+ (fcol + 0.03)*(1/date_scale),
+ (frow + 0.03)*(1/date_scale),
+ v_date
);
}
glColor3f(0.0, 0.0, 0.0);
-
-
// Week numbers
+ float week_num_scale = scales[1];
+ Vertexer<Coords> v_week_num(coords1, week_num_scale);
+
for (int i=0; i<weeks; i++) {
static char buffer[64];
sprintf(buffer, "%i", first_week_number + i);
Text::renderIter(*r, buffer, buffer+strlen(buffer),
- 0.1 , month_name_h + weekday_h + i + 0.8, v
+ (0.1)*(1/week_num_scale),
+ (month_name_h + weekday_h + i +
shifts[1])*(1/week_num_scale),
+ v_week_num
);
}
- float scale = 0.3;
-
- ZPt box(2,2,0); // compensate for -1/1 coordsys
- box = coords2.transform(box);
-
- cout << box.y << " box\\n";
- float y = box.y/2 - (weekday_h)/4;
- cout << y << "\\n";
- Vertexer<Coords> v_weekday(coords1, scale, y/100);
-
// Weekdays
+ float weekday_scale = scales[2];
+ Vertexer<Coords> v_weekday(coords1, weekday_scale);
+
for (int i=0; i<7; i++) {
Text::renderIter(*r, d_txt[i].begin(), d_txt[i].end(),
- week_num_w + i, month_name_h + weekday_h -0.1,
+ (week_num_w + i+ 0.1)*(1/weekday_scale),
+ (month_name_h + weekday_h - shifts[2]) *
(1/weekday_scale),
v_weekday
);
}
+ // Month name
+ float month_name_scale = scales[3];
+ Vertexer<Coords> v_month(coords1, month_name_scale);
+
Text::renderIter(*r, m_txt.begin(), m_txt.end(),
- week_num_w+1.5, month_name_h-0.1, v
+ (week_num_w+shifts[3])*(1/month_name_scale), // x
+ (month_name_h-0.15)*(1/month_name_scale), // y
+ v_month
);
glPopAttrib();
Index: gzz/gzz/vob/CalendarVob.java
diff -u gzz/gzz/vob/CalendarVob.java:1.4 gzz/gzz/vob/CalendarVob.java:1.5
--- gzz/gzz/vob/CalendarVob.java:1.4 Wed Oct 30 10:07:03 2002
+++ gzz/gzz/vob/CalendarVob.java Thu Oct 31 12:34:06 2002
@@ -11,7 +11,7 @@
import java.util.*;
public class CalendarVob extends Vob {
-public static final String rcsid = "$Id: CalendarVob.java,v 1.4 2002/10/30
15:07:03 mudyc Exp $";
+public static final String rcsid = "$Id: CalendarVob.java,v 1.5 2002/10/31
17:34:06 mudyc Exp $";
public static boolean dbg = false;
static final void p(String s) { if(dbg) System.out.println(s); }
static final void pa(String s) { System.out.println(s); }
@@ -22,6 +22,18 @@
static protected TextStyle style_week_numbers;
static private float linewidth;
+ static private float[] scales = { 1.1f, // date
+ 0.3f, // weekday
+ 0.5f, // week number
+ 1.7f // month name
+ };
+
+ static private float[] shifts = { 0.0f, // date
+ 0.0f, // weekday
+ 0.0f, // week number
+ 1.0f // month name
+ };
+
static private float weeknumber_width;
static private float weekday_height;
static private float month_name_height;
@@ -33,9 +45,11 @@
private int days_in_month;
private int first_week_number;
- private String text[] = {"Ma", "Ti", "Ke", "To",
- "Pe", "La", "Su", "MONTH NAME" };
+ private String text[] = {"Maanantai", "Tiistai", "Keskiviikko", "Torstai",
+ "Perjantai", "Lauantai", "Sunnuntai", "MONTH NAME"
};
+
+
public CalendarVob(int year, int month) {
this.year = year;
@@ -58,11 +72,12 @@
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(year);
+
+ // Deprecated. As of JDK version 1.1, replaced by
Calendar.set(Calendar.YEAR, year + 1900).
+ date.setYear(year - 1900);
// set first day of month
date.setDate(1);
@@ -77,13 +92,16 @@
"\n ");
// count empty day at the beginning of the month.
- if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
- empty_before_first_day = 6;
- } else {
- empty_before_first_day =
- calendar.get(Calendar.DAY_OF_WEEK) - 2;
+ switch(calendar.get(Calendar.DAY_OF_WEEK)) {
+ case Calendar.MONDAY: empty_before_first_day = 0; break;
+ case Calendar.TUESDAY: empty_before_first_day = 1; break;
+ case Calendar.WEDNESDAY: empty_before_first_day = 2; break;
+ case Calendar.THURSDAY: empty_before_first_day = 3; break;
+ case Calendar.FRIDAY: empty_before_first_day = 4; break;
+ case Calendar.SATURDAY: empty_before_first_day = 5; break;
+ case Calendar.SUNDAY: empty_before_first_day = 6; break;
}
-
+
for (int i=0; i< empty_before_first_day; i++) {
if (dbg) System.out.print(" ");
}
@@ -154,6 +172,20 @@
CalendarVob.linewidth = linewidth;
}
+ static public void setScales(float date, float week_num, float weekday,
float month) {
+ CalendarVob.scales[0] = date;
+ CalendarVob.scales[1] = week_num;
+ CalendarVob.scales[2] = weekday;
+ CalendarVob.scales[3] = month;
+ }
+
+ static public void setShifting(float date, float week_num, float weekday,
float month) {
+ CalendarVob.shifts[0] = date;
+ CalendarVob.shifts[1] = week_num;
+ CalendarVob.shifts[2] = weekday;
+ CalendarVob.shifts[3] = month;
+ }
+
static public void setBounds(float weeknumber_width,
float weekday_height,
float month_name_height)
@@ -164,6 +196,7 @@
}
+
// public Rectangle clip;
Color bgcolor;
@@ -219,6 +252,16 @@
text[5],
text[6],
text[7],
+
+ scales[0],
+ scales[1],
+ scales[2],
+ scales[3],
+
+ shifts[0],
+ shifts[1],
+ shifts[2],
+ shifts[3],
weeknumber_width,
weekday_height,