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 = AffineTransform.getScaleInstance(scale, scale); public static final AffineTransform INVERSE = AffineTransform.getScaleInstance(1/scale, 1/scale); 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; } }