Changeset 27926 in osm for applications
- Timestamp:
- 2012-02-23T03:11:27+01:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/canvec_helper/src/org/openstreetmap/josm/plugins/canvec_helper
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/canvec_helper/src/org/openstreetmap/josm/plugins/canvec_helper/CanVecTile.java
r27925 r27926 152 152 else this.tileid = String.format("%03d%s%02d%s",corda,cordb,cordc,cordd); 153 153 valid = true; 154 debug(index.toString()); 155 debug("creating tileid: "+this.tileid); 154 //debug(index.toString()); 155 //debug("creating tileid: "+this.tileid); 156 156 } 157 157 public boolean isValid() { return valid; } … … 257 257 break; 258 258 case 2: 259 debug("making layer2 tiles, index: "+index.toString());260 259 p = Pattern.compile("\\d\\d\\d[A-Z](\\d\\d).*"); 261 260 int last_cell2 = -1; 262 261 for (int i = 0; i < index.size(); i++) { 263 debug(index.get(i));264 262 Matcher m = p.matcher(index.get(i)); 265 263 m.matches(); … … 271 269 buffer.add(m.group(0)); 272 270 } else { 273 debug(buffer.toString());274 debug(""+last_cell2);275 271 sub_tiles.add(new CanVecTile(corda,cordb,last_cell2,"",plugin_self,buffer)); 276 272 buffer = new ArrayList<String>(); … … 284 280 sub_tiles_made = true; 285 281 } 286 public void paint(Graphics2D g, MapView mv, Bounds bounds) { 282 public void paint(Graphics2D g, MapView mv, Bounds bounds, int max_zoom) { 287 283 boolean show_sub_tiles = false; 288 284 if (!isVisible(bounds)) return; 289 285 if ((depth == 3) && (bounds.getArea() < 0.5)) { // 022B01 290 downloadSelf(); 291 debug(sub_tile_ids.toString()); 286 if (max_zoom == 4) downloadSelf(); 292 287 show_sub_tiles = true; 293 288 } else if ((depth == 2) && (bounds.getArea() < 20)) { // its a layer2 tile … … 298 293 make_sub_tiles(1); 299 294 show_sub_tiles = true; 295 } 296 if (show_sub_tiles && (depth < max_zoom)) { 297 for (int i = 0; i < sub_tiles.size(); i++) { 298 CanVecTile tile = sub_tiles.get(i); 299 tile.paint(g,mv,bounds,max_zoom); 300 } 300 301 } else { 301 302 Point corners[] = getCorners(mv); … … 306 307 g.drawString(getTileId(),corners[0].x,corners[0].y); 307 308 } 308 if (show_sub_tiles) {309 for (int i = 0; i < sub_tiles.size(); i++) {310 CanVecTile tile = sub_tiles.get(i);311 tile.paint(g,mv,bounds);312 }313 }314 309 } 315 310 } -
applications/editors/josm/plugins/canvec_helper/src/org/openstreetmap/josm/plugins/canvec_helper/CanvecHelperAction.java
r27920 r27926 2 2 3 3 import org.openstreetmap.josm.actions.JosmAction; 4 import org.openstreetmap.josm.plugins.Plugin;5 4 import org.openstreetmap.josm.Main; 6 5 -
applications/editors/josm/plugins/canvec_helper/src/org/openstreetmap/josm/plugins/canvec_helper/canvec_helper.java
r27920 r27926 13 13 } 14 14 public void mapFrameInitialized(MapFrame old, MapFrame new1) { 15 System.out.println("mapFrame made!");16 15 updateLayer(); 17 16 } -
applications/editors/josm/plugins/canvec_helper/src/org/openstreetmap/josm/plugins/canvec_helper/canvec_layer.java
r27924 r27926 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 import org.openstreetmap.josm.gui.layer.Layer; 5 import java.awt.Component; 5 6 import java.awt.Graphics2D; 7 import java.awt.event.ActionEvent; 6 8 import java.awt.event.MouseEvent; 7 9 import java.awt.event.MouseListener; … … 13 15 import java.io.IOException; 14 16 17 import javax.swing.AbstractAction; 15 18 import javax.swing.Action; 16 19 import javax.swing.Icon; 17 20 import javax.swing.ImageIcon; 21 import javax.swing.JMenu; 22 import javax.swing.JMenuItem; 18 23 import org.openstreetmap.josm.actions.RenameLayerAction; 19 24 import org.openstreetmap.josm.data.Bounds; … … 27 32 import java.util.regex.Pattern; 28 33 import java.util.regex.Matcher; 34 import java.util.List; 29 35 30 36 // most of the layout was copied from the openstreetbugs plugin to get things started 31 37 public class canvec_layer extends Layer implements MouseListener { 32 38 private Icon layerIcon = null; 39 private int max_zoom = 3; 33 40 canvec_helper plugin_self; 34 41 private ArrayList<CanVecTile> tiles = new ArrayList<CanVecTile>(); … … 80 87 LayerListDialog.getInstance().createDeleteLayerAction(), 81 88 SeparatorLayerAction.INSTANCE, 82 new LayerListPopup.InfoAction(this)}; 89 new LayerListPopup.InfoAction(this), 90 new MaxZoomAction(this)}; 91 } 92 public class MaxZoomAction extends AbstractAction implements LayerAction { 93 private canvec_layer parent; 94 public MaxZoomAction(canvec_layer parent) { 95 this.parent = parent; 96 } 97 public void actionPerformed(ActionEvent e) {} 98 public boolean supportLayers(List<Layer> layers) { 99 return false; 100 } 101 public Component createMenuComponent() { 102 JMenu max_zoom = new JMenu("max zoom"); 103 max_zoom.add(new JMenuItem(new SetMaxZoom(parent,1))); 104 max_zoom.add(new JMenuItem(new SetMaxZoom(parent,2))); 105 max_zoom.add(new JMenuItem(new SetMaxZoom(parent,3))); 106 max_zoom.add(new JMenuItem(new SetMaxZoom(parent,4))); 107 return max_zoom; 108 } 109 } 110 public void setMaxZoom(int max_zoom) { 111 this.max_zoom = max_zoom; 83 112 } 84 113 public Object getInfoComponent() { … … 101 130 for (int i = 0; i < tiles.size(); i++) { 102 131 CanVecTile tile = tiles.get(i); 103 tile.paint(g,mv,bounds); 132 tile.paint(g,mv,bounds,max_zoom); 104 133 } 105 134 long end = System.currentTimeMillis();
Note:
See TracChangeset
for help on using the changeset viewer.