Class: MotionPlot::Legend

Inherits:
Object
  • Object
show all
Defined in:
lib/motion-plot/utilities/legend.rb

Constant Summary collapse

DEFAULTS =
{
  swatch_size: [25.0, 25.0],
  corner_radius: 5,
  position: "top",
  displacement: [0.0, 0.0],
  fill_color: "FFFFFF"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Legend

Returns a new instance of Legend.



14
15
16
17
18
19
20
21
22
# File 'lib/motion-plot/utilities/legend.rb', line 14

def initialize(args={})
  options = DEFAULTS.merge(args)

  options.each_pair {|key, value|
    send("#{key}=", value) if(respond_to?("#{key}="))
  }

  @style = args[:style] ? Style.new(args[:style]) : Style.new
end

Instance Attribute Details

#corner_radiusObject

Returns the value of attribute corner_radius.



4
5
6
# File 'lib/motion-plot/utilities/legend.rb', line 4

def corner_radius
  @corner_radius
end

#displacementObject

Returns the value of attribute displacement.



4
5
6
# File 'lib/motion-plot/utilities/legend.rb', line 4

def displacement
  @displacement
end

#enabledObject

Returns the value of attribute enabled.



4
5
6
# File 'lib/motion-plot/utilities/legend.rb', line 4

def enabled
  @enabled
end

#fill_colorObject

Returns the value of attribute fill_color.



4
5
6
# File 'lib/motion-plot/utilities/legend.rb', line 4

def fill_color
  @fill_color
end

#number_of_columnsObject

Returns the value of attribute number_of_columns.



4
5
6
# File 'lib/motion-plot/utilities/legend.rb', line 4

def number_of_columns
  @number_of_columns
end

#number_of_rowsObject

Returns the value of attribute number_of_rows.



4
5
6
# File 'lib/motion-plot/utilities/legend.rb', line 4

def number_of_rows
  @number_of_rows
end

#positionObject

Returns the value of attribute position.



4
5
6
# File 'lib/motion-plot/utilities/legend.rb', line 4

def position
  @position
end

#styleObject

Returns the value of attribute style.



4
5
6
# File 'lib/motion-plot/utilities/legend.rb', line 4

def style
  @style
end

#swatch_sizeObject

Returns the value of attribute swatch_size.



4
5
6
# File 'lib/motion-plot/utilities/legend.rb', line 4

def swatch_size
  @swatch_size
end

Instance Method Details

#cpt_legend(graph) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/motion-plot/utilities/legend.rb', line 32

def cpt_legend(graph)
  legend              = CPTLegend.legendWithGraph(graph)
  legend.fill         = CPTFill.fillWithColor(fill_color.to_color.to_cpt_color)
  legend.cornerRadius = corner_radius
  legend.swatchSize   = swatch_size
  legend.textStyle    = TextStyle.cpt_text_style(@style) if(@style)

  p @style
  
  legend
end

#enabled?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/motion-plot/utilities/legend.rb', line 24

def enabled?
  enabled
end