Changeset 24530 in osm for applications/editors/josm
- Timestamp:
- 2010-12-02T18:52:49+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/tms/TMSLayer.java
r24521 r24530 14 14 import java.awt.event.MouseAdapter; 15 15 import java.awt.event.MouseEvent; 16 import java.awt.font.TextAttribute; 16 17 import java.awt.geom.Rectangle2D; 17 18 import java.awt.image.ImageObserver; … … 20 21 import java.net.URISyntaxException; 21 22 import java.util.ArrayList; 23 import java.util.HashMap; 22 24 import java.util.HashSet; 23 25 import java.util.LinkedList; … … 42 44 import org.openstreetmap.josm.actions.RenameLayerAction; 43 45 import org.openstreetmap.josm.data.Bounds; 46 import org.openstreetmap.josm.data.coor.EastNorth; 44 47 import org.openstreetmap.josm.data.coor.LatLon; 45 48 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; … … 102 105 public int currentZoomLevel; 103 106 104 LatLonlastTopLeft;105 LatLonlastBotRight;107 EastNorth lastTopLeft; 108 EastNorth lastBotRight; 106 109 private Image bufferImage; 107 110 private Tile clickedTile; … … 114 117 private String attrTermsUrl; 115 118 private Rectangle attrImageBounds, attrToUBounds; 116 private static Font ATTR_FONT = Font.decode("Arial 10"); 117 private static Font ATTR_LINK_FONT = Font.decode("Arial Underline 10"); 119 private static final Font ATTR_FONT = new Font("Arial", Font.PLAIN, 10); 120 private static final Font ATTR_LINK_FONT; 121 static { 122 HashMap<TextAttribute, Integer> aUnderline = new HashMap<TextAttribute, Integer>(); 123 aUnderline.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); 124 ATTR_LINK_FONT = ATTR_FONT.deriveFont(aUnderline); 125 } 118 126 119 127 protected boolean autoZoom; … … 479 487 void loadAllTiles(boolean force) { 480 488 MapView mv = Main.map.mapView; 481 LatLon topLeft = mv.getLatLon(0, 0);482 LatLon botRight = mv.getLatLon(mv.getWidth(), mv.getHeight());489 EastNorth topLeft = mv.getEastNorth(0, 0); 490 EastNorth botRight = mv.getEastNorth(mv.getWidth(), mv.getHeight()); 483 491 484 492 TileSet ts = new TileSet(topLeft, botRight, currentZoomLevel); … … 788 796 int tileMax = -1; 789 797 798 /** 799 * Create a TileSet by EastNorth bbox taking a layer shift in account 800 */ 801 TileSet(EastNorth topLeft, EastNorth botRight, int zoom) { 802 this(Main.proj.eastNorth2latlon(topLeft.add(-getDx(), -getDy())), 803 Main.proj.eastNorth2latlon(botRight.add(-getDx(), -getDy())),zoom); 804 } 805 806 /** 807 * Create a TileSet by known LatLon bbox without layer shift correction 808 */ 790 809 TileSet(LatLon topLeft, LatLon botRight, int zoom) { 791 810 this.zoom = zoom; 811 792 812 z12x0 = lonToTileX(topLeft.lon(), zoom); 793 813 z12y0 = latToTileY(topLeft.lat(), zoom); … … 860 880 { 861 881 List<Tile> tiles = this.allTiles(true); 862 boolean autoload = TMSLayer.this.autoLoad; 863 if (!autoload && !force) 882 if (!autoLoad && !force) 864 883 return; 865 884 int nr_queued = 0; … … 886 905 public void paint(Graphics2D g, MapView mv, Bounds bounds) { 887 906 //long start = System.currentTimeMillis(); 888 LatLon topLeft = mv.getLatLon(0, 0);889 LatLon botRight = mv.getLatLon(mv.getWidth(), mv.getHeight());907 EastNorth topLeft = mv.getEastNorth(0, 0); 908 EastNorth botRight = mv.getEastNorth(mv.getWidth(), mv.getHeight()); 890 909 Graphics2D oldg = g; 891 910 892 if (botRight. lon() == 0.0 || botRight.lat() == 0) {911 if (botRight.east() == 0.0 || botRight.north() == 0) { 893 912 Main.debug("still initializing??"); 894 913 // probably still initializing … … 896 915 } 897 916 898 if (lastTopLeft != null && lastBotRight != null && topLeft.equals Epsilon(lastTopLeft)899 && botRight.equals Epsilon(lastBotRight) && bufferImage != null917 if (lastTopLeft != null && lastBotRight != null && topLeft.equals(lastTopLeft) 918 && botRight.equals(lastBotRight) && bufferImage != null 900 919 && mv.getWidth() == bufferImage.getWidth(null) && mv.getHeight() == bufferImage.getHeight(null) 901 920 && !needRedraw) { … … 990 1009 if (tileSource.requiresAttribution()) { 991 1010 // Draw attribution 992 g.setColor(Color. white);1011 g.setColor(Color.black); 993 1012 Font font = g.getFont(); 994 1013 g.setFont(ATTR_LINK_FONT); … … 1011 1030 int x = 2; 1012 1031 int height = attrImage.getHeight(this); 1013 int y = termsTextY - height ;1032 int y = termsTextY - height - textHeight - 5; 1014 1033 attrImageBounds = new Rectangle(x, y, imgWidth, height); 1015 1034 g.drawImage(attrImage, x, y, this); 1016 1035 } 1017 1036 1018 String attributionText = tileSource.getAttributionText(currentZoomLevel, topLeft, botRight); 1037 g.setFont(ATTR_FONT); 1038 String attributionText = tileSource.getAttributionText(currentZoomLevel, 1039 Main.proj.eastNorth2latlon(topLeft), Main.proj.eastNorth2latlon(botRight)); 1019 1040 Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(attributionText, g); 1020 1041 g.drawString(attributionText, mv.getWidth() - (int) stringBounds.getWidth(), mv.getHeight() - textHeight); … … 1062 1083 MapView mv = Main.map.mapView; 1063 1084 Point clicked = new Point(px, py); 1064 LatLon topLeft = mv.getLatLon(0, 0);1065 LatLon botRight = mv.getLatLon(mv.getWidth(), mv.getHeight());1085 EastNorth topLeft = mv.getEastNorth(0, 0); 1086 EastNorth botRight = mv.getEastNorth(mv.getWidth(), mv.getHeight()); 1066 1087 int z = currentZoomLevel; 1067 1088 TileSet ts = new TileSet(topLeft, botRight, z); -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/tms/TMSPreferences.java
r24521 r24530 59 59 maxZoomLvl = PROP_MIN_ZOOM_LVL.get(); 60 60 } 61 if (ts != null && ts.getMaxZoom() < PROP_MIN_ZOOM_LVL.get()) {62 System.err.println("decreasing maxZoomLvl to match newtile source");61 if (ts != null && ts.getMaxZoom() < maxZoomLvl) { 62 System.err.println("decreasing maxZoomLvl to match tile source"); 63 63 maxZoomLvl = ts.getMaxZoom(); 64 64 } … … 86 86 minZoomLvl = getMaxZoomLvl(ts); 87 87 } 88 if (ts != null && ts.getMinZoom() > PROP_MIN_ZOOM_LVL.get()) {89 System.err.println("increasomg minZoomLvl to match newtile source");88 if (ts != null && ts.getMinZoom() > minZoomLvl) { 89 System.err.println("increasomg minZoomLvl to match tile source"); 90 90 minZoomLvl = ts.getMinZoom(); 91 91 } -
applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapLayer.java
r24488 r24530 14 14 import java.awt.event.MouseAdapter; 15 15 import java.awt.event.MouseEvent; 16 import java.awt.font.TextAttribute; 16 17 import java.awt.geom.Rectangle2D; 17 18 import java.awt.image.ImageObserver; … … 20 21 import java.net.URISyntaxException; 21 22 import java.util.ArrayList; 23 import java.util.HashMap; 22 24 import java.util.HashSet; 23 25 import java.util.LinkedList; … … 112 114 private String attrTermsUrl; 113 115 private Rectangle attrImageBounds, attrToUBounds; 114 private static Font ATTR_FONT = Font.decode("Arial 10"); 115 private static Font ATTR_LINK_FONT = Font.decode("Arial Underline 10"); 116 private static final Font ATTR_FONT = new Font("Arial", Font.PLAIN, 10); 117 private static final Font ATTR_LINK_FONT; 118 static { 119 HashMap<TextAttribute, Integer> aUnderline = new HashMap<TextAttribute, Integer>(); 120 aUnderline.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); 121 ATTR_LINK_FONT = ATTR_FONT.deriveFont(aUnderline); 122 } 116 123 117 124 void redraw() … … 979 986 int x = 2; 980 987 int height = attrImage.getHeight(this); 981 int y = termsTextY - height ;988 int y = termsTextY - height - textHeight - 5; 982 989 attrImageBounds = new Rectangle(x, y, imgWidth, height); 983 990 g.drawImage(attrImage, x, y, this); 984 991 } 985 992 993 g.setFont(ATTR_FONT); 986 994 String attributionText = tileSource.getAttributionText(currentZoomLevel, topLeft, botRight); 987 995 Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(attributionText, g);
Note:
See TracChangeset
for help on using the changeset viewer.