class CTioga2::Graphics::Styles::BackgroundStyle

The style of the background of a plot. Handles:

Public Class Methods

new(location = nil, type = nil, label = nil) click to toggle source

Creates a new AxisStyle object at the given location with the given style.

# File lib/ctioga2/graphics/styles/background.rb, line 44
def initialize(location = nil, type = nil, label = nil)
  @background_color = nil
  @watermark_style = MarkerStringStyle.new
  @watermark_style.color = [0.5,0.5,0.5]
end

Public Instance Methods

draw_background(t) click to toggle source

Draws the background of the current plot. Fills up the current frame.

# File lib/ctioga2/graphics/styles/background.rb, line 52
def draw_background(t)
  t.context do
    xl, yb, xr, yt = 
      t.bounds_left, t.bounds_bottom, t.bounds_right, t.bounds_top
    if @background_color
      t.fill_color = @background_color
      t.fill_frame
    end
    draw_watermark(t)
  end
end
draw_watermark(t) click to toggle source
# File lib/ctioga2/graphics/styles/background.rb, line 64
def draw_watermark(t)
  if @watermark
    x = t.convert_frame_to_figure_x(0.5)
    y = t.convert_frame_to_figure_y(0.5)
    
    delta_y = t.default_text_height_dy * @watermark_style.
      real_vertical_scale
    
    # We split lines on \\, just like in standard LaTeX
    lines = @watermark.split(/\s*\\\\\s*/)
    i = + (lines.size-1)/2.0
    for text in lines 
      @watermark_style.
        draw_string_marker(t, text, x, y + delta_y * i)
      i -= 1
    end
  end
end