Пример #1
0
def highlight_loops(view):
        """Takes a view, calculates its dominator tree, and highlights its loops."""
        
        if len(view.graph.nodes) == 0:
                MessageBox.showError(None, "Can not create dominator tree of empty views")
                return

        nodeListArray = GraphAlgorithms.getGraphLoops(view.graph)

        for nodeList in nodeListArray:
            for node2 in nodeList:
                c = node2.getColor()
                node2.setColor( java.awt.Color(c.getRed()-20, c.getGreen(), c.getBlue()))
                c2 = node2.getBorderColor()
                node2.setBorderColor( java.awt.Color( 255, 0, 0 )) #c2.getRed()+20, c2.getGreen()+20, c2.getBlue()))
Пример #2
0
def create_dominator_view(view):
	"""Takes a view, calculates its dominator tree, and creates a new view
	   that shows that dominator tree."""
	
	if len(view.graph.nodes) == 0:
		MessageBox.showError("Can not create dominator tree of empty views")
		return
	
	# Calculate the dominator tree
	dominator_tree = GraphAlgorithms.getDominatorTree(view.graph, findRoot(view.graph.nodes), None)
	
	try:
		# Create the new view
		tree_view = view.container.createView("Dominator Tree: '%s'" % view.name, "")
		
		# Copy all the nodes from the dominator tree into the new view
		createView(tree_view, dominator_tree.rootNode)
		
		return tree_view
	except CouldntSaveDataException:
		MessageBox.showError("Could not create the dominator tree view")
		return None
Пример #3
0
def create_dominator_view(view):
    """Takes a view, calculates its dominator tree, and creates a new view
	   that shows that dominator tree."""

    if len(view.graph.nodes) == 0:
        MessageBox.showError("Can not create dominator tree of empty views")
        return

    # Calculate the dominator tree
    dominator_tree = GraphAlgorithms.getDominatorTree(
        view.graph, findRoot(view.graph.nodes), None)

    try:
        # Create the new view
        tree_view = view.container.createView(
            "Dominator Tree: '%s'" % view.name, "")

        # Copy all the nodes from the dominator tree into the new view
        createView(tree_view, dominator_tree.rootNode)

        return tree_view
    except CouldntSaveDataException:
        MessageBox.showError("Could not create the dominator tree view")
        return None