package org.simantics.maps; import java.awt.geom.AffineTransform; public class MapScalingTransform { private MapScalingTransform() { } public static final double scale = 256.0d / 360.0d; public static final AffineTransform INSTANCE = new AffineTransform(scale, 0, 0, scale, 0, 0); public static double getScaleX() { return INSTANCE.getScaleX(); } public static double getScaleY() { return INSTANCE.getScaleY(); } public static int zoomLevel(AffineTransform current) { double org = INSTANCE.getScaleX(); double cur = current.getScaleX(); double f = cur / org; double zoomLevel = Math.log10(f) / Math.log10(2); if (zoomLevel < 0) { zoomLevel = 0; } return (int) zoomLevel; } }