# class Tk::BLT::PlotComponent::Marker

### Constants

MarkerID_TBL
MarkerTypeName
MarkerTypeToClass

### Public Class Methods

create(chart, keys={}) click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1276
    def self.create(chart, keys={})
      unless self::MarkerTypeName
        fail RuntimeError, "#{self} is an abstract class"
      end
      args, fontkeys, methodkeys = _parse_create_args(keys)
      idnum = tk_call_without_enc(chart.path, 'marker', 'create',
                                  self::MarkerTypeName, *args)
      chart.marker_configure(idnum, fontkeys) unless fontkeys.empty?
      chart.marker_configure(idnum, methodkeys) unless methodkeys.empty?
      idnum.to_i  # 'item id' is an integer number
    end

create_type(chart, type, keys={}) click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1288
    def self.create_type(chart, type, keys={})
      args, fontkeys, methodkeys = _parse_create_args(keys)
      idnum = tk_call_without_enc(chart.path, 'marker', 'create',
                                  type, *args)
      chart.marker_configure(idnum, fontkeys) unless fontkeys.empty?
      chart.marker_configure(idnum, methodkeys) unless methodkeys.empty?
      id = idnum.to_i  # 'item id' is an integer number
      obj = self.allocate
      obj.instance_eval{
        @parent = @chart = chart
        @cpath = chart.path
        @id = id
        Tk::BLT::PlotComponent::Marker::MarkerID_TBL.mutex.synchronize{
          Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] ||= {}
          Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath][@id] = self
        }
      }
      obj
    end

id2obj(chart, id) click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1219
    def Marker.id2obj(chart, id)
      cpath = chart.path
      MarkerID_TBL.mutex.synchronize{
        if MarkerID_TBL[cpath]
          MarkerID_TBL[cpath][id]? MarkerID_TBL[cpath][id]: id
        else
          id
        end
      }
    end

new(parent, *args) click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1308
    def initialize(parent, *args)
      @parent = @chart = parent
      @cpath = parent.path

      @path = @id = create_self(*args) # an integer number as 'item id'
      Tk::BLT::PlotComponent::Marker::MarkerID_TBL.mutex.synchronize{
        Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] ||= {}
        Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath][@id] = self
      }
    end

type2class(type) click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1215
    def Marker.type2class(type)
      MarkerTypeToClass[type]
    end

### Private Class Methods

_parse_create_args(keys) click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1230
    def self._parse_create_args(keys)
      fontkeys = {}
      methodkeys = {}
      if keys.kind_of? Hash
        keys = _symbolkey2str(keys)

        __item_font_optkeys(nil).each{|key|
          fkey = key.to_s
          fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)

          fkey = "kanji#{key}"
          fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)

          fkey = "latin#{key}"
          fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)

          fkey = "ascii#{key}"
          fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
        }

        __item_optkey_aliases(nil).each{|alias_name, real_name|
          alias_name = alias_name.to_s
          if keys.has_key?(alias_name)
            keys[real_name.to_s] = keys.delete(alias_name)
          end
        }

        __item_methodcall_optkeys(nil).each{|key|
          key = key.to_s
          methodkeys[key] = keys.delete(key) if keys.key?(key)
        }

        __item_ruby2val_optkeys(nil).each{|key, method|
          key = key.to_s
          keys[key] = method.call(keys[key]) if keys.has_key?(key)
        }

        args = itemconfig_hash_kv(nil, keys)
      else
        args = []
      end

      [args, fontkeys, methodkeys]
    end

### Public Instance Methods

after(target=None) click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1351
    def after(target=None)
      @chart.marker_after(@id, target)
    end

before(target=None) click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1355
    def before(target=None)
      @chart.marker_before(@id, target)
    end

cget(option) click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1334
    def cget(option)
      @chart.marker_cget(@id, option)
    end

cget_strict(option) click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1337
    def cget_strict(option)
      @chart.marker_cget_strict(@id, option)
    end

cget_tkstring(option) click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1331
    def cget_tkstring(option)
      @chart.marker_cget_tkstring(@id, option)
    end

configinfo(key=nil) click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1344
    def configinfo(key=nil)
      @chart.marker_configinfo(@id, key)
    end

configure(key, value=None) click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1340
    def configure(key, value=None)
      @chart.marker_configure(@id, key, value)
      self
    end

current_configinfo(key=nil) click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1347
    def current_configinfo(key=nil)
      @chart.current_marker_configinfo(@id, key)
    end

delete() click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1359
    def delete
      @chart.marker_delete(@id)
    end

exist?() click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1363
    def exist?
      @chart.marker_exist(@id)
    end

id() click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1323
    def id
      @id
    end

to_eval() click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1327
    def to_eval
      @id
    end

type() click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1367
    def type
      @chart.marker_type(@id)
    end

### Private Instance Methods

create_self(*args) click to toggle source

    # File lib/tkextlib/blt/component.rb, line 1318
    def create_self(*args)
      self.class.create(@chart, *args) # return an integer as 'item id'
    end