Skip to content

Commit 7737c7b

Browse files
Rect
1 parent 3e30a45 commit 7737c7b

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,11 @@ private void createRepFromSourceAndApplyFlag(NSBitmapImageRep srcRep, int srcWid
527527
* </ul>
528528
*
529529
* @see #dispose()
530+
*
531+
* @deprecated use {@link Image#Image(Device, int, int)} instead
532+
* @since 3.130
530533
*/
534+
@Deprecated(since = "2025-05", forRemoval = true)
531535
public Image(Device device, Rectangle bounds) {
532536
super(device);
533537
if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,11 @@ public Image(Device device, Image srcImage, int flag) {
403403
* </ul>
404404
*
405405
* @see #dispose()
406+
*
407+
* @deprecated use {@link Image#Image(Device, int, int)} instead
408+
* @since 3.130
406409
*/
410+
@Deprecated(since = "2025-05", forRemoval = true)
407411
public Image(Device device, Rectangle bounds) {
408412
super(device);
409413
if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public Image(Device device, Image srcImage, int flag) {
342342
* @deprecated use {@link Image#Image(Device, int, int)} instead
343343
* @since 3.130
344344
*/
345-
@Deprecated
345+
@Deprecated(since = "2025-05", forRemoval = true)
346346
public Image(Device device, Rectangle bounds) {
347347
super(device);
348348
if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Image.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,40 +119,41 @@ public void test_ConstructorLorg_eclipse_swt_graphics_DeviceII() {
119119
image.dispose();
120120
}
121121

122+
@SuppressWarnings("deprecation")
122123
@Test
123124
public void test_ConstructorLorg_eclipse_swt_graphics_DeviceLorg_eclipse_swt_graphics_Rectangle() {
124125
Image image;
125126
IllegalArgumentException e;
126127
Rectangle bounds1 = null;
127-
e = assertThrows(IllegalArgumentException.class, () -> new Image(display, bounds1.width, bounds1.height));
128+
e = assertThrows(IllegalArgumentException.class, () -> new Image(display, bounds1));
128129
assertSWTProblem("Incorrect exception thrown for rectangle == null", SWT.ERROR_NULL_ARGUMENT, e);
129130

130131
Rectangle bounds2 = new Rectangle(0, 0, -1, 10);
131-
e = assertThrows(IllegalArgumentException.class, () -> new Image(display, bounds2.width, bounds2.height));
132+
e = assertThrows(IllegalArgumentException.class, () -> new Image(display, bounds2));
132133
assertSWTProblem("Incorrect exception thrown for width < 0", SWT.ERROR_INVALID_ARGUMENT, e);
133134

134135
Rectangle bounds3 = new Rectangle(0, 0, 0, 10);
135-
e = assertThrows(IllegalArgumentException.class, () -> new Image(display, bounds3.width, bounds3.height));
136+
e = assertThrows(IllegalArgumentException.class, () -> new Image(display, bounds3));
136137
assertSWTProblem("Incorrect exception thrown for width == 0", SWT.ERROR_INVALID_ARGUMENT, e);
137138

138139
Rectangle bounds4 = new Rectangle(0, 0, 10, -1);
139-
e = assertThrows(IllegalArgumentException.class, () -> new Image(display, bounds4.width, bounds4.height));
140+
e = assertThrows(IllegalArgumentException.class, () -> new Image(display, bounds4));
140141
assertSWTProblem("Incorrect exception thrown for height < 0", SWT.ERROR_INVALID_ARGUMENT, e);
141142

142143
Rectangle bounds5 = new Rectangle(0, 0, 10, 0);
143-
e = assertThrows(IllegalArgumentException.class, () -> new Image(display, bounds5.width, bounds5.height));
144+
e = assertThrows(IllegalArgumentException.class, () -> new Image(display, bounds5));
144145
assertSWTProblem("Incorrect exception thrown for height == 0", SWT.ERROR_INVALID_ARGUMENT, e);
145146

146147
// valid images
147148
Rectangle bounds = new Rectangle(-1, -10, 10, 10);
148-
image = new Image(display, bounds.width, bounds.height);
149+
image = new Image(display, bounds);
149150
image.dispose();
150151

151152
bounds = new Rectangle(0, 0, 10, 10);
152-
image = new Image(null, bounds.width, bounds.height);
153+
image = new Image(null, bounds);
153154
image.dispose();
154155

155-
image = new Image(display, bounds.width, bounds.height);
156+
image = new Image(display, bounds);
156157
image.dispose();
157158
}
158159

0 commit comments

Comments
 (0)