本文整理汇总了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)
示例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')
示例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')
示例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')
示例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')
示例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'))