Class TaskJuggler::GanttLine
In: lib/taskjuggler/reports/GanttLine.rb
Parent: Object

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.

Methods

Included Modules

HTMLGraphics

Attributes

height  [R] 
query  [R] 
y  [R] 

Public Class methods

Create a GanttLine object and generate the abstract representation.

[Source]

# File lib/taskjuggler/reports/GanttLine.rb, line 35
    def initialize(chart, query, y, height, 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 x coordinates of the time-off zones. It's an Array of [ startX, endX
      # ] touples.
      @timeOffZones = []

      generate
    end

Public Instance methods

Register the areas that dependency lines should not cross.

[Source]

# File lib/taskjuggler/reports/GanttLine.rb, line 109
    def addBlockedZones(router)
      @content.each do |c|
        c.addBlockedZones(router)
      end
    end

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

[Source]

# File lib/taskjuggler/reports/GanttLine.rb, line 100
    def getTask
      if @content.length == 1
        @content[0]
      else
        nil
      end
    end

Convert the abstract representation of the GanttLine into HTML elements.

[Source]

# File lib/taskjuggler/reports/GanttLine.rb, line 60
    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

      div
    end

[Validate]