Class: TaskJuggler::GanttTaskBar

Inherits:
Object
  • Object
show all
Includes:
HTMLGraphics
Defined in:
lib/taskjuggler/reports/GanttTaskBar.rb

Overview

The GanttTaskBar represents a normal task that is part of a GanttChart.

Constant Summary collapse

@@size =

The size of the bar in pixels from center to top/bottom.

6

Instance Method Summary collapse

Methods included from HTMLGraphics

#arrowHeadToHTML, #diamondToHTML, #jagToHTML, #lineToHTML, #rectToHTML

Constructor Details

#initialize(query, lineHeight, xStart, xEnd, y) ⇒ GanttTaskBar

Create a GanttContainer object based on the following information: line is a reference to the GanttLine. xStart is the left edge of the task in chart coordinates. xEnd is the right edge.



29
30
31
32
33
34
35
# File 'lib/taskjuggler/reports/GanttTaskBar.rb', line 29

def initialize(query, lineHeight, xStart, xEnd, y)
  @query = query
  @lineHeight = lineHeight
  @start = xStart
  @end = xEnd
  @y = y
end

Instance Method Details

#addBlockedZones(router) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/taskjuggler/reports/GanttTaskBar.rb', line 59

def addBlockedZones(router)
  # Horizontal block for whole bar.
  router.addZone(@start, @y + (@lineHeight / 2) - @@size - 1,
                 @end - @start + 1, 2 * @@size + 3, true, false)
  # Block for arrowhead.
  router.addZone(@start - 9, @y + (@lineHeight / 2) - 7, 10, 15, true, true)
  # Vertical block for end cap
  router.addZone(@start - 2, @y, 5, @lineHeight,
                 false, true)
  router.addZone(@end - 2, @y, 5, @lineHeight, false, true)
end

#endDepLineEndObject

Return the point [ x, y ] where task end dependency lines should end at.



55
56
57
# File 'lib/taskjuggler/reports/GanttTaskBar.rb', line 55

def endDepLineEnd
  [ @end - 1, @y + @lineHeight / 2 ]
end

#endDepLineStartObject

Return the point [ x, y ] where task end dependency lines should start from.



50
51
52
# File 'lib/taskjuggler/reports/GanttTaskBar.rb', line 50

def endDepLineStart
  [ @end + 1, @y + @lineHeight / 2 ]
end

#startDepLineEndObject

Return the point [ x, y ] where task start dependency lines should end at.



44
45
46
# File 'lib/taskjuggler/reports/GanttTaskBar.rb', line 44

def startDepLineEnd
  [ @start - 1, @y + @lineHeight / 2 ]
end

#startDepLineStartObject

Return the point [ x, y ] where task start dependency lines should start from.



39
40
41
# File 'lib/taskjuggler/reports/GanttTaskBar.rb', line 39

def startDepLineStart
  [ @start + 1, @y + @lineHeight / 2 ]
end

#to_htmlObject

Convert the abstact representation of the GanttTaskBar into HTML elements.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/taskjuggler/reports/GanttTaskBar.rb', line 73

def to_html
  xStart = @start.to_i
  yCenter = (@lineHeight / 2).to_i
  width = @end.to_i - @start.to_i + 1

  html = []

  # Invisible trigger frame for tooltips.
  html << rectToHTML(xStart, 0, width, @lineHeight, 'tj_gantt_frame')

  # First we draw the task frame.
  html << rectToHTML(xStart, yCenter - @@size, width, 2 * @@size,
                     'taskbarframe')

  # The we draw the filling.
  html << rectToHTML(xStart + 1, yCenter - @@size + 1, width - 2,
                     2 * @@size - 2, 'taskbar')
  # And then the progress bar. If query is null we assume 50% completion.
  if @query
    @query.attributeId = 'complete'
    @query.process
    res = @query.result
    completion = res ? res / 100.0 : 0.0
  else
    completion = 0.5
  end
  html << rectToHTML(xStart + 1, yCenter - @@size / 2,
                     (width - 2) * completion, @@size, 'progressbar')
end