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

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

Methods

Included Modules

HTMLGraphics

Public Class methods

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.

[Source]

# 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

Public Instance methods

[Source]

# 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

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

[Source]

# File lib/taskjuggler/reports/GanttTaskBar.rb, line 55
    def endDepLineEnd
      [ @end - 1, @y + @lineHeight / 2 ]
    end

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

[Source]

# File lib/taskjuggler/reports/GanttTaskBar.rb, line 50
    def endDepLineStart
      [ @end + 1, @y + @lineHeight / 2 ]
    end

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

[Source]

# File lib/taskjuggler/reports/GanttTaskBar.rb, line 44
    def startDepLineEnd
      [ @start - 1, @y + @lineHeight / 2 ]
    end

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

[Source]

# File lib/taskjuggler/reports/GanttTaskBar.rb, line 39
    def startDepLineStart
      [ @start + 1, @y + @lineHeight / 2 ]
    end

Convert the abstact representation of the GanttTaskBar into HTML elements.

[Source]

# 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

[Validate]