This module provides some functions to render simple graphical objects like filled rectangles and lines as HTML elements.
# File lib/reports/HTMLGraphics.rb, line 72 72: def arrowHeadToHTML(x, y) 73: XMLElement.new('div', 'class' => 'tj_arrow_head', 74: 'style' => "left:#{x.to_i - 5}px; " + 75: "top:#{y.to_i - 5}px;") 76: end
# File lib/reports/HTMLGraphics.rb, line 61 61: def diamondToHTML(x, y) 62: html = [] 63: html << XMLElement.new('div', 'class' => 'tj_diamond_top', 64: 'style' => "left:#{x.to_i - 6}px; " + 65: "top:#{y.to_i - 7}px;") 66: html << XMLElement.new('div', 'class' => 'tj_diamond_bottom', 67: 'style' => "left:#{x.to_i - 6}px; " + 68: "top:#{y.to_i}px;") 69: html 70: end
# File lib/reports/HTMLGraphics.rb, line 55 55: def jagToHTML(x, y) 56: XMLElement.new('div', 'class' => 'tj_gantt_jag', 57: 'style' => "left:#{x.to_i - 5}px; " + 58: "top:#{y.to_i}px;") 59: end
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 25 25: def lineToHTML(xs, ys, xe, ye, category) 26: xs = xs.to_i 27: ys = ys.to_i 28: xe = xe.to_i 29: ye = ye.to_i 30: if ys == ye 31: # Horizontal line 32: xs, xe = xe, xs if xe < xs 33: style = "left:#{xs}px; top:#{ys}px; " + 34: "width:#{xe - xs + 1}px; height:1px;" 35: elsif xs == xe 36: # Vertical line 37: ys, ye = ye, ys if ye < ys 38: style = "left:#{xs}px; top:#{ys}px; " + 39: "width:1px; height:#{ye - ys + 1}px;" 40: else 41: raise "Can't draw diagonal line #{xs}/#{ys} to #{xe}/#{ye}!" 42: end 43: XMLElement.new('div', 'class' => category, 'style' => style) 44: end
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 49 49: def rectToHTML(x, y, w, h, category) 50: style = "left:#{x.to_i}px; top:#{y.to_i}px; " + 51: "width:#{w.to_i}px; height:#{h.to_i}px;" 52: XMLElement.new('div', 'class' => category, 'style' => style) 53: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.