Class: TaskJuggler::GanttLine

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

Overview

This class models the abstract (output independent) form of a line of a Gantt chart. Each line represents a property. Depending on the type of property and it’s context (for nested properties) the content varies. Tasks (not nested) are represented as task bars or milestones. When nested into a resource they are represented as load stacks.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HTMLGraphics

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

Constructor Details

#initialize(chart, query, y, height, lineIndex, tooltip) ⇒ GanttLine

Create a GanttLine object and generate the abstract representation.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/taskjuggler/reports/GanttLine.rb', line 35

def initialize(chart, query, y, height, lineIndex, tooltip)
  # A reference to the chart that the line belongs to.
  @chart = chart
  # Register the line with the chart.
  @chart.addLine(self)

  # The query is used to access the presented project data.
  @query = query
  # A CellSettingPatternList object to determine the tooltips for the
  # line's content.
  @tooltip = tooltip
  # The category determines the background color of the line.
  @category = nil
  # The y coordinate of the topmost pixel of this line.
  @y = y + chart.header.height + 1
  # The height of the line in screen pixels.
  @height = height

  # The index of the line in the chart. It starts with 0 and is
  # incremented for each line by one.
  @lineIndex = lineIndex
  # The x coordinates of the time-off zones. It's an Array of [ startX, endX
  # ] touples.
  @timeOffZones = []

  generate
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



32
33
34
# File 'lib/taskjuggler/reports/GanttLine.rb', line 32

def height
  @height
end

#queryObject (readonly)

Returns the value of attribute query.



32
33
34
# File 'lib/taskjuggler/reports/GanttLine.rb', line 32

def query
  @query
end

#yObject (readonly)

Returns the value of attribute y.



32
33
34
# File 'lib/taskjuggler/reports/GanttLine.rb', line 32

def y
  @y
end

Instance Method Details

#addBlockedZones(router) ⇒ Object

Register the areas that dependency lines should not cross.



118
119
120
121
122
# File 'lib/taskjuggler/reports/GanttLine.rb', line 118

def addBlockedZones(router)
  @content.each do |c|
    c.addBlockedZones(router)
  end
end

#getTaskObject

This function only works for primary task lines. It returns the generated intermediate object for that line.



109
110
111
112
113
114
115
# File 'lib/taskjuggler/reports/GanttLine.rb', line 109

def getTask
  if @content.length == 1
    @content[0]
  else
    nil
  end
end

#to_htmlObject

Convert the abstract representation of the GanttLine into HTML elements.



64
65
66
67
68
69
70
71
72
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
102
103
104
105
# File 'lib/taskjuggler/reports/GanttLine.rb', line 64

def to_html
  # The whole line is put in a 'div' section. All coordinates relative to
  # the top-left corner of this div. Elements that extend over the
  # boundaries of this div are cut off.
  div = XMLElement.new('div', 'class' => @category,
                       'style' => "margin:0px; padding:0px; " +
                       "position:absolute; " +
                       "left:0px; top:#{@y}px; " +
                       "width:#{@chart.width.to_i}px; " +
                       "height:#{@height}px; " +
                       "font-size:10px;")
  # Render time-off zones.
  @timeOffZones.each do |zone|
    div << rectToHTML(zone[0], 0, zone[1], @height, 'offduty')
  end

  # Render grid lines. The grid lines are determined by the large scale.
  @chart.header.gridLines.each do |line|
    div << rectToHTML(line, 0, 1, @height, 'tabvline')
  end

  # Now render the content as HTML elements.
  @content.each do |c|
    html = c.to_html
    if html && html[0]
      addHtmlTooltip(@tooltip, @query, html[0], div)
      div << html
    end
  end

  # Render the 'now' line
  if @chart.header.nowLineX
    div << rectToHTML(@chart.header.nowLineX, 0, 1, @height, 'nowline')
  end

  # Render the 'markdate' line
  if @chart.header.markdateLineX
    div << rectToHTML(@chart.header.markdateLineX, 0, 1, @height, 'markdateline')
  end

  div
end