Changeset 30333 in osm for applications/editors/josm
- Timestamp:
- 2014-03-20T15:14:02+01:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/smed2/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/panels/PanelS57.java
r30325 r30333 53 53 PanelMain.setStatus("Select OSM types file", Color.yellow); 54 54 JFileChooser ifc = new JFileChooser(Main.pref.get("smed2plugin.typesfile")); 55 ifc.setSelectedFile(new File(Main.pref.get("smed2plugin.typesfile"))); 55 56 int returnVal = ifc.showOpenDialog(Main.parent); 56 57 if (returnVal == JFileChooser.APPROVE_OPTION) { -
applications/editors/josm/plugins/smed2/src/render/Renderer.java
r30323 r30333 529 529 530 530 public static void lightSector(Feature feature, Color col1, Color col2, double radius, double s1, double s2, boolean dir, String str) { 531 // private static Point2D.Double radial(Feature feature, Snode centre, double radius, double angle) { 532 // Point2D origin = Renderer.context.getPoint(centre); 533 // return new Point2D.Double(origin.getX() - (radius * Renderer.context.mile(feature) * Math.sin(angle)), origin.getY() - (radius * Renderer.context.mile(feature) * Math.cos(angle))); 534 //} 535 531 if ((zoom >= 16) && (radius > 0.2)) { 532 radius = 0.2 / (Math.pow(2, zoom-16)); 533 } 534 double mid = (((s1 + s2) / 2) + (s1 > s2 ? 180 : 0)) % 360; 535 g2.setStroke(new BasicStroke((float) (3.0 * sScale), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1, new float[] {20 * (float)sScale, 20 * (float)sScale}, 0)); 536 g2.setPaint(Color.black); 537 Point2D.Double centre = (Point2D.Double) context.getPoint(feature.geom.centre); 538 double radial = radius * context.mile(feature); 539 if (dir) { 540 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)))); 541 } else { 542 g2.draw(new Line2D.Double(centre.x, centre.y, centre.x - radial * Math.sin(Math.toRadians(s1)), centre.y + radial * Math.cos(Math.toRadians(s1)))); 543 g2.draw(new Line2D.Double(centre.x, centre.y, centre.x - radial * Math.sin(Math.toRadians(s2)), centre.y + radial * Math.cos(Math.toRadians(s2)))); 544 } 545 double arcWidth = 10.0 * sScale; 546 g2.setStroke(new BasicStroke((float)arcWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1)); 547 g2.setPaint(col1); 548 g2.draw(new Arc2D.Double(centre.x - radial, centre.y - radial, 2 * radial, 2 * radial, -(s1 + 90), (s1 - s2 - 360) % 360, Arc2D.OPEN)); 549 if (col2 != null) { 550 g2.setPaint(col2); 551 g2.draw(new Arc2D.Double(centre.x - radial + arcWidth, centre.y - radial + arcWidth, 2 * (radial - arcWidth), 2 * (radial - arcWidth), -(s1 + 90), (s1 - s2 - 360) % 360, Arc2D.OPEN)); 552 } 553 if ((str != null) && (!str.isEmpty())) { 554 g2.setPaint(Color.black); 555 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 556 FontRenderContext frc = g2.getFontRenderContext(); 557 Font font = new Font("Arial", Font.PLAIN, 40); 558 GeneralPath path = new GeneralPath(); 559 GlyphVector gv = font.deriveFont((float)(font.getSize()*sScale)).createGlyphVector(frc, (" " + str)); 560 double gwidth = gv.getLogicalBounds().getWidth(); 561 boolean hand = false; 562 double offset = 0; 563 Point2D origin; 564 double arc = (s2 - s1 + 360) % 360; 565 if (dir) { 566 radial += 10 * sScale; 567 if (mid < 180) { 568 radial += gwidth; 569 hand = true; 570 } 571 origin = new Point2D.Double(centre.x - radial * Math.sin(Math.toRadians(mid)), centre.y + radial * Math.cos(Math.toRadians(mid))); 572 int length = gv.getNumGlyphs(); 573 for (int i = 0; i < length; i++) { 574 Shape shape = gv.getGlyphOutline(i); 575 Point2D point = gv.getGlyphPosition(i); 576 AffineTransform at = AffineTransform.getTranslateInstance(origin.getX(), origin.getY()); 577 at.rotate(Math.toRadians(mid + (hand ? -90 : 90))); 578 at.translate(-point.getX() + offset, -point.getY() + (15 * sScale)); 579 path.append(at.createTransformedShape(shape), false); 580 offset += gv.getGlyphMetrics(i).getAdvance(); 581 g2.fill(path); 582 } 583 } else { 584 double awidth = (Math.toRadians(arc) * radial); 585 if (gwidth < awidth) { 586 offset = 0; 587 double phi = 0; 588 if ((mid > 270) || (mid < 90)) { 589 hand = true; 590 phi = Math.toRadians(s2) - ((awidth - gwidth) / 2) /radial; 591 radial -= 20 * sScale; 592 } else { 593 phi = Math.toRadians(s1) + (((awidth - gwidth) / 2)) /radial; 594 radial += 20 * sScale; 595 } 596 origin = new Point2D.Double(centre.x - radial * Math.sin(phi), centre.y + radial * Math.cos(phi)); 597 int length = gv.getNumGlyphs(); 598 for (int i = 0; i < length; i++) { 599 Shape shape = gv.getGlyphOutline(i); 600 Point2D point = gv.getGlyphPosition(i); 601 AffineTransform at = AffineTransform.getTranslateInstance(origin.getX(), origin.getY()); 602 at.rotate(phi + (hand ? 0 : Math.toRadians(180))); 603 at.translate(-point.getX() + offset, -point.getY()); 604 path.append(at.createTransformedShape(shape), false); 605 double advance = gv.getGlyphMetrics(i).getAdvance(); 606 offset += advance; 607 phi += (hand ? -0.5 : +0.5) * advance / radial; 608 g2.fill(path); 609 } 610 } 611 } 612 } 536 613 } 537 614 } -
applications/editors/josm/plugins/smed2/src/render/Rules.java
r30325 r30333 577 577 case BERTHS: 578 578 if (Renderer.zoom >= 14) { 579 Renderer.labelText(feature, name == null ? " " : name, new Font("Arial", Font.PLAIN, 40), Msymb, LabelStyle.RRCT, Mline, Color.white, null); 579 Renderer.lineVector(feature, new LineStyle(Mline, 6, new float[] { 20, 20 })); 580 Renderer.labelText(feature, name == null ? " " : name, new Font("Arial", Font.PLAIN, 40), Msymb, LabelStyle.RRCT, Mline, Color.white); 580 581 } 581 582 break; -
applications/editors/josm/plugins/smed2/src/render/Signals.java
r30323 r30333 316 316 } 317 317 if (atts.containsKey(Att.SECTR2)) { 318 s 1= (Double) atts.get(Att.SECTR2).val;318 s2 = (Double) atts.get(Att.SECTR2).val; 319 319 } else { 320 320 continue; … … 326 326 } 327 327 } 328 Renderer.lightSector(feature, lightColours.get(col1), lightColours.get(col2), radius, s1, s2, dir, ""); 328 String str = ""; 329 if (atts.containsKey(Att.LITCHR)) { 330 str += lightCharacters.get(atts.get(Att.LITCHR).val); 331 } 332 if (atts.containsKey(Att.SIGGRP)) { 333 str += "(" + atts.get(Att.SIGGRP).val + ")"; 334 } else if (!str.isEmpty()) { 335 str += "."; 336 } 337 if (atts.containsKey(Att.COLOUR)) { 338 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val; 339 str += lightLetters.get(cols.get(0)); 340 if (cols.size() > 1) 341 str += lightLetters.get(cols.get(1)); 342 } 343 if (dir && atts.containsKey(Att.ORIENT)) { 344 double orient = (Double)atts.get(Att.ORIENT).val; 345 str += " " + orient + "°"; 346 s1 = (orient - 4 + 360) % 360; 347 s2 = (orient + 4) % 360; 348 double n1 = 360; 349 double n2 = 360; 350 for (AttMap sect : objs.values()) { 351 if (sect != atts) { 352 353 } 354 } 355 } 356 Renderer.lightSector(feature, lightColours.get(col1), lightColours.get(col2), radius, s1, s2, dir, str); 329 357 } 330 358 }
Note:
See TracChangeset
for help on using the changeset viewer.