Changeset 32088 in osm for applications/editors/josm/plugins/seachart
- Timestamp:
- 2016-02-29T11:29:17+01:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/seachart
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/jrender/src/jrender/Jrender.java
r32082 r32088 83 83 } 84 84 85 static final boolean test = true; 86 85 87 public static void tileMap(String idir, int zoom) throws IOException { 86 88 BufferedImage img; 87 89 context = new Context(); 88 90 89 int size = 768;90 //for (int i = 0; i < (12 - zoom); i++) size *= 2;91 int size = 256; 92 for (int i = 0; i < (12 - zoom); i++) size *= 2; 91 93 Rectangle rect = new Rectangle(size, size); 92 // img = new BufferedImage(rect.width, rect.height, BufferedImage.TYPE_INT_ARGB); 93 // Renderer.reRender(img.createGraphics(), rect, zoom, 0.05, map, context); 94 // ByteArrayOutputStream bos = new ByteArrayOutputStream(); 95 // ImageIO.write(img, "png", bos); 96 // empty = bos.size(); 97 // tile(zoom, 1, 0, 0); 98 // FileOutputStream fos = new FileOutputStream(dstdir + "tst_" + zoom + "-" + xtile + "-" + ytile + ".png"); 99 // bos.writeTo(fos); 100 // fos.close(); 101 102 // for (int z = 12; z <= 18; z++) { 103 DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation(); 104 Document document = domImpl.createDocument("http://www.w3.org/2000/svg", "svg", null); 105 SVGGraphics2D svgGenerator = new SVGGraphics2D(document); 106 // svgGenerator.setBackground(Symbols.Bwater); 107 svgGenerator.clearRect(rect.x, rect.y, rect.width, rect.height); 108 svgGenerator.setSVGCanvasSize(rect.getSize()); 109 svgGenerator.setClip(rect.x, rect.y, rect.width, rect.height); 110 // svgGenerator.translate(-256, -256); 111 Renderer.reRender(svgGenerator, rect, zoom, 1.0, map, context); 112 // svgGenerator.stream(dstdir + "tst_" + zoom + "-" + xtile + "-" + ytile + ".svg"); 113 svgGenerator.stream(dstdir); 114 // } 94 img = new BufferedImage(rect.width, rect.height, BufferedImage.TYPE_INT_ARGB); 95 Renderer.reRender(img.createGraphics(), rect, zoom, 1.0, map, context); 96 ByteArrayOutputStream bos = new ByteArrayOutputStream(); 97 ImageIO.write(img, "png", bos); 98 empty = bos.size(); 99 100 if (test) { 101 for (int z = 12; z <= 18; z++) { 102 DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation(); 103 Document document = domImpl.createDocument("http://www.w3.org/2000/svg", "svg", null); 104 SVGGraphics2D svgGenerator = new SVGGraphics2D(document); 105 svgGenerator.clearRect(rect.x, rect.y, rect.width, rect.height); 106 svgGenerator.setSVGCanvasSize(rect.getSize()); 107 svgGenerator.setClip(rect.x, rect.y, rect.width, rect.height); 108 svgGenerator.translate(-256, -256); 109 Renderer.reRender(svgGenerator, rect, z, 1.0, map, context); 110 svgGenerator.stream(dstdir + "tst_" + z + "-" + xtile + "-" + ytile + ".svg"); 111 } 112 } else { 113 tile(zoom, 1, 0, 0); 114 } 115 115 } 116 116 … … 180 180 send = new ArrayList<String>(); 181 181 deletes = new HashMap<String, Boolean>(); 182 // BufferedReader in = new BufferedReader(new FileReader(srcdir + zoom + "-" + xtile + "-" + ytile + ".osm")); 183 BufferedReader in = new BufferedReader(new FileReader(srcdir)); 182 BufferedReader in = new BufferedReader(new FileReader(srcdir + zoom + "-" + xtile + "-" + ytile + ".osm")); 184 183 map = new S57map(true); 185 184 S57osm.OSMmap(in, map, false); 186 185 in.close(); 187 //if (zoom == 12) {188 //clean(12, 0, 0);189 //}186 if (zoom == 12) { 187 clean(12, 0, 0); 188 } 190 189 tileMap(dstdir, zoom); 191 190 // if ((send.size() + deletes.size()) > 0) { -
applications/editors/josm/plugins/seachart/src/render/Renderer.java
r32084 r32088 548 548 } 549 549 550 public static void lightSector(Feature feature, Color col1, Color col2, double radius, double s1, double s2, booleandir, String str) {550 public static void lightSector(Feature feature, Color col1, Color col2, double radius, double s1, double s2, Double dir, String str) { 551 551 if ((zoom >= 16) && (radius > 0.2)) { 552 radius = 0.2 / (Math.pow(2, zoom-16));552 radius /= (Math.pow(2, zoom-15)); 553 553 } 554 554 double mid = (((s1 + s2) / 2) + (s1 > s2 ? 180 : 0)) % 360; … … 557 557 Point2D.Double centre = (Point2D.Double) context.getPoint(feature.geom.centre); 558 558 double radial = radius * context.mile(feature); 559 if (dir ) {560 g2.draw(new Line2D.Double(centre.x, centre.y, centre.x - radial * Math.sin(Math.toRadians( mid)), centre.y + radial * Math.cos(Math.toRadians(mid))));559 if (dir != null) { 560 g2.draw(new Line2D.Double(centre.x, centre.y, centre.x - radial * Math.sin(Math.toRadians(dir)), centre.y + radial * Math.cos(Math.toRadians(dir)))); 561 561 } else { 562 562 if ((s1 != 0.0) || (s2 != 360.0)) { … … 574 574 } 575 575 if ((str != null) && (!str.isEmpty())) { 576 g2.setPaint(Color.black); 577 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 578 FontRenderContext frc = g2.getFontRenderContext(); 579 Font font = new Font("Arial", Font.PLAIN, 40); 580 GeneralPath path = new GeneralPath(); 581 GlyphVector gv = font.deriveFont(font.getSize2D() * (float)sScale).createGlyphVector(frc, (" " + str)); 582 double gwidth = gv.getLogicalBounds().getWidth(); 583 boolean hand = false; 584 double offset = 0; 585 Point2D origin; 586 if (dir) { 587 radial += 10 * sScale; 588 if (mid < 180) { 589 radial += gwidth; 590 hand = true; 591 } 592 origin = new Point2D.Double(centre.x - radial * Math.sin(Math.toRadians(mid)), centre.y + radial * Math.cos(Math.toRadians(mid))); 593 int length = gv.getNumGlyphs(); 594 for (int i = 0; i < length; i++) { 595 Shape shape = gv.getGlyphOutline(i); 596 Point2D point = gv.getGlyphPosition(i); 597 AffineTransform at = AffineTransform.getTranslateInstance(origin.getX(), origin.getY()); 598 at.rotate(Math.toRadians(mid + (hand ? -90 : 90))); 599 at.translate(-point.getX() + offset, -point.getY() + (15 * sScale)); 600 path.append(at.createTransformedShape(shape), false); 601 offset += gv.getGlyphMetrics(i).getAdvance(); 602 g2.fill(path); 603 } 604 } else { 605 double arc = (s2 > s1) ? (s2 - s1) : (s2 - s1 + 360); 606 double awidth = (Math.toRadians(arc) * radial); 607 if (gwidth < awidth) { 608 offset = 0; 609 double phi = 0; 610 if ((mid > 270) || (mid < 90)) { 611 hand = true; 612 phi = Math.toRadians(s2) - ((awidth - gwidth) / 2) /radial; 613 radial -= 20 * sScale; 614 } else { 615 phi = Math.toRadians(s1) + (((awidth - gwidth) / 2)) /radial; 616 radial += 20 * sScale; 617 } 618 origin = new Point2D.Double(centre.x - radial * Math.sin(phi), centre.y + radial * Math.cos(phi)); 619 int length = gv.getNumGlyphs(); 620 for (int i = 0; i < length; i++) { 621 Shape shape = gv.getGlyphOutline(i); 622 Point2D point = gv.getGlyphPosition(i); 623 AffineTransform at = AffineTransform.getTranslateInstance(origin.getX(), origin.getY()); 624 at.rotate(phi + (hand ? 0 : Math.toRadians(180))); 625 at.translate(-point.getX() + offset, -point.getY()); 626 path.append(at.createTransformedShape(shape), false); 627 double advance = gv.getGlyphMetrics(i).getAdvance(); 628 offset += advance; 629 phi += (hand ? -0.5 : +0.5) * advance / radial; 630 g2.fill(path); 631 } 632 } 576 FontRenderContext frc = g2.getFontRenderContext(); 577 Font font = new Font("Arial", Font.PLAIN, 40); 578 GlyphVector gv = font.deriveFont(font.getSize2D() * (float)sScale).createGlyphVector(frc, str); 579 double arc = (s2 > s1) ? (s2 - s1) : (s2 - s1 + 360); 580 double awidth = (Math.toRadians(arc) * radial); 581 boolean hand = ((mid > 270) || (mid < 90)); 582 double phi = Math.toRadians(mid); 583 radial += 30 * sScale; 584 AffineTransform at = AffineTransform.getTranslateInstance(-radial * Math.sin(phi) / sScale, radial * Math.cos(phi) / sScale); 585 if (gv.getLogicalBounds().getWidth() < awidth) { 586 at.rotate(Math.toRadians(mid + (hand ? 0 : 180))); 587 Renderer.labelText(feature, str, font, Color.black, new Delta(Handle.CC, at)); 588 } else if (gv.getLogicalBounds().getHeight() < awidth) { 589 hand = (mid < 180); 590 at.rotate(Math.toRadians(mid + (hand ? -90 : 90))); 591 Renderer.labelText(feature, str, font, Color.black, hand ? new Delta(Handle.RC, at) : new Delta(Handle.LC, at)); 592 } 593 if (dir != null) { 594 font = new Font("Arial", Font.PLAIN, 30); 595 str = dir + "°"; 596 hand = (dir > 180); 597 phi = Math.toRadians(dir + (hand ? -0.5 : 0.5)); 598 radial -= 70 * sScale; 599 at = AffineTransform.getTranslateInstance(-radial * Math.sin(phi) / sScale, radial * Math.cos(phi) / sScale); 600 at.rotate(Math.toRadians(dir + (hand ? 90 : -90))); 601 Renderer.labelText(feature, str, font, Color.black, hand ? new Delta(Handle.BR, at) : new Delta(Handle.BL, at)); 633 602 } 634 603 } -
applications/editors/josm/plugins/seachart/src/render/Signals.java
r32084 r32088 329 329 Enum<ColCOL> col2 = null; 330 330 double radius = 0.2; 331 double s1 = 0;332 double s2 = 0;333 boolean dir = false;331 double s1 = 361; 332 double s2 = 361; 333 Double dir = null; 334 334 if (atts.containsKey(Att.COLOUR)) { 335 335 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val; … … 343 343 radius = (Double) atts.get(Att.LITRAD).val; 344 344 } 345 if (atts.containsKey(Att.SECTR1)) {346 s1 = (Double) atts.get(Att.SECTR1).val;347 } else {348 continue;349 }350 if (atts.containsKey(Att.SECTR2)) {351 s2 = (Double) atts.get(Att.SECTR2).val;352 } else {353 continue;354 }355 345 if (atts.containsKey(Att.CATLIT)) { 356 346 ArrayList<CatLIT> cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val; 357 347 if (cats.contains(CatLIT.LIT_DIR)) { 358 dir = true; 359 } 348 if (atts.containsKey(Att.ORIENT)) { 349 dir = (Double) atts.get(Att.ORIENT).val; 350 s1 = ((dir - 4) + 360) % 360; 351 s2 = (dir + 4) % 360; 352 for (AttMap satts : lights.values()) { 353 double srad = 0.2; 354 double ss1 = 361; 355 double ss2 = 361; 356 Double sdir = null; 357 if (satts == atts) continue; 358 if (satts.containsKey(Att.LITRAD)) { 359 srad = (Double) satts.get(Att.LITRAD).val; 360 } 361 if (srad == radius) { 362 ArrayList<CatLIT> scats = (satts.containsKey(Att.CATLIT)) ? (ArrayList<CatLIT>) satts.get(Att.CATLIT).val : new ArrayList<CatLIT>(); 363 if (scats.contains(CatLIT.LIT_DIR)) { 364 if (satts.containsKey(Att.ORIENT)) { 365 sdir = (Double) satts.get(Att.ORIENT).val; 366 ss1 = sdir; 367 ss2 = sdir; 368 } 369 } else { 370 if (satts.containsKey(Att.SECTR1)) { 371 ss1 = (Double) satts.get(Att.SECTR1).val; 372 } 373 if (satts.containsKey(Att.SECTR2)) { 374 ss2 = (Double) satts.get(Att.SECTR2).val; 375 } 376 } 377 if ((ss1 > 360) || (ss2 > 360)) continue; 378 if (sdir != null) { 379 if (((dir - sdir + 360) % 360) < 8) { 380 s1 = ((((sdir > dir) ? 360 : 0) + sdir + dir) / 2) % 360; 381 } 382 if (((sdir - dir + 360) % 360) < 8) { 383 s2 = ((((dir > sdir) ? 360 : 0) + sdir + dir) / 2) % 360; 384 } 385 } else { 386 if (((dir - ss2 + 360) % 360) < 4) { 387 s1 = ss2; 388 } 389 if (((ss1 - dir + 360) % 360) < 4) { 390 s2 = ss1; 391 } 392 } 393 } 394 } 395 } 396 } 397 } 398 if ((s1 > 360) && atts.containsKey(Att.SECTR1)) { 399 s1 = (Double) atts.get(Att.SECTR1).val; 400 } else if (dir == null) { 401 continue; 402 } 403 if ((s2 > 360) && atts.containsKey(Att.SECTR2)) { 404 s2 = (Double) atts.get(Att.SECTR2).val; 405 } else if (dir == null) { 406 continue; 360 407 } 361 408 str = ""; … … 377 424 str += "." + df.format(atts.get(Att.SIGPER).val) + "s"; 378 425 } 379 if (dir && atts.containsKey(Att.ORIENT)) { 380 double orient = (Double) atts.get(Att.ORIENT).val; 381 str += " " + orient + "°"; 382 s1 = (orient - 4 + 360) % 360; 383 s2 = (orient + 4) % 360; 384 double n1 = 360; 385 double n2 = 360; 386 for (AttMap sect : lights.values()) { 387 if (sect != atts) { 388 389 } 390 } 391 } 392 Renderer.lightSector(feature, LightColours.get(col1), LightColours.get(col2), radius, s1, s2, dir, (Renderer.zoom >= 15) ? str : ""); 426 if ((s1 <= 360) && (s2 <= 360) && (s1 != s2)) 427 Renderer.lightSector(feature, LightColours.get(col1), LightColours.get(col2), radius, s1, s2, dir, (Renderer.zoom >= 15) ? str : ""); 393 428 } 394 429 if (Renderer.zoom >= 15) { … … 403 438 double hgt; 404 439 } 405 str = "";406 440 ArrayList<LitSect> litatts = new ArrayList<>(); 407 441 for (AttMap atts : lights.values()) { 408 442 LitSect sect = new LitSect(); 409 sect.dir = (atts.containsKey(Att.CATLIT) ) && (atts.get(Att.CATLIT).val == CatLIT.LIT_DIR);443 sect.dir = (atts.containsKey(Att.CATLIT) && ((ArrayList<CatLIT>)atts.get(Att.CATLIT).val).contains(CatLIT.LIT_DIR)); 410 444 sect.chr = atts.containsKey(Att.LITCHR) ? ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0) : LitCHR.CHR_UNKN; 411 445 switch (sect.chr) { … … 501 535 } 502 536 LitSect tmp = group.get(0); 503 if (tmp.dir) 504 str += "Dir"; 537 str = (tmp.dir) ? "Dir" : ""; 505 538 str += LightCharacters.get(tmp.chr); 506 539 if (!tmp.grp.isEmpty()) … … 531 564 cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val; 532 565 } 533 str += (cats.contains(CatLIT.LIT_DIR)) ? "Dir" : "";566 str = (cats.contains(CatLIT.LIT_DIR)) ? "Dir" : ""; 534 567 str += (atts.containsKey(Att.MLTYLT)) ? atts.get(Att.MLTYLT).val : ""; 535 568 if (atts.containsKey(Att.LITCHR)) { -
applications/editors/josm/plugins/seachart/src/seachart/SeachartAction.java
r31846 r32088 113 113 protected void createChartLayer() { 114 114 rendering = new ChartImage(new ImageryInfo("SeaChart")); 115 rendering.setBackgroundLayer(true); 115 116 Main.main.addLayer(rendering); 116 117 MapView.addEditLayerChangeListener(this); 117 118 MapView.addLayerChangeListener(this); 118 119 editLayerChanged(Main.main.getEditLayer(), Main.main.getEditLayer()); 119 rendering.setBackgroundLayer(true);120 120 } 121 121 -
applications/editors/josm/plugins/seachart/src/symbols/Harbours.java
r31044 r32088 38 38 public static final Symbol Anchorage = new Symbol(); 39 39 static { 40 Anchorage.add(new Instr(Form.SYMB, new Symbols.SubSymbol(Harbours.Anchor, 1.0, 0, 0, new Scheme(Symbols.Msymb), null)));40 Anchorage.add(new Instr(Form.SYMB, new Symbols.SubSymbol(Harbours.Anchor, 0.67, 0, 0, new Scheme(Symbols.Msymb), null))); 41 41 } 42 42 public static final Symbol Bollard = new Symbol();
Note:
See TracChangeset
for help on using the changeset viewer.