Changeset 35391 in osm for applications/editors/josm/plugins/seachart/src/render
- Timestamp:
- 2020-03-21T19:12:28+01:00 (5 years ago)
- Location:
- applications/editors/josm/plugins/seachart/src/render
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/src/render/ChartContext.java
r32907 r35391 20 20 21 21 boolean clip(); 22 23 int grid(); 22 24 23 25 Color background(S57map map); -
applications/editors/josm/plugins/seachart/src/render/Renderer.java
r34896 r35391 79 79 do {} while (!Rules.rules()); 80 80 } 81 grid(); 81 82 } 82 83 … … 326 327 } 327 328 } 329 330 public static void grid() { 331 if (context.grid() > 0) { 332 LineStyle style = new LineStyle(Color.black, (float)2.0); 333 double nspan = 60 * Math.toDegrees(map.bounds.maxlon - map.bounds.minlon) / 5.0; 334 double mult = 1.0; 335 if (nspan < 1.0) { 336 do { 337 nspan *= 10.0; 338 mult *= 10.0; 339 } while (nspan < 1.0); 340 } else if (nspan > 10.0){ 341 do { 342 nspan /= 10.0; 343 mult /= 10.0; 344 } while (nspan > 10.0); 345 } 346 if (nspan < 2.0) nspan = 1.0; 347 else if (nspan < 5.0) nspan = 2.0; 348 else nspan = 5.0; 349 nspan = nspan / mult / 60.0; 350 double left = Math.toDegrees(map.bounds.minlon) + 180.0; 351 left = Math.ceil(left / nspan); 352 left = Math.toRadians((left * nspan) - 180.0); 353 g2.setStroke(new BasicStroke((float) (style.width * sScale), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); 354 Path2D.Double p = new Path2D.Double(); 355 for (double lon = left; lon < map.bounds.maxlon; lon += Math.toRadians(nspan)) { 356 Point2D point = context.getPoint(new Snode(map.bounds.maxlat, lon)); 357 p.moveTo(point.getX(), point.getY()); 358 point = context.getPoint(new Snode(map.bounds.minlat, lon)); 359 p.lineTo(point.getX(), point.getY()); 360 double deg = Math.toDegrees(lon); 361 String ew = (deg < 0) ? "W" : "E"; 362 deg = Math.abs(deg); 363 String dstr = String.format("%03d°", (int)Math.floor(deg)); 364 double min = (deg - Math.floor(deg)) * 60.0; 365 String mstr = String.format("%05.2f'%s", min, ew); 366 Symbol label = new Symbol(); 367 if (point.getX() > 500.0) { 368 label.add(new Instr(Form.TEXT, new Caption(dstr, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.BR, AffineTransform.getTranslateInstance(-10, -20))))); 369 label.add(new Instr(Form.TEXT, new Caption(mstr, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.BL, AffineTransform.getTranslateInstance(20, 0))))); 370 Symbols.drawSymbol(g2, label, sScale, point.getX(), point.getY(), null, null); 371 } 372 } 373 g2.setPaint(style.line); 374 g2.draw(p); 375 double tspan = 60 * Math.toDegrees(map.bounds.maxlat - map.bounds.minlat) / 5.0; 376 mult = 1.0; 377 if (tspan < 1.0) { 378 do { 379 tspan *= 10.0; 380 mult *= 10.0; 381 } while (tspan < 1.0); 382 } else if (tspan > 10.0){ 383 do { 384 tspan /= 10.0; 385 mult /= 10.0; 386 } while (tspan > 10.0); 387 } 388 if (tspan < 2.0) tspan = 1.0; 389 else if (tspan < 5.0) tspan = 2.0; 390 else tspan = 5.0; 391 tspan = tspan / mult / 60.0; 392 double bottom = Math.toDegrees(map.bounds.minlat) + 90.0; 393 bottom = Math.ceil(bottom / tspan); 394 bottom = Math.toRadians((bottom * tspan) - 90.0); 395 g2.setStroke(new BasicStroke((float) (style.width * sScale), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); 396 p = new Path2D.Double(); 397 for (double lat = bottom; lat < map.bounds.maxlat; lat += Math.toRadians(tspan)) { 398 Point2D point = context.getPoint(new Snode(lat, map.bounds.maxlon)); 399 p.moveTo(point.getX(), point.getY()); 400 point = context.getPoint(new Snode(lat, map.bounds.minlon)); 401 p.lineTo(point.getX(), point.getY()); 402 double deg = Math.toDegrees(lat); 403 String ns = (deg < 0) ? "S" : "N"; 404 deg = Math.abs(deg); 405 String dstr = String.format("%02d°%s", (int)Math.floor(deg), ns); 406 double min = (deg - Math.floor(deg)) * 60.0; 407 String mstr = String.format("%05.2f'", min); 408 Symbol label = new Symbol(); 409 label.add(new Instr(Form.TEXT, new Caption(dstr, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.BL, AffineTransform.getTranslateInstance(10, -10))))); 410 label.add(new Instr(Form.TEXT, new Caption(mstr, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.BL, AffineTransform.getTranslateInstance(0, 50))))); 411 Symbols.drawSymbol(g2, label, sScale, point.getX(), point.getY(), null, null); 412 } 413 g2.setPaint(style.line); 414 g2.draw(p); 415 } 416 } 328 417 329 418 public static void lineCircle(LineStyle style, double radius, UniHLU units) { -
applications/editors/josm/plugins/seachart/src/render/Rules.java
r35388 r35391 882 882 break; 883 883 case BUISGL: 884 if (Renderer.zoom >= 1 6) {884 if (Renderer.zoom >= 15) { 885 885 Renderer.lineVector(new LineStyle(Color.black, 8, new Color(0xffc0c0c0, true))); 886 if (testAttribute(Obj.BUISGL, Att.FUNCTN, FncFNC.FNC_LOOK)) { 887 Renderer.labelText("Lookout", new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.CC, AffineTransform.getTranslateInstance(0, 50))); 888 addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.CC, AffineTransform.getTranslateInstance(0, -50))); 889 } 890 } else if (Renderer.zoom >= 16) { 886 891 if (testAttribute(Obj.BUISGL, Att.STATUS, StsSTS.STS_ILLD)) { 887 892 Renderer.symbol(Beacons.Floodlight);
Note:
See TracChangeset
for help on using the changeset viewer.