18 package org.turro.zkoss.svg;
20 import org.turro.string.Strings;
21 import org.turro.i18n.I_;
29 static final private int
37 private int taskPanelWidth = 300, hoursPanelWidth;
48 public void rule(
int units) {
49 String nunit =
I_.
byKey(measure.toString());
51 text(nunit, taskPanelWidth - (nunit.length() *
GanttData.CHAR_PIXELS) - 5, RULE_HEIGHT + 6);
52 line(taskPanelWidth, 15, taskPanelWidth + (units * RULE_SPAN), 15,
"#000",
"1px");
53 for(
int i = 0; i <= units; i++) {
54 line(taskPanelWidth + (i * RULE_SPAN), 15, taskPanelWidth + (i * RULE_SPAN), 20,
"#000",
"1px");
56 text(
"" + i, taskPanelWidth + (i * RULE_SPAN) - 5, RULE_HEIGHT);
61 public void startComposing(String onUserEvent, String width, String height,
double scale) {
65 hoursPanelWidth = maxUnits * RULE_SPAN;
68 width =
"" + ((taskPanelWidth + (maxUnits * RULE_SPAN) + 20) * scale);
71 height =
"" + (((data.size() * ITEM_SPAN) + RULE_HEIGHT + 20) * scale);
73 super.startComposing(onUserEvent, width, height, scale);
76 "style='stroke:none'",
78 "font-style='normal'",
79 "font-family='Ubuntu'"
87 gi.setPosition(count);
88 int x1 = (int) (taskPanelWidth + (measure.
convert(gi.getStart()) * RULE_SPAN));
89 int dx2a = (int) (RULE_SPAN * measure.
convert(gi.getHours()));
90 int dx2b = (int) (RULE_SPAN * measure.
convert(gi.getDone()));
91 int y1 = (ITEM_SPAN * (gi.getPosition() - 1)) + ITEM_INIT;
92 int dy2 = ITEM_HEIGHT;
93 if(!Strings.isBlank(gi.getUniqueId())) {
107 if(gi.isMilestone()) {
108 int x = (int) Math.max(x1 + dx2a, x1 + dx2b) +5;
109 int y = (ITEM_SPAN * (count - 1)) + ITEM_INIT + 5;
110 int square = (int) (ITEM_HEIGHT * 0.6);
116 square,
"#000000", 1);
123 line(5, y1 + ITEM_HEIGHT + ((ITEM_SPAN - ITEM_HEIGHT) / 2),
124 5 + taskPanelWidth + hoursPanelWidth, y1 + ITEM_HEIGHT + ((ITEM_SPAN - ITEM_HEIGHT) / 2),
128 int x1 = (int) (taskPanelWidth + (measure.
convert(gi.getStart()) * RULE_SPAN));
129 int y1 = (ITEM_SPAN * (gi.getPosition() - 1)) + ITEM_INIT;
131 GanttItem predecessor = data.getItem(gp.getIndex());
132 int px1 = (int) (taskPanelWidth + (measure.
convert(predecessor.
getStart()) * RULE_SPAN));
134 int py1 = (ITEM_SPAN * (predecessor.
getPosition() - 1)) + ITEM_INIT;
135 String lineColor= gp.isSameSpace() ?
"#333" :
"#F33";
137 circle(x1, y1 + ITEM_HEIGHT / 2, 4, lineColor,
"1px", lineColor, 1);
139 line(x1, y1 + ITEM_HEIGHT / 2, px1, py1 + ITEM_HEIGHT / 2, lineColor,
"2px");
140 line(px1 - 1, py1 + ITEM_HEIGHT / 2, px1 + 3, py1 + ITEM_HEIGHT / 2, lineColor,
"2px");
142 circle(x1, y1 + ITEM_HEIGHT / 2, 4, lineColor,
"1px", lineColor, 1);
143 line(x1, y1 + ITEM_HEIGHT / 2, px1 + pdx2, py1 + ITEM_HEIGHT / 2, lineColor,
"2px");
144 line(px1 + pdx2 + 1, py1 + ITEM_HEIGHT / 2, px1 + pdx2 - 3, py1 + ITEM_HEIGHT / 2, lineColor,
"2px");
static String byKey(String key)
double getMaxHoursLenght()
static final int MAX_NAME_LENGTH
static final int GANTT_START_TO_START
void setData(GanttData data)
void startComposing(String onUserEvent, String width, String height, double scale)
void shadowedRoundSpan(int x, int y, int width, int height, String fill, double opacity)
void shadowedRoundRectangle(int x, int y, int width, int height, String fill, double opacity, String tooltip)
void circle(int x, int y, int r)
void setForceStyle(String forceStyle)
HTMLGenerator startTag(String tag, String[] attributes)
void setClickElementData(String clickElementData)
void line(int x1, int y1, int x2, int y2, String stroke, String strokeWidth)
void setForceTransform(String forceTransform)
void text(String text, int x, int y)
void shadowedRectangle(int x, int y, int width, int height, String fill, double opacity)
static GanttMeasure chooseMeasure(double hours)
double convert(double hours)