Changeset 29271 in osm for applications/editors/josm/plugins/smed2
- Timestamp:
- 2013-02-21T15:10:49+01:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/smed2/src/seamap
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/seamap/Renderer.java
r29270 r29271 20 20 import seamap.SeaMap; 21 21 import seamap.SeaMap.*; 22 import seamap.SeaMap.Area; 22 23 import symbols.Symbols; 23 24 import symbols.Symbols.*; … … 92 93 93 94 public static void lineSymbols(Feature feature, Symbol prisymb, double space, Symbol secsymb, int ratio) { 94 if (feature.flag != Fflag.POINT) { 95 Rectangle prect = symbolSize(prisymb); 96 Rectangle srect = symbolSize(secsymb); 97 if (srect == null) 98 ratio = 0; 99 if (prect != null) { 100 ArrayList<Long> ways = new ArrayList<Long>(); 101 double psize = Math.abs(prect.getY()) * sScale; 102 double ssize = (srect != null) ? Math.abs(srect.getY()) * sScale : 0; 103 // if (map.outers.containsKey(feature.refs)) { 104 // ways.addAll(map.mpolys.get(map.outers.get(feature.refs))); 105 // } else { 106 // if (map.mpolys.containsKey(feature.refs)) { 107 // ways.addAll(map.mpolys.get(feature.refs)); 108 // } else { 109 // ways.add(feature.refs); 110 // } 111 // } 112 Point2D prev = new Point2D.Double(); 113 Point2D next = new Point2D.Double(); 114 Point2D curr = new Point2D.Double(); 115 Point2D succ = new Point2D.Double(); 116 boolean gap = true; 117 boolean piv = false; 118 double len = 0; 119 double angle = 0; 120 int scount = ratio; 121 Symbol symbol = prisymb; 122 for (long way : ways) { 123 boolean first = true; 124 /* for (long node : map.ways.get(way)) { 125 prev = next; 126 next = helper.getPoint(map.points.get(node)); 127 angle = Math.atan2(next.getY() - prev.getY(), next.getX() - prev.getX()); 128 piv = true; 129 if (first) { 130 curr = succ = next; 131 gap = (space > 0); 132 scount = ratio; 133 symbol = prisymb; 134 len = gap ? psize * space * 0.5 : psize; 135 first = false; 136 } else { 137 while (curr.distance(next) >= len) { 138 if (piv) { 139 double rem = len; 140 double s = prev.distance(next); 141 double p = curr.distance(prev); 142 if ((s > 0) && (p > 0)) { 143 double n = curr.distance(next); 144 double theta = Math.acos((s * s + p * p - n * n) / 2 / s / p); 145 double phi = Math.asin(p / len * Math.sin(theta)); 146 rem = len * Math.sin(Math.PI - theta - phi) / Math.sin(theta); 147 } 148 succ = new Point2D.Double(prev.getX() + (rem * Math.cos(angle)), prev.getY() + (rem * Math.sin(angle))); 149 piv = false; 150 } else { 151 succ = new Point2D.Double(curr.getX() + (len * Math.cos(angle)), curr.getY() + (len * Math.sin(angle))); 95 Area area; 96 switch (feature.flag) { 97 case LINE: 98 Edge edge = map.edges.get(feature.refs); 99 area = map.new Area(); 100 area.add(map.new Bound(map.new Side(edge, true), true)); 101 break; 102 case AREA: 103 area = map.areas.get(feature.refs); 104 break; 105 default: 106 return; 107 } 108 Rectangle prect = symbolSize(prisymb); 109 Rectangle srect = symbolSize(secsymb); 110 if (srect == null) 111 ratio = 0; 112 if (prect != null) { 113 double psize = Math.abs(prect.getY()) * sScale; 114 double ssize = (srect != null) ? Math.abs(srect.getY()) * sScale : 0; 115 Point2D prev = new Point2D.Double(); 116 Point2D next = new Point2D.Double(); 117 Point2D curr = new Point2D.Double(); 118 Point2D succ = new Point2D.Double(); 119 boolean gap = true; 120 boolean piv = false; 121 double len = 0; 122 double angle = 0; 123 int scount = ratio; 124 Symbol symbol = prisymb; 125 for (Bound bound : area) { 126 BoundIterator bit = map.new BoundIterator(bound); 127 boolean first = true; 128 while (bit.hasNext()) { 129 prev = next; 130 next = helper.getPoint(bit.next()); 131 angle = Math.atan2(next.getY() - prev.getY(), next.getX() - prev.getX()); 132 piv = true; 133 if (first) { 134 curr = succ = next; 135 gap = (space > 0); 136 scount = ratio; 137 symbol = prisymb; 138 len = gap ? psize * space * 0.5 : psize; 139 first = false; 140 } else { 141 while (curr.distance(next) >= len) { 142 if (piv) { 143 double rem = len; 144 double s = prev.distance(next); 145 double p = curr.distance(prev); 146 if ((s > 0) && (p > 0)) { 147 double n = curr.distance(next); 148 double theta = Math.acos((s * s + p * p - n * n) / 2 / s / p); 149 double phi = Math.asin(p / len * Math.sin(theta)); 150 rem = len * Math.sin(Math.PI - theta - phi) / Math.sin(theta); 152 151 } 153 if (!gap) { 154 Symbols.drawSymbol(g2, symbol, sScale, curr.getX(), curr.getY(), 155 new Delta(Handle.BC, AffineTransform.getRotateInstance(Math.atan2((succ.getY() - curr.getY()), (succ.getX() - curr.getX()) + Math.toRadians(90)))), null); 156 } 157 if (space > 0) gap = !gap; 158 curr = succ; 159 len = gap ? (psize * space) : (--scount == 0) ? ssize : psize; 160 if (scount == 0) { 161 symbol = secsymb; 162 scount = ratio; 163 } else { 164 symbol = prisymb; 165 } 152 succ = new Point2D.Double(prev.getX() + (rem * Math.cos(angle)), prev.getY() + (rem * Math.sin(angle))); 153 piv = false; 154 } else { 155 succ = new Point2D.Double(curr.getX() + (len * Math.cos(angle)), curr.getY() + (len * Math.sin(angle))); 156 } 157 if (!gap) { 158 Symbols.drawSymbol(g2, symbol, sScale, curr.getX(), curr.getY(), 159 new Delta(Handle.BC, AffineTransform.getRotateInstance(Math.atan2((succ.getY() - curr.getY()), (succ.getX() - curr.getX()) + Math.toRadians(90)))), null); 160 } 161 if (space > 0) gap = !gap; 162 curr = succ; 163 len = gap ? (psize * space) : (--scount == 0) ? ssize : psize; 164 if (scount == 0) { 165 symbol = secsymb; 166 scount = ratio; 167 } else { 168 symbol = prisymb; 166 169 } 167 170 } 168 171 } 169 */}172 } 170 173 } 171 174 } … … 175 178 Path2D.Double p = new Path2D.Double(); 176 179 p.setWindingRule(GeneralPath.WIND_EVEN_ODD); 180 Point2D point; 177 181 switch (feature.flag) { 178 182 case LINE: 183 EdgeIterator eit = map.new EdgeIterator(map.edges.get(feature.refs), true); 184 point = helper.getPoint(eit.next()); 185 p.moveTo(point.getX(), point.getY()); 186 while (eit.hasNext()) { 187 point = helper.getPoint(eit.next()); 188 p.lineTo(point.getX(), point.getY()); 189 } 179 190 break; 180 191 case AREA: 181 break; 182 /* ArrayList<Long> ways = new ArrayList<Long>(); 183 if (map.outers.containsKey(feature.refs)) { 184 ways.addAll(map.mpolys.get(map.outers.get(feature.refs))); 192 for (Bound bound : map.areas.get(feature.refs)) { 193 BoundIterator bit = map.new BoundIterator(bound); 194 point = helper.getPoint(bit.next()); 195 p.moveTo(point.getX(), point.getY()); 196 while (bit.hasNext()) { 197 point = helper.getPoint(bit.next()); 198 p.lineTo(point.getX(), point.getY()); 199 } 200 } 201 break; 202 } 203 if (style.line != null) { 204 if (style.dash != null) { 205 float[] dash = new float[style.dash.length]; 206 System.arraycopy(style.dash, 0, dash, 0, style.dash.length); 207 for (int i = 0; i < style.dash.length; i++) { 208 dash[i] *= (float) sScale; 209 } 210 g2.setStroke(new BasicStroke((float) (style.width * sScale), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1, dash, 0)); 185 211 } else { 186 if (map.mpolys.containsKey(feature.refs)) { 187 ways.addAll(map.mpolys.get(feature.refs)); 188 } else { 189 ways.add(feature.refs); 190 } 191 } 192 for (long way : ways) { 193 boolean first = true; 194 for (long node : map.ways.get(way)) { 195 Point2D point = helper.getPoint(map.points.get(node)); 196 if (first) { 197 p.moveTo(point.getX(), point.getY()); 198 first = false; 199 } else { 200 p.lineTo(point.getX(), point.getY()); 201 } 202 } 203 } 204 if (style.line != null) { 205 if (style.dash != null) { 206 float[] dash = new float[style.dash.length]; 207 System.arraycopy(style.dash, 0, dash, 0, style.dash.length); 208 for (int i = 0; i < style.dash.length; i++) { 209 dash[i] *= (float) sScale; 210 } 211 g2.setStroke(new BasicStroke((float) (style.width * sScale), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1, dash, 0)); 212 } else { 213 g2.setStroke(new BasicStroke((float) (style.width * sScale), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); 214 } 215 g2.setPaint(style.line); 216 g2.draw(p); 217 } 218 if (style.fill != null) { 219 g2.setPaint(style.fill); 220 g2.fill(p); 221 }*/ 212 g2.setStroke(new BasicStroke((float) (style.width * sScale), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); 213 } 214 g2.setPaint(style.line); 215 g2.draw(p); 216 } 217 if (style.fill != null) { 218 g2.setPaint(style.fill); 219 g2.fill(p); 222 220 } 223 221 } -
applications/editors/josm/plugins/smed2/src/seamap/SeaMap.java
r29270 r29271 275 275 } 276 276 277 public class AreaIterator {278 Area area;279 }280 281 public class FeatureIterator {282 Feature feature;283 }284 285 277 public SeaMap() { 286 278 nodes = new NodeTab();
Note:
See TracChangeset
for help on using the changeset viewer.