Class Index [+]

Quicksearch

TaskJuggler::HTMLGraphics

This module provides some functions to render simple graphical objects like filled rectangles and lines as HTML elements.

Public Instance Methods

arrowHeadToHTML(x, y) click to toggle source
    # File lib/reports/HTMLGraphics.rb, line 71
71:     def arrowHeadToHTML(x, y)
72:       XMLElement.new('div', 'class' => 'tj_arrow_head',
73:                             'style' => "left:#{x.to_i - 5}px; " +
74:                                        "top:#{y.to_i - 5}px;")
75:     end
diamondToHTML(x, y) click to toggle source
    # File lib/reports/HTMLGraphics.rb, line 60
60:     def diamondToHTML(x, y)
61:       html = []
62:       html << XMLElement.new('div', 'class' => 'tj_diamond_top',
63:                              'style' => "left:#{x.to_i - 6}px; " +
64:                                         "top:#{y.to_i - 7}px;")
65:       html << XMLElement.new('div', 'class' => 'tj_diamond_bottom',
66:                              'style' => "left:#{x.to_i - 6}px; " +
67:                                         "top:#{y.to_i}px;")
68:       html
69:     end
jagToHTML(x, y) click to toggle source
    # File lib/reports/HTMLGraphics.rb, line 54
54:     def jagToHTML(x, y)
55:       XMLElement.new('div', 'class' => 'tj_gantt_jag',
56:                             'style' => "left:#{x.to_i - 5}px; " +
57:                                        "top:#{y.to_i}px;")
58:     end
lineToHTML(xs, ys, xe, ye, category) click to toggle source

Render a line as HTML element. We use ‘div’s with a single pixel width or height for this purpose. As a consequence of this, we can only generate horizontal or vertical lines. Diagonal lines are not supported. xs and ys are the start coordinates, xe and ye are the end coordinates. category determines the color.

    # File lib/reports/HTMLGraphics.rb, line 24
24:     def lineToHTML(xs, ys, xe, ye, category)
25:       xs = xs.to_i
26:       ys = ys.to_i
27:       xe = xe.to_i
28:       ye = ye.to_i
29:       if ys == ye
30:         # Horizontal line
31:         xs, xe = xe, xs if xe < xs
32:         style = "left:#{xs}px; top:#{ys}px; " +
33:                 "width:#{xe - xs + 1}px; height:1px;"
34:       elsif xs == xe
35:         # Vertical line
36:         ys, ye = ye, ys if ye < ys
37:         style = "left:#{xs}px; top:#{ys}px; " +
38:                 "width:1px; height:#{ye - ys + 1}px;"
39:       else
40:         raise "Can't draw diagonal line #{xs}/#{ys} to #{xe}/#{ye}!"
41:       end
42:       XMLElement.new('div', 'class' => category, 'style' => style)
43:     end
rectToHTML(x, y, w, h, category) click to toggle source

Draw a filled rectable at position x and y with the dimension w and h into another HTML element. The color is determined by the class category.

    # File lib/reports/HTMLGraphics.rb, line 48
48:     def rectToHTML(x, y, w, h, category)
49:       style = "left:#{x.to_i}px; top:#{y.to_i}px; " +
50:               "width:#{w.to_i}px; height:#{h.to_i}px;"
51:       XMLElement.new('div', 'class' => category, 'style' => style)
52:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.