Changeset 7343 in osm for applications/editors/josm/plugins/slippy_map_chooser/src/OsmTile.java
- Timestamp:
- 2008-04-12T15:59:42+02:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/slippy_map_chooser/src/OsmTile.java
r7199 r7343 1 1 // License: GPL. Copyright 2007 by Tim Haussmann 2 2 3 import java.awt.geom.AffineTransform; 3 4 import java.awt.image.BufferedImage; 4 5 import java.awt.Color; 5 6 import java.awt.Graphics; 7 import java.awt.Graphics2D; 8 import java.awt.RenderingHints; 9 import java.awt.Shape; 6 10 7 11 /** … … 48 52 } 49 53 50 public void paint(Graphics g ){54 public void paint(Graphics g,TileDB db){ 51 55 52 56 if(iMapImage != null && ! isInvalid){ … … 57 61 } 58 62 else{ 59 g.setColor(Color.RED); 60 g.drawLine(iX, iY, iX+WIDTH-1, iY+HEIGHT-1); 61 g.drawLine(iX, iY+HEIGHT-1, iX+WIDTH-1, iY); 62 g.drawRect(iX, iY, WIDTH-1, HEIGHT-1); 63 // first try to interpolate tile from parent 64 OsmTile parent = getParent(db); 65 if (parent!=null){ 66 Graphics2D g2d = (Graphics2D) g; 67 AffineTransform oldTr = g2d.getTransform(); 68 Shape oldClip = g2d.getClip(); 69 g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); 70 71 // since the parent will paint 4 tiles in the 72 // current zoom level we have to clip the drawing 73 // region to the current tile 74 g2d.clipRect(iX, iY, WIDTH, HEIGHT); 75 g2d.scale(2, 2); 76 parent.paint(g,db); 77 78 g2d.setTransform(oldTr); 79 g2d.setClip(oldClip); 80 } 81 else{ 82 // otherwise draw placeholder 83 g.setColor(Color.RED); 84 g.drawLine(iX, iY, iX+WIDTH-1, iY+HEIGHT-1); 85 g.drawLine(iX, iY+HEIGHT-1, iX+WIDTH-1, iY); 86 g.drawRect(iX, iY, WIDTH-1, HEIGHT-1); 87 } 63 88 } 64 89 } … … 93 118 } 94 119 120 public OsmTile getParent(TileDB db){ 121 return iZoomLevel == 0 ? null : db.get(parentKey()); 122 } 123 124 public String parentKey() { 125 return key(iZoomLevel - 1,iIndexX/2,iIndexY/2); 126 } 95 127 }
Note:
See TracChangeset
for help on using the changeset viewer.