]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.district.maps/src/org/simantics/maps/MapScalingTransform.java
Adjustments to map diagram info label rendering
[simantics/district.git] / org.simantics.district.maps / src / org / simantics / maps / MapScalingTransform.java
1 package org.simantics.maps;
2
3 import java.awt.geom.AffineTransform;
4
5 public class MapScalingTransform {
6
7     private MapScalingTransform() {
8     }
9     public static final double scale = 256.0d / 360.0d;
10     public static final AffineTransform INSTANCE = AffineTransform.getScaleInstance(scale, scale);
11     public static final AffineTransform INVERSE = AffineTransform.getScaleInstance(1/scale, 1/scale);
12
13     public static double getScaleX() {
14         return INSTANCE.getScaleX();
15     }
16
17     public static double getScaleY() {
18         return INSTANCE.getScaleY();
19     }
20     
21     public static int zoomLevel(AffineTransform current) {
22         double org = INSTANCE.getScaleX();
23         double cur = current.getScaleX();
24         double f = cur / org;
25         double zoomLevel = Math.log10(f) / Math.log10(2);
26         if (zoomLevel < 0) {
27             zoomLevel = 0;
28         }
29         return (int) zoomLevel;
30     }
31 }