class TaskJuggler::GanttLine

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.

Attributes

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

Public Class Methods

new(chart, query, y, height, lineIndex, tooltip) click to toggle source

Create a GanttLine object and generate the abstract representation.

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

Public Instance Methods

addBlockedZones(router) click to toggle source

Register the areas that dependency lines should not cross.

# File lib/taskjuggler/reports/GanttLine.rb, line 111
def addBlockedZones(router)
  @content.each do |c|
    c.addBlockedZones(router)
  end
end
getTask() click to toggle source

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

# File lib/taskjuggler/reports/GanttLine.rb, line 102
def getTask
  if @content.length == 1
    @content[0]
  else
    nil
  end
end
to_html() click to toggle source

Convert the abstract representation of the GanttLine into HTML elements.

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