class TaskJuggler::ReportTableLegend

The ReportTableLegend models an output format independent legend for the ReportTable. It lists the graphical symbols used in the table together with a short textual description.

Attributes

showGanttItems[RW]

Public Class Methods

new() click to toggle source

Create a new ReportTableLegend object.

# File lib/taskjuggler/reports/ReportTableLegend.rb, line 24
def initialize
  @showGanttItems = false
  @ganttItems = []
  @calendarItems = []
end

Public Instance Methods

addCalendarItem(text, color) click to toggle source

Add another chart item to the legend. Make sure we don’t have any duplicates.

# File lib/taskjuggler/reports/ReportTableLegend.rb, line 38
def addCalendarItem(text, color)
  unless @calendarItems.include?([ text, color ])
    @calendarItems << [ text, color ]
  end
end
addGanttItem(text, color) click to toggle source

Add another Gantt item to the legend. Make sure we don’t have any duplicates.

# File lib/taskjuggler/reports/ReportTableLegend.rb, line 32
def addGanttItem(text, color)
  @ganttItems << [ text, color ] unless @ganttItems.include?([ text, color ])
end
to_html() click to toggle source

Convert the abstract description into HTML elements.

# File lib/taskjuggler/reports/ReportTableLegend.rb, line 45
def to_html
  return nil if !@showGanttItems && @ganttItems.empty? &&
                @calendarItems.empty?

  frame = XMLElement.new('div', 'class' => 'tj_table_legend_frame')
  frame << (legend = XMLElement.new('table', 'class' => 'tj_table_legend',
                                             'cellspacing' => '1'))

  legend << headlineToHTML('Gantt Chart Symbols:')
  # Generate the Gantt chart symbols
  if @showGanttItems
    legend << (row = XMLElement.new('tr', 'class' => 'tj_legend_row'))

    row << ganttItemToHTML(GanttContainer.new(15, 10, 35, 0),
                           'Container Task', 40)
    row << ganttItemToHTML(GanttTaskBar.new(nil, 15, 5, 35, 0),
                           'Normal Task', 40)
    row << ganttItemToHTML(GanttMilestone.new(15, 10, 0), 'Milestone', 20)
    row << XMLElement.new('td', 'class' => 'tj_legend_spacer')
  end

  legend << itemsToHTML(@ganttItems)

  legend << headlineToHTML('Calendar Symbols:')
  legend << itemsToHTML(@calendarItems)

  frame
end