Skip to content

Commit 7dad3b1

Browse files
committed
Use new GC Api
1 parent 1732b69 commit 7dad3b1

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

org.eclipse.draw2d/src/org/eclipse/draw2d/Graphics.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ public final void drawFocus(Rectangle r) {
139139
*/
140140
public abstract void drawImage(Image srcImage, int x, int y);
141141

142+
/**
143+
* Draws the given Image at the location (x,y) with the provided size (width,
144+
* height).
145+
*
146+
* @param srcImage the Image
147+
* @param x the x coordinate of the destination
148+
* @param y the y coordinate of the destination
149+
* @param width the width of the destination
150+
* @param height the height of the destination
151+
*/
152+
public abstract void drawImage(Image srcImage, int x, int y, int width, int height);
153+
142154
/**
143155
* Draws a rectangular section of the given Image to the specified rectangular
144156
* reagion on the canvas. The section of the image bounded by the rectangle
@@ -168,6 +180,16 @@ public final void drawImage(Image image, Point p) {
168180
drawImage(image, p.x, p.y);
169181
}
170182

183+
/**
184+
* @see #drawImage(Image, int, int, int, int)
185+
*
186+
* @param srcImage the Image
187+
* @param dest the destination bounds
188+
*/
189+
public final void drawImage(Image srcImage, Rectangle dest) {
190+
drawImage(srcImage, dest.x, dest.y, dest.width, dest.height);
191+
}
192+
171193
/**
172194
* @see #drawImage(Image, int, int, int, int, int, int, int, int)
173195
*/

org.eclipse.draw2d/src/org/eclipse/draw2d/PrinterGraphics.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ public void drawImage(Image srcImage, int x, int y) {
8383
super.drawImage(printerImage(srcImage), x, y);
8484
}
8585

86+
@Override
87+
public void drawImage(Image srcImage, int x, int y, int width, int height) {
88+
super.drawImage(printerImage(srcImage), x, y, width, height);
89+
}
90+
8691
/**
8792
* @see Graphics#drawImage(Image, int, int, int, int, int, int, int, int)
8893
*/

org.eclipse.draw2d/src/org/eclipse/draw2d/SWTGraphics.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,15 @@ public void drawImage(Image srcImage, int x, int y) {
419419
gc.drawImage(srcImage, x + translateX, y + translateY);
420420
}
421421

422+
/**
423+
* @see Graphics#drawImage(Image, int, int, int, int)
424+
*/
425+
@Override
426+
public void drawImage(Image srcImage, int x, int y, int width, int height) {
427+
checkGC();
428+
gc.drawImage(srcImage, x + translateX, y + translateY, width, height);
429+
}
430+
422431
/**
423432
* @see Graphics#drawImage(Image, int, int, int, int, int, int, int, int)
424433
*/

org.eclipse.draw2d/src/org/eclipse/draw2d/ScaledGraphics.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,13 @@ public void drawImage(Image srcImage, int x, int y) {
259259
(int) (Math.floor((size.height * zoom + fractionalY))));
260260
}
261261

262+
@Override
263+
public void drawImage(Image srcImage, int x, int y, int width, int height) {
264+
graphics.drawImage(srcImage, (int) (Math.floor((x * zoom + fractionalX))),
265+
(int) (Math.floor((y * zoom + fractionalY))), (int) (Math.floor((width * zoom + fractionalX))),
266+
(int) (Math.floor((height * zoom + fractionalY))));
267+
}
268+
262269
/** @see Graphics#drawImage(Image, int, int, int, int, int, int, int, int) */
263270
@Override
264271
public void drawImage(Image srcImage, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th) {
@@ -994,7 +1001,7 @@ private TextLayout zoomTextLayout(TextLayout layout) {
9941001

9951002
if (zoomWidth < -1 || zoomWidth == 0) {
9961003
return null;
997-
}
1004+
}
9981005

9991006
TextLayout zoomed = new TextLayout(Display.getCurrent());
10001007
zoomed.setText(layout.getText());

0 commit comments

Comments
 (0)