Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapViewState.java
r10375 r10398 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 } -
trunk/test/unit/org/openstreetmap/josm/gui/MapViewStateTest.java
r10375 r10398 3 3 4 4 import static org.junit.Assert.assertEquals; 5 6 import java.awt.geom.AffineTransform; 7 import java.awt.geom.Point2D; 8 import java.util.Arrays; 5 9 6 10 import org.junit.Before; … … 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(); … … 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 }
Note:
See TracChangeset
for help on using the changeset viewer.