Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
GraphVizPluginApi | 39 | 10 | 0% | 10 | 20 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software 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. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package com.xpn.xwiki.plugin.graphviz; | |
21 | ||
22 | import java.io.IOException; | |
23 | ||
24 | import com.xpn.xwiki.XWikiContext; | |
25 | import com.xpn.xwiki.plugin.PluginApi; | |
26 | ||
27 | /** | |
28 | * Plugin which wraps the <a href="http://graphviz.org/">GraphViz</a> <tt>dot</tt> executable; transforming dot source | |
29 | * files (representing graphs) into images, image maps, or other output formats supported by GraphViz. | |
30 | * <p> | |
31 | * See http://www.graphviz.org/doc/info/lang.html for the dot language specification. See | |
32 | * http://www.graphviz.org/doc/info/output.html for the possible output formats | |
33 | * </p> | |
34 | * | |
35 | * @deprecated the plugin technology is deprecated | |
36 | * @version $Id: e2cd99dd342b331873de2e7a5f1410e78c5cca14 $ | |
37 | */ | |
38 | @Deprecated | |
39 | public class GraphVizPluginApi extends PluginApi<GraphVizPlugin> | |
40 | { | |
41 | /** | |
42 | * Default plugin API constructor. | |
43 | * | |
44 | * @param plugin the wrapped plugin instance | |
45 | * @param context the current request context | |
46 | */ | |
47 | 0 | public GraphVizPluginApi(GraphVizPlugin plugin, XWikiContext context) |
48 | { | |
49 | 0 | super(plugin, context); |
50 | } | |
51 | ||
52 | /** | |
53 | * Return the inner plugin object, if the user has the required programming rights. | |
54 | * | |
55 | * @return The wrapped plugin object. | |
56 | */ | |
57 | 0 | public GraphVizPlugin getPlugin() |
58 | { | |
59 | 0 | return getInternalPlugin(); |
60 | } | |
61 | ||
62 | /** | |
63 | * Executes GraphViz and return the content of the resulting image (PNG format). | |
64 | * | |
65 | * @param content the dot source code | |
66 | * @param dot which engine to execute: {@code dot} if {@code true}, {@code neato} if {@code false} | |
67 | * @return the content of the generated image | |
68 | * @throws IOException if writing the input or output files to the disk fails | |
69 | */ | |
70 | 0 | public byte[] getDotImage(String content, boolean dot) throws IOException |
71 | { | |
72 | 0 | return getProtectedPlugin().getDotImage(content, dot); |
73 | } | |
74 | ||
75 | /** | |
76 | * Executes GraphViz and return the content of the resulting image (PNG format). | |
77 | * | |
78 | * @param content the dot source code | |
79 | * @param extension the output file extension | |
80 | * @param dot which engine to execute: {@code dot} if {@code true}, {@code neato} if {@code false} | |
81 | * @return the content of the generated file | |
82 | * @throws IOException if writing the input or output files to the disk fails | |
83 | */ | |
84 | 0 | public byte[] getDotImage(String content, String extension, boolean dot) throws IOException |
85 | { | |
86 | 0 | return getProtectedPlugin().getDotImage(content, extension, dot); |
87 | } | |
88 | ||
89 | /** | |
90 | * Executes GraphViz and returns the URL for the produced file, a PNG image. | |
91 | * | |
92 | * @param content the dot source | |
93 | * @param dot which engine to execute: {@code dot} if {@code true}, {@code neato} if {@code false} | |
94 | * @return the URL which can be used to access the generated image | |
95 | * @throws IOException if writing the input or output files to the disk fails | |
96 | */ | |
97 | 0 | public String getDotImageURL(String content, boolean dot) throws IOException |
98 | { | |
99 | 0 | return getProtectedPlugin().getDotImageURL(content, dot, getXWikiContext()); |
100 | } | |
101 | ||
102 | /** | |
103 | * Executes GraphViz, writes the resulting image (PNG format) in a temporary file on disk, and returns the filename. | |
104 | * | |
105 | * @param content the dot source code | |
106 | * @param dot which engine to execute: {@code dot} if {@code true}, {@code neato} if {@code false} | |
107 | * @return the name of the file where the generated output is stored | |
108 | * @throws IOException if writing the input or output files to the disk fails | |
109 | */ | |
110 | 0 | public String writeDotImage(String content, boolean dot) throws IOException |
111 | { | |
112 | 0 | return getProtectedPlugin().writeDotImage(content, dot); |
113 | } | |
114 | ||
115 | /** | |
116 | * Executes GraphViz, writes the resulting image (in the requested format) in a temporary file on disk, and returns | |
117 | * the filename. | |
118 | * | |
119 | * @param content the dot source code | |
120 | * @param extension the output file extension | |
121 | * @param dot which engine to execute: {@code dot} if {@code true}, {@code neato} if {@code false} | |
122 | * @return the name of the file where the generated output is stored | |
123 | * @throws IOException if writing the input or output files to the disk fails | |
124 | */ | |
125 | 0 | public String writeDotImage(String content, String extension, boolean dot) throws IOException |
126 | { | |
127 | 0 | return getProtectedPlugin().writeDotImage(content, extension, dot); |
128 | } | |
129 | ||
130 | /** | |
131 | * Executes GraphViz and writes the resulting image (PNG format) into the response. | |
132 | * | |
133 | * @param content the dot source code | |
134 | * @param dot which engine to execute: {@code dot} if {@code true}, {@code neato} if {@code false} | |
135 | * @throws IOException if writing the input or output files to the disk fails, or if writing the response body fails | |
136 | */ | |
137 | 0 | public void outputDotImage(String content, boolean dot) throws IOException |
138 | { | |
139 | 0 | getProtectedPlugin().outputDotImage(content, "png", dot, getXWikiContext()); |
140 | } | |
141 | ||
142 | /** | |
143 | * Executes GraphViz and writes the resulting image (in the requested format) into the response. | |
144 | * | |
145 | * @param content the dot source code | |
146 | * @param extension the output file extension | |
147 | * @param dot which engine to execute: {@code dot} if {@code true}, {@code neato} if {@code false} | |
148 | * @throws IOException if writing the input or output files to the disk fails, or if writing the response body fails | |
149 | */ | |
150 | 0 | public void outputDotImage(String content, String extension, boolean dot) throws IOException |
151 | { | |
152 | 0 | getProtectedPlugin().outputDotImage(content, extension, dot, getXWikiContext()); |
153 | } | |
154 | ||
155 | /** | |
156 | * Discard all generated output from the temporary file storage. | |
157 | */ | |
158 | 0 | public void flushCache() |
159 | { | |
160 | 0 | getProtectedPlugin().flushCache(); |
161 | } | |
162 | } |