package org.timepedia.chronoscope.client.render.domain;

import org.timepedia.chronoscope.client.util.TimeUnit;
import org.timepedia.chronoscope.client.util.DateFormatter;
import org.timepedia.chronoscope.client.util.date.DateFormatHelper;

/**
 * @author chad takahashi
 */
public class HoursTickFormatter extends DateTickFormatter {

  public HoursTickFormatter(DateTickFormatter superFormatter) {
    super("00xx"); // e.g. "12pm"
    this.superFormatter = superFormatter;
    this.subFormatter = new MinutesTickFormatter(this);
    this.possibleTickSteps = new int[] {1, 3, 6, 12};
    this.timeUnitTickInterval = TimeUnit.HOUR;
  }

  @Override
  public String formatTick() {
    DateFormatter hourFormat = DateFormatHelper.getHourFormatter();
    int hourOfDay = Integer.valueOf(hourFormat.format(currTick.getTime()));
      
    switch (hourOfDay) {
      case 0:
        return dateFormat.dayAndMonth(currTick);
      default:
        return dateFormat.hourAndMinute(currTick);
    }
  }

  public int getSubTickStep(int primaryTickStep) {
    switch (primaryTickStep) {
      case 12:
      case 1:
        return 4;
      case 6:
        return 2;
      default:
        return super.getSubTickStep(primaryTickStep);
    }
  }
  
  @Override
  public boolean isBoundary() {
    return currTick.getHour() == 0;
  }

}

@@ -109,68 +109,8 @@
 it;%0A
-import org.timepedia.chronoscope.client.util.DateFormatter;%0A
 impo
@@ -268,16 +268,18 @@
 atter %7B%0A
+  
 %0A  publi
@@ -352,10 +352,11 @@
 (%2200
-xx
+:00
 %22); 
@@ -368,12 +368,13 @@
 g. %22
-12pm
+01:00
 %22%0A  
@@ -574,16 +574,18 @@
 UR;%0A  %7D%0A
+  
 %0A  @Over
@@ -628,35 +628,33 @@
     
-DateFormatter hourFormat = 
+if (0 == Integer.valueOf(
 Date
@@ -688,131 +688,39 @@
 er()
-;%0A    int hourOfDay = Integer.valueOf(hourFormat.format(currTick.getTime()));%0A      %0A    switch (hourOfDay) %7B%0A      case 0:
+.format(currTick.getTime()))) %7B
 %0A   
@@ -765,39 +765,26 @@
 rTick);%0A    
-  
-default:%0A    
+%7D%0A
     return d
@@ -818,22 +818,16 @@
 rTick);%0A
-    %7D%0A
   %7D%0A%0A  p
@@ -1121,16 +1121,80 @@
  return 
+0 == Integer.valueOf(DateFormatHelper.getHourFormatter().format(
 currTick
@@ -1201,19 +1201,16 @@
 .get
-Hour() == 0
+Time()))
 ;%0A  

put the boundary label of the day in the 00:00 tick