Class: CTioga::LegendItem

Inherits:
Object
  • Object
show all
Includes:
Debug, Log
Defined in:
lib/CTioga/legends/item.rb

Overview

The base class for all legends items (real legends, spacing, lines).

Direct Known Subclasses

CurveLegend, LegendLine

Constant Summary collapse

@@legend_item_numbering =

This class-wide variable is used to number text in a unique fashion

0

Instance Method Summary collapse

Methods included from Log

#identify, #init_logger, #logger, #logger_options, #spawn

Methods included from Debug

#debug_figmaker, #debug_patterns, #debug_puts, #figmaker_options, #test_pattern, #test_pattern_right

Constructor Details

#initializeLegendItem

Returns a new instance of LegendItem.



33
34
35
36
# File 'lib/CTioga/legends/item.rb', line 33

def initialize
  @legend_number = @@legend_item_numbering
  @@legend_item_numbering += 1
end

Instance Method Details

#draw(t, legend_style, x, y) ⇒ Object

Draws the legend at the given top left position (x,y) in figure coordinates.



49
50
# File 'lib/CTioga/legends/item.rb', line 49

def draw(t, legend_style, x, y)
end

#get_baseline_y(t, legend_style, y) ⇒ Object

We put the baseline so that the space above and below in the box of height legend_style.dy is even.



59
60
61
62
# File 'lib/CTioga/legends/item.rb', line 59

def get_baseline_y(t, legend_style, y)
  return y - 0.5 * ( TextDimension.new(1.0).to_figure(t, :y)  +
                     legend_style.dy.to_figure(t, :y))
end

#legend_nameObject

For internal use



53
54
55
# File 'lib/CTioga/legends/item.rb', line 53

def legend_name
  return "legend-#{@legend_number}"
end

#size(t, legend_style) ⇒ Object

Returns the (width, height) in figure coordinates of the legend element with the given LegendStyle and FigureMaker reference objects.

The returned values can be inaccurate to some extent.



43
44
45
# File 'lib/CTioga/legends/item.rb', line 43

def size(t, legend_style)
  return [0, 0]
end