Python svgitem.SvgItem() Examples
The following are 11
code examples of svgitem.SvgItem().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
svgitem
, or try the search function
.
Example #1
Source File: core.py From ntu-dsi-dcn with GNU General Public License v2.0 | 4 votes |
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()
Example #2
Source File: core.py From IEEE-802.11ah-ns-3 with GNU General Public License v2.0 | 4 votes |
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()
Example #3
Source File: core.py From ns3-load-balance with GNU General Public License v2.0 | 4 votes |
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()
Example #4
Source File: core.py From 802.11ah-ns3 with GNU General Public License v2.0 | 4 votes |
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()
Example #5
Source File: core.py From ns3-rdma with GNU General Public License v2.0 | 4 votes |
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()
Example #6
Source File: core.py From royal-chaos with MIT License | 4 votes |
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()
Example #7
Source File: core.py From ns-3-dev-git with GNU General Public License v2.0 | 4 votes |
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()
Example #8
Source File: core.py From CRE-NS3 with GNU General Public License v2.0 | 4 votes |
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()
Example #9
Source File: core.py From ns3-ecn-sharp with GNU General Public License v2.0 | 4 votes |
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()
Example #10
Source File: core.py From ns3-802.11ad with GNU General Public License v2.0 | 4 votes |
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()
Example #11
Source File: core.py From Tocino with GNU General Public License v2.0 | 4 votes |
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()