|
39 | 39 | import org.eclipse.swt.graphics.ImageData;
|
40 | 40 | import org.eclipse.swt.graphics.ImageDataProvider;
|
41 | 41 | import org.eclipse.swt.graphics.ImageFileNameProvider;
|
42 |
| -import org.eclipse.swt.graphics.SVGRasterizer; |
43 |
| -import org.eclipse.swt.graphics.SVGRasterizerRegistry; |
44 | 42 |
|
45 | 43 | /**
|
46 | 44 | * An ImageDescriptor that gets its information from a URL. This class is not
|
@@ -101,6 +99,22 @@ public ImageData getImageData(int zoom) {
|
101 | 99 | return URLImageDescriptor.getImageData(url, zoom);
|
102 | 100 | }
|
103 | 101 |
|
| 102 | + @Override |
| 103 | + public ImageData getCustomizedImageData(int zoom, int flag) { |
| 104 | + return URLImageDescriptor.getCustomizedImageData(url, zoom, flag); |
| 105 | + } |
| 106 | + |
| 107 | + @Override |
| 108 | + public boolean supportsRasterizationFlag(int flag) { |
| 109 | + boolean supportsFlag = flag == SWT.IMAGE_DISABLE || flag == SWT.IMAGE_GRAY || flag == SWT.IMAGE_COPY; |
| 110 | + URL tempURL = getURL(url); |
| 111 | + if (tempURL != null) { |
| 112 | + if (tempURL.toString().endsWith(".svg") && supportsFlag) { //$NON-NLS-1$ |
| 113 | + return true; |
| 114 | + } |
| 115 | + } |
| 116 | + return false; |
| 117 | + } |
104 | 118 | }
|
105 | 119 |
|
106 | 120 | private static long cumulativeTime;
|
@@ -168,15 +182,31 @@ private static ImageData getImageData(String url, int zoom) {
|
168 | 182 | return null;
|
169 | 183 | }
|
170 | 184 |
|
| 185 | + private static ImageData getCustomizedImageData(String url, int zoom, int flag) { |
| 186 | + URL tempURL = getURL(url); |
| 187 | + if (tempURL != null) { |
| 188 | + try (InputStream in = getStream(tempURL)) { |
| 189 | + return getImageData(tempURL, zoom, flag); |
| 190 | + } catch (IOException e) { |
| 191 | + // ignore. |
| 192 | + } |
| 193 | + } |
| 194 | + return null; |
| 195 | + } |
| 196 | + |
171 | 197 | private static ImageData getImageData(URL url) {
|
172 |
| - return getImageData(url, 0); |
| 198 | + return getImageData(url, 0, SWT.IMAGE_COPY); |
173 | 199 | }
|
174 | 200 |
|
175 | 201 | private static ImageData getImageData(URL url, int zoom) {
|
| 202 | + return getImageData(url, zoom, SWT.IMAGE_COPY); |
| 203 | + } |
| 204 | + |
| 205 | + private static ImageData getImageData(URL url, int zoom, int flag) { |
176 | 206 | ImageData result = null;
|
177 | 207 | try (InputStream in = getStream(url)) {
|
178 | 208 | if (in != null) {
|
179 |
| - result = new ImageData(in, zoom); |
| 209 | + result = new ImageData(in, zoom, flag); |
180 | 210 | }
|
181 | 211 | } catch (SWTException e) {
|
182 | 212 | if (e.code != SWT.ERROR_INVALID_IMAGE) {
|
|
0 commit comments