Class: CTioga2::Graphics::Styles::LegendStorageStyle

Inherits:
BasicStyle
  • Object
show all
Defined in:
lib/ctioga2/graphics/styles/legend.rb

Overview

Style of a given Legends::LegendStorage object.

Constant Summary

Constants inherited from BasicStyle

BasicStyle::AllStyles, BasicStyle::OldAttrAccessor

Instance Method Summary collapse

Methods inherited from BasicStyle

alias_for, aliases, attr_accessor, attribute_type, attribute_types, attributes, convert_string_hash, defined_aliases, deprecated_attribute, from_hash, inherited, #instance_variable_defined?, normalize_hash, normalize_in, normalize_out, options_hash, #set_from_hash, sub_style, sub_styles, #to_hash, typed_attribute, #update_from_other, #use_defaults_from

Constructor Details

#initializeLegendStorageStyle

Returns a new instance of LegendStorageStyle.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/ctioga2/graphics/styles/legend.rb', line 59

def initialize

  # @dy = Types::Dimension.new(:dy, 1.6, :y)

  @vpadding = Types::Dimension.new(:dy, 0.3, :y)

  @picto_width = Types::Dimension.new(:dy, 1.6, :x)
  @picto_height = Types::Dimension.new(:dy, 0.6, :y)

  @picto_to_text = Types::Dimension.new(:dy, 0.3, :x)

  @scale = 0.8
  @text_scale = 0.82
  @symbol_scale = 1

  @frame = BoxStyle.new()
  
  @frame_padding = Types::Dimension.from_text("1mm", :x)
end

Instance Method Details

#dy_to_figure(t) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
# File 'lib/ctioga2/graphics/styles/legend.rb', line 79

def dy_to_figure(t)

  # Defaults to one line height + the padding

  if @dy
    return @dy.to_figure(t, :y)
  end

  line = Types::Dimension.new(:dy, 1, :y) 
  return line.to_figure(t, :y) + @vpadding.to_figure(t, :y)
end

#vpadding_to_figure(t) ⇒ Object



91
92
93
94
95
96
97
# File 'lib/ctioga2/graphics/styles/legend.rb', line 91

def vpadding_to_figure(t)
  if @dy 
    line = Types::Dimension.new(:dy, 1, :y) 
    return (@dy.to_figure(t, :y) - line.to_figure(t, :y))
  end
  return @vpadding.to_figure(t, :y)
end