當前位置: 首頁>>代碼示例>>Python>>正文


Python base.transform_distance_simulation_to_canvas方法代碼示例

本文整理匯總了Python中base.transform_distance_simulation_to_canvas方法的典型用法代碼示例。如果您正苦於以下問題:Python base.transform_distance_simulation_to_canvas方法的具體用法?Python base.transform_distance_simulation_to_canvas怎麽用?Python base.transform_distance_simulation_to_canvas使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在base的用法示例。


在下文中一共展示了base.transform_distance_simulation_to_canvas方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _update_appearance

# 需要導入模塊: import base [as 別名]
# 或者: from base import transform_distance_simulation_to_canvas [as 別名]
def _update_appearance(self):
        """Update the node aspect to reflect the selected/highlighted state"""

        size = transform_distance_simulation_to_canvas(self._size)
        if self.svg_item is not None:
            alpha = 0x80
        else:
            alpha = 0xff
        fill_color_rgba = (self._color & 0xffffff00) | alpha
        self.canvas_item.set_properties(radius_x=size, radius_y=size,
                                        fill_color_rgba=fill_color_rgba)
        if self._selected:
            line_width = size*.3
        else:
            line_width = size*.15
        if self.highlighted:
            stroke_color = 'yellow'
        else:
            stroke_color = 'black'
        self.canvas_item.set_properties(line_width=line_width, stroke_color=stroke_color)

        if self._label is not None:
            if self._label_canvas_item is None:
                self._label_canvas_item = goocanvas.Text(visibility_threshold=0.5,
                                                         font="Sans Serif 10",
                                                         fill_color_rgba=0x808080ff,
                                                         alignment=pango.ALIGN_CENTER,
                                                         anchor=gtk.ANCHOR_N,
                                                         parent=self.visualizer.canvas.get_root_item(),
                                                         pointer_events=0)
                self._label_canvas_item.lower(None)

            self._label_canvas_item.set_properties(visibility=goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD,
                                                   text=self._label)
            self._update_position() 
開發者ID:ntu-dsi-dcn,項目名稱:ntu-dsi-dcn,代碼行數:37,代碼來源:core.py

示例2: _update_appearance

# 需要導入模塊: import base [as 別名]
# 或者: from base import transform_distance_simulation_to_canvas [as 別名]
def _update_appearance(self):
        """!
        Update the node aspect to reflect the selected/highlighted state

        @param self: class object.
        @return none
        """

        size = transform_distance_simulation_to_canvas(self._size)
        if self.svg_item is not None:
            alpha = 0x80
        else:
            alpha = 0xff
        fill_color_rgba = (self._color & 0xffffff00) | alpha
        self.canvas_item.set_properties(radius_x=size, radius_y=size,
                                        fill_color_rgba=fill_color_rgba)
        if self._selected:
            line_width = size*.3
        else:
            line_width = size*.15
        if self.highlighted:
            stroke_color = 'yellow'
        else:
            stroke_color = 'black'
        self.canvas_item.set_properties(line_width=line_width, stroke_color=stroke_color)

        if self._label is not None:
            if self._label_canvas_item is None:
                self._label_canvas_item = goocanvas.Text(visibility_threshold=0.5,
                                                         font="Sans Serif 10",
                                                         fill_color_rgba=0x808080ff,
                                                         alignment=pango.ALIGN_CENTER,
                                                         anchor=gtk.ANCHOR_N,
                                                         parent=self.visualizer.canvas.get_root_item(),
                                                         pointer_events=0)
                self._label_canvas_item.lower(None)

            self._label_canvas_item.set_properties(visibility=goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD,
                                                   text=self._label)
            self._update_position() 
開發者ID:KTH,項目名稱:royal-chaos,代碼行數:42,代碼來源:core.py

示例3: set_svg_icon

# 需要導入模塊: import base [as 別名]
# 或者: from base import transform_distance_simulation_to_canvas [as 別名]
def set_svg_icon(self, file_base_name, width=None, height=None, align_x=0.5, align_y=0.5):
        """
        Set a background SVG icon for the node.

        @param file_base_name: base file name, including .svg
        extension, of the svg file.  Place the file in the folder
        src/contrib/visualizer/resource.
        
        @param width: scale to the specified width, in meters
        @param width: scale to the specified height, in meters

        @param align_x: horizontal alignment of the icon relative to
        the node position, from 0 (icon fully to the left of the node)
        to 1.0 (icon fully to the right of the node)

        @param align_y: vertical alignment of the icon relative to the
        node position, from 0 (icon fully to the top of the node) to
        1.0 (icon fully to the bottom of the node)

        """
        if width is None and height is None:
            raise ValueError("either width or height must be given")
        rsvg_handle = svgitem.rsvg_handle_factory(file_base_name)
        x = self.canvas_item.props.center_x
        y = self.canvas_item.props.center_y
        self.svg_item = svgitem.SvgItem(x, y, rsvg_handle)
        self.svg_item.props.parent = self.visualizer.canvas.get_root_item()
        self.svg_item.props.pointer_events = 0
        self.svg_item.lower(None)
        self.svg_item.props.visibility = goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD
        if width is not None:
            self.svg_item.props.width = transform_distance_simulation_to_canvas(width)
        if height is not None:
            self.svg_item.props.height = transform_distance_simulation_to_canvas(height)

        #threshold1 = 10.0/self.svg_item.props.height
        #threshold2 = 10.0/self.svg_item.props.width
        #self.svg_item.props.visibility_threshold = min(threshold1, threshold2)

        self.svg_align_x = align_x
        self.svg_align_y = align_y
        self._update_svg_position(x, y)
        self._update_appearance() 
開發者ID:ntu-dsi-dcn,項目名稱:ntu-dsi-dcn,代碼行數:45,代碼來源:core.py

示例4: set_svg_icon

# 需要導入模塊: import base [as 別名]
# 或者: from base import transform_distance_simulation_to_canvas [as 別名]
def set_svg_icon(self, file_base_name, width=None, height=None, align_x=0.5, align_y=0.5):
        """!
        Set a background SVG icon for the node.

        @param file_base_name: base file name, including .svg
        extension, of the svg file.  Place the file in the folder
        src/contrib/visualizer/resource.
        
        @param width: scale to the specified width, in meters
        @param height: scale to the specified height, in meters

        @param align_x: horizontal alignment of the icon relative to
        the node position, from 0 (icon fully to the left of the node)
        to 1.0 (icon fully to the right of the node)

        @param align_y: vertical alignment of the icon relative to the
        node position, from 0 (icon fully to the top of the node) to
        1.0 (icon fully to the bottom of the node)

        @return a ValueError exception if invalid dimensions.

        """
        if width is None and height is None:
            raise ValueError("either width or height must be given")
        rsvg_handle = svgitem.rsvg_handle_factory(file_base_name)
        x = self.canvas_item.props.center_x
        y = self.canvas_item.props.center_y
        self.svg_item = svgitem.SvgItem(x, y, rsvg_handle)
        self.svg_item.props.parent = self.visualizer.canvas.get_root_item()
        self.svg_item.props.pointer_events = 0
        self.svg_item.lower(None)
        self.svg_item.props.visibility = goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD
        if width is not None:
            self.svg_item.props.width = transform_distance_simulation_to_canvas(width)
        if height is not None:
            self.svg_item.props.height = transform_distance_simulation_to_canvas(height)

        #threshold1 = 10.0/self.svg_item.props.height
        #threshold2 = 10.0/self.svg_item.props.width
        #self.svg_item.props.visibility_threshold = min(threshold1, threshold2)

        self.svg_align_x = align_x
        self.svg_align_y = align_y
        self._update_svg_position(x, y)
        self._update_appearance() 
開發者ID:KTH,項目名稱:royal-chaos,代碼行數:47,代碼來源:core.py


注:本文中的base.transform_distance_simulation_to_canvas方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。