コード例 #1
0
ファイル: sumtree.py プロジェクト: mdrasmus/summon
    def _setup_tree(self):
        """configure a new tree"""
        
        # setup layout
        if self.layout is None:
            if self.xscale > 0:
                self.layout = treelib.layout_tree(self.tree, self.xscale, -1.0)
            else:
                self.layout = treelib.layout_tree(
                    self.tree, 1.0, -1.0, minlen=1.0)
        

        # setup branch labels
        if self.show_boot:
            for node in self.tree:
                if node.data.get("boot", 0) > 0:
                    self.branch_labels[node.name] = (
                        "%.2f" % node.data["boot"] + 
                        self.branch_labels.get(node.name, ""))
                
        
        # setup colors
        self.set_colors(self.tree)

        # setup labels
        self._label_viewer.set_tree(self.tree, self.layout)
コード例 #2
0
ファイル: matrix.py プロジェクト: mdrasmus/summon
    def open_tree_windows(self):
        """startup tree windows"""

        x, y = self.win.get_position()
        w, h = self.win.get_size()
        deco = self.win.get_decoration()

        treesize = 100

        # open row tree
        if self.rtree:
            if self.tree_windows[0] != None and \
               self.tree_windows[0].win.is_open():
                left = self.tree_windows[0]
                left.show()
            else:
                if self.use_tree_lens[0]:
                    layout = treelib.layout_tree(self.rtree, 1, -1)
                else:
                    layout = treelib.layout_tree_hierarchical(self.rtree, 1, -1)
                offset = max(c[1] for c in layout.itervalues())
                boundary1 = min(c[0] for c in layout.itervalues()) - 1.0
                boundary2 = max(c[0] for c in layout.itervalues())
                left = sumtree.SumTree(self.rtree, name="row tree", 
                                       show_labels=False,
                                       xscale=0, layout=layout,
                                       winsize=(treesize, h),
                                       winpos=(x-treesize-deco[0], y))
                left.show()
                #left.win.set_bgcolor(*self.win.get_bgcolor())
                left.win.set_visible(boundary1, 0, boundary2, 1)
                
                if not self.use_tree_lens[0]:
                    left.win.set_boundary(boundary1, -util.INF, boundary2, util.INF)
                
                self.row_ensemble.add_window(left.win, 0, coordy=offset)
        else:
            left = None
        
        # open col tree
        if self.ctree:
            if self.tree_windows[1] != None and \
               self.tree_windows[1].win.is_open():
                top = self.tree_windows[1]
                top.show()
            else:
                if self.use_tree_lens[1]:
                    layout = treelib.layout_tree(self.ctree, 1, 1)
                else:
                    layout = treelib.layout_tree_hierarchical(self.ctree, 1, 1)
                offset = min(c[1] for c in layout.itervalues())
                boundary1 = min(c[0] for c in layout.itervalues()) - 1.0
                boundary2 = max(c[0] for c in layout.itervalues()) 
                top = sumtree.SumTree(self.ctree, "col tree", 
                                      show_labels=False,
                                      xscale=0, layout=layout,
                                      vertical=True,
                                      winsize=(w, treesize),
                                      winpos=(x, y-treesize-deco[1]))
                top.show()
                #top.win.set_bgcolor(*self.win.get_bgcolor())
                top.win.set_visible(0, -boundary1, 1, -boundary2)
                
                if not self.use_tree_lens[1]:
                    top.win.set_boundary(-util.INF, -boundary1, util.INF, -boundary2)
                
                self.col_ensemble.add_window(top.win, 0, coordx=offset)
        else:
            top = None
        
        self.tree_windows = [left, top]