use of org.eclipse.gef.editparts.ZoomManager in project knime-core by knime.
the class PasteActionContextMenu method newShiftCalculator.
/**
* {@inheritDoc}
*/
@Override
protected ShiftCalculator newShiftCalculator() {
return new ShiftCalculator() {
/**
* {@inheritDoc}
*/
@Override
public int[] calculateShift(final Iterable<int[]> boundsList, final WorkflowManager manager, final ClipboardObject clipObject) {
int x = getEditor().getSelectionTool().getXLocation();
int y = getEditor().getSelectionTool().getYLocation();
int smallestX = Integer.MAX_VALUE;
int smallestY = Integer.MAX_VALUE;
for (int[] bounds : boundsList) {
int currentX = bounds[0];
int currentY = bounds[1];
if (currentX < smallestX) {
smallestX = currentX;
}
if (currentY < smallestY) {
smallestY = currentY;
}
}
ZoomManager zoomManager = (ZoomManager) getEditor().getViewer().getProperty(ZoomManager.class.toString());
Point viewPortLocation = zoomManager.getViewport().getViewLocation();
x += viewPortLocation.x;
y += viewPortLocation.y;
double zoom = zoomManager.getZoom();
x /= zoom;
y /= zoom;
int shiftx = x - smallestX;
int shifty = y - smallestY;
if (getEditor().getEditorSnapToGrid()) {
shiftx = getEditor().getEditorGridXOffset(shiftx);
shifty = getEditor().getEditorGridYOffset(shifty);
}
return new int[] { shiftx, shifty };
}
};
}
use of org.eclipse.gef.editparts.ZoomManager in project yamcs-studio by yamcs.
the class DisplayEditpart method deactivate.
@Override
public void deactivate() {
final Control control = getViewer().getControl();
if (getViewer() != null && !control.isDisposed()) {
// This needs to be executed in UI Thread
final ZoomManager zoomManager = getZoomManager();
control.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (zoomListener != null && !control.isDisposed()) {
// recover zoom
zoomManager.setZoom(1.0);
control.removeControlListener(zoomListener);
}
if (scaleListener != null && !control.isDisposed()) {
control.removeControlListener(scaleListener);
}
}
});
}
super.deactivate();
}
use of org.eclipse.gef.editparts.ZoomManager in project yamcs-studio by yamcs.
the class TextEditManager method bringDown.
/**
* @see org.eclipse.gef.tools.DirectEditManager#bringDown()
*/
@Override
protected void bringDown() {
ZoomManager zoomMgr = (ZoomManager) getEditPart().getViewer().getProperty(ZoomManager.class.toString());
if (zoomMgr != null)
zoomMgr.removeZoomListener(zoomListener);
if (actionHandler != null) {
actionHandler.dispose();
actionHandler = null;
}
if (actionBars != null) {
restoreSavedActions(actionBars);
actionBars.updateActionBars();
actionBars = null;
}
super.bringDown();
// dispose any scaled fonts that might have been created
disposeScaledFont();
}
use of org.eclipse.gef.editparts.ZoomManager in project jbosstools-hibernate by jbosstools.
the class DiagramViewer method getFitHeightZoomValue.
public double getFitHeightZoomValue() {
double res = 1.0;
ZoomManager manager = (ZoomManager) getGraphicalViewer().getProperty(ZoomManager.class.toString());
Method m = null;
try {
// $NON-NLS-1$
m = manager.getClass().getDeclaredMethod("getFitHeightZoomLevel");
m.setAccessible(true);
res = (Double) m.invoke(manager);
} catch (SecurityException e) {
} catch (NoSuchMethodException e) {
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
}
return res;
}
use of org.eclipse.gef.editparts.ZoomManager in project jbosstools-hibernate by jbosstools.
the class DiagramViewer method getZoom.
/**
* Returns the current zoom level.
* @return double the zoom level
*/
public double getZoom() {
double zoom = 1.0;
ZoomManager manager = (ZoomManager) getGraphicalViewer().getProperty(ZoomManager.class.toString());
if (manager != null) {
zoom = manager.getZoom();
}
return zoom;
}
Aggregations