Changeset 29921 in osm for applications/editors/josm/plugins/ElevationProfile/src
- Timestamp:
- 2013-09-08T19:49:30+02:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation
- Files:
-
- 3 added
- 6 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ColoredElevationLayer.java
r29907 r29921 1 1 package org.openstreetmap.josm.plugins.elevation; 2 2 3 import static org.openstreetmap.josm.tools.I18n.tr;4 import java.awt.Color;5 3 import java.awt.Graphics2D; 6 4 import java.awt.Point; … … 16 14 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 17 15 import org.openstreetmap.josm.gui.layer.Layer; 18 import org.openstreetmap.josm.plugins.elevation.gui.ElevationColors;19 16 import org.openstreetmap.josm.plugins.elevation.gui.Triangle; 20 17 import org.openstreetmap.josm.tools.ImageProvider; 21 18 22 19 public class ColoredElevationLayer extends Layer implements IEleRenderingListener { 23 private ElevationRenderer renderer;24 20 private GridRenderer gridRenderer; 21 private IVertexRenderer vertexRenderer; 25 22 26 23 public ColoredElevationLayer(String name) { 27 24 super(name); 28 25 29 // 30 setOpacity(0.5); 26 // make this layer transparent by 20% 27 setOpacity(0.8); 28 vertexRenderer = new SimpleVertexRenderer(); 31 29 } 32 30 33 31 @Override 34 32 public void paint(Graphics2D g, MapView mv, Bounds box) { 35 if ( renderer == null) {36 renderer = new ElevationRenderer(getName(), box, this);33 if (gridRenderer == null) { 34 gridRenderer = new GridRenderer(getName(), box, this); 37 35 System.out.println("Start renderer..."); 38 Main.worker.submit( renderer);36 Main.worker.submit(gridRenderer); 39 37 } 40 38 41 if ( renderer.getVertices().size() > 0) {42 BlockingDeque<EleVertex> list = renderer.getVertices();39 if (gridRenderer.getVertices().size() > 0) { 40 BlockingDeque<EleVertex> list = gridRenderer.getVertices(); 43 41 for (EleVertex eleVertex : list) { 44 42 Point p0 = mv.getPoint(eleVertex.get(0)); … … 47 45 Triangle t = new Triangle(p0, p1, p2); 48 46 49 50 //g.setColor(Color.magenta); 51 //g.draw(t); 52 g.setColor(ElevationColors.getElevationColor(eleVertex.getEle())); 47 // obtain vertex color 48 g.setColor(vertexRenderer.getElevationColor(eleVertex)); 53 49 g.fill(t); 54 50 } … … 106 102 } 107 103 104 public IVertexRenderer getVertexRenderer() { 105 return vertexRenderer; 106 } 107 108 public void setVertexRenderer(IVertexRenderer vertexRenderer) { 109 this.vertexRenderer = vertexRenderer; 110 } 108 111 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/EleVertex.java
r29907 r29921 107 107 108 108 // TODO: Check for proper limit 109 return z < 75 ||getArea() < (30 * 30); // = 3 * 25109 return /*z < 75 || */getArea() < (30 * 30); // = 3 * 25 110 110 } 111 111 -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationHelper.java
r29907 r29921 289 289 double eleHgt = hgt.getElevationFromHgt(ll); 290 290 291 System.out.println("Get elevation from HGT " + ll + " => " + eleHgt);291 //System.out.println("Get elevation from HGT " + ll + " => " + eleHgt); 292 292 if (isValidElevation(eleHgt)) { 293 293 return eleHgt; -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfilePlugin.java
r29907 r29921 15 15 package org.openstreetmap.josm.plugins.elevation; 16 16 17 import static org.openstreetmap.josm.tools.I18n.tr; 18 19 import java.awt.Color; 20 17 21 import org.openstreetmap.josm.Main; 18 22 import org.openstreetmap.josm.actions.JosmAction; … … 25 29 import org.openstreetmap.josm.plugins.elevation.gui.ElevationProfileDialog; 26 30 import org.openstreetmap.josm.plugins.elevation.gui.ElevationProfileLayer; 27 import static org.openstreetmap.josm.tools.I18n.tr;28 31 29 32 /** … … 51 54 JosmAction action = new AddElevationLayerAction(); 52 55 56 createColorMaps(); 57 53 58 MainMenu.add(Main.main.menu.viewMenu, action, false, 0); 54 55 59 } catch (Exception e1) { 56 60 System.err.println("Init of ElevationProfilePlugin failed: " + e1); … … 89 93 return currentLayer; 90 94 } 95 96 private void createColorMaps() { 97 // Data taken from http://proceedings.esri.com/library/userconf/proc98/proceed/to850/pap842/p842.htm 98 ColorMap.create("Physical_US", 99 new Color[]{ 100 new Color(18,129,242), 101 new Color(113,153,89), 102 new Color(117,170,101), 103 new Color(149,190,113), 104 new Color(178,214,117), 105 new Color(202,226,149), 106 new Color(222,238,161), 107 new Color(242,238,161), 108 new Color(238,222,153), 109 new Color(242,206,133), 110 new Color(234,182,129), 111 new Color(218,157,121), 112 new Color(194,141,125), 113 new Color(214,157,145), 114 new Color(226,174,165), 115 new Color(222,186,182), 116 new Color(238,198,210), 117 new Color(255,206,226), 118 new Color(250,218,234), 119 new Color(255,222,230), 120 new Color(255,230,242), 121 new Color(255,242,255) 122 }, 123 // elevation in meters - the page above uses feet, so these values differs slightly 124 new int[]{ 125 -3000, 126 0, 127 150, 128 300, 129 450, 130 600, 131 750, 132 900, 133 1050, 134 1200, 135 1350, 136 1500, 137 1650, 138 1800, 139 1950, 140 2100, 141 2250, 142 2400, 143 2550, 144 2700, 145 2750, 146 3000 147 } 148 ); 149 } 91 150 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/GridRenderer.java
r29920 r29921 17 17 import org.xml.sax.SAXException; 18 18 19 public class ElevationRenderer extends PleaseWaitRunnable {19 public class GridRenderer extends PleaseWaitRunnable { 20 20 private Bounds box; 21 21 private IEleRenderingListener listener; … … 26 26 private volatile boolean stop = false; 27 27 28 public ElevationRenderer(String title, Bounds box, IEleRenderingListener listener) {28 public GridRenderer(String title, Bounds box, IEleRenderingListener listener) { 29 29 this(title, NullProgressMonitor.INSTANCE, true, box, listener); 30 30 } 31 31 32 public ElevationRenderer(String title, boolean ignoreException, Bounds box, IEleRenderingListener listener) {32 public GridRenderer(String title, boolean ignoreException, Bounds box, IEleRenderingListener listener) { 33 33 this(title, NullProgressMonitor.INSTANCE, ignoreException, box, listener); 34 34 } 35 35 36 public ElevationRenderer(Component parent, String title,36 public GridRenderer(Component parent, String title, 37 37 boolean ignoreException, Bounds box) throws IllegalArgumentException { 38 38 super(parent, title, ignoreException); … … 42 42 } 43 43 44 public ElevationRenderer(String title, ProgressMonitor progressMonitor,44 public GridRenderer(String title, ProgressMonitor progressMonitor, 45 45 boolean ignoreException, Bounds box, IEleRenderingListener listener) { 46 46 super(title, progressMonitor, ignoreException); -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/HgtReader.java
r29907 r29921 57 57 } 58 58 } 59 60 System.out.println("Get elevation from HGT file " + file);61 59 62 60 // read elevation value -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationColors.java
r29907 r29921 33 33 public static Color EPMidBeige = new Color(227, 222, 215); 34 34 35 35 // TODO: Move to ColorMap.java or delete it 36 36 static class ColorMapEntry { 37 37 private int ele; // limit … … 52 52 } 53 53 54 55 54 56 private static ColorMapEntry[] colors = new ColorMapEntry[]{ 55 57 new ColorMapEntry(new Color(0,128, 0), 0), … … 62 64 }; 63 65 64 public static Color interpolate(java.awt.Color c1, java.awt.Color c2) { 65 int r = (c1.getRed() + c2.getRed()) / 2; 66 int g = (c1.getGreen() + c2.getGreen()) / 2; 67 int b = (c1.getBlue() + c2.getBlue()) / 2; 68 return new Color(r, g, b); 69 } 70 66 71 67 public static Color getElevationColor(double ele) { 72 68 if (!ElevationHelper.isValidElevation(ele)) {
Note:
See TracChangeset
for help on using the changeset viewer.