~ubuntu-branches/ubuntu/wily/ctioga2/wily

« back to all changes in this revision

Viewing changes to lib/ctioga2/graphics/styles/axes.rb

  • Committer: Package Import Robot
  • Author(s): Vincent Fourmond
  • Date: 2013-07-08 20:58:17 UTC
  • mfrom: (6.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130708205817-cephnc6etndyxrrp
Tags: 0.4-2
* Upload to unstable
* Already conforms to newer standards

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# This module contains all the classes used by ctioga
18
18
module CTioga2
19
19
 
20
 
  Version::register_svn_info('$Revision: 202 $', '$Date: 2010-11-30 22:21:17 +0100 (Tue, 30 Nov 2010) $')
 
20
  Version::register_svn_info('$Revision: 357 $', '$Date: 2012-12-26 00:49:11 +0100 (Wed, 26 Dec 2012) $')
21
21
 
22
22
  module Graphics
23
23
 
33
33
        # AXIS_WITH_TICKS_ONLY,
34
34
        # AXIS_WITH_MAJOR_TICKS_AND_NUMERIC_LABELS, and
35
35
        # AXIS_WITH_TICKS_AND_NUMERIC_LABELS.
36
 
        attr_accessor :decoration
 
36
        typed_attribute :decoration, 'axis-decoration'
37
37
        
38
38
        # The position of the axis. Can be one of :left, :right, :top,
39
39
        # :bottom, :at_y_origin or :at_x_origin.
40
 
        attr_accessor :location
 
40
        typed_attribute :location, 'location'
41
41
 
42
42
        # Offset of the axis with respect to its normal position. It
43
43
        # is counted *away* from the graph. It is either a
44
44
        # Types::Dimension object or _nil_.
45
 
        attr_accessor :offset
 
45
        typed_attribute :offset, 'dimension'
46
46
 
47
47
        # The background lines for the given axis. _nil_ for nothing,
48
48
        # or a StrokeStyle object if we want to draw something.
49
 
        attr_accessor :background_lines
 
49
        #
 
50
        # @todo Use a sub-style for that when that is implemented.
 
51
        sub_style :background_lines, StrokeStyle
50
52
 
51
53
        # The style of the tick labels
52
 
        attr_accessor :tick_label_style
 
54
        sub_style :tick_label_style, FullTextStyle, "tick_label_%s"
53
55
 
54
56
        # The label of the axis, if there is one
55
 
        attr_accessor :axis_label
 
57
        sub_style :axis_label, TextLabel
56
58
 
57
59
        # Whether the axis should be log scale or not
58
 
        attr_accessor :log
 
60
        typed_attribute :log, 'boolean'
59
61
 
60
62
        # Transform: a Types::Bijection object specifying a coordinate
61
63
        # transformation for the axis.
62
 
        attr_accessor :transform
 
64
        typed_attribute :transform, 'bijection'
63
65
 
64
66
        # The color of the stroke for the lines of the axis
65
 
        attr_accessor :stroke_color
 
67
        typed_attribute :stroke_color, 'color'
 
68
 
 
69
        typed_attribute :major_tick_length, 'float'
 
70
        typed_attribute :major_tick_width, 'float'
 
71
 
 
72
        typed_attribute :minor_tick_length, 'float'
 
73
        typed_attribute :minor_tick_width, 'float'
66
74
 
67
75
 
68
76
        # Creates a new AxisStyle object at the given location with
89
97
          spec = get_axis_specification(t)
90
98
          # Add tick label style:
91
99
          spec.merge!(@tick_label_style.to_hash)
92
 
          if @stroke_color
93
 
            spec['stroke_color'] = @stroke_color
 
100
 
 
101
          # Direct copy of attributes 
 
102
          for key in %w(stroke_color major_tick_length major_tick_width
 
103
minor_tick_length minor_tick_width)
 
104
            val = self.send(key.to_sym)
 
105
            if val
 
106
              spec[key] = val
 
107
            end
94
108
          end
95
109
          t.show_axis(spec)
96
110
          @axis_label.loc = @location
258
272
       
259
273
      end
260
274
 
261
 
      PartialAxisStyle = {
262
 
        'transform' => CmdArg.new('bijection'),
263
 
        'location' => CmdArg.new('location'),
264
 
        'stroke_color' => CmdArg.new('color')
265
 
      }
266
 
 
267
 
      FullAxisStyle = PartialAxisStyle.dup
268
 
      FullAxisStyle['decoration'] = CmdArg.new('axis-decoration')
269
 
                       
270
 
 
 
275
      AxisStyleOptions = AxisStyle.options_hash()
 
276
      PartialAxisStyle = AxisStyleOptions.without('decoration')
 
277
      
271
278
    end
272
279
  end
273
280
end