Changeset 35788 in osm for applications/editors/josm/plugins/seachart
- Timestamp:
- 2021-07-17T11:31:07+02:00 (3 years ago)
- Location:
- applications/editors/josm/plugins/seachart/src/render
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/src/render/Renderer.java
r35685 r35788 79 79 do {} while (!Rules.rules()); 80 80 } 81 grid(); 81 if ((context.grid() > 0) && (map != null)) { 82 rose(); 83 grid(); 84 } 82 85 } 83 86 … … 353 356 double nspan = 60 * Math.toDegrees(map.bounds.maxlon - map.bounds.minlon) / (context.grid() * (ratio > 1.0 ? ratio : 1.0)); 354 357 double mult = 1.0; 358 boolean ndiv = false; 355 359 if (nspan < 1.0) { 356 360 do { … … 366 370 if (nspan < 2.0) nspan = 1.0; 367 371 else if (nspan < 5.0) nspan = 2.0; 368 else nspan = 5.0; 372 else { 373 nspan = 5.0; 374 ndiv = true; 375 } 369 376 nspan = nspan / mult / 60.0; 370 377 double left = Math.toDegrees(map.bounds.minlon) + 180.0; 371 378 left = Math.ceil(left / nspan); 372 379 left = Math.toRadians((left * nspan) - 180.0); 380 double tspan = 60 * Math.toDegrees(map.bounds.maxlat - map.bounds.minlat) / (context.grid() / (ratio < 1.0 ? ratio : 1.0)); 381 mult = 1.0; 382 boolean tdiv = false; 383 if (tspan < 1.0) { 384 do { 385 tspan *= 10.0; 386 mult *= 10.0; 387 } while (tspan < 1.0); 388 } else if (tspan > 10.0){ 389 do { 390 tspan /= 10.0; 391 mult /= 10.0; 392 } while (tspan > 10.0); 393 } 394 if (tspan < 2.0) tspan = 1.0; 395 else if (tspan < 5.0) tspan = 2.0; 396 else { 397 tspan = 5.0; 398 tdiv = true; 399 } 400 tspan = tspan / mult / 60.0; 401 double bottom = Math.toDegrees(map.bounds.minlat) + 90.0; 402 bottom = Math.ceil(bottom / tspan); 403 bottom = Math.toRadians((bottom * tspan) - 90.0); 373 404 g2.setStroke(new BasicStroke((float) (style.width * sScale), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); 374 405 Path2D.Double p = new Path2D.Double(); … … 378 409 point = context.getPoint(new Snode(map.bounds.minlat, lon)); 379 410 p.lineTo(point.getX(), point.getY()); 411 for (int i = 1; i < 10; i++) { 412 int grad = (i % (ndiv ? 2 : 5)) == 0 ? 2 : 1; 413 point = context.getPoint(new Snode(map.bounds.maxlat, lon + (i * (nspan / 10)))); 414 p.moveTo(point.getX(), point.getY()); 415 point = context.getPoint(new Snode(map.bounds.maxlat - (grad * (tspan / 10)), lon + (i * (nspan / 10)))); 416 p.lineTo(point.getX(), point.getY()); 417 point = context.getPoint(new Snode(map.bounds.minlat, lon + (i * (nspan / 10)))); 418 p.moveTo(point.getX(), point.getY()); 419 point = context.getPoint(new Snode(map.bounds.minlat + (grad * (tspan / 10)), lon + (i * (nspan / 10)))); 420 p.lineTo(point.getX(), point.getY()); 421 } 380 422 double deg = Math.toDegrees(lon); 381 423 String ew = (deg < -0.001) ? "W" : (deg > 0.001) ? "E" : ""; … … 393 435 g2.setPaint(style.line); 394 436 g2.draw(p); 395 double tspan = 60 * Math.toDegrees(map.bounds.maxlat - map.bounds.minlat) / (context.grid() / (ratio < 1.0 ? ratio : 1.0));396 mult = 1.0;397 if (tspan < 1.0) {398 do {399 tspan *= 10.0;400 mult *= 10.0;401 } while (tspan < 1.0);402 } else if (tspan > 10.0){403 do {404 tspan /= 10.0;405 mult /= 10.0;406 } while (tspan > 10.0);407 }408 if (tspan < 2.0) tspan = 1.0;409 else if (tspan < 5.0) tspan = 2.0;410 else tspan = 5.0;411 tspan = tspan / mult / 60.0;412 double bottom = Math.toDegrees(map.bounds.minlat) + 90.0;413 bottom = Math.ceil(bottom / tspan);414 bottom = Math.toRadians((bottom * tspan) - 90.0);415 437 g2.setStroke(new BasicStroke((float) (style.width * sScale), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); 416 438 p = new Path2D.Double(); … … 448 470 Symbols.drawSymbol(g2, legend, sScale, point.getX(), point.getY(), null, new Delta(Handle.BL, AffineTransform.getTranslateInstance(0, 0))); 449 471 } 472 } 473 474 public static void rose() { 475 LineStyle style = new LineStyle(Color.black, (float)2.0); 476 Point2D point = context.getPoint(new Snode(Math.toRadians(53.91649), Math.toRadians(-0.16141))); 477 g2.setPaint(Color.white); 478 g2.fill(new Ellipse2D.Double(point.getX() - 30, point.getY() - 30, 60, 60)); 479 g2.setStroke(new BasicStroke((float) (style.width * sScale), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); 480 Path2D.Double p = new Path2D.Double(); 481 p.moveTo(point.getX() - 30, point.getY());p.lineTo(point.getX() + 30, point.getY()); 482 p.moveTo(point.getX(), point.getY() - 30);p.lineTo(point.getX(), point.getY() + 30); 483 for (int i = 0; i < 360; i++) { 484 double inner = ((i % 10) == 0) ? 0.92 : ((i % 5) == 0) ? 0.96 : 0.98; 485 double xouter = 1750 * Math.sin(Math.toRadians(i)); 486 double youter = -1750 * Math.cos(Math.toRadians(i)); 487 p.moveTo(point.getX() + xouter, point.getY() + youter); 488 p.lineTo(point.getX() + (inner * xouter), point.getY() + (inner * youter)); 489 if ((i % 10) == 0) { 490 Handle h = Handle.BC; 491 if ((i > 0) && (i <= 90)) h = Handle.BL; 492 else if (i == 90) h = Handle.LC; 493 else if ((i > 90) && (i < 180)) h = Handle.LC; 494 else if (i == 180) h = Handle.CC; 495 else if ((i > 180) && (i <= 270)) h = Handle.RC; 496 else if (i > 270) h = Handle.BR; 497 Symbol value = new Symbol(); 498 value.add(new Instr(Form.BBOX, new Rectangle2D.Double(0, 0, 60, 30))); 499 value.add(new Instr(Form.TEXT, new Caption(String.format("%03d", i), new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.CC, AffineTransform.getTranslateInstance(30, 25))))); 500 Symbols.drawSymbol(g2, value, sScale, point.getX(), point.getY(), null, new Delta(h, AffineTransform.getTranslateInstance(1.02*xouter/sScale, 1.02*youter/sScale))); 501 } 502 } 503 g2.setPaint(style.line); 504 g2.draw(p); 450 505 } 451 506 -
applications/editors/josm/plugins/seachart/src/render/Rules.java
r35775 r35788 1671 1671 Renderer.symbol(Areas.WreckND); 1672 1672 } 1673 addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, - 50)));1673 addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -60))); 1674 1674 } 1675 1675 }
Note:
See TracChangeset
for help on using the changeset viewer.