Skip to content

Commit e067170

Browse files
committed
cleanup
1 parent 9e5a09c commit e067170

File tree

10 files changed

+173
-222
lines changed

10 files changed

+173
-222
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 Vector Informatik GmbH and others.
3+
*
4+
* This program and the accompanying materials are made available under the terms of the Eclipse
5+
* Public License 2.0 which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Michael Bangas (Vector Informatik GmbH) - initial API and implementation
12+
*******************************************************************************/
13+
package org.eclipse.swt.graphics;
14+
15+
import java.util.*;
16+
17+
/**
18+
* @since 3.131
19+
*/
20+
public interface ImageDataAtSizeProvider extends ImageDataProvider {
21+
22+
Optional<ImageData> getImageData(int targetWidth, int targetHeight);
23+
24+
}

bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageDataLoader.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ public static boolean canLoadAtZoom(InputStream stream, int fileZoom, int target
4141
return ImageLoader.canLoadAtZoom(stream, fileZoom, targetZoom);
4242
}
4343

44-
public static ElementAtZoom<ImageData> load(InputStream stream, int fileZoom, int targetZoom) {
45-
List<ElementAtZoom<ImageData>> data = new ImageLoader().load(stream, fileZoom, targetZoom);
46-
if (data.isEmpty()) SWT.error(SWT.ERROR_INVALID_IMAGE);
47-
return data.get(0);
48-
}
49-
5044
public static boolean canLoadAtZoom(String filename, int fileZoom, int targetZoom) {
5145
return ImageLoader.canLoadAtZoom(filename, fileZoom, targetZoom);
5246
}
5347

54-
public static ElementAtZoom<ImageData> load(String filename, int fileZoom, int targetZoom) {
55-
List<ElementAtZoom<ImageData>> data = new ImageLoader().load(filename, fileZoom, targetZoom);
48+
public static ElementAtZoom<ImageData> loadByZoom(InputStream stream, int fileZoom, int targetZoom) {
49+
List<ElementAtZoom<ImageData>> data = new ImageLoader().loadByZoom(stream, fileZoom, targetZoom);
50+
if (data.isEmpty()) SWT.error(SWT.ERROR_INVALID_IMAGE);
51+
return data.get(0);
52+
}
53+
54+
public static ElementAtZoom<ImageData> loadByZoom(String filename, int fileZoom, int targetZoom) {
55+
List<ElementAtZoom<ImageData>> data = new ImageLoader().loadByZoom(filename, fileZoom, targetZoom);
5656
if (data.isEmpty()) SWT.error(SWT.ERROR_INVALID_IMAGE);
5757
return data.get(0);
5858
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 Vector Informatik GmbH and others.
3+
*
4+
* This program and the accompanying materials are made available under the terms of the Eclipse
5+
* Public License 2.0 which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Michael Bangas (Vector Informatik GmbH) - initial API and implementation
12+
*******************************************************************************/
13+
package org.eclipse.swt.graphics;
14+
15+
import java.util.*;
16+
17+
/**
18+
* @since 3.131
19+
*/
20+
public interface ImageFileNameAtSizeProvider extends ImageFileNameProvider {
21+
22+
/**
23+
* Returns the image file path most suitable for rendering at the given target size.
24+
*
25+
*/
26+
Optional<String> getImagePath(int targetWidth, int targetHeight);
27+
28+
}

bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoader.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ void reset() {
151151
* </ul>
152152
*/
153153
public ImageData[] load(InputStream stream) {
154-
load(stream, FileFormat.DEFAULT_ZOOM, FileFormat.DEFAULT_ZOOM);
154+
loadByZoom(stream, FileFormat.DEFAULT_ZOOM, FileFormat.DEFAULT_ZOOM);
155155
return data;
156156
}
157157

158-
List<ElementAtZoom<ImageData>> load(InputStream stream, int fileZoom, int targetZoom) {
158+
List<ElementAtZoom<ImageData>> loadByZoom(InputStream stream, int fileZoom, int targetZoom) {
159159
if (stream == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
160160
reset();
161161
List<ElementAtZoom<ImageData>> images = NativeImageLoader.load(new ElementAtZoom<>(stream, fileZoom), this, targetZoom);
@@ -195,14 +195,14 @@ static boolean canLoadAtZoom(InputStream stream, int fileZoom, int targetZoom) {
195195
* </ul>
196196
*/
197197
public ImageData[] load(String filename) {
198-
load(filename, FileFormat.DEFAULT_ZOOM, FileFormat.DEFAULT_ZOOM);
198+
loadByZoom(filename, FileFormat.DEFAULT_ZOOM, FileFormat.DEFAULT_ZOOM);
199199
return data;
200200
}
201201

202-
List<ElementAtZoom<ImageData>> load(String filename, int fileZoom, int targetZoom) {
202+
List<ElementAtZoom<ImageData>> loadByZoom(String filename, int fileZoom, int targetZoom) {
203203
if (filename == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
204204
try (InputStream stream = new FileInputStream(filename)) {
205-
return load(stream, fileZoom, targetZoom);
205+
return loadByZoom(stream, fileZoom, targetZoom);
206206
} catch (IOException e) {
207207
SWT.error(SWT.ERROR_IO, e);
208208
}

bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/SizeAwareImageDataProvider.java

Lines changed: 0 additions & 12 deletions
This file was deleted.

bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/SizeAwareImageFileNameProvider.java

Lines changed: 0 additions & 16 deletions
This file was deleted.

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ private void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHei
11341134
int destWidth, int destHeight, int imageZoom, int scaledImageZoom) {
11351135
Rectangle src;
11361136
Rectangle dest;
1137-
if(image.createdWithTargetSize()) {
1137+
if (image.createdWithTargetSize()) {
11381138
dest = new Rectangle(destX, destY, destWidth, destHeight);
11391139
src = dest;
11401140
} else {
@@ -1256,7 +1256,7 @@ private void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int src
12561256

12571257
private void drawWithTempHandle(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY,
12581258
int destWidth, int destHeight, boolean simple) {
1259-
srcImage.drawOnGCAtTargetSize(tempImageHandle -> {
1259+
srcImage.executeOnImageHandleAtSize(tempImageHandle -> {
12601260
switch (srcImage.type) {
12611261
case SWT.BITMAP:
12621262
drawBitmap(srcImage, tempImageHandle, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight,

0 commit comments

Comments
 (0)