Changeset 30025 in osm
- Timestamp:
- 2013-10-18T11:30:13+02:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/smed2/src
- Files:
-
- 6 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/panels/ShowFrame.java
r30024 r30025 12 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 13 14 import seamap.Map Helper;14 import seamap.MapContext; 15 15 import seamap.Renderer; 16 16 import seamap.SeaMap; … … 22 22 Picture picture; 23 23 24 class Picture extends JPanel implements Map Helper{24 class Picture extends JPanel implements MapContext { 25 25 26 26 public void drawPicture(OsmPrimitive osm, SeaMap map) { -
applications/editors/josm/plugins/smed2/src/seamap/Lights.java
r29787 r30025 17 17 18 18 private static Point2D.Double radial(Snode centre, double radius, double angle) { 19 Point2D origin = Renderer. helper.getPoint(centre);20 double mile = Renderer. helper.getPoint(Renderer.map.new Snode((centre.lat + Math.toRadians(1/60)), centre.lon)).getY() - origin.getY();19 Point2D origin = Renderer.context.getPoint(centre); 20 double mile = Renderer.context.getPoint(Renderer.map.new Snode((centre.lat + Math.toRadians(1/60)), centre.lon)).getY() - origin.getY(); 21 21 return new Point2D.Double(origin.getX() - (radius * mile * Math.sin(angle)), origin.getY() - (radius * mile * Math.cos(angle))); 22 22 } -
applications/editors/josm/plugins/smed2/src/seamap/MapContext.java
r30024 r30025 5 5 import seamap.SeaMap.*; 6 6 7 public interface Map Helper{7 public interface MapContext { 8 8 Point2D getPoint(Snode coord); 9 9 double mile(Feature feature); -
applications/editors/josm/plugins/smed2/src/seamap/Renderer.java
r30024 r30025 65 65 public enum LabelStyle { NONE, RRCT, RECT, ELPS, CIRC } 66 66 67 static Map Helper helper;67 static MapContext context; 68 68 static SeaMap map; 69 69 static double sScale; … … 72 72 static int zoom; 73 73 74 public static void reRender(Graphics2D g, int z, double factor, SeaMap m, Map Helper h) {74 public static void reRender(Graphics2D g, int z, double factor, SeaMap m, MapContext c) { 75 75 g2 = g; 76 76 zoom = z; 77 helper = h;77 context = c; 78 78 map = m; 79 79 sScale = symbolScale[zoom] * factor; … … 107 107 108 108 public static void symbol(Feature feature, Symbol symbol, Obj obj, Delta delta, Scheme scheme) { 109 Point2D point = helper.getPoint(feature.centre);109 Point2D point = context.getPoint(feature.centre); 110 110 if (obj == null) { 111 111 Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), delta, scheme); … … 177 177 while (bit.hasNext()) { 178 178 prev = next; 179 next = helper.getPoint(bit.next());179 next = context.getPoint(bit.next()); 180 180 angle = Math.atan2(next.getY() - prev.getY(), next.getX() - prev.getX()); 181 181 piv = true; … … 233 233 case LINE: 234 234 EdgeIterator eit = map.new EdgeIterator(map.edges.get(feature.refs), true); 235 point = helper.getPoint(eit.next());235 point = context.getPoint(eit.next()); 236 236 p.moveTo(point.getX(), point.getY()); 237 237 while (eit.hasNext()) { 238 point = helper.getPoint(eit.next());238 point = context.getPoint(eit.next()); 239 239 p.lineTo(point.getX(), point.getY()); 240 240 } … … 243 243 for (Bound bound : map.areas.get(feature.refs)) { 244 244 BoundIterator bit = map.new BoundIterator(bound); 245 point = helper.getPoint(bit.next());245 point = context.getPoint(bit.next()); 246 246 p.moveTo(point.getX(), point.getY()); 247 247 while (bit.hasNext()) { 248 point = helper.getPoint(bit.next());248 point = context.getPoint(bit.next()); 249 249 p.lineTo(point.getX(), point.getY()); 250 250 } … … 292 292 break; 293 293 } 294 radius *= helper.mile(feature);294 radius *= context.mile(feature); 295 295 Symbol circle = new Symbol(); 296 296 if (style.fill != null) { … … 301 301 circle.add(new Instr(Prim.STRK, new BasicStroke(style.width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, style.dash, 0))); 302 302 circle.add(new Instr(Prim.ELPS, new Ellipse2D.Double(-radius,-radius,radius*2,radius*2))); 303 Point2D point = helper.getPoint(feature.centre);304 Symbols.drawSymbol(g2, circle, sScale, point.getX(), point.getY(), null, null);303 Point2D point = context.getPoint(feature.centre); 304 Symbols.drawSymbol(g2, circle, 1, point.getX(), point.getY(), null, null); 305 305 } 306 306 … … 312 312 switch (feature.flag) { 313 313 case POINT: 314 point = helper.getPoint(feature.centre);314 point = context.getPoint(feature.centre); 315 315 g2.drawImage(image, new AffineTransformOp(AffineTransform.getScaleInstance(sScale, sScale), AffineTransformOp.TYPE_NEAREST_NEIGHBOR), 316 316 (int)(point.getX() - (50 * sScale)), (int)(point.getY() - (50 * sScale))); … … 319 319 for (Bound bound : map.areas.get(feature.refs)) { 320 320 BoundIterator bit = map.new BoundIterator(bound); 321 point = helper.getPoint(bit.next());321 point = context.getPoint(bit.next()); 322 322 p.moveTo(point.getX(), point.getY()); 323 323 while (bit.hasNext()) { 324 point = helper.getPoint(bit.next());324 point = context.getPoint(bit.next()); 325 325 p.lineTo(point.getX(), point.getY()); 326 326 } … … 340 340 GlyphVector gv = font.deriveFont((float)(font.getSize())).createGlyphVector(frc, str.equals(" ") ? "M" : str); 341 341 Rectangle2D bounds = gv.getVisualBounds(); 342 double width = bounds.getWidth() * 1.5;343 double height = bounds.getHeight() * 1.5;344 double dx = 0; 345 double dy = 0; 342 double width = bounds.getWidth(); 343 double height = bounds.getHeight(); 344 double dx = 0.25 * width; 345 double dy = 0.25 * height; 346 346 switch (delta.h) { 347 347 case CC: 348 dx = width / 2.0; 349 dy = height / 2.0; 348 dx += width / 2.0; 349 dy += height / 2.0; 350 350 break; 351 351 case TL: 352 dx = 0; 353 dy = 0; 352 dx += 0; 353 dy += 0; 354 354 break; 355 355 case TR: 356 dx = width; 357 dy = 0; 356 dx += width; 357 dy += 0; 358 358 break; 359 359 case TC: 360 dx = width / 2.0; 361 dy = 0; 360 dx += width / 2.0; 361 dy += 0; 362 362 break; 363 363 case LC: 364 dx = 0; 365 dy = height / 2.0; 364 dx += 0; 365 dy += height / 2.0; 366 366 break; 367 367 case RC: 368 dx = width; 369 dy = height / 2.0; 368 dx += width; 369 dy += height / 2.0; 370 370 break; 371 371 case BL: 372 dx = 0; 373 dy = height; 372 dx += 0; 373 dy += height; 374 374 break; 375 375 case BR: 376 dx = width; 377 dy = height; 376 dx += width; 377 dy += height; 378 378 break; 379 379 case BC: 380 dx = width / 2.0; 381 dy = height; 380 dx += width / 2.0; 381 dy += height; 382 382 break; 383 383 } … … 386 386 case RRCT: 387 387 if (width < height) width = height; 388 width *= 1.5; 389 height *= 1.5; 388 390 label.add(new Instr(Prim.FILL, bg)); 389 label.add(new Instr(Prim.RSHP, new RoundRectangle2D.Double(-dx,-dy /1.25,width,height,height,height)));391 label.add(new Instr(Prim.RSHP, new RoundRectangle2D.Double(-dx,-dy,width,height,height,height))); 390 392 label.add(new Instr(Prim.FILL, fg)); 391 393 label.add(new Instr(Prim.STRK, new BasicStroke(1 + (int)(height/10), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER))); 392 label.add(new Instr(Prim.RRCT, new RoundRectangle2D.Double(-dx,-dy /1.25,width,height,height,height)));394 label.add(new Instr(Prim.RRCT, new RoundRectangle2D.Double(-dx,-dy,width,height,height,height))); 393 395 break; 394 396 } 395 397 label.add(new Instr(Prim.TEXT, new Caption(str, font, fg, delta))); 396 Point2D point = helper.getPoint(feature.centre);398 Point2D point = context.getPoint(feature.centre); 397 399 Symbols.drawSymbol(g2, label, sScale, point.getX(), point.getY(), null, null); 398 400 } … … 431 433 while (bit.hasNext()) { 432 434 prev = next; 433 next = helper.getPoint(bit.next());435 next = context.getPoint(bit.next()); 434 436 angle = Math.atan2(next.getY() - prev.getY(), next.getX() - prev.getX()); 435 437 piv = true; -
applications/editors/josm/plugins/smed2/src/seamap/Rules.java
r30024 r30025 34 34 ArrayList<Feature> objects; 35 35 if ((objects = map.features.get(Obj.SLCONS)) != null) for (Feature feature : objects) shoreline(feature); 36 if ((objects = map.features.get(Obj.SLCONS)) != null) for (Feature feature : objects) shoreline(feature);;37 36 if ((objects = map.features.get(Obj.PIPSOL)) != null) for (Feature feature : objects) pipelines(feature); 38 37 if ((objects = map.features.get(Obj.CBLSUB)) != null) for (Feature feature : objects) cables(feature); … … 62 61 if ((objects = map.features.get(Obj.ACHARE)) != null) for (Feature feature : objects) harbours(feature); 63 62 if ((objects = map.features.get(Obj.ACHBRT)) != null) for (Feature feature : objects) harbours(feature); 63 if ((objects = map.features.get(Obj.BERTHS)) != null) for (Feature feature : objects) harbours(feature); 64 64 if ((objects = map.features.get(Obj.LOKBSN)) != null) for (Feature feature : objects) locks(feature); 65 65 if ((objects = map.features.get(Obj.LKBSPT)) != null) for (Feature feature : objects) locks(feature); … … 245 245 246 246 } 247 /* Att_t *attv = getAtt(getObj(item, BRIDGE, 0), VERCLR); 247 /* case BRIDGE: { 248 Att_t *attv = getAtt(getObj(item, BRIDGE, 0), VERCLR); 248 249 if (attv == NULL) attv = getAtt(getObj(item, BRIDGE, 0), VERCSA); 249 250 Att_t *attc = getAtt(getObj(item, BRIDGE, 0), VERCCL); … … 254 255 } 255 256 else if ((attc != NULL) && (atto == NULL)) { 257 char *string=strdup(stringValue(attc->val)); 258 string = realloc(string, strlen(string) + 3); strcat(string, "/-"); 256 259 renderSymbol(item, obja, "clear_v", "", "", CC, 0, 0, 0); 257 drawText(item, stringValue(attc->val), "font-family:Arial; font-weight:normal; font-size:70; text-anchor:middle", 0, 12); 260 drawText(item, string, "font-family:Arial; font-weight:normal; font-size:70; text-anchor:middle", 0, 12); 261 free(string); 258 262 } 259 263 else if ((attc != NULL) && (atto != NULL)) { 260 renderSymbol(item, obja, "clear_v", "", "", RC, 5, 0, 0); 261 drawText(item, stringValue(attc->val), "font-family:Arial; font-weight:normal; font-size:70; text-anchor:middle", -35, 12); 262 renderSymbol(item, obja, "clear_v", "", "", LC, -5, 0, 0); 263 drawText(item, stringValue(atto->val), "font-family:Arial; font-weight:normal; font-size:70; text-anchor:middle", 35, 12); 264 char *string=strdup(stringValue(attc->val)); 265 string = realloc(string, strlen(string) + 2); strcat(string, "/"); 266 string = realloc(string, strlen(string) + strlen(stringValue(atto->val)) + 1); strcat(string, stringValue(atto->val)); 267 renderSymbol(item, obja, "clear_v", "", "", CC, 0, 0, 0); 268 drawText(item, string, "font-family:Arial; font-weight:normal; font-size:60; text-anchor:middle", 0, 10); 269 free(string); 264 270 } 265 271 } … … 318 324 if (radius != 0) { 319 325 UniHLU units = (UniHLU)Renderer.getAttVal(feature, Obj.ACHBRT, 0, Att.HUNITS); 320 Renderer.lineCircle (feature, new LineStyle(new Color(0xc480ff), 10, new float[] {25, 25}, null), radius, units);326 Renderer.lineCircle (feature, new LineStyle(new Color(0xc480ff), 4, new float[] { 10, 10 }, null), radius, units); 321 327 } 322 328 break; … … 366 372 break; 367 373 } 374 } 375 break; 376 case BERTHS: 377 if (zoom >= 14) { 378 Renderer.labelText(feature, name == null ? " " : (String) name.val, new Font("Arial", Font.PLAIN, 40), LabelStyle.RRCT, new Color(0xc480ff), Color.white, null); 368 379 } 369 380 break; … … 895 906 break; 896 907 case ROS_VAIS: 897 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));908 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70))); 898 909 break; 899 910 case ROS_VANC: 900 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));911 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70))); 901 912 Renderer.symbol(feature, Topmarks.TopNorth, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null); 902 913 break; 903 914 case ROS_VASC: 904 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));915 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70))); 905 916 Renderer.symbol(feature, Topmarks.TopSouth, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null); 906 917 break; 907 918 case ROS_VAEC: 908 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));919 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70))); 909 920 Renderer.symbol(feature, Topmarks.TopEast, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null); 910 921 break; 911 922 case ROS_VAWC: 912 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));923 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70))); 913 924 Renderer.symbol(feature, Topmarks.TopWest, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null); 914 925 break; 915 926 case ROS_VAPL: 916 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));927 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70))); 917 928 Renderer.symbol(feature, Topmarks.TopCan, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null); 918 929 break; 919 930 case ROS_VASL: 920 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));931 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70))); 921 932 Renderer.symbol(feature, Topmarks.TopCone, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null); 922 933 break; 923 934 case ROS_VAID: 924 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));935 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70))); 925 936 Renderer.symbol(feature, Topmarks.TopIsol, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null); 926 937 break; 927 938 case ROS_VASW: 928 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));939 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70))); 929 940 Renderer.symbol(feature, Topmarks.TopSphere, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null); 930 941 break; 931 942 case ROS_VASP: 932 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));943 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70))); 933 944 Renderer.symbol(feature, Topmarks.TopX, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null); 934 945 break; 935 946 case ROS_VAWK: 936 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));947 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70))); 937 948 Renderer.symbol(feature, Topmarks.TopCross, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null); 938 949 break; 939 950 } 940 951 } 941 if (!str.isEmpty()) Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BR, AffineTransform.getTranslateInstance(-30, - 80)));952 if (!str.isEmpty()) Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BR, AffineTransform.getTranslateInstance(-30, -70))); 942 953 break; 943 954 case RADSTA: -
applications/editors/josm/plugins/smed2/src/smed2/MapImage.java
r30024 r30025 29 29 import org.openstreetmap.josm.gui.layer.ImageryLayer; 30 30 31 import seamap.Map Helper;31 import seamap.MapContext; 32 32 import seamap.Renderer; 33 33 import seamap.SeaMap.*; 34 34 35 public class MapImage extends ImageryLayer implements ZoomChangeListener, Map Helper{35 public class MapImage extends ImageryLayer implements ZoomChangeListener, MapContext { 36 36 37 37 private Smed2Action dlg; … … 102 102 103 103 public double mile(Feature feature) { 104 return Math.pow(2, zoom) * 256 / (21600 * Math.abs(Math.cos(feature.centre.lat)));104 return 185000 / Main.map.mapView.getDist100Pixel(); 105 105 } 106 106 } -
applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java
r30023 r30025 12 12 import java.awt.*; 13 13 import java.awt.event.*; 14 import java.awt.image.BufferedImage;15 import java.io.File;16 14 import java.util.*; 17 15 import java.util.Map.Entry; 18 16 19 import javax.imageio.ImageIO;20 17 import javax.swing.*; 21 18
Note:
See TracChangeset
for help on using the changeset viewer.