krysalis-jcharts/src/scratchpad/org/krysalis/jcharts/gantt DateHandlerTest.java,1.2,1.3 Plan.java,1.2,1.3 DateHandler.java,1.9,1.10

[email protected] Wed, 03 Dec 2003 02:19:27 -0800
Newsgroups gmane.comp.krysalis.jcharts.cvs
Message-ID <[email protected]>
Update of /cvsroot/jcharts/krysalis-jcharts/src/scratchpad/org/krysalis/jcharts/gantt
In directory sc8-pr-cvs1:/tmp/cvs-serv28635/src/scratchpad/org/krysalis/jcharts/gantt

Modified Files:
	DateHandlerTest.java Plan.java DateHandler.java 
Log Message:
Bunch of updates and fixes.

Index: DateHandlerTest.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/scratchpad/org/krysalis/jcharts/gantt/DateHandlerTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DateHandlerTest.java	4 Sep 2003 11:45:16 -0000	1.2
--- DateHandlerTest.java	3 Dec 2003 10:19:24 -0000	1.3
***************
*** 54,61 ****
    final public void testGetStringDateFromWeek() throws ParseException {
      //TRANSFORMING WEEK: 39 into: Mon Sep 22 10:36:32 CEST 2003
!     String result = DateHandler.getStringDateFromWeek(39, true);
      Assert.assertEquals(result, "20030922");
      //TRANSFORMING WEEK: 40 into: Fri Oct 03 10:36:32 CEST 2003
!     result = DateHandler.getStringDateFromWeek(40, false);
      Assert.assertEquals(result, "20031003");
    }
--- 54,64 ----
    final public void testGetStringDateFromWeek() throws ParseException {
      //TRANSFORMING WEEK: 39 into: Mon Sep 22 10:36:32 CEST 2003
!     String result = DateHandler.getStringDateFromWeek("39", true);
      Assert.assertEquals(result, "20030922");
      //TRANSFORMING WEEK: 40 into: Fri Oct 03 10:36:32 CEST 2003
!     result = DateHandler.getStringDateFromWeek("40", false);
!     Assert.assertEquals(result, "20031003");
!     //TRANSFORMING WEEK: 200340 into: Fri Oct 03 10:36:32 CEST 2003
!     result = DateHandler.getStringDateFromWeek("200340", false);
      Assert.assertEquals(result, "20031003");
    }

Index: Plan.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/scratchpad/org/krysalis/jcharts/gantt/Plan.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Plan.java	4 Sep 2003 11:43:22 -0000	1.2
--- Plan.java	3 Dec 2003 10:19:24 -0000	1.3
***************
*** 211,214 ****
--- 211,234 ----
    }
    
+   public Dimension getMinimumSize() {
+     //@todo use real width and hight!
+     return new Dimension(1100, 6000);
+   }
+ 
+   public Dimension getSize() {
+     //@todo use real width and hight!
+     return new Dimension(1100, 6000);
+   }
+   
+   public int getWidth() {
+     //@todo use real width and hight!
+     return 1100;
+   }
+ 
+   public int getHeight() {
+     //@todo use real width and hight!
+     return 6000;
+   }
+   
    public void saveAsSvg(File outFile) throws IOException {
         //Get a DOMImplementation

Index: DateHandler.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/scratchpad/org/krysalis/jcharts/gantt/DateHandler.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** DateHandler.java	4 Sep 2003 11:45:16 -0000	1.9
--- DateHandler.java	3 Dec 2003 10:19:24 -0000	1.10
***************
*** 176,180 ****
    }
  
!   public static Date getDate(String label) {
      Calendar cal = Calendar.getInstance();
  
--- 176,198 ----
    }
  
!   public static Date getDate(String label) throws IndexOutOfBoundsException{
!     return getDate(label, "unspecified");
!   }
!   
!   public static Date getDateSafe(String label, Object what){
!     try {
!       return getDate(label, what);
!     }catch(Exception e){
!         System.out.println(e);
!     }
!     return new Date();
!   }  
!   
!   public static Date getDate(String label, Object what) throws IndexOutOfBoundsException{
!     
!    if(label.length()!=8){
!      throw new IndexOutOfBoundsException("Wrong date!:'" + label + "' \noffending:\n"+what);
!    }
!               
      Calendar cal = Calendar.getInstance();
  
***************
*** 222,234 ****
    }
  
!   //TODO ! add year handling!!!
!   public static String getStringDateFromWeek(int week, boolean startDay)
      throws ParseException {
      //@debug
!     //System.out.print("TRANSFORMING WEEK: " + String.valueOf(week));
      Calendar c = Calendar.getInstance();
      c.setTime(new Date());
-     c.set(Calendar.WEEK_OF_YEAR, week);
      c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
      
      // | S | M | T | W | T | F |
--- 240,261 ----
    }
  
!   public static String getStringDateFromWeek(String yearweek, boolean startDay)
      throws ParseException {
      //@debug
!     //System.out.print("TRANSFORMING WEEK: " + week);
!       
      Calendar c = Calendar.getInstance();
      c.setTime(new Date());
      c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
+     int week;
+     if(yearweek.length()<3) {
+         c.set(Calendar.WEEK_OF_YEAR, Integer.parseInt(yearweek));
+     }else if(yearweek.length()<6) {
+         c.set(Calendar.WEEK_OF_YEAR, Integer.parseInt(yearweek.substring(4,5)));
+         c.set(Calendar.YEAR, Integer.parseInt(yearweek.substring(0,4)));
+     }else {
+         c.set(Calendar.WEEK_OF_YEAR, Integer.parseInt(yearweek.substring(4,6)));
+         c.set(Calendar.YEAR, Integer.parseInt(yearweek.substring(0,4)));        
+     }
      
      // | S | M | T | W | T | F |
***************
*** 271,274 ****
--- 298,302 ----
      return formatter.format(date);
    }
+ 
  
  }




-------------------------------------------------------
This SF.net email is sponsored by OSDN's Audience Survey.
Help shape OSDN's sites and tell us what you think. Take this
five minute survey and you could win a $250 Gift Certificate.
http://www.wrgsurveys.com/2003/osdntech03.php?site=8