public class ZoomManager
extends java.lang.Object
org.eclipse.gef.ui.actions.ZoomInAction
org.eclipse.gef.ui.actions.ZoomOutAction
org.eclipse.gef.ui.actions.ZoomComboContributionItem
A ZoomManager controls how zoom in and zoom out are performed. It also
determines the list of choices the user sees in the drop-down Combo on the
toolbar. The zoom manager controls a ScalableFigure
, which
performs the actual zoom, and also a Viewport
. The viewport is
needed so that the scrolled location is preserved as the zoom level changes.
NOTE: For the settings of Page
, Width
and Height
to work properly, the given
Viewport
should have its scrollbars always visible or never
visible. Otherwise, these settings may cause undesired effects.
Modifier and Type | Field and Description |
---|---|
static int |
ANIMATE_NEVER
Style bit meaning don't animate any zooms
|
static int |
ANIMATE_ZOOM_IN_OUT
|
static java.lang.String |
FIT_ALL
String constant for the "Page" zoom level.
|
static java.lang.String |
FIT_HEIGHT
String constant for the "Height" zoom level.
|
static java.lang.String |
FIT_WIDTH
String constant for the "Width" zoom level.
|
Constructor and Description |
---|
ZoomManager(org.eclipse.draw2d.ScalableFigure pane,
org.eclipse.draw2d.Viewport viewport)
Creates a new ZoomManager.
|
ZoomManager(org.eclipse.draw2d.ScalableFreeformLayeredPane pane,
org.eclipse.draw2d.Viewport viewport)
Deprecated.
Use
ZoomManager(ScalableFigure, Viewport) instead.
Creates a new ZoomManager |
Modifier and Type | Method and Description |
---|---|
void |
addZoomListener(ZoomListener listener)
Adds the given ZoomListener to this ZoomManager's list of listeners.
|
boolean |
canZoomIn()
returns
true if the zoommanager can perform
zoomIn() . |
boolean |
canZoomOut()
returns
true if the zoommanager can perform
zoomOut() . |
protected void |
fireZoomChanged()
Notifies listeners that the zoom level has changed.
|
protected double |
getFitHeightZoomLevel()
Calculates and returns the zoom percent required so that the entire
height of the
scalable figure is visible on
the screen. |
protected double |
getFitPageZoomLevel()
Calculates and returns the zoom percentage required to fit the entire
scalable figure on the screen. |
protected double |
getFitWidthZoomLevel()
Calculates and returns the zoom percentage required so that the entire
width of the
scalable figure is visible on
the screen. |
double |
getMaxZoom()
Returns the maxZoom.
|
double |
getMinZoom()
Returns the minZoom.
|
double |
getNextZoomLevel()
Returns the zoom level that is one level higher than the current level.
|
double |
getPreviousZoomLevel()
Returns the zoom level that is one level higher than the current level.
|
org.eclipse.draw2d.ScalableFigure |
getScalableFigure()
Returns the figure which performs the actual zooming.
|
double |
getUIMultiplier()
Returns the mutltiplier.
|
org.eclipse.draw2d.Viewport |
getViewport()
Returns the viewport.
|
double |
getZoom()
Returns the current zoom level.
|
java.lang.String |
getZoomAsText()
Returns the current zoom level as a percentage formatted String
|
java.util.List<java.lang.String> |
getZoomLevelContributions()
Returns the list of strings that should be appended to the list of
numerical zoom levels.
|
double[] |
getZoomLevels()
Returns the zoomLevels.
|
java.lang.String[] |
getZoomLevelsAsText()
Returns the list of zoom levels as Strings in percent notation, plus any
additional zoom levels that were contributed using
setZoomLevelContributions(List) . |
protected void |
primSetZoom(double zoom)
Sets the zoom level to the given value.
|
void |
removeZoomListener(ZoomListener listener)
Removes the given ZoomListener from this ZoomManager's list of listeners.
|
void |
setUIMultiplier(double multiplier)
Sets the UI multiplier.
|
void |
setViewLocation(org.eclipse.draw2d.geometry.Point p)
Sets the Viewport's view associated with this ZoomManager to the passed
Point
|
void |
setZoom(double zoom)
Sets the zoom level to the given value.
|
void |
setZoomAnimationStyle(int style)
Sets which zoom methods get animated.
|
void |
setZoomAsText(java.lang.String zoomString)
Sets zoom to the passed string.
|
void |
setZoomLevelContributions(java.util.List<java.lang.String> contributions)
Sets the list of zoom level contributions (as strings).
|
void |
setZoomLevels(double[] zoomLevels)
Sets the zoomLevels.
|
void |
zoomIn()
Sets the zoom level to be one level higher
|
void |
zoomOut()
Sets the zoom level to be one level lower
|
void |
zoomTo(org.eclipse.draw2d.geometry.Rectangle rect)
Currently does nothing.
|
public static final int ANIMATE_NEVER
public static final int ANIMATE_ZOOM_IN_OUT
public static final java.lang.String FIT_HEIGHT
public static final java.lang.String FIT_WIDTH
public static final java.lang.String FIT_ALL
public ZoomManager(org.eclipse.draw2d.ScalableFigure pane, org.eclipse.draw2d.Viewport viewport)
pane
- The ScalableFigure associated with this ZoomManagerviewport
- The Viewport assoicated with this ZoomManagerpublic ZoomManager(org.eclipse.draw2d.ScalableFreeformLayeredPane pane, org.eclipse.draw2d.Viewport viewport)
ZoomManager(ScalableFigure, Viewport)
instead.
Creates a new ZoomManagerpane
- The ScalableFreeformLayeredPane associated with this
ZoomManagerviewport
- The Viewport assoicated with this viewportpublic void addZoomListener(ZoomListener listener)
listener
- the ZoomListener to be addedpublic boolean canZoomIn()
true
if the zoommanager can perform
zoomIn()
.public boolean canZoomOut()
true
if the zoommanager can perform
zoomOut()
.protected void fireZoomChanged()
protected double getFitHeightZoomLevel()
scalable figure
is visible on
the screen. This is the zoom level associated with FIT_HEIGHT
.protected double getFitPageZoomLevel()
scalable figure
on the screen. This is the
zoom setting associated with FIT_ALL
. It is the minimum of
getFitHeightZoomLevel()
and getFitWidthZoomLevel()
.protected double getFitWidthZoomLevel()
scalable figure
is visible on
the screen. This is the zoom setting associated with FIT_WIDTH
.public double getMaxZoom()
public double getMinZoom()
public double getUIMultiplier()
public double getNextZoomLevel()
public double getPreviousZoomLevel()
public org.eclipse.draw2d.ScalableFigure getScalableFigure()
public org.eclipse.draw2d.Viewport getViewport()
public double getZoom()
public java.lang.String getZoomAsText()
public java.util.List<java.lang.String> getZoomLevelContributions()
null
.public double[] getZoomLevels()
public java.lang.String[] getZoomLevelsAsText()
setZoomLevelContributions(List)
.protected void primSetZoom(double zoom)
zoom
- the new zoom levelpublic void removeZoomListener(ZoomListener listener)
listener
- the ZoomListener to be removedpublic void setUIMultiplier(double multiplier)
getZoomAsText()
).
Similarly, the multiplier is inversely applied when the user specifies a
zoom level (setZoomAsText(String)
).
When the UI multiplier is 1.0
, the User will see the exact
zoom level that is being applied. If the value is 2.0
, then
a scale of 0.5
will be labeled "100%" to the User.
multiplier
- The mutltiplier to setpublic void setViewLocation(org.eclipse.draw2d.geometry.Point p)
p
- The new location for the Viewport's view.public void setZoom(double zoom)
zoom
- the new zoom levelpublic void setZoomAnimationStyle(int style)
style
- the style bits determining the zoom methods to be animated.public void setZoomAsText(java.lang.String zoomString)
zoomString
- The new zoom levelpublic void setZoomLevelContributions(java.util.List<java.lang.String> contributions)
FIT_HEIGHT
, FIT_WIDTH
and
FIT_ALL
you must subclass this class and override this method to
implement your contributed zoom function.contributions
- the list of contributed zoom levelspublic void setZoomLevels(double[] zoomLevels)
zoomLevels
- The zoomLevels to setpublic void zoomIn()
public void zoomTo(org.eclipse.draw2d.geometry.Rectangle rect)
rect
- a rectanglepublic void zoomOut()
Copyright (c) 2014 itemis AG and others. All rights reserved.