diff --git a/src/org/openstreetmap/josm/gui/MapViewState.java b/src/org/openstreetmap/josm/gui/MapViewState.java
index a975608..fc74e39 100644
|
a
|
b
|
public final class MapViewState {
|
| 171 | 171 | * @since xxx |
| 172 | 172 | */ |
| 173 | 173 | public AffineTransform getAffineTransform() { |
| 174 | | return new AffineTransform(1.0 / scale, 0.0, 0.0, -1.0 / scale, topLeft.east() / scale, |
| | 174 | return new AffineTransform(1.0 / scale, 0.0, 0.0, -1.0 / scale, -topLeft.east() / scale, |
| 175 | 175 | topLeft.north() / scale); |
| 176 | 176 | } |
| 177 | 177 | |
diff --git a/test/unit/org/openstreetmap/josm/gui/MapViewStateTest.java b/test/unit/org/openstreetmap/josm/gui/MapViewStateTest.java
index 334a020..8bf9591 100644
|
a
|
b
|
package org.openstreetmap.josm.gui;
|
| 3 | 3 | |
| 4 | 4 | import static org.junit.Assert.assertEquals; |
| 5 | 5 | |
| | 6 | import java.awt.geom.AffineTransform; |
| | 7 | import java.awt.geom.Point2D; |
| | 8 | import java.util.Arrays; |
| | 9 | |
| 6 | 10 | import org.junit.Before; |
| 7 | 11 | import org.junit.BeforeClass; |
| 8 | 12 | import org.junit.Test; |
| … |
… |
public class MapViewStateTest {
|
| 99 | 103 | MapViewPoint p = state.getForView(WIDTH / 2, HEIGHT / 2); |
| 100 | 104 | assertHasViewCoords(WIDTH / 2, HEIGHT / 2, p); |
| 101 | 105 | |
| 102 | | |
| 103 | 106 | EastNorth eastnorth = p.getEastNorth(); |
| 104 | 107 | LatLon shouldLatLon = Main.getProjection().getWorldBoundsLatLon().getCenter(); |
| 105 | 108 | EastNorth shouldEastNorth = Main.getProjection().latlon2eastNorth(shouldLatLon); |
| … |
… |
public class MapViewStateTest {
|
| 116 | 119 | assertEquals("east", 2, p2.getEastNorth().east(), 0.01); |
| 117 | 120 | assertEquals("north", 3, p2.getEastNorth().north(), 0.01); |
| 118 | 121 | } |
| | 122 | |
| | 123 | /** |
| | 124 | * Test {@link MapViewState#getAffineTransform()} |
| | 125 | */ |
| | 126 | @Test |
| | 127 | public void testGetAffineTransform() { |
| | 128 | for (EastNorth en : Arrays.asList(new EastNorth(100, 100), new EastNorth(0, 0), new EastNorth(300, 200), |
| | 129 | new EastNorth(-1, -2.5))) { |
| | 130 | MapViewPoint should = state.getPointFor(en); |
| | 131 | AffineTransform transform = state.getAffineTransform(); |
| | 132 | Point2D result = transform.transform(new Point2D.Double(en.getX(), en.getY()), null); |
| | 133 | |
| | 134 | assertEquals("x", should.getInViewX(), result.getX(), 0.01); |
| | 135 | assertEquals("y", should.getInViewY(), result.getY(), 0.01); |
| | 136 | } |
| | 137 | } |
| 119 | 138 | } |