1
|
/*******************************************************************************
|
2
|
* Copyright (c) 2000, 2010 IBM Corporation and others.
|
3
|
* All rights reserved. This program and the accompanying materials
|
4
|
* are made available under the terms of the Eclipse Public License v1.0
|
5
|
* which accompanies this distribution, and is available at
|
6
|
* http://www.eclipse.org/legal/epl-v10.html
|
7
|
*
|
8
|
* Contributors:
|
9
|
* IBM Corporation - initial API and implementation
|
10
|
*******************************************************************************/
|
11
|
package org.eclipse.gef.editparts;
|
12
|
|
13
|
import com.ibm.icu.text.DecimalFormat;
|
14
|
import com.ibm.icu.text.NumberFormat;
|
15
|
|
16
|
import java.util.ArrayList;
|
17
|
import java.util.Collections;
|
18
|
import java.util.Iterator;
|
19
|
import java.util.List;
|
20
|
|
21
|
import org.eclipse.swt.widgets.Display;
|
22
|
|
23
|
import org.eclipse.core.runtime.Assert;
|
24
|
import org.eclipse.core.runtime.Platform;
|
25
|
|
26
|
import org.eclipse.draw2d.FreeformFigure;
|
27
|
import org.eclipse.draw2d.IFigure;
|
28
|
import org.eclipse.draw2d.ScalableFigure;
|
29
|
import org.eclipse.draw2d.ScalableFreeformLayeredPane;
|
30
|
import org.eclipse.draw2d.Viewport;
|
31
|
import org.eclipse.draw2d.geometry.Dimension;
|
32
|
import org.eclipse.draw2d.geometry.Point;
|
33
|
import org.eclipse.draw2d.geometry.Rectangle;
|
34
|
|
35
|
import org.eclipse.gef.SharedMessages;
|
36
|
|
37
|
/**
|
38
|
* Manage the primary zoom function in a graphical viewer. This class is used by
|
39
|
* the zoom contribution items, including:
|
40
|
* <UL>
|
41
|
* <LI>{@link org.eclipse.gef.ui.actions.ZoomInAction}
|
42
|
* <LI>{@link org.eclipse.gef.ui.actions.ZoomOutAction}
|
43
|
* <LI>and {@link org.eclipse.gef.ui.actions.ZoomComboContributionItem}
|
44
|
* </UL>
|
45
|
* <P>
|
46
|
* A ZoomManager controls how zoom in and zoom out are performed. It also
|
47
|
* determines the list of choices the user sees in the drop-down Combo on the
|
48
|
* toolbar. The zoom manager controls a <code>ScalableFigure</code>, which
|
49
|
* performs the actual zoom, and also a <code>Viewport</code>. The viewport is
|
50
|
* needed so that the scrolled location is preserved as the zoom level changes.
|
51
|
* <p>
|
52
|
* <b>NOTE:</b> For the settings of {@link #FIT_ALL Page}, {@link #FIT_WIDTH
|
53
|
* Width} and {@link #FIT_HEIGHT Height} to work properly, the given
|
54
|
* <code>Viewport</code> should have its scrollbars always visible or never
|
55
|
* visible. Otherwise, these settings may cause undesired effects.
|
56
|
*
|
57
|
* @author Dan Lee
|
58
|
* @author Eric Bordeau
|
59
|
*/
|
60
|
public class ZoomManager {
|
61
|
|
62
|
/** Style bit meaning don't animate any zooms */
|
63
|
public static final int ANIMATE_NEVER = 0;
|
64
|
/** Style bit meaning animate during {@link #zoomIn()} and {@link #zoomOut()} */
|
65
|
public static final int ANIMATE_ZOOM_IN_OUT = 1;
|
66
|
|
67
|
private List listeners = new ArrayList();
|
68
|
|
69
|
private double multiplier = 1.0;
|
70
|
private ScalableFigure pane;
|
71
|
private Viewport viewport;
|
72
|
private double zoom = 1.0;
|
73
|
// private int zoomAnimationStyle = ANIMATE_NEVER;
|
74
|
private double[] zoomLevels = { .5, .75, 1.0, 1.5, 2.0, 2.5, 3, 4 };
|
75
|
/**
|
76
|
* String constant for the "Height" zoom level. At this zoom level, the zoom
|
77
|
* manager will adopt a zoom setting such that the entire height of the
|
78
|
* diagram will be visible on the screen.
|
79
|
*/
|
80
|
public static final String FIT_HEIGHT = SharedMessages.FitHeightAction_Label;
|
81
|
/**
|
82
|
* String constant for the "Width" zoom level. At this zoom level, the zoom
|
83
|
* manager will adopt a zoom setting such that the entire width of the
|
84
|
* diagram will be visible on the screen.
|
85
|
*/
|
86
|
public static final String FIT_WIDTH = SharedMessages.FitWidthAction_Label;
|
87
|
/**
|
88
|
* String constant for the "Page" zoom level. At this zoom level, the zoom
|
89
|
* manager will adopt a zoom setting such that the entire diagram will be
|
90
|
* visible on the screen.
|
91
|
*/
|
92
|
public static final String FIT_ALL = SharedMessages.FitAllAction_Label;
|
93
|
private List zoomLevelContributions = Collections.EMPTY_LIST;
|
94
|
|
95
|
DecimalFormat format = new DecimalFormat("####%"); //$NON-NLS-1$
|
96
|
|
97
|
/**
|
98
|
* Creates a new ZoomManager.
|
99
|
*
|
100
|
* @param pane
|
101
|
* The ScalableFigure associated with this ZoomManager
|
102
|
* @param viewport
|
103
|
* The Viewport assoicated with this ZoomManager
|
104
|
*/
|
105
|
public ZoomManager(ScalableFigure pane, Viewport viewport) {
|
106
|
this.pane = pane;
|
107
|
this.viewport = viewport;
|
108
|
}
|
109
|
|
110
|
/**
|
111
|
* @deprecated Use {@link #ZoomManager(ScalableFigure, Viewport)} instead.
|
112
|
* Creates a new ZoomManager
|
113
|
* @param pane
|
114
|
* The ScalableFreeformLayeredPane associated with this
|
115
|
* ZoomManager
|
116
|
* @param viewport
|
117
|
* The Viewport assoicated with this viewport
|
118
|
*/
|
119
|
public ZoomManager(ScalableFreeformLayeredPane pane, Viewport viewport) {
|
120
|
this.pane = pane;
|
121
|
this.viewport = viewport;
|
122
|
}
|
123
|
|
124
|
/**
|
125
|
* Adds the given ZoomListener to this ZoomManager's list of listeners.
|
126
|
*
|
127
|
* @param listener
|
128
|
* the ZoomListener to be added
|
129
|
*/
|
130
|
public void addZoomListener(ZoomListener listener) {
|
131
|
listeners.add(listener);
|
132
|
}
|
133
|
|
134
|
/**
|
135
|
* returns <code>true</code> if the zoommanager can perform
|
136
|
* <code>zoomIn()</code>.
|
137
|
*
|
138
|
* @return boolean true if zoomIn can be called
|
139
|
*/
|
140
|
public boolean canZoomIn() {
|
141
|
return getZoom() < getMaxZoom();
|
142
|
}
|
143
|
|
144
|
/**
|
145
|
* returns <code>true</code> if the zoommanager can perform
|
146
|
* <code>zoomOut()</code>.
|
147
|
*
|
148
|
* @return boolean true if zoomOut can be called
|
149
|
*/
|
150
|
public boolean canZoomOut() {
|
151
|
return getZoom() > getMinZoom();
|
152
|
}
|
153
|
|
154
|
/**
|
155
|
* Notifies listeners that the zoom level has changed.
|
156
|
*/
|
157
|
protected void fireZoomChanged() {
|
158
|
Iterator iter = listeners.iterator();
|
159
|
while (iter.hasNext())
|
160
|
((ZoomListener) iter.next()).zoomChanged(zoom);
|
161
|
}
|
162
|
|
163
|
private double getFitXZoomLevel(int which) {
|
164
|
IFigure fig = getScalableFigure();
|
165
|
|
166
|
Dimension available = getViewport().getClientArea().getSize();
|
167
|
Dimension desired;
|
168
|
if (fig instanceof FreeformFigure)
|
169
|
desired = ((FreeformFigure) fig).getFreeformExtent().getCopy()
|
170
|
.union(0, 0).getSize();
|
171
|
else
|
172
|
desired = fig.getPreferredSize().getCopy();
|
173
|
|
174
|
desired.width -= fig.getInsets().getWidth();
|
175
|
desired.height -= fig.getInsets().getHeight();
|
176
|
|
177
|
while (fig != getViewport()) {
|
178
|
available.width -= fig.getInsets().getWidth();
|
179
|
available.height -= fig.getInsets().getHeight();
|
180
|
fig = fig.getParent();
|
181
|
}
|
182
|
|
183
|
double scaleX = Math.min(available.width * zoom / desired.width,
|
184
|
getMaxZoom());
|
185
|
double scaleY = Math.min(available.height * zoom / desired.height,
|
186
|
getMaxZoom());
|
187
|
if (which == 0)
|
188
|
return scaleX;
|
189
|
if (which == 1)
|
190
|
return scaleY;
|
191
|
return Math.min(scaleX, scaleY);
|
192
|
}
|
193
|
|
194
|
/**
|
195
|
* Calculates and returns the zoom percent required so that the entire
|
196
|
* height of the {@link #getScalableFigure() scalable figure} is visible on
|
197
|
* the screen. This is the zoom level associated with {@link #FIT_HEIGHT}.
|
198
|
*
|
199
|
* @return zoom setting required to fit the scalable figure vertically on
|
200
|
* the screen
|
201
|
*/
|
202
|
protected double getFitHeightZoomLevel() {
|
203
|
return getFitXZoomLevel(1);
|
204
|
}
|
205
|
|
206
|
/**
|
207
|
* Calculates and returns the zoom percentage required to fit the entire
|
208
|
* {@link #getScalableFigure() scalable figure} on the screen. This is the
|
209
|
* zoom setting associated with {@link #FIT_ALL}. It is the minimum of
|
210
|
* {@link #getFitHeightZoomLevel()} and {@link #getFitWidthZoomLevel()}.
|
211
|
*
|
212
|
* @return zoom setting required to fit the entire scalable figure on the
|
213
|
* screen
|
214
|
*/
|
215
|
protected double getFitPageZoomLevel() {
|
216
|
return getFitXZoomLevel(2);
|
217
|
}
|
218
|
|
219
|
/**
|
220
|
* Calculates and returns the zoom percentage required so that the entire
|
221
|
* width of the {@link #getScalableFigure() scalable figure} is visible on
|
222
|
* the screen. This is the zoom setting associated with {@link #FIT_WIDTH}.
|
223
|
*
|
224
|
* @return zoom setting required to fit the scalable figure horizontally on
|
225
|
* the screen
|
226
|
*/
|
227
|
protected double getFitWidthZoomLevel() {
|
228
|
return getFitXZoomLevel(0);
|
229
|
}
|
230
|
|
231
|
/**
|
232
|
* Returns the maxZoom.
|
233
|
*
|
234
|
* @return double
|
235
|
*/
|
236
|
public double getMaxZoom() {
|
237
|
return getZoomLevels()[getZoomLevels().length - 1];
|
238
|
}
|
239
|
|
240
|
/**
|
241
|
* Returns the minZoom.
|
242
|
*
|
243
|
* @return double
|
244
|
*/
|
245
|
public double getMinZoom() {
|
246
|
return getZoomLevels()[0];
|
247
|
}
|
248
|
|
249
|
/**
|
250
|
* Returns the mutltiplier. This value is used to use zoom levels internally
|
251
|
* that are proportionally different than those displayed to the user. e.g.
|
252
|
* with a multiplier value of 2.0, the zoom level 1.0 will be displayed as
|
253
|
* "200%".
|
254
|
*
|
255
|
* @return double The multiplier
|
256
|
*/
|
257
|
public double getUIMultiplier() {
|
258
|
return multiplier;
|
259
|
}
|
260
|
|
261
|
/**
|
262
|
* Returns the zoom level that is one level higher than the current level.
|
263
|
* If zoom level is at maximum, returns the maximum.
|
264
|
*
|
265
|
* @return double The next zoom level
|
266
|
*/
|
267
|
public double getNextZoomLevel() {
|
268
|
for (int i = 0; i < zoomLevels.length; i++)
|
269
|
if (zoomLevels[i] > zoom)
|
270
|
return zoomLevels[i];
|
271
|
return getMaxZoom();
|
272
|
}
|
273
|
|
274
|
/**
|
275
|
* @deprecated Use {@link #getScalableFigure()} instead. Returns the pane.
|
276
|
* @return the pane
|
277
|
*/
|
278
|
public ScalableFreeformLayeredPane getPane() {
|
279
|
Assert.isTrue(pane instanceof ScalableFreeformLayeredPane);
|
280
|
return (ScalableFreeformLayeredPane) pane;
|
281
|
}
|
282
|
|
283
|
/**
|
284
|
* Returns the zoom level that is one level higher than the current level.
|
285
|
* If zoom level is at maximum, returns the maximum.
|
286
|
*
|
287
|
* @return double The previous zoom level
|
288
|
*/
|
289
|
public double getPreviousZoomLevel() {
|
290
|
for (int i = 1; i < zoomLevels.length; i++)
|
291
|
if (zoomLevels[i] >= zoom)
|
292
|
return zoomLevels[i - 1];
|
293
|
return getMinZoom();
|
294
|
}
|
295
|
|
296
|
/**
|
297
|
* Returns the figure which performs the actual zooming.
|
298
|
*
|
299
|
* @return the scalable figure
|
300
|
*/
|
301
|
public ScalableFigure getScalableFigure() {
|
302
|
return pane;
|
303
|
}
|
304
|
|
305
|
/**
|
306
|
* Returns the viewport.
|
307
|
*
|
308
|
* @return Viewport
|
309
|
*/
|
310
|
public Viewport getViewport() {
|
311
|
return viewport;
|
312
|
}
|
313
|
|
314
|
/**
|
315
|
* Returns the current zoom level.
|
316
|
*
|
317
|
* @return double the zoom level
|
318
|
*/
|
319
|
public double getZoom() {
|
320
|
return zoom;
|
321
|
}
|
322
|
|
323
|
/**
|
324
|
* Returns the current zoom level as a percentage formatted String
|
325
|
*
|
326
|
* @return String The current zoom level as a String
|
327
|
*/
|
328
|
public String getZoomAsText() {
|
329
|
String newItem = format.format(zoom * multiplier);
|
330
|
return newItem;
|
331
|
}
|
332
|
|
333
|
/**
|
334
|
* Returns the list of strings that should be appended to the list of
|
335
|
* numerical zoom levels. These could be things such as Fit Width, Fit Page,
|
336
|
* etc. May return <code>null</code>.
|
337
|
*
|
338
|
* @return the list of contributed zoom levels
|
339
|
*/
|
340
|
public List getZoomLevelContributions() {
|
341
|
return zoomLevelContributions;
|
342
|
}
|
343
|
|
344
|
/**
|
345
|
* Returns the zoomLevels.
|
346
|
*
|
347
|
* @return double[]
|
348
|
*/
|
349
|
public double[] getZoomLevels() {
|
350
|
return zoomLevels;
|
351
|
}
|
352
|
|
353
|
/**
|
354
|
* Returns the list of zoom levels as Strings in percent notation, plus any
|
355
|
* additional zoom levels that were contributed using
|
356
|
* {@link #setZoomLevelContributions(List)}.
|
357
|
*
|
358
|
* @return List The list of zoom levels
|
359
|
*/
|
360
|
public String[] getZoomLevelsAsText() {
|
361
|
String[] zoomLevelStrings = new String[zoomLevels.length
|
362
|
+ zoomLevelContributions.size()];
|
363
|
for (int i = 0; i < zoomLevels.length; i++) {
|
364
|
zoomLevelStrings[i] = format.format(zoomLevels[i] * multiplier);
|
365
|
}
|
366
|
if (zoomLevelContributions != null) {
|
367
|
for (int i = 0; i < zoomLevelContributions.size(); i++) {
|
368
|
zoomLevelStrings[i + zoomLevels.length] = (String) zoomLevelContributions
|
369
|
.get(i);
|
370
|
}
|
371
|
}
|
372
|
return zoomLevelStrings;
|
373
|
}
|
374
|
|
375
|
/**
|
376
|
* Sets the zoom level to the given value. Min-max range check is not done.
|
377
|
*
|
378
|
* @param zoom
|
379
|
* the new zoom level
|
380
|
*/
|
381
|
protected void primSetZoom(double zoom) {
|
382
|
Point p1 = getViewport().getClientArea().getCenter();
|
383
|
Point p2 = p1.getCopy();
|
384
|
Point p = getViewport().getViewLocation();
|
385
|
double prevZoom = this.zoom;
|
386
|
this.zoom = zoom;
|
387
|
pane.setScale(zoom);
|
388
|
fireZoomChanged();
|
389
|
getViewport().validate();
|
390
|
|
391
|
p2.scale(zoom / prevZoom);
|
392
|
Dimension dif = p2.getDifference(p1);
|
393
|
p.x += dif.width;
|
394
|
p.y += dif.height;
|
395
|
setViewLocation(p);
|
396
|
}
|
397
|
|
398
|
/**
|
399
|
* Removes the given ZoomListener from this ZoomManager's list of listeners.
|
400
|
*
|
401
|
* @param listener
|
402
|
* the ZoomListener to be removed
|
403
|
*/
|
404
|
public void removeZoomListener(ZoomListener listener) {
|
405
|
listeners.remove(listener);
|
406
|
}
|
407
|
|
408
|
/**
|
409
|
* Sets the UI multiplier. The UI multiplier is applied to all zoom settings
|
410
|
* when they are presented to the user ({@link #getZoomAsText()}).
|
411
|
* Similarly, the multiplier is inversely applied when the user specifies a
|
412
|
* zoom level ({@link #setZoomAsText(String)}).
|
413
|
* <P>
|
414
|
* When the UI multiplier is <code>1.0</code>, the User will see the exact
|
415
|
* zoom level that is being applied. If the value is <code>2.0</code>, then
|
416
|
* a scale of <code>0.5</code> will be labeled "100%" to the User.
|
417
|
*
|
418
|
* @param multiplier
|
419
|
* The mutltiplier to set
|
420
|
*/
|
421
|
public void setUIMultiplier(double multiplier) {
|
422
|
this.multiplier = multiplier;
|
423
|
}
|
424
|
|
425
|
/**
|
426
|
* Sets the Viewport's view associated with this ZoomManager to the passed
|
427
|
* Point
|
428
|
*
|
429
|
* @param p
|
430
|
* The new location for the Viewport's view.
|
431
|
*/
|
432
|
public void setViewLocation(Point p) {
|
433
|
viewport.setViewLocation(p.x, p.y);
|
434
|
|
435
|
}
|
436
|
|
437
|
/**
|
438
|
* Sets the zoom level to the given value. If the zoom is out of the min-max
|
439
|
* range, it will be ignored.
|
440
|
*
|
441
|
* @param zoom
|
442
|
* the new zoom level
|
443
|
*/
|
444
|
public void setZoom(double zoom) {
|
445
|
zoom = Math.min(getMaxZoom(), zoom);
|
446
|
zoom = Math.max(getMinZoom(), zoom);
|
447
|
if (this.zoom != zoom)
|
448
|
primSetZoom(zoom);
|
449
|
}
|
450
|
|
451
|
/**
|
452
|
* Sets which zoom methods get animated.
|
453
|
*
|
454
|
* @param style
|
455
|
* the style bits determining the zoom methods to be animated.
|
456
|
*/
|
457
|
public void setZoomAnimationStyle(int style) {
|
458
|
// zoomAnimationStyle = style;
|
459
|
}
|
460
|
|
461
|
/**
|
462
|
* Sets zoom to the passed string. The string must be composed of numeric
|
463
|
* characters only with the exception of a decimal point and a '%' as the
|
464
|
* last character. If the zoom level contribution list has been set, this
|
465
|
* method should be overridden to provide the appropriate zoom
|
466
|
* implementation for the new zoom levels.
|
467
|
*
|
468
|
* @param zoomString
|
469
|
* The new zoom level
|
470
|
*/
|
471
|
public void setZoomAsText(String zoomString) {
|
472
|
if (zoomString.equalsIgnoreCase(FIT_HEIGHT)) {
|
473
|
primSetZoom(getFitHeightZoomLevel());
|
474
|
viewport.getUpdateManager().performUpdate();
|
475
|
viewport.setViewLocation(viewport.getHorizontalRangeModel()
|
476
|
.getValue(), viewport.getVerticalRangeModel().getMinimum());
|
477
|
} else if (zoomString.equalsIgnoreCase(FIT_ALL)) {
|
478
|
primSetZoom(getFitPageZoomLevel());
|
479
|
viewport.getUpdateManager().performUpdate();
|
480
|
viewport.setViewLocation(viewport.getHorizontalRangeModel()
|
481
|
.getMinimum(), viewport.getVerticalRangeModel()
|
482
|
.getMinimum());
|
483
|
} else if (zoomString.equalsIgnoreCase(FIT_WIDTH)) {
|
484
|
primSetZoom(getFitWidthZoomLevel());
|
485
|
viewport.getUpdateManager().performUpdate();
|
486
|
viewport.setViewLocation(viewport.getHorizontalRangeModel()
|
487
|
.getMinimum(), viewport.getVerticalRangeModel().getValue());
|
488
|
} else {
|
489
|
try {
|
490
|
// Trim off the '%'
|
491
|
if (zoomString.charAt(zoomString.length() - 1) == '%')
|
492
|
zoomString = zoomString.substring(0,
|
493
|
zoomString.length() - 1);
|
494
|
double newZoom = NumberFormat.getInstance().parse(zoomString)
|
495
|
.doubleValue() / 100;
|
496
|
setZoom(newZoom / multiplier);
|
497
|
} catch (Exception e) {
|
498
|
// Workaround for MacOS X Cocoa Bugzilla 300837
|
499
|
if (!("".equals(zoomString) && Platform.WS_COCOA //$NON-NLS-1$
|
500
|
.equals(Platform.getWS()))) {
|
501
|
Display.getCurrent().beep();
|
502
|
}
|
503
|
}
|
504
|
}
|
505
|
}
|
506
|
|
507
|
/**
|
508
|
* Sets the list of zoom level contributions (as strings). If you contribute
|
509
|
* something <b>other than</b> {@link #FIT_HEIGHT}, {@link #FIT_WIDTH} and
|
510
|
* {@link #FIT_ALL} you must subclass this class and override this method to
|
511
|
* implement your contributed zoom function.
|
512
|
*
|
513
|
* @param contributions
|
514
|
* the list of contributed zoom levels
|
515
|
*/
|
516
|
public void setZoomLevelContributions(List contributions) {
|
517
|
zoomLevelContributions = contributions;
|
518
|
}
|
519
|
|
520
|
/**
|
521
|
* Sets the zoomLevels.
|
522
|
*
|
523
|
* @param zoomLevels
|
524
|
* The zoomLevels to set
|
525
|
*/
|
526
|
public void setZoomLevels(double[] zoomLevels) {
|
527
|
this.zoomLevels = zoomLevels;
|
528
|
}
|
529
|
|
530
|
/**
|
531
|
* Sets the zoom level to be one level higher
|
532
|
*/
|
533
|
public void zoomIn() {
|
534
|
setZoom(getNextZoomLevel());
|
535
|
}
|
536
|
|
537
|
/**
|
538
|
* Currently does nothing.
|
539
|
*
|
540
|
* @param rect
|
541
|
* a rectangle
|
542
|
*/
|
543
|
public void zoomTo(Rectangle rect) {
|
544
|
}
|
545
|
|
546
|
// private void performAnimatedZoom(Rectangle rect, boolean zoomIn, int
|
547
|
// iterationCount) {
|
548
|
// double finalRatio;
|
549
|
// double zoomIncrement;
|
550
|
//
|
551
|
// if (zoomIn) {
|
552
|
// finalRatio = zoom / getNextZoomLevel();
|
553
|
// zoomIncrement = (getNextZoomLevel() - zoom) / iterationCount;
|
554
|
// } else {
|
555
|
// finalRatio = zoom / getPreviousZoomLevel();
|
556
|
// zoomIncrement = (getPreviousZoomLevel() - zoom) / iterationCount;
|
557
|
// }
|
558
|
//
|
559
|
// getScalableFigure().translateToRelative(rect);
|
560
|
// Point originalViewLocation = getViewport().getViewLocation();
|
561
|
// Point finalViewLocation = calculateViewLocation(rect, finalRatio);
|
562
|
//
|
563
|
// double xIncrement =
|
564
|
// (double) (finalViewLocation.x - originalViewLocation.x) / iterationCount;
|
565
|
// double yIncrement =
|
566
|
// (double) (finalViewLocation.y - originalViewLocation.y) / iterationCount;
|
567
|
//
|
568
|
// double originalZoom = zoom;
|
569
|
// Point currentViewLocation = new Point();
|
570
|
// for (int i = 1; i < iterationCount; i++) {
|
571
|
// currentViewLocation.x = (int)(originalViewLocation.x + (xIncrement * i));
|
572
|
// currentViewLocation.y = (int)(originalViewLocation.y + (yIncrement * i));
|
573
|
// setZoom(originalZoom + zoomIncrement * i);
|
574
|
// getViewport().validate();
|
575
|
// setViewLocation(currentViewLocation);
|
576
|
// getViewport().getUpdateManager().performUpdate();
|
577
|
// }
|
578
|
//
|
579
|
// if (zoomIn)
|
580
|
// setZoom(getNextZoomLevel());
|
581
|
// else
|
582
|
// setZoom(getPreviousZoomLevel());
|
583
|
//
|
584
|
// getViewport().validate();
|
585
|
// setViewLocation(finalViewLocation);
|
586
|
// }
|
587
|
//
|
588
|
// private Point calculateViewLocation(Rectangle zoomRect, double ratio) {
|
589
|
// Point viewLocation = new Point();
|
590
|
// viewLocation.x = (int)(zoomRect.x / ratio);
|
591
|
// viewLocation.y = (int)(zoomRect.y / ratio);
|
592
|
// return viewLocation;
|
593
|
// }
|
594
|
|
595
|
/**
|
596
|
* Sets the zoom level to be one level lower
|
597
|
*/
|
598
|
public void zoomOut() {
|
599
|
setZoom(getPreviousZoomLevel());
|
600
|
}
|
601
|
|
602
|
}
|