当前位置: 首页>>代码示例>>Python>>正文


Python Screen.read_xml_point方法代码示例

本文整理汇总了Python中singleton_store.Screen.read_xml_point方法的典型用法代码示例。如果您正苦于以下问题:Python Screen.read_xml_point方法的具体用法?Python Screen.read_xml_point怎么用?Python Screen.read_xml_point使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在singleton_store.Screen的用法示例。


在下文中一共展示了Screen.read_xml_point方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: read_package

# 需要导入模块: from singleton_store import Screen [as 别名]
# 或者: from singleton_store.Screen import read_xml_point [as 别名]
  def read_package( self, package, atom):
    typ = package.getAttribute( 'type')
    cls = globals().get( typ, None)
    if cls:
      auto = 0 #package.getAttribute( 'auto') != None and package.getAttribute( 'auto')) or 0
      x, y, z = Screen.read_xml_point( package)
      size = package.getAttribute( 'size') and float( package.getAttribute( 'size')) or None
      if size:
        m = cls( atom, x, y, size=size, auto=int(auto))
      else:
        m = cls( atom, x, y, auto=int(auto))

      # class specific attributes
      for (attr, typ) in m.meta__save_attrs.items():
        val = package.getAttribute( attr)
        if val != '':
          if typ == bool:
            value = bool( data.booleans.index( val))
          elif typ == int:
            value = int( val)
          else:
            value = val
          setattr( m, attr, value)

      if hasattr( m, "_after_read_package"):
        m._after_read_package()
      return m
    else:
      raise ValueError("no such mark type %s" % typ)
开发者ID:sctincman,项目名称:bkchem,代码行数:31,代码来源:marks.py

示例2: read_package

# 需要导入模块: from singleton_store import Screen [as 别名]
# 或者: from singleton_store.Screen import read_xml_point [as 别名]
 def read_package( self, package):
   """reads the dom element package and sets internal state according to it"""
   if package.getAttribute( 'id'):
     self.id = package.getAttribute( 'id')
   pnt = package.getElementsByTagName( 'point')[0]
   self.x, self.y, z = Screen.read_xml_point( pnt)
   if package.getAttribute( 'font_size'):
     self.font_size = int( package.getAttribute( 'font_size'))
   if package.getAttribute( 'color'):
     self.line_color = package.getAttribute( 'color')
   if package.getAttribute( 'background-color'):
     self.area_color = package.getAttribute( 'background-color')
开发者ID:sctincman,项目名称:bkchem,代码行数:14,代码来源:classes.py

示例3: read_package

# 需要导入模块: from singleton_store import Screen [as 别名]
# 或者: from singleton_store.Screen import read_xml_point [as 别名]
  def read_package( self, package):
    """reads the dom element package and sets internal state according to it"""
    a = ['no','yes']
    on_off = ['off','on']
    self.id = package.getAttribute( 'id')
    # marks
    for m in package.getElementsByTagName( 'mark'):
      mrk = marks.mark.read_package( m, self)
      self.marks.add( mrk)

    # position
    self.pos = package.getAttribute( 'pos')
    position = package.getElementsByTagName( 'point')[0]
    # reading of coords regardless of their unit
    x, y, z = Screen.read_xml_point( position)
    if z != None:
      self.z = z* self.paper.real_to_screen_ratio()
    # needed to support transparent handling of molecular size
    x, y = self.paper.real_to_screen_coords( (x, y))
    self.x = x
    self.y = y
    ft = package.getElementsByTagName('ftext')
    if ft:
      self.set_name(''.join(e.nodeValue for e in ft[0].childNodes
                                          if isinstance(e, dom.Text)))
    else:
      raise TypeError("Not text atom.")
    # font and fill color
    fnt = package.getElementsByTagName('font')
    if fnt:
      fnt = fnt[0]
      self.font_size = int( fnt.getAttribute( 'size'))
      self.font_family = fnt.getAttribute( 'family')
      if fnt.getAttribute( 'color'):
        self.line_color = fnt.getAttribute( 'color')
    # background color
    if package.getAttributeNode( 'background-color'):
      self.area_color = package.getAttribute( 'background-color')
    # number
    if package.getAttribute( 'show_number'):
      self.show_number = bool( data.booleans.index( package.getAttribute( 'show_number')))
    if package.getAttribute( 'number'):
      self.number = package.getAttribute( 'number')
开发者ID:sctincman,项目名称:bkchem,代码行数:45,代码来源:textatom.py

示例4: read_package

# 需要导入模块: from singleton_store import Screen [as 别名]
# 或者: from singleton_store.Screen import read_xml_point [as 别名]
  def read_package( self, package):
    """reads the dom element package and sets internal state according to it"""
    a = ['no','yes']
    on_off = ['off','on']
    self.id = package.getAttribute( 'id')
    self.pos = package.getAttribute( 'pos')
    position = package.getElementsByTagName( 'point')[0]
    # reading of coords regardless of their unit
    x, y, z = Screen.read_xml_point( position)
    if z != None:
      self.z = z* self.paper.real_to_screen_ratio()
    # needed to support transparent handling of molecular size
    x, y = self.paper.real_to_screen_coords( (x, y))
    self.x = x
    self.y = y
    self.group_type = package.getAttribute( "group-type")
    if self.group_type in ("implicit","explicit"):
      #read the graph once
      pass
    self.symbol = package.getAttribute( "name")

    # font and fill color
    fnt = package.getElementsByTagName('font')
    if fnt:
      fnt = fnt[0]
      self.font_size = int( fnt.getAttribute( 'size'))
      self.font_family = fnt.getAttribute( 'family')
      if fnt.getAttribute( 'color'):
        self.line_color = fnt.getAttribute( 'color')
    # background color
    if package.getAttributeNode( 'background-color'):
      self.area_color = package.getAttribute( 'background-color')

    # marks
    for m in package.getElementsByTagName( 'mark'):
      mrk = marks.mark.read_package( m, self)
      self.marks.add( mrk)
    # number
    if package.getAttribute( 'show_number'):
      self.show_number = bool( data.booleans.index( package.getAttribute( 'show_number')))
    if package.getAttribute( 'number'):
      self.number = package.getAttribute( 'number')
开发者ID:bartlebee,项目名称:bkchem,代码行数:44,代码来源:group.py

示例5: read_package

# 需要导入模块: from singleton_store import Screen [as 别名]
# 或者: from singleton_store.Screen import read_xml_point [as 别名]
  def read_package( self, package):
    """reads the dom element package and sets internal state according to it"""
    if package.getAttribute( 'id'):
      self.id = package.getAttribute( 'id')
    pos = package.getElementsByTagName( 'point')[0]
    x, y, z = Screen.read_xml_point( pos)
    self.set_xy( x, y)
    ft = package.getElementsByTagName('ftext')
    try:
      self.xml_ftext = reduce( operator.add, [e.nodeValue for e in ft[0].childNodes if isinstance( e, dom.Text)], '')
    except IndexError:
      self.xml_ftext = "?"

    fnt = package.getElementsByTagName('font')
    if fnt:
      fnt = fnt[0]
      self.font_size = int( fnt.getAttribute( 'size'))
      self.font_family = fnt.getAttribute( 'family')
      if fnt.getAttribute( 'color'):
        self.line_color = fnt.getAttribute( 'color')
    if package.getAttribute( 'background-color'):
      self.area_color = package.getAttribute( 'background-color')
开发者ID:bartlebee,项目名称:bkchem,代码行数:24,代码来源:classes.py

示例6: read_package

# 需要导入模块: from singleton_store import Screen [as 别名]
# 或者: from singleton_store.Screen import read_xml_point [as 别名]
 def read_package( self, package):
   """reads the dom element package and sets internal state according to it"""
   a = ['no','yes']
   on_off = ['off','on']
   self.id = package.getAttribute( 'id')
   # marks (we read them here because they influence the charge)
   for m in package.getElementsByTagName( 'mark'):
     mrk = marks.mark.read_package( m, self)
     self.marks.add( mrk)
   self.pos = package.getAttribute( 'pos')
   position = package.getElementsByTagName( 'point')[0]
   # reading of coords regardless of their unit
   x, y, z = Screen.read_xml_point( position)
   if z is not None:
     self.z = z* self.paper.real_to_screen_ratio()
   # needed to support transparent handling of molecular size
   x, y = self.paper.real_to_screen_coords( (x, y))
   self.x = x
   self.y = y
   ft = package.getElementsByTagName('ftext')
   if ft:
     self.set_name(''.join([e.toxml('utf-8') for e in ft[0].childNodes]),
                   check_valency=0,
                   interpret=0)
   else:
     self.set_name( package.getAttribute( 'name'), check_valency=0)
   # charge
   self.charge = package.getAttribute('charge') and int( package.getAttribute('charge')) or 0
   # hydrogens
   if package.getAttribute( 'hydrogens'):
     self.show_hydrogens = package.getAttribute('hydrogens')
   else:
     self.show_hydrogens = 0
   # font and fill color
   fnt = package.getElementsByTagName('font')
   if fnt:
     fnt = fnt[0]
     self.font_size = int( fnt.getAttribute( 'size'))
     self.font_family = fnt.getAttribute( 'family')
     if fnt.getAttribute( 'color'):
       self.line_color = fnt.getAttribute( 'color')
   # show
   if package.getAttribute( 'show'):
     self.show = package.getAttribute( 'show')
   else:
     self.show = (self.symbol!='C')
   # background color
   if package.getAttributeNode( 'background-color'):
     self.area_color = package.getAttribute( 'background-color')
   # multiplicity
   if package.getAttribute( 'multiplicity'):
     self.multiplicity = int( package.getAttribute( 'multiplicity'))
   # valency
   if package.getAttribute( 'valency'):
     self.valency = int( package.getAttribute( 'valency'))
   # number
   if package.getAttribute( 'show_number'):
     self.show_number = bool( data.booleans.index( package.getAttribute( 'show_number')))
   if package.getAttribute( 'number'):
     self.number = package.getAttribute( 'number')
   # free_sites
   if package.getAttribute( 'free_sites'):
     self.free_sites = int( package.getAttribute( 'free_sites'))
开发者ID:sctincman,项目名称:bkchem,代码行数:65,代码来源:atom.py


注:本文中的singleton_store.Screen.read_xml_point方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。