1 package org.simantics.district.network.ui;
3 import org.simantics.g2d.participant.PanZoomRotateHandler;
4 import org.simantics.scenegraph.g2d.events.MouseEvent.MouseWheelMovedEvent;
5 import org.simantics.scenegraph.g2d.nodes.NavigationNode;
7 public class DistrictPanZoomRotateHandler extends PanZoomRotateHandler {
9 public DistrictPanZoomRotateHandler() {
13 protected Class<? extends NavigationNode> getNavigationNodeClass() {
14 return DistrictNavigationNode.class;
17 public static class DistrictNavigationNode extends NavigationNode {
19 private static final long serialVersionUID = 5452897272925816875L;
22 public Double getZoomInLimit() {
23 return super.getZoomInLimit();
27 public Double getZoomOutLimit() {
28 return super.getZoomOutLimit();
32 public boolean mouseWheelMoved(MouseWheelMovedEvent me) {
33 if (navigationEnabled && zoomEnabled) {
34 double scroll = Math.min(0.9, -me.wheelRotation / 20.0);
35 double z = 1 - scroll;
36 double dx = (me.controlPosition.getX() - transform.getTranslateX()) / transform.getScaleX();
37 double dy = (me.controlPosition.getY() - transform.getTranslateY()) / transform.getScaleY();
40 double limitedScale = limitScaleFactor(z);
41 if (limitedScale != 1.0) {