Skip to content

Commit 90e117f

Browse files
fedejeannearunjose696
authored andcommitted
Replacing Image(Device, ImageData) constructor in DefaultRangeIndicator with Image(Device, ImageDataProvider)
1 parent b141132 commit 90e117f

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.eclipse.swt.graphics.GC;
2121
import org.eclipse.swt.graphics.Image;
2222
import org.eclipse.swt.graphics.ImageData;
23+
import org.eclipse.swt.graphics.ImageDataProvider;
2324
import org.eclipse.swt.graphics.PaletteData;
2425
import org.eclipse.swt.graphics.Point;
2526
import org.eclipse.swt.graphics.RGB;
@@ -135,20 +136,28 @@ private Image getImage(Control control, Color rangeIndicatorColor) {
135136
*/
136137
private static Image createImage(Display display, Point size, Color rangeIndicatorColor) {
137138

138-
int width= size.x;
139-
int height= size.y;
140-
141-
142-
ImageData imageData= new ImageData(width, height, 1, createPalette(display, rangeIndicatorColor));
143-
144-
for (int y= 0, offset= 1; y < height; y++, offset= (offset + 1) % 2)
145-
for (int x= offset; x < width; x += 2)
146-
imageData.setPixel(x, y, 1);
147-
148-
imageData.transparentPixel= 1;
149-
139+
int width = size.x;
140+
int height = size.y;
141+
142+
ImageDataProvider imageDataProvider = zoom -> {
143+
float scaleFactor = zoom / 100.0f;
144+
int scaledWidth = Math.round(width * scaleFactor);
145+
int scaledHeight = Math.round(height * scaleFactor);
146+
ImageData imageData = new ImageData(scaledWidth, scaledHeight, 1,
147+
createPalette(display, rangeIndicatorColor));
148+
int blockSize = Math.round(scaleFactor);
149+
for (int y = 0; y < scaledHeight; y++) {
150+
for (int x = 0; x < scaledWidth; x++) {
151+
if (((x / blockSize) + (y / blockSize)) % 2 == 0) {
152+
imageData.setPixel(x, y, 1);
153+
}
154+
}
155+
}
156+
imageData.transparentPixel = 1;
157+
return imageData;
158+
};
150159

151-
return new Image(display, imageData);
160+
return new Image(display, imageDataProvider);
152161
}
153162

154163
/**

0 commit comments

Comments
 (0)