Sha256: c0e886428e24ed5f5620a17ce7e6f5b117bb239303abf02f6ae6a6c3f3f21a4a

Contents?: true

Size: 1.64 KB

Versions: 5

Compression:

Stored size: 1.64 KB

Contents

# items.rb: individual legend items
# copyright (c) 2008,2009 by Vincent Fourmond

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details (in the COPYING file).

require 'ctioga2/utils'
require 'ctioga2/log'

module CTioga2

  Version::register_svn_info('$Revision: 2 $', '$Date: 2009-04-25 14:03:30 +0200 (Sat, 25 Apr 2009) $')

  module Graphics

    module Legends

      # This class is in charge of providing a legend for the given
      # dataset. Most of its job is simply to collect --legend
      # arguments from the command-line.
      class LegendProvider

        # The legend to be used for the next curve, if applicable
        attr_accessor :current_legend

        # Whether we automatically give a name to curves or not.
        attr_accessor :auto_legend

        def initialize
          @current_legend = nil
          @auto_legend = false
        end

        # Returns a legend suitable for the next curve.
        def dataset_legend(dataset)
          if @current_legend
            l = @current_legend
            @current_legend = nil
            return l
          elsif @auto_legend
            return dataset.name
          else
            return nil
          end
        end
        
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ctioga2-0.5 lib/ctioga2/graphics/legends/provider.rb
ctioga2-0.4 lib/ctioga2/graphics/legends/provider.rb
ctioga2-0.2 lib/ctioga2/graphics/legends/provider.rb
ctioga2-0.1 lib/ctioga2/graphics/legends/provider.rb
ctioga2-0.0 lib/ctioga2/graphics/legends/provider.rb