def layout(node): node.img_style["size"] = 5 node.img_style["hz_line_width"] = 0 node.img_style["vt_line_width"] = 0 if node.is_leaf(): f = faces.AttrFace("name", fgcolor="steelblue", fsize=20) faces.add_face_to_node(f, node, 0, position="aligned") f = faces.AttrFace("name", fsize=15) faces.add_face_to_node(f, node, 0, position="branch-right") else: f = faces.TextFace("uno", fsize=8) for x in xrange(random.randint(1, 5)): faces.add_face_to_node(f, node, 0, position="branch-top") f = faces.TextFace("otromassssssssssss", fsize=8) for x in xrange(random.randint(1, 5)): faces.add_face_to_node(f, node, 0, position="branch-bottom") f = faces.CircleFace(20, "red") f.opacity = 0.3 faces.add_face_to_node(f, node, 0, position="float") f = faces.CircleFace(23, "blue") f.opacity = 0.3 faces.add_face_to_node(f, node, 0, position="float-behind")
def npr_layout(node): if node.is_leaf(): name = faces.AttrFace("name", fsize=12) faces.add_face_to_node(name, node, 0, position="branch-right") if hasattr(node, "sequence"): seq_face = faces.SeqFace(node.sequence, []) faces.add_face_to_node(seq_face, node, 0, position="aligned") if "alg_type" in node.features: faces.add_face_to_node(faces.AttrFace("alg_type", fsize=8), node, 0, position="branch-top") ttype = faces.AttrFace("tree_type", fsize=8, fgcolor="DarkBlue") faces.add_face_to_node(ttype, node, 0, position="branch-top") #ttype.background.color = "DarkOliveGreen" node.img_style["size"] = 20 node.img_style["fgcolor"] = "red" if "treemerger_rf" in node.features: faces.add_face_to_node(faces.AttrFace("treemerger_rf", fsize=8), node, 0, position="branch-bottom") support_radius = (1.0 - node.support) * 50 if not node.is_leaf() and support_radius > 1: support_face = faces.CircleFace(support_radius, "red") faces.add_face_to_node(support_face, node, 0, position="float-behind") support_face.opacity = 0.25 faces.add_face_to_node(faces.AttrFace("support", fsize=8), node, 0, position="branch-bottom") if "clean_alg_mean_identn" in node.features: identity = node.clean_alg_mean_identn elif "alg_mean_identn" in node.features: identity = node.alg_mean_identn if "highlighted" in node.features: node.img_style["bgcolor"] = "LightCyan" if "npr_iter" in node.features: node.img_style["size"] = 50 if "improve" in node.features: color = "orange" if float(node.improve) < 0 else "green" if float(node.improve) == 0: color = "blue" support_face = faces.CircleFace(200, color) faces.add_face_to_node(support_face, node, 0, position="float-behind")
def sphere_map(node): # Creates a random color sphere face that will be floating over nodes bubble = faces.CircleFace(random.randint(5, 40), random_color(), "sphere") bubble.opacity = 0.7 faces.add_face_to_node(bubble, node, 0, position="float")
position="aligned") I.aligned_header.add_face(faces.TextFace("H1"), 0) I.aligned_header.add_face(faces.TextFace("H1"), 1) I.aligned_header.add_face(faces.TextFace("H1"), 2) I.aligned_header.add_face(faces.TextFace("H1111111111111"), 3) I.aligned_header.add_face(faces.TextFace("H1"), 4) I.aligned_foot.add_face(faces.TextFace("FO1"), 0) I.aligned_foot.add_face(faces.TextFace("FO1"), 1) I.aligned_foot.add_face(faces.TextFace("FO1"), 2) I.aligned_foot.add_face(faces.TextFace("F1"), 3) I.aligned_foot.add_face(faces.TextFace("FO1"), 4) I.legend.add_face(faces.CircleFace(30, random_color(), "sphere"), 0) I.legend.add_face(faces.CircleFace(30, random_color(), "sphere"), 0) I.legend.add_face(faces.TextFace("HOLA"), 1) I.legend.add_face(faces.TextFace("HOLA"), 1) # Creates a random tree with 10 leaves t2 = Tree() t2.populate(10) # Creates a fixed NodeStyle object containing a TreeFace (A tree image # as a face within another tree image) # t.add_face(faces.TreeFace(t2, I), "branch-right", 0) # Attach the fixed style to the first child of the root node # t.children[0].img_style = style I.rotation = 90