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


Python Screen.px_to_cm方法代码示例

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


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

示例1: add_arrow

# 需要导入模块: from singleton_store import Screen [as 别名]
# 或者: from singleton_store.Screen import px_to_cm [as 别名]
 def add_arrow( self, a, page):
   for item in a.items:
     # polygons (arrow heads, etc.)
     if self.paper.type( item) == "polygon":
       a_color = self.paper.itemcget( item, "fill")
       l_color = self.paper.itemcget( item, "outline")
       l_width = float( self.paper.itemcget( item, "width"))
       s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( l_color),
                           fill_color=self.paper.any_color_to_rgb_string( a_color),
                           stroke_width=Screen.px_to_cm( l_width))
       style_name = self.get_appropriate_style_name( s)
       ps = geometry.coordinate_flat_list_to_xy_tuples( self.paper.coords( item))
       points = [map( Screen.px_to_cm, p) for p in ps]
       self.create_oo_polygon( points, page, style_name)
     # polylines - standard arrows
     elif self.paper.type( item) == "line":
       line_pin = a._pins.index( self.paper.itemcget( item, 'arrow'))
       end_pin, start_pin = None,None
       if line_pin==1 or line_pin==3:
         end_pin = 1
       if line_pin==2 or line_pin==3:
         start_pin = 1
       l_color = self.paper.itemcget( item, "fill")
       l_width = float( self.paper.itemcget( item, "width"))
       s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( l_color),
                           marker_end=end_pin,
                           marker_start=start_pin,
                           stroke_width=Screen.px_to_cm( l_width))
       style_name = self.get_appropriate_style_name( s)
       ps = geometry.coordinate_flat_list_to_xy_tuples( self.paper.coords( item))
       points = [map( Screen.px_to_cm, p) for p in ps]
       if self.paper.itemcget( item, "smooth") == "0":
         self.create_oo_polyline( points, page, style_name)
       else:
         self.create_oo_bezier( points, page, style_name)
开发者ID:sctincman,项目名称:bkchem,代码行数:37,代码来源:openoffice.py

示例2: add_plus_mark

# 需要导入模块: from singleton_store import Screen [as 别名]
# 或者: from singleton_store.Screen import px_to_cm [as 别名]
 def add_plus_mark( self, o, page):
   s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( o.atom.line_color),
                       fill_color=self.paper.any_color_to_rgb_string( o.atom.area_color),
                       stroke_width=Screen.px_to_cm( 1))
   style_name = self.get_appropriate_style_name( s)
   # we must process oval first - it would otherwise cover the lines
   for i in o.items:
     if self.paper.type( i) == "oval":
       x, y, x2, y2 = map( Screen.px_to_cm, self.paper.coords( i))
       size = Screen.px_to_cm( o.size)
       dom_extensions.elementUnder( page, 'draw:ellipse',
                                    (( 'svg:x', '%fcm' %  x),
                                     ( 'svg:y', '%fcm' %  y),
                                     ( 'svg:width', '%fcm' %  size),
                                     ( 'svg:height', '%fcm' % size),
                                     ( 'draw:style-name', style_name)))
   for i in o.items:
     if self.paper.type( i) == "line":
       coords = self.paper.coords( i)
       # because some weird bug in tcl/tk i had to hack the coordinates in marks.py
       # the hack is reversed here in order to get the coords back
       # I also reduce the size of the mark a little
       #if o.items.index( i) == 1:
       #  coords[0] += 0
       #  coords[2] += -1
       #elif o.items.index( i) == 2:
       #  coords[1] += 0
       #  coords[3] += -1
       # end of hack
       coords = map( Screen.px_to_cm, coords)
       self.create_oo_line( coords, page, style_name)
开发者ID:sctincman,项目名称:bkchem,代码行数:33,代码来源:openoffice.py

示例3: add_radical_mark

# 需要导入模块: from singleton_store import Screen [as 别名]
# 或者: from singleton_store.Screen import px_to_cm [as 别名]
 def add_radical_mark( self, o, page):
   s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( o.atom.line_color),
                       fill_color=self.paper.any_color_to_rgb_string( o.atom.line_color),
                       stroke_width=Screen.px_to_cm( 0.1))
   style_name = self.get_appropriate_style_name( s)
   for i in o.items:
     x, y, x2, y2 = map( Screen.px_to_cm, self.paper.coords( i))
     size = Screen.px_to_cm( o.size)
     dom_extensions.elementUnder( page, 'draw:ellipse',
                                  (( 'svg:x', '%fcm' %  x),
                                   ( 'svg:y', '%fcm' %  y),
                                   ( 'svg:width', '%fcm' %  size),
                                   ( 'svg:height', '%fcm' % size),
                                   ( 'draw:style-name', style_name)))
开发者ID:sctincman,项目名称:bkchem,代码行数:16,代码来源:openoffice.py

示例4: add_polygon

# 需要导入模块: from singleton_store import Screen [as 别名]
# 或者: from singleton_store.Screen import px_to_cm [as 别名]
 def add_polygon( self, o, page):
   s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( o.line_color),
                       fill_color=self.paper.any_color_to_rgb_string( o.area_color),
                       stroke_width=Screen.px_to_cm( o.line_width))
   style_name = self.get_appropriate_style_name( s)
   points = [map( Screen.px_to_cm, p.get_xy()) for p in o.points]
   self.create_oo_polygon( points, page, style_name)
开发者ID:sctincman,项目名称:bkchem,代码行数:9,代码来源:openoffice.py

示例5: add_electronpair_mark

# 需要导入模块: from singleton_store import Screen [as 别名]
# 或者: from singleton_store.Screen import px_to_cm [as 别名]
 def add_electronpair_mark( self, o, page):
   i = o.items[0]
   width = float( self.paper.itemcget( i, 'width'))
   s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( o.atom.line_color),
                       fill_color=self.paper.any_color_to_rgb_string( o.atom.line_color),
                       stroke_width=Screen.px_to_cm( width))
   style_name = self.get_appropriate_style_name( s)
   coords = map( Screen.px_to_cm, self.paper.coords( i))
   self.create_oo_line( coords, page, style_name)
开发者ID:sctincman,项目名称:bkchem,代码行数:11,代码来源:openoffice.py

示例6: add_bond

# 需要导入模块: from singleton_store import Screen [as 别名]
# 或者: from singleton_store.Screen import px_to_cm [as 别名]
  def add_bond( self, b, page):
    """adds bond item to page"""
    s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( b.line_color),
                        stroke_width=Screen.px_to_cm( b.line_width))
    style_name = self.get_appropriate_style_name( s)
    l_group = page
    # items to export
    line_items, items = b.get_exportable_items()

    # the export itself
    if b.type in 'nhd':
      for i in items:
        coords = map( Screen.px_to_cm, self.paper.coords( i))
        self.create_oo_line( coords, page, style_name)
    elif b.type == 'o':
      for i in items:
        x, y, x2, y2 = map( Screen.px_to_cm, self.paper.coords( i))
        size = Screen.px_to_cm( x2-x)
        dom_extensions.elementUnder( page, 'draw:ellipse',
                                     (( 'svg:x', '%fcm' %  x),
                                      ( 'svg:y', '%fcm' %  y),
                                      ( 'svg:width', '%fcm' %  size),
                                      ( 'svg:height', '%fcm' % size),
                                      ( 'draw:style-name', style_name)))
    elif b.type == 'b':
      # bold bonds width is determined by the wedge_width
      s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( b.line_color),
                          stroke_width=Screen.px_to_cm( b.wedge_width))
      b_style_name = self.get_appropriate_style_name( s)
      for i in items:
        coords = map( Screen.px_to_cm, self.paper.coords( i))
        self.create_oo_line( coords, page, b_style_name)
    elif b.type == 'w':
      s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( b.line_color),
                          fill_color=self.paper.any_color_to_rgb_string( b.line_color),
                          stroke_width=Screen.px_to_cm( b.line_width))
      style_name = self.get_appropriate_style_name( s)
      for i in items:
        coords = map( Screen.px_to_cm, self.paper.coords( i))
        point_array = []
        for i in range( 0, len( coords), 2):
          point_array.append( (coords[i], coords[i+1]))
        self.create_oo_polygon( point_array, page, style_name)
    elif b.type == 'a':
      s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( b.line_color),
                          stroke_width=Screen.px_to_cm( b.line_width))
      style_name = self.get_appropriate_style_name( s)
      for i in items:
        coords = self.paper.coords( i)
        points = []
        for j in range( 0, len( coords), 2):
          points.append( ( Screen.px_to_cm( coords[j]), Screen.px_to_cm(coords[j+1])))
        self.create_oo_polyline( points, page, style_name)
    # line_items
    for i in line_items:
      coords = map( Screen.px_to_cm, self.paper.coords( i))
      self.create_oo_line( coords, page, style_name)
开发者ID:sctincman,项目名称:bkchem,代码行数:59,代码来源:openoffice.py

示例7: add_oval

# 需要导入模块: from singleton_store import Screen [as 别名]
# 或者: from singleton_store.Screen import px_to_cm [as 别名]
 def add_oval( self, o, page):
   s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( o.line_color),
                       fill_color=self.paper.any_color_to_rgb_string( o.area_color),
                       stroke_width=Screen.px_to_cm( o.line_width))
   style_name = self.get_appropriate_style_name( s)
   x, y, x2, y2 = map( Screen.px_to_cm, o.coords)
   dom_extensions.elementUnder( page, 'draw:ellipse',
                                      (( 'svg:x', '%fcm' %  x),
                                       ( 'svg:y', '%fcm' %  y),
                                       ( 'svg:width', '%fcm' %  (x2-x)),
                                       ( 'svg:height', '%fcm' % (y2-y)),
                                       ( 'draw:style-name', style_name)))
开发者ID:sctincman,项目名称:bkchem,代码行数:14,代码来源:openoffice.py

示例8: add_orbital

# 需要导入模块: from singleton_store import Screen [as 别名]
# 或者: from singleton_store.Screen import px_to_cm [as 别名]
  def add_orbital( self, o, page):
    s = graphics_style( stroke_color=self.paper.any_color_to_rgb_string( o.atom.line_color),
                        fill_color=self.paper.any_color_to_rgb_string( o.atom.area_color),
                        stroke_width=Screen.px_to_cm( 1.0))

    style_name = self.get_appropriate_style_name( s)
    i = 0
    points = []
    for c in o._get_my_curve( num_points=50):
      if not i:
        x = c
        i = 1
      else:
        points.append( map( Screen.px_to_cm, (x, c)))
        i = 0

    self.create_oo_polygon( points, page, style_name)
开发者ID:sctincman,项目名称:bkchem,代码行数:19,代码来源:openoffice.py


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