|
Lines 45-51
Link Here
|
| 45 |
static final int MAX_BUFFER_SIZE = 256; |
45 |
static final int MAX_BUFFER_SIZE = 256; |
| 46 |
private int currentHTile, currentVTile; |
46 |
private int currentHTile, currentVTile; |
| 47 |
private int hTiles, vTiles; |
47 |
private int hTiles, vTiles; |
|
|
48 |
|
| 48 |
private Dimension tileSize; |
49 |
private Dimension tileSize; |
|
|
50 |
private Dimension sourceSize; // the source size that was used for the |
| 51 |
// tileSize computation |
| 52 |
|
| 49 |
private boolean isActive = true; |
53 |
private boolean isActive = true; |
| 50 |
|
54 |
|
| 51 |
private boolean isRunning = false; |
55 |
private boolean isRunning = false; |
|
Lines 115-130
Link Here
|
| 115 |
* tile size and current tile index. |
119 |
* tile size and current tile index. |
| 116 |
*/ |
120 |
*/ |
| 117 |
public void resetTileValues() { |
121 |
public void resetTileValues() { |
| 118 |
hTiles = (int) Math.ceil((float) getSourceRectangle().width |
122 |
// keep track of source size that matches the computed tile size |
|
|
123 |
sourceSize = getSourceRectangle().getSize(); |
| 124 |
|
| 125 |
hTiles = (int) Math.ceil((float) sourceSize.width |
| 119 |
/ (float) MAX_BUFFER_SIZE); |
126 |
/ (float) MAX_BUFFER_SIZE); |
| 120 |
vTiles = (int) Math.ceil((float) getSourceRectangle().height |
127 |
vTiles = (int) Math.ceil((float) sourceSize.height |
| 121 |
/ (float) MAX_BUFFER_SIZE); |
128 |
/ (float) MAX_BUFFER_SIZE); |
| 122 |
|
129 |
|
| 123 |
tileSize = new Dimension( |
130 |
tileSize = new Dimension((int) Math.ceil((float) sourceSize.width |
| 124 |
(int) Math.ceil((float) getSourceRectangle().width |
131 |
/ (float) hTiles), |
| 125 |
/ (float) hTiles), |
132 |
(int) Math.ceil((float) sourceSize.height / (float) vTiles)); |
| 126 |
(int) Math.ceil((float) getSourceRectangle().height |
|
|
| 127 |
/ (float) vTiles)); |
| 128 |
|
133 |
|
| 129 |
currentHTile = 0; |
134 |
currentHTile = 0; |
| 130 |
currentVTile = 0; |
135 |
currentVTile = 0; |
|
Lines 152-166
Link Here
|
| 152 |
public void run() { |
157 |
public void run() { |
| 153 |
if (!isActive() || !isRunning() || tileGraphics == null) |
158 |
if (!isActive() || !isRunning() || tileGraphics == null) |
| 154 |
return; |
159 |
return; |
|
|
160 |
|
| 155 |
int v = getCurrentVTile(); |
161 |
int v = getCurrentVTile(); |
| 156 |
int sy1 = v * tileSize.height; |
162 |
int sy1 = v * tileSize.height; |
| 157 |
int sy2 = Math.min((v + 1) * tileSize.height, |
163 |
int sy2 = Math.min((v + 1) * tileSize.height, sourceSize.height); |
| 158 |
getSourceRectangle().height); |
|
|
| 159 |
|
164 |
|
| 160 |
int h = getCurrentHTile(); |
165 |
int h = getCurrentHTile(); |
| 161 |
int sx1 = h * tileSize.width; |
166 |
int sx1 = h * tileSize.width; |
| 162 |
int sx2 = Math.min((h + 1) * tileSize.width, |
167 |
int sx2 = Math.min((h + 1) * tileSize.width, sourceSize.width); |
| 163 |
getSourceRectangle().width); |
|
|
| 164 |
|
168 |
|
| 165 |
tileGraphics.pushState(); |
169 |
tileGraphics.pushState(); |
| 166 |
// clear the background (by filling with the background color) |
170 |
// clear the background (by filling with the background color) |
|
Lines 168-181
Link Here
|
| 168 |
tileGraphics.fillRectangle(rect); |
172 |
tileGraphics.fillRectangle(rect); |
| 169 |
|
173 |
|
| 170 |
// let the source figure paint into the tile image |
174 |
// let the source figure paint into the tile image |
| 171 |
// IMPORTANT (fix for bug #309912): we do not let the source figure |
175 |
// IMPORTANT (fix for bug #309912): we do not let the source |
| 172 |
// paint directly into the thumbnail image, because we cannot ensure |
176 |
// figure |
| 173 |
// that it paints completely inside the current tile area (it may |
177 |
// paint directly into the thumbnail image, because we cannot |
| 174 |
// set its own clip inside paint(Graphics) and overwrite areas of |
178 |
// ensure |
| 175 |
// tile that have already been rendered. By providing an own tile |
179 |
// that it paints completely inside the current tile area (it |
| 176 |
// image and copying from it into the thumbnail image, we are safe. |
180 |
// may |
|
|
181 |
// set its own clip inside paint(Graphics) and overwrite areas |
| 182 |
// of |
| 183 |
// tile that have already been rendered. By providing an own |
| 184 |
// tile |
| 185 |
// image and copying from it into the thumbnail image, we are |
| 186 |
// safe. |
| 177 |
org.eclipse.draw2d.geometry.Point p = getSourceRectangle() |
187 |
org.eclipse.draw2d.geometry.Point p = getSourceRectangle() |
| 178 |
.getLocation(); |
188 |
.getLocation(); |
|
|
189 |
|
| 179 |
tileGraphics.translate(-p.x - sx1, -p.y - sy1); |
190 |
tileGraphics.translate(-p.x - sx1, -p.y - sy1); |
| 180 |
tileGraphics.scale(getScaleX()); |
191 |
tileGraphics.scale(getScaleX()); |
| 181 |
sourceFigure.paint(tileGraphics); |
192 |
sourceFigure.paint(tileGraphics); |
|
Lines 195-203
Link Here
|
| 195 |
setCurrentVTile(0); |
206 |
setCurrentVTile(0); |
| 196 |
} |
207 |
} |
| 197 |
|
208 |
|
| 198 |
if (getCurrentHTile() != 0 || getCurrentVTile() != 0) |
209 |
if (getCurrentHTile() != 0 || getCurrentVTile() != 0) { |
| 199 |
Display.getCurrent().asyncExec(this); |
210 |
Display.getCurrent().asyncExec(this); |
| 200 |
else if (isDirty()) { |
211 |
} else if (isDirty()) { |
| 201 |
setDirty(false); |
212 |
setDirty(false); |
| 202 |
Display.getCurrent().asyncExec(this); |
213 |
Display.getCurrent().asyncExec(this); |
| 203 |
repaint(); |
214 |
repaint(); |
|
Lines 278-285
Link Here
|
| 278 |
tileGraphics.setBackgroundColor(color); |
289 |
tileGraphics.setBackgroundColor(color); |
| 279 |
tileGraphics.setFont(sourceFigure.getFont()); |
290 |
tileGraphics.setFont(sourceFigure.getFont()); |
| 280 |
|
291 |
|
| 281 |
setScales(targetSize.width / (float) getSourceRectangle().width, |
292 |
setScales(targetSize.width / (float) sourceSize.width, |
| 282 |
targetSize.height / (float) getSourceRectangle().height); |
293 |
targetSize.height / (float) sourceSize.height); |
| 283 |
|
294 |
|
| 284 |
Display.getCurrent().asyncExec(this); |
295 |
Display.getCurrent().asyncExec(this); |
| 285 |
} |
296 |
} |
|
Lines 349-356
Link Here
|
| 349 |
private float scaleX; |
360 |
private float scaleX; |
| 350 |
private float scaleY; |
361 |
private float scaleY; |
| 351 |
|
362 |
|
| 352 |
private IFigure sourceFigure; |
|
|
| 353 |
Dimension targetSize = new Dimension(0, 0); |
363 |
Dimension targetSize = new Dimension(0, 0); |
|
|
364 |
private IFigure sourceFigure; |
| 354 |
private Image thumbnailImage; |
365 |
private Image thumbnailImage; |
| 355 |
|
366 |
|
| 356 |
private Dimension thumbnailImageSize; |
367 |
private Dimension thumbnailImageSize; |