Class: MotionPlot::DataLabel

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

Constant Summary collapse

DEFAULTS =
{
  displacement: [0.0, 12.0]
}.merge(Style::DEFAULTS)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ DataLabel

Returns a new instance of DataLabel.



10
11
12
13
# File 'lib/motion-plot/utilities/data_label.rb', line 10

def initialize(options={})
  @attributes = DEFAULTS.merge(options)
  @style      = Style.new(@attributes)
end

Instance Attribute Details

#annotationObject

Returns the value of attribute annotation.



8
9
10
# File 'lib/motion-plot/utilities/data_label.rb', line 8

def annotation
  @annotation
end

Instance Method Details

#annotation_for(value, atCoordinate: coordinate, plotSpace: plot_space) ⇒ Object



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

def annotation_for(value, atCoordinate: coordinate, plotSpace: plot_space)
  @annotation               = CPTPlotSpaceAnnotation.alloc.initWithPlotSpace(plot_space, anchorPlotPoint:coordinate)
  @annotation.contentLayer  = annotation_text_style(value)
  @annotation.displacement  = @attributes[:displacement]

  @annotation
end

#annotation_text_style(value) ⇒ Object



31
32
33
# File 'lib/motion-plot/utilities/data_label.rb', line 31

def annotation_text_style(value)
  CPTTextLayer.alloc.initWithText(value.to_s, style:style)
end

#displacementObject



19
20
21
# File 'lib/motion-plot/utilities/data_label.rb', line 19

def displacement
  @attributes[:displacement]
end

#styleObject



15
16
17
# File 'lib/motion-plot/utilities/data_label.rb', line 15

def style
  TextStyle.cpt_text_style(@style)
end