Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
SVGRasterizer | 38 | 0 | - | 0 | 0 |
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 org.xwiki.platform.svg; | |
21 | ||
22 | import org.xwiki.component.annotation.Role; | |
23 | import org.xwiki.model.reference.DocumentReference; | |
24 | import org.xwiki.resource.temporary.TemporaryResourceReference; | |
25 | import org.xwiki.stability.Unstable; | |
26 | ||
27 | import java.io.File; | |
28 | import java.io.IOException; | |
29 | ||
30 | /** | |
31 | * Utilities for working with SVG images. | |
32 | * | |
33 | * @version $Id: fefca23c60ee08ef978a96a36ac2884d91219298 $ | |
34 | * @since 8.0M1 | |
35 | */ | |
36 | @Role | |
37 | @Unstable("New API introduced in 8.0") | |
38 | public interface SVGRasterizer | |
39 | { | |
40 | /** | |
41 | * Rasterize an image as PNG into a temporary file. | |
42 | * | |
43 | * @param content the SVG image | |
44 | * @param width the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size | |
45 | * is used | |
46 | * @param height the desired height of the raster image, in pixels; if 0 or a negative number, the image's native | |
47 | * size is used | |
48 | * @return the file where the PNG is stored | |
49 | * @throws IOException if temporary files can't be accessed | |
50 | */ | |
51 | File rasterizeToTemporaryFile(String content, int width, int height) throws IOException; | |
52 | ||
53 | /** | |
54 | * Rasterize an image as PNG into a temporary resource belonging to the current document, accessible through the | |
55 | * "tmp" resource URL handler. | |
56 | * | |
57 | * @param content the SVG image | |
58 | * @param width the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size | |
59 | * is used | |
60 | * @param height the desired height of the raster image, in pixels; if 0 or a negative number, the image's native | |
61 | * size is used | |
62 | * @return the temporary resource where the PNG is stored | |
63 | * @throws IOException if temporary files can't be accessed | |
64 | */ | |
65 | TemporaryResourceReference rasterizeToTemporaryResource(String content, int width, int height) throws IOException; | |
66 | ||
67 | /** | |
68 | * Rasterize an image as PNG into a temporary resource belonging to the specified document, accessible through the | |
69 | * "tmp" resource URL handler. | |
70 | * | |
71 | * @param content the SVG image | |
72 | * @param width the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size | |
73 | * is used | |
74 | * @param height the desired height of the raster image, in pixels; if 0 or a negative number, the image's native | |
75 | * size is used | |
76 | * @param targetContext the document which will "own" the new temporary resource | |
77 | * @return the temporary resource where the PNG is stored | |
78 | * @throws IOException if temporary files can't be accessed | |
79 | */ | |
80 | TemporaryResourceReference rasterizeToTemporaryResource(String content, int width, int height, | |
81 | DocumentReference targetContext) throws IOException; | |
82 | ||
83 | /** | |
84 | * Rasterize an image as PNG into the current response. | |
85 | * | |
86 | * @param content the SVG image | |
87 | * @param width the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size | |
88 | * is used | |
89 | * @param height the desired height of the raster image, in pixels; if 0 or a negative number, the image's native | |
90 | * size is used | |
91 | * @throws IOException if writing the response fails | |
92 | */ | |
93 | void rasterizeToResponse(String content, int width, int height) throws IOException; | |
94 | } |