Skip to content

Commit

Permalink
disabled icon logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael5601 committed Dec 18, 2024
1 parent c78cac3 commit 44692e8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public ImageData getImageData(int zoom) {
InputStream in = getStream(zoom);
if (in != null) {
try (BufferedInputStream stream = new BufferedInputStream(in)) {
return new ImageData(stream, zoom);
return new ImageData(stream, zoom, SWT.IMAGE_COPY);
} catch (SWTException e) {
if (e.code != SWT.ERROR_INVALID_IMAGE) {
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,27 @@ public ImageData getImageData(int zoom) {
return URLImageDescriptor.getImageData(url, zoom);
}

@Override
public ImageData getCustomizedImageData(int zoom, int flag) {
return URLImageDescriptor.getCustomizedImageData(url, zoom, flag);
}

@Override
public boolean supportsRasterizationFlag(int flag) {
boolean supportsFlag = flag == SWT.IMAGE_DISABLE || flag == SWT.IMAGE_GRAY || flag == SWT.IMAGE_COPY;
URL tempURL = getURL(url);
SVGRasterizer rasterizer = SVGRasterizerRegistry.getRasterizer();
if (tempURL != null && rasterizer != null) {
try (InputStream in = getStream(tempURL)) {
if (rasterizer.isSVGFile(in) && supportsFlag) {
return true;
}
} catch (IOException e) {
return false;
}
}
return false;
}
}

private static long cumulativeTime;
Expand Down Expand Up @@ -168,15 +189,36 @@ private static ImageData getImageData(String url, int zoom) {
return null;
}

private static ImageData getCustomizedImageData(String url, int zoom, int flag) {
URL tempURL = getURL(url);
if (tempURL != null) {
SVGRasterizer rasterizer = SVGRasterizerRegistry.getRasterizer();
if (rasterizer != null) {
try (InputStream in = getStream(tempURL)) {
if (rasterizer.isSVGFile(in)) {
return getImageData(tempURL, zoom, flag);
}
} catch (IOException e) {
// ignore.
}
}
}
return null;
}

private static ImageData getImageData(URL url) {
return getImageData(url, 0);
return getImageData(url, 0, SWT.IMAGE_COPY);
}

private static ImageData getImageData(URL url, int zoom) {
return getImageData(url, zoom, SWT.IMAGE_COPY);
}

private static ImageData getImageData(URL url, int zoom, int flag) {
ImageData result = null;
try (InputStream in = getStream(url)) {
if (in != null) {
result = new ImageData(in, zoom);
result = new ImageData(in, zoom, flag);
}
} catch (SWTException e) {
if (e.code != SWT.ERROR_INVALID_IMAGE) {
Expand Down

0 comments on commit 44692e8

Please sign in to comment.