summaryrefslogtreecommitdiff
path: root/libvaladoc/charts/simplechartfactory.vala
blob: 06da97e133553078179ddf111074ce4193420379 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* simplechartfactory.vala
 *
 * Copyright (C) 2008  Florian Brosch
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 * Author:
 * 	Florian Brosch <flo.brosch@gmail.com>
 */



public class Valadoc.Charts.SimpleFactory : Charts.Factory {
	protected virtual Gvc.Node configure_type (Gvc.Node node, Api.Node item) {
 		node.safe_set ("shape", "box", "");
		node.safe_set ("fontname", "Times", "");
		node.safe_set ("label", item.get_full_name (), "");
		return node;
	}

	public override Gvc.Graph create_graph (Api.Node item) {
		#if WITH_CGRAPH
		var graph = new Gvc.Graph (item.get_full_name (), Gvc.Agdirected, 0);
		#else
		var graph = new Gvc.Graph (item.get_full_name (), Gvc.GraphKind.AGDIGRAPH);
		#endif
		return graph;
	}

	public override Gvc.Context create_context (Gvc.Graph graph) {
		var context = new Gvc.Context ();
		context.layout_jobs (graph);
		context.layout (graph, "dot");
		return context;
	}

	public override Gvc.Node create_class (Gvc.Graph graph, Api.Class item) {
		var node = configure_type (create_type (graph, item), item);
		node.safe_set ("style", "bold", "");
		return node;
	}

	public override Gvc.Node create_struct (Gvc.Graph graph, Api.Struct item) {
		var node = configure_type (create_type (graph, item), item);
		node.safe_set ("style", "bold", "");
		return node;
	}

	public override Gvc.Node create_interface (Gvc.Graph graph, Api.Interface item) {
		return configure_type (create_type (graph, item), item);
	}

	public override Gvc.Node create_enum (Gvc.Graph graph, Api.Enum item) {
		return configure_type (create_type (graph, item), item);
	}

	public override Gvc.Node create_delegate (Gvc.Graph graph, Api.Delegate item) {
		return configure_type (create_type (graph, item), item);
	}

	public override Gvc.Node create_errordomain (Gvc.Graph graph, Api.ErrorDomain item) {
		return configure_type (create_type (graph, item), item);
	}

	public override Gvc.Node create_namespace (Gvc.Graph graph, Api.Namespace item) {
		return configure_type (create_type (graph, item), item);
	}

	public override Gvc.Edge add_children (Gvc.Graph graph, Gvc.Node parent, Gvc.Node child) {
		var edge = graph.create_edge (parent, child);
		edge.safe_set ("dir", "back", "");
		return edge;
	}
}