|
From: <nic...@us...> - 2003-09-02 16:26:03
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/scratchpad/org/krysalis/jcharts/gantt
In directory sc8-pr-cvs1:/tmp/cvs-serv19839/src/scratchpad/org/krysalis/jcharts/gantt
Modified Files:
DateHandler.java PlanRenderer.java
Log Message:
Much better date visualization.
Index: DateHandler.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/scratchpad/org/krysalis/jcharts/gantt/DateHandler.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** DateHandler.java 2 Sep 2003 12:45:17 -0000 1.6
--- DateHandler.java 2 Sep 2003 16:25:55 -0000 1.7
***************
*** 56,60 ****
private final static DateFormat dateStampFormat =
new SimpleDateFormat("yyyyMMdd");
!
private Date currentDay;
private long currentTime;
--- 56,64 ----
private final static DateFormat dateStampFormat =
new SimpleDateFormat("yyyyMMdd");
! private final static DateFormat dayOfWeekFormat =
! new SimpleDateFormat("E");
! private final static DateFormat weekNumberFormat =
! new SimpleDateFormat("w");
!
private Date currentDay;
private long currentTime;
***************
*** 103,106 ****
--- 107,118 ----
}
+ public String shortDayOfWeekFormat(Date d) {
+ return dayOfWeekFormat.format(d).substring(0,1);
+ }
+
+ public String weekNumberFormat(Date d) {
+ return weekNumberFormat.format(d);
+ }
+
public Date getCurrentDate() {
return currentDay;
Index: PlanRenderer.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/scratchpad/org/krysalis/jcharts/gantt/PlanRenderer.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** PlanRenderer.java 2 Sep 2003 11:32:36 -0000 1.7
--- PlanRenderer.java 2 Sep 2003 16:25:55 -0000 1.8
***************
*** 90,94 ****
//@todo String height
LineMetrics lm = font.getLineMetrics(title, g2.getFontRenderContext());
! float currentTopEdge = lm.getHeight() + 5;
float rightEdge;
--- 90,103 ----
//@todo String height
LineMetrics lm = font.getLineMetrics(title, g2.getFontRenderContext());
!
! // -----------------------------------------
! // Month *1
! // -----------------------------------------
! // Week *2
! // -----------------------------------------
! // Day *3
! // -----------------------------------------
! float singleDateHeight = (lm.getHeight() + 2);
! float currentTopEdge = singleDateHeight * 3;
float rightEdge;
***************
*** 120,124 ****
(float) font.getStringBounds(title, g2.getFontRenderContext()).getWidth();
! float titlePosition = (float) (80 - titleWidth / 2.0);
if (titlePosition < 5) {
titlePosition = 5;
--- 129,133 ----
(float) font.getStringBounds(title, g2.getFontRenderContext()).getWidth();
! float titlePosition = (float) ((leftWidth - titleWidth) / 2.0);
if (titlePosition < 5) {
titlePosition = 5;
***************
*** 126,148 ****
g2.setPaint(Color.BLACK);
! g2.drawString(title, titlePosition, 18);
//Draw Dates
DateHandler dh = new DateHandler(startDate, endDate);
g2.setPaint(Color.BLACK);
g2.draw(new Line2D.Float(0, currentTopEdge, width, currentTopEdge));
! //firstdate
! g2.drawString(
! dh.shortFormat(dh.getStartDate()),
! leftWidth + 1,
! currentTopEdge - 1);
! //lastdate
! g2.drawString(
! dh.shortFormat(dh.getEndDate()),
! (int) width,
! (int) currentTopEdge - 1);
g2.setPaint(new Color(150, 150, 150));
--- 135,169 ----
g2.setPaint(Color.BLACK);
! g2.drawString(title, titlePosition, singleDateHeight);
//Draw Dates
DateHandler dh = new DateHandler(startDate, endDate);
+ float topDateHeight = singleDateHeight;
+ float middleDateHeight = singleDateHeight*2;
+ float bottomDateHeight = singleDateHeight*3;
+
g2.setPaint(Color.BLACK);
+ g2.draw(new Line2D.Float(0, topDateHeight, width, topDateHeight));
+ g2.draw(new Line2D.Float(leftWidth, middleDateHeight, width, middleDateHeight));
+ g2.draw(new Line2D.Float(leftWidth, bottomDateHeight, width, bottomDateHeight));
+ //currentTopEdge!=necessarily to bottomDateHeight
g2.draw(new Line2D.Float(0, currentTopEdge, width, currentTopEdge));
! g2.draw(new Line2D.Float(leftWidth, 0, leftWidth, currentTopEdge));
! //todo need a better positioning if ever
! //
! // //firstdate
! // g2.drawString(
! // dh.shortFormat(dh.getStartDate()),
! // leftWidth + 1,
! // currentTopEdge - 2);
! //
! // //lastdate
! // g2.drawString(
! // dh.shortFormat(dh.getEndDate()),
! // (int) width,
! // currentTopEdge - 2);
g2.setPaint(new Color(150, 150, 150));
***************
*** 164,167 ****
--- 185,229 ----
float currentDateLocation = leftWidth + offset * singleDayWidth;
+ if (count % 7 == 2) {
+ //Monday
+ g2.setPaint(Color.BLACK);
+
+ g2.draw(new Line2D.Float(currentDateLocation, topDateHeight, currentDateLocation, middleDateHeight));
+
+ g2.drawString(
+ dh.shortFormat(cal.getTime()),
+ (int) currentDateLocation+2,
+ (int) (middleDateHeight - 2));
+
+ // Week number
+ g2.setPaint(Color.BLACK);
+
+ String weekNumString = dh.weekNumberFormat(cal.getTime());
+ float weekNumStringWidth =
+ (float) font.getStringBounds(weekNumString, g2.getFontRenderContext()).getWidth();
+
+ //@todo fix centering routing (need string width)
+ g2.drawString(
+ dh.weekNumberFormat(cal.getTime()),
+ (int) (currentDateLocation + 3.5 * singleDayWidth - weekNumStringWidth / 2) - 2,
+ (int) (bottomDateHeight - 2));
+
+ g2.draw(new Line2D.Float(currentDateLocation ,middleDateHeight, currentDateLocation, bottomDateHeight));
+
+
+
+
+ }
+
+ //@todo activate every day as fourth date hint?
+ // g2.setPaint(Color.BLACK);
+ //
+ // g2.drawString(
+ // dh.shortDayOfWeekFormat(cal.getTime()),
+ // (int) currentDateLocation +2,
+ // (int) (bottomDateHeight - 2));
+ //
+ // g2.draw(new Line2D.Float(currentDateLocation ,middleDateHeight, currentDateLocation, bottomDateHeight));
+
Shape currentDay =
new Rectangle2D.Float(
***************
*** 195,201 ****
// currentDateLocation + 1,
// currentTopEdge + offset*15);
!
! //@todo add date number eventually
!
if (cal.get(Calendar.DAY_OF_MONTH) == 1) {
g2.setPaint(Color.BLACK);
--- 257,262 ----
// currentDateLocation + 1,
// currentTopEdge + offset*15);
!
! //if MONTH
if (cal.get(Calendar.DAY_OF_MONTH) == 1) {
g2.setPaint(Color.BLACK);
***************
*** 203,208 ****
g2.drawString(
dh.monthFormat(cal.getTime()),
! (int) currentDateLocation,
! (int) (currentTopEdge - 1));
g2.setPaint(Color.BLACK);
--- 264,269 ----
g2.drawString(
dh.monthFormat(cal.getTime()),
! (int) currentDateLocation +2,
! (int) (topDateHeight - 2));
g2.setPaint(Color.BLACK);
***************
*** 210,217 ****
new Line2D.Float(
currentDateLocation,
(float) currentTopEdge,
currentDateLocation,
(height - currentTopEdge)));
-
}
--- 271,284 ----
new Line2D.Float(
currentDateLocation,
+ 0,
+ currentDateLocation,
+ (topDateHeight)));
+
+ g2.draw(
+ new Line2D.Float(
+ currentDateLocation,
(float) currentTopEdge,
currentDateLocation,
(height - currentTopEdge)));
}
|