BrightSide Workbench Full Report + Source Code
GanttData.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 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 
20 import java.util.Objects;
21 import java.util.TreeSet;
22 
27 public class GanttData extends TreeSet<GanttItem> {
28 
29  public static final int
31  CHAR_PIXELS = 8;
32 
33  public GanttItem addGanttItem(long reference, String uniqueId, String name, double hours, double done) {
34  GanttItem gi = new GanttItem(reference, uniqueId, name, hours, done);
35  gi.setSet(this);
36  add(gi);
37  return gi;
38  }
39 
40  public int getMaxNameLenght() {
41  int maxLenght = 0;
42  for(GanttItem gi : this) {
43  maxLenght = Math.max(gi.getName().length(), maxLenght);
44  }
45  return Math.min(maxLenght, MAX_NAME_LENGTH);
46  }
47 
48  public double getMaxHoursLenght() {
49  double maxLenght = 0.0;
50  for(GanttItem gi : this) {
51  maxLenght = Math.max(gi.getStart() + gi.getMaxHours(), maxLenght);
52  }
53  return maxLenght;
54  }
55 
56  public GanttItem getItem(String index) {
57  for(GanttItem gi : this) {
58  if(Objects.equals(gi.getUniqueId(), index)) {
59  return gi;
60  }
61  }
62  return null;
63  }
64 
65  public void initData() {
66  for(GanttItem dummy : this) {
67  // does nothing but ensures multiple relations
68  for(GanttItem gi : this) {
69  gi.initStart();
70  }
71  }
72  for(GanttItem gi : this) {
73  gi.initReference();
74  }
75  }
76 
77 }
GanttItem getItem(String index)
Definition: GanttData.java:56
GanttItem addGanttItem(long reference, String uniqueId, String name, double hours, double done)
Definition: GanttData.java:33
static final int MAX_NAME_LENGTH
Definition: GanttData.java:30