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

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.

Methods

Attributes

showGanttItems  [RW] 

Public Class methods

Create a new ReportTableLegend object.

[Source]

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

Public Instance methods

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

[Source]

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

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

[Source]

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

Convert the abstract description into HTML elements.

[Source]

# 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

[Validate]