~ubuntu-branches/ubuntu/utopic/ctioga2/utopic

« back to all changes in this revision

Viewing changes to lib/ctioga2/graphics/elements/containers.rb

  • Committer: Package Import Robot
  • Author(s): Vincent Fourmond
  • Date: 2013-12-27 21:04:22 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20131227210422-a3f0c7alorq6lwq2
Tags: 0.8-1
* New upstream release
* Updated URLs and debian/watch to follow its new location
* Already conforms to standards 3.9.5
* Finally updated VCS URLS

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
module CTioga2
19
19
 
20
 
  Version::register_svn_info('$Revision: 529 $', '$Date: 2013-09-25 18:23:27 +0200 (Wed, 25 Sep 2013) $')
21
 
 
22
20
  module Graphics
23
21
 
24
22
    module Elements
51
49
        # Defaults to the #legend_storage, but it can be changed
52
50
        attr_accessor :legend_item_target
53
51
 
 
52
        # A general-purpose cache that objects may use.
 
53
        #
 
54
        # It is a hash, and its contents are reset at the beginning of
 
55
        # each invocation of #do.
 
56
        attr_accessor :gp_cache
 
57
 
 
58
 
 
59
        # @todo Add an iterator over all leaf elements (including
 
60
        # children or not ?)
 
61
 
54
62
        # Creates an empty new Container with the given _parent_.
55
63
        def initialize(parent = nil, root = nil)
56
64
          super()
72
80
          @legend_area = nil
73
81
        end
74
82
 
 
83
        def do(t)
 
84
          # reset the cache
 
85
          @gp_cache = {}
 
86
          super
 
87
        end
 
88
 
75
89
        # Returns the number of child elements
76
90
        def size
77
91
          return @elements.size
123
137
          end
124
138
        end
125
139
 
 
140
        def each_item(leaf_only = true, recursive = false, tl = true, &blk)
 
141
          if (!recursive && !tl)
 
142
            return              # We're at the bottom level
 
143
          end
 
144
          for el in @elements
 
145
            if el.respond_to? :each_item
 
146
              if ! leaf_only
 
147
                blk.call(el)
 
148
              end
 
149
              el.each_item(leaf_only, recursive, false, &blk)
 
150
            else
 
151
              blk.call(el)
 
152
            end
 
153
          end
 
154
        end
 
155
 
126
156
        # \todo provide coordinate conversion facilities...
127
157
 
128
158
        protected