Class: MotionPlot::PlotArea

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

Constant Summary collapse

DEFAULTS =
{
  padding: [50.0, 10.0, 20.0, 20.0],
  border_line_style: default_border_line_style,
  mask_to_border: false,
  corner_radius: 5.0
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ PlotArea

Returns a new instance of PlotArea.



21
22
23
24
25
26
27
# File 'lib/motion-plot/utilities/plot_area.rb', line 21

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

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

Instance Attribute Details

#border_line_styleObject

Returns the value of attribute border_line_style.



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

def border_line_style
  @border_line_style
end

#corner_radiusObject

Returns the value of attribute corner_radius.



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

def corner_radius
  @corner_radius
end

#mask_to_borderObject

Returns the value of attribute mask_to_border.



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

def mask_to_border
  @mask_to_border
end

#paddingObject

Returns the value of attribute padding.



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

def padding
  @padding
end

Class Method Details

.default_border_line_styleObject



6
7
8
9
10
11
12
# File 'lib/motion-plot/utilities/plot_area.rb', line 6

def self.default_border_line_style
  line_style = CPTMutableLineStyle.lineStyle
  line_style.lineColor = CPTColor.blackColor
  line_style.lineWidth = 2.0

  line_style
end

Instance Method Details

#add_style(graph_plot_area) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/motion-plot/utilities/plot_area.rb', line 29

def add_style(graph_plot_area)
  graph_plot_area.masksToBorder     = @mask_to_border
  graph_plot_area.borderLineStyle   = @border_line_style || nil
  graph_plot_area.cornerRadius      = @corner_radius unless(border_line_style.nil?)


  %W(left top right bottom).each_with_index do |pos, index|
    graph_plot_area.send("padding#{pos.camelize}=", @padding[index]) unless(padding[index].nil?)
  end

  graph_plot_area
end