3 * Copyright (C) 2008 Florian Brosch
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Florian Brosch <flo.brosch@gmail.com>
23 [CCode (cname
= "valadoc_compat_gvc_init")]
24 extern void valadoc_gvc_init ();
26 public class Valadoc
.Charts
.Chart
: Api
.Visitor
{
27 protected Gvc
.Context context
;
28 protected Gvc
.Graph graph
;
29 protected Factory factory
;
35 public Chart (Factory factory
, Api
.Node node
) {
36 graph
= factory
.create_graph (node
);
37 this
.factory
= factory
;
41 public void save (string file_name
, string file_type
= "png") {
42 if (context
== null) {
43 context
= factory
.create_context (graph
);
45 context
.render_filename (graph
, file_type
, file_name
);
48 public void write (GLib
.FileStream file
, string file_type
) {
49 if (context
== null) {
50 context
= factory
.create_context (graph
);
52 context
.render (graph
, file_type
, file
);
55 public uint8[]?
write_buffer (string file_type
) {
56 if (context
== null) {
57 context
= factory
.create_context (graph
);
62 /* This will return null in data if it fails. */
63 context
.render_data (graph
, file_type
, out data
);
68 if (context
!= null) {
69 context
.free_layout (graph
);