BrightSide Workbench Full Report + Source Code
GanttMeasure.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2012 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.zkoss.svg;
19 
24 public enum GanttMeasure {
25 
32 
33  public double convert(double hours) {
34  if(this.equals(GANTT_BY_DAYS)) {
35  return toDays(hours);
36  } else if(this.equals(GANTT_BY_WEEKS)) {
37  return toWeeks(hours);
38  } else if(this.equals(GANTT_BY_MONTHS)) {
39  return toMonths(hours);
40  } else if(this.equals(GANTT_BY_QUARTERS)) {
41  return toQuarters(hours);
42  } else if(this.equals(GANTT_BY_YEARS)) {
43  return toYears(hours);
44  }
45  return hours;
46  }
47 
48  private static final double SWITCH_MEASURE = 100.0d;
49 
50  public static GanttMeasure chooseMeasure(double hours) {
51  if(hours > SWITCH_MEASURE) {
52  if(toDays(hours) > SWITCH_MEASURE) {
53  if(toWeeks(hours) > SWITCH_MEASURE) {
54  if(toMonths(hours) > SWITCH_MEASURE) {
55  if(toQuarters(hours) > SWITCH_MEASURE) {
56  return GANTT_BY_YEARS;
57  } else {
58  return GANTT_BY_QUARTERS;
59  }
60  } else {
61  return GANTT_BY_MONTHS;
62  }
63  } else {
64  return GANTT_BY_WEEKS;
65  }
66  } else {
67  return GANTT_BY_DAYS;
68  }
69  } else {
70  return GANTT_BY_HOURS;
71  }
72  }
73 
74  public static double toDays(double hours) {
75  return hours / 8.0d;
76  }
77 
78  public static double toWeeks(double hours) {
79  return hours / (8.0d * 5.0d);
80  }
81 
82  public static double toMonths(double hours) {
83  return hours / (8.0d * 22.0d);
84  }
85 
86  public static double toQuarters(double hours) {
87  return hours / (8.0d * 22.0d * 3.0d);
88  }
89 
90  public static double toYears(double hours) {
91  return hours / (8.0d * 22.0d * 12.0d);
92  }
93 
94 }
static double toWeeks(double hours)
static GanttMeasure chooseMeasure(double hours)
static double toDays(double hours)
static double toQuarters(double hours)
static double toYears(double hours)
static double toMonths(double hours)
double convert(double hours)