Class: MotionPlot::PlotSymbol

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

Constant Summary collapse

ALIASES =
{
  :rectangle  => "rectanglePlotSymbol",
  :plus       => "plusPlotSymbol",
  :star       => "starPlotSymbol",
  :diamond    => "diamondPlotSymbol",
  :triangle   => "trianglePlotSymbol",
  :pentagon   => "pentagonPlotSymbol",
  :hexagon    => "hexagonPlotSymbol",
  :dash       => "dashPlotSymbol",
  :snow       => "snowPlotSymbol"
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ PlotSymbol

Returns a new instance of PlotSymbol.



34
35
36
37
38
39
40
# File 'lib/motion-plot/utilities/plot_symbol.rb', line 34

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

  @type = options[:type] ? self.class.send(options[:type]) : MotionPlot::PlotSymbol[options[:index]]
end

Instance Attribute Details

#enabledObject

Returns the value of attribute enabled.



32
33
34
# File 'lib/motion-plot/utilities/plot_symbol.rb', line 32

def enabled
  @enabled
end

#sizeObject

Returns the value of attribute size.



32
33
34
# File 'lib/motion-plot/utilities/plot_symbol.rb', line 32

def size
  @size
end

#typeObject

Returns the value of attribute type.



32
33
34
# File 'lib/motion-plot/utilities/plot_symbol.rb', line 32

def type
  @type
end

Class Method Details

.[](index) ⇒ Object



25
26
27
28
29
# File 'lib/motion-plot/utilities/plot_symbol.rb', line 25

def [](index)
  index = 0 if(index > 9)

  send(ALIASES.keys[index])
end

.method_missing(m, *args, &block) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/motion-plot/utilities/plot_symbol.rb', line 17

def method_missing(m, *args, &block)
  method_name = m == :default ? :rectangle : m

  raise unless(ALIASES.keys.include?(method_name))        

  CPTPlotSymbol.send(ALIASES[method_name])
end

Instance Method Details

#symbol_for(plot) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/motion-plot/utilities/plot_symbol.rb', line 42

def symbol_for(plot)
  _style            = CPTMutableLineStyle.lineStyle
  _style.lineColor  = plot.dataLineStyle.lineColor
  symbol            = @type
  symbol.fill       = CPTFill.fillWithColor(plot.dataLineStyle.lineColor, colorWithAlphaComponent:0.5)
  symbol.lineStyle  = _style
  symbol.size       = CGSizeMake(size.to_f, size.to_f)

  symbol
end