Changeset 32776 in osm
- Timestamp:
- 2016-08-06T04:32:28+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/data/PTRouteSegment.java
r32747 r32776 3 3 import java.util.ArrayList; 4 4 import java.util.List; 5 6 import org.openstreetmap.josm.data.osm.Way; 5 7 6 8 /** … … 20 22 private List<PTWay> ptways; 21 23 private List<List<PTWay>> fixVariants; 22 24 23 25 public PTRouteSegment(PTStop firstStop, PTStop lastStop, List<PTWay> ways) { 24 26 this.firstStop = firstStop; … … 28 30 fixVariants = new ArrayList<>(); 29 31 } 30 32 31 33 public List<PTWay> getPTWays() { 32 34 return this.ptways; 33 35 } 34 36 35 37 public void setPTWays(List<PTWay> ptwayList) { 36 38 this.ptways = ptwayList; 37 39 this.fixVariants.clear(); 38 40 } 39 41 40 42 public PTStop getFirstStop() { 41 43 return this.firstStop; 42 44 } 43 45 44 46 public PTStop getLastStop() { 45 47 return this.lastStop; 46 48 } 47 49 48 50 public PTWay getFirstPTWay() { 49 51 if (ptways.isEmpty()) { … … 52 54 return ptways.get(0); 53 55 } 54 56 55 57 public PTWay getLastPTWay() { 56 58 if (ptways.isEmpty()) { … … 59 61 return ptways.get(ptways.size() - 1); 60 62 } 61 63 62 64 public void addFixVariant(List<PTWay> list) { 63 65 this.fixVariants.add(list); 64 66 } 65 67 66 68 public List<List<PTWay>> getFixVariants() { 67 69 return this.fixVariants; 68 70 } 69 71 72 /** 73 * Checks if this and the other route segments are equal 74 * 75 * @param other 76 * @return 77 */ 78 public boolean equalsRouteSegment(PTRouteSegment other) { 79 List<Way> thisWays = new ArrayList<>(); 80 for (PTWay ptway : this.ptways) { 81 thisWays.addAll(ptway.getWays()); 82 } 83 List<Way> otherWays = new ArrayList<>(); 84 for (PTWay ptway : other.getPTWays()) { 85 otherWays.addAll(ptway.getWays()); 86 } 87 if (thisWays.size() != otherWays.size()) { 88 return false; 89 } 90 91 for (int i = 0; i < thisWays.size(); i++) { 92 if (thisWays.get(i) != otherWays.get(i)) { 93 return false; 94 } 95 } 96 97 return true; 98 } 70 99 71 100 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantLayer.java
r32647 r32776 8 8 import java.util.ArrayList; 9 9 import java.util.Collection; 10 import java.util.HashMap; 10 11 import java.util.List; 11 12 … … 32 33 import org.openstreetmap.josm.gui.layer.LayerPositionStrategy; 33 34 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 35 import org.openstreetmap.josm.plugins.pt_assistant.data.PTWay; 34 36 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; 35 37 import org.openstreetmap.josm.tools.ImageProvider; … … 41 43 private List<OsmPrimitive> primitives = new ArrayList<>(); 42 44 private PTAssistantPaintVisitor paintVisitor; 45 private HashMap<Character, List<PTWay>> fixVariants = new HashMap<>(); 43 46 44 47 private PTAssistantLayer() { … … 64 67 this.primitives.clear(); 65 68 } 69 70 public void clearFixVariants() { 71 fixVariants.clear(); 72 Main.map.mapView.repaint(); 73 } 74 75 /** 76 * Adds fix variants to be displayed in the pt_assistant layer 77 * @param fixVariants 78 */ 79 public void addFixVariants(List<List<PTWay>> fixVariants) { 80 char alphabet = 'A'; 81 for (int i = 0; i < fixVariants.size(); i++) { 82 if (i < 5) { 83 List<PTWay> fixVariant = fixVariants.get(0); 84 this.fixVariants.put(alphabet, fixVariant); 85 alphabet++; 86 } 87 } 88 89 // for (List<PTWay> fixVariant: fixVariants) { 90 // 91 // this.fixVariants.put(alphabet, fixVariant); 92 // alphabet++; 93 // } 94 } 95 96 /** 97 * Returns fix variant (represented by a list of PTWays) that corresponds to the given character. 98 * @param c 99 * @return 100 */ 101 public List<PTWay> getFixVariant(char c) { 102 return this.fixVariants.get(Character.toUpperCase(c)); 103 } 104 66 105 67 106 @Override … … 72 111 for (OsmPrimitive primitive : primitives) { 73 112 paintVisitor.visit(primitive); 74 75 } 113 } 114 115 paintVisitor.visitFixVariants(this.fixVariants); 76 116 77 117 } … … 199 239 paintVisitor.visit(primitive); 200 240 } 241 242 paintVisitor.visitFixVariants(this.fixVariants); 201 243 202 244 Main.map.mapView.repaint(); -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantPaintVisitor.java
r32622 r32776 11 11 import java.util.List; 12 12 13 import org.openstreetmap.josm.Main; 13 14 import org.openstreetmap.josm.data.osm.Node; 14 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 19 20 import org.openstreetmap.josm.data.validation.PaintVisitor; 20 21 import org.openstreetmap.josm.gui.MapView; 22 import org.openstreetmap.josm.plugins.pt_assistant.data.PTWay; 21 23 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; 24 import org.openstreetmap.josm.tools.Pair; 22 25 23 26 public class PTAssistantPaintVisitor extends PaintVisitor { … … 85 88 86 89 stopOrderMap.put(rm.getUniqueId(), label); 87 drawStopLabel(rm.getMember(), label); 90 try { 91 drawStopLabel(rm.getMember(), label); 92 } catch (NullPointerException ex) { 93 // do nothing 94 } 88 95 stopCount++; 89 96 } … … 170 177 protected void drawSegment(Node n1, Node n2, Color color, int oneway) { 171 178 if (n1.isDrawable() && n2.isDrawable() && isSegmentVisible(n1, n2)) { 172 drawSegment(mv.getPoint(n1), mv.getPoint(n2), color, oneway); 179 try { 180 drawSegment(mv.getPoint(n1), mv.getPoint(n2), color, oneway); 181 } catch (NullPointerException ex) { 182 // do nothing 183 } 184 173 185 } 174 186 } … … 281 293 Point p = mv.getPoint(n); 282 294 283 g.setColor(Color.WHITE); 284 Font stringFont = new Font("SansSerif", Font.PLAIN, 24); 285 g.setFont(stringFont); 286 g.drawString(label, p.x + 20, p.y - 20); 295 if (label != null && !label.equals("")) { 296 g.setColor(Color.WHITE); 297 Font stringFont = new Font("SansSerif", Font.PLAIN, 24); 298 g.setFont(stringFont); 299 g.drawString(label, p.x + 20, p.y - 20); 300 } 287 301 288 302 // draw the ref values of all parent routes: … … 382 396 } 383 397 398 /** 399 * 400 * @param fixVariants 401 */ 402 protected void visitFixVariants(HashMap<Character, List<PTWay>> fixVariants) { 403 Color[] colors = { new Color(255, 0, 0, 150), new Color(0, 255, 0, 150), new Color(0, 0, 255, 150), 404 new Color(255, 255, 0, 150), new Color(0, 255, 255, 150) }; 405 406 int colorIndex = 0; 407 408 double letterX = Main.map.mapView.getBounds().getMinX() + 20; 409 double letterY = Main.map.mapView.getBounds().getMinY() + 100; 410 411 for (Character c : fixVariants.keySet()) { 412 if (fixVariants.get(c) != null) { 413 drawFixVariant(fixVariants.get(c), colors[colorIndex % 5]); 414 drawFixVariantLetter(fixVariants.get(c), c, colors[colorIndex%5], letterX, letterY); 415 colorIndex++; 416 letterY = letterY + 60; 417 } 418 } 419 420 421 } 422 423 /** 424 * 425 * @param fixVariant 426 * @param color 427 */ 428 private void drawFixVariant(List<PTWay> fixVariant, Color color) { 429 for (PTWay ptway : fixVariant) { 430 for (Way way : ptway.getWays()) { 431 for (Pair<Node, Node> nodePair : way.getNodePairs(false)) { 432 drawSegment(nodePair.a, nodePair.b, color, 0); 433 } 434 } 435 } 436 } 437 438 private void drawFixVariantLetter(List<PTWay> fixVariant, Character letter, Color color, double letterX, double letterY) { 439 g.setColor(color); 440 Font stringFont = new Font("SansSerif", Font.PLAIN, 50); 441 g.setFont(stringFont); 442 g.drawString(letter.toString(), (int) letterX, (int) letterY); 443 g.drawString(letter.toString(), (int) letterX, (int) letterY); 444 } 445 384 446 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/PTAssistantValidatorTest.java
r32747 r32776 419 419 // run fix task asynchronously 420 420 FixTask fixTask = new FixTask(testErrors); 421 // Main.worker.submit(fixTask);422 421 423 422 Thread t = new Thread(fixTask); … … 431 430 } 432 431 432 } 433 434 public void addFixVariants(List<List<PTWay>> fixVariants) { 435 layer.addFixVariants(fixVariants); 436 } 437 438 public void clearFixVariants() { 439 layer.clearFixVariants(); 440 } 441 442 public List<PTWay> getFixVariant(Character c) { 443 return layer.getFixVariant(c); 433 444 } 434 445 -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentChecker.java
r32751 r32776 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.lang.reflect.InvocationTargetException; 5 6 import java.util.ArrayList; 7 import java.util.Collection; 6 8 import java.util.HashMap; 7 9 import java.util.List; 8 10 9 11 import javax.swing.JOptionPane; 10 12 import javax.swing.SwingUtilities; 13 14 import org.openstreetmap.josm.Main; 15 import org.openstreetmap.josm.actions.AutoScaleAction; 11 16 import org.openstreetmap.josm.command.ChangeCommand; 12 17 import org.openstreetmap.josm.command.Command; 18 import org.openstreetmap.josm.command.SelectCommand; 13 19 import org.openstreetmap.josm.data.coor.LatLon; 14 20 import org.openstreetmap.josm.data.osm.Node; … … 21 27 import org.openstreetmap.josm.data.validation.Test; 22 28 import org.openstreetmap.josm.data.validation.TestError; 29 import org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditor; 30 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 31 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 23 32 import org.openstreetmap.josm.plugins.pt_assistant.data.PTRouteDataManager; 24 33 import org.openstreetmap.josm.plugins.pt_assistant.data.PTRouteSegment; 25 34 import org.openstreetmap.josm.plugins.pt_assistant.data.PTStop; 26 35 import org.openstreetmap.josm.plugins.pt_assistant.data.PTWay; 36 import org.openstreetmap.josm.plugins.pt_assistant.gui.PTAssistantLayer; 27 37 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; 28 38 import org.openstreetmap.josm.plugins.pt_assistant.utils.StopToWayAssigner; … … 95 105 */ 96 106 public static void addCorrectSegment(PTRouteSegment segment) { 107 for (PTRouteSegment correctSegment : correctSegments) { 108 if (correctSegment.equalsRouteSegment(segment)) { 109 return; 110 } 111 } 97 112 correctSegments.add(segment); 98 113 } … … 283 298 if (sortingCorrect) { 284 299 PTRouteSegment routeSegment = new PTRouteSegment(startStop, endStop, segmentWays); 285 correctSegments.add(routeSegment);300 addCorrectSegment(routeSegment); 286 301 unusedWays.removeAll(segmentWays); 287 302 } else { … … 452 467 453 468 highlighted.addAll(current.getWays()); 454 highlighted.add(currentNode);455 469 456 470 TestError e = new TestError(this.test, Severity.WARNING, tr("PT: Problem in the route segment"), … … 558 572 559 573 if (testError.getCode() == PTAssistantValidatorTest.ERROR_CODE_STOP_BY_STOP) { 560 if (isFixableByUsingCorrectSegment(testError)) { 561 return true; 562 } 563 if (isFixableBySortingAndRemoval(testError)) { 564 return true; 565 } 566 if (isFixableBySimpleRouting()) { 567 return true; 568 } 574 return true; 569 575 } 570 576 … … 573 579 } 574 580 581 @SuppressWarnings("unused") 575 582 private static boolean isFixableByUsingCorrectSegment(TestError testError) { 576 583 PTRouteSegment wrongSegment = wrongSegments.get(testError); … … 588 595 } 589 596 597 @SuppressWarnings("unused") 590 598 private static boolean isFixableBySortingAndRemoval(TestError testError) { 591 599 PTRouteSegment wrongSegment = wrongSegments.get(testError); … … 597 605 } 598 606 599 private static boolean isFixableBySimpleRouting() {600 // TODO601 return false;602 }603 604 607 protected void findFixes() { 605 608 for (TestError error : wrongSegments.keySet()) { … … 638 641 } 639 642 } 640 641 643 642 644 } … … 644 646 /** 645 647 * Recursive method to parse the route segment 648 * 646 649 * @param allFixes 647 650 * @param currentFix … … 657 660 658 661 List<PTWay> nextWays = this.findNextPTWaysInDirectionOfTravel(currentWay, nextNode); 659 662 660 663 if (nextWays.size() > 1) { 661 664 for (int i = 1; i < nextWays.size(); i++) { … … 678 681 } 679 682 680 681 682 683 return allFixes; 683 684 } 684 685 686 /** 687 * Fixes the error by first searching in the list of correct segments and 688 * then trying to sort and remove existing route relation members 689 * 690 * @param testError 691 * @return 692 */ 685 693 protected static Command fixError(TestError testError) { 686 694 … … 688 696 689 697 // 1) try to fix by using the correct segment: 690 PTRouteSegment correctSegment = null; 691 // TODO: now just the first correctSegment is taken over. Change that 692 // the segment is selected. 698 List<PTRouteSegment> correctSegmentsForThisError = new ArrayList<>(); 693 699 for (PTRouteSegment segment : correctSegments) { 694 700 if (wrongSegment.getFirstStop().equalsStop(segment.getFirstStop()) 695 701 && wrongSegment.getLastStop().equalsStop(segment.getLastStop())) { 696 correctSegment = segment; 697 break; 698 } 699 } 700 701 if (correctSegment != null) { 702 // TODO: ask user if the change should be undertaken 702 correctSegmentsForThisError.add(segment); 703 } 704 } 705 706 if (!correctSegmentsForThisError.isEmpty()) { 707 708 List<PTWay> fix = null; 709 710 if (correctSegmentsForThisError.size() > 1) { 711 fix = displayCorrectSegmentVariants(correctSegmentsForThisError, testError); 712 if (fix == null) { 713 return null; 714 } 715 } else { 716 fix = correctSegmentsForThisError.get(0).getPTWays(); 717 final Collection<OsmPrimitive> waysToZoom = new ArrayList<>(); 718 for (Object highlightedPrimitive: testError.getHighlighted()) { 719 waysToZoom.add((OsmPrimitive)highlightedPrimitive); 720 } 721 if (SwingUtilities.isEventDispatchThread()) { 722 AutoScaleAction.zoomTo(waysToZoom); 723 } else { 724 SwingUtilities.invokeLater(new Runnable() { 725 @Override 726 public void run() { 727 AutoScaleAction.zoomTo(waysToZoom); 728 } 729 }); 730 } 731 synchronized(SegmentChecker.class) { 732 try { 733 SegmentChecker.class.wait(2000); 734 } catch (InterruptedException e) { 735 // TODO Auto-generated catch block 736 e.printStackTrace(); 737 } 738 } 739 } 740 703 741 Relation originalRelation = (Relation) testError.getPrimitives().iterator().next(); 704 742 Relation modifiedRelation = new Relation(originalRelation); … … 735 773 for (int i = 0; i < waysOfOriginalRelation.size(); i++) { 736 774 if (waysOfOriginalRelation.get(i).getWay() == wrongSegment.getPTWays().get(0).getWays().get(0)) { 737 for (PTWay ptway : correctSegment.getPTWays()) {775 for (PTWay ptway : fix) { 738 776 if (ptway.getRole().equals("forward") || ptway.getRole().equals("backward")) { 739 777 modifiedRelationMembers.add(new RelationMember("", ptway.getMember())); … … 760 798 761 799 } else if (!wrongSegment.getFixVariants().isEmpty()) { 762 800 801 List<PTWay> fix = null; 802 803 if (wrongSegment.getFixVariants().size() > 1) { 804 fix = displayFixVariants(wrongSegment.getFixVariants(), testError); 805 if (fix == null) { 806 return null; 807 } 808 } else { 809 fix = wrongSegment.getFixVariants().get(0); 810 final Collection<OsmPrimitive> waysToZoom = new ArrayList<>(); 811 for (Object highlightedPrimitive: testError.getHighlighted()) { 812 waysToZoom.add((OsmPrimitive)highlightedPrimitive); 813 } 814 if (SwingUtilities.isEventDispatchThread()) { 815 AutoScaleAction.zoomTo(waysToZoom); 816 } else { 817 SwingUtilities.invokeLater(new Runnable() { 818 @Override 819 public void run() { 820 AutoScaleAction.zoomTo(waysToZoom); 821 } 822 }); 823 } 824 synchronized(SegmentChecker.class) { 825 try { 826 SegmentChecker.class.wait(2000); 827 } catch (InterruptedException e) { 828 // TODO Auto-generated catch block 829 e.printStackTrace(); 830 } 831 } 832 } 833 763 834 // 2) try to fix by using the sort & remove method: 764 835 // TODO: ask user if the change should be undertaken … … 797 868 for (int i = 0; i < waysOfOriginalRelation.size(); i++) { 798 869 if (waysOfOriginalRelation.get(i).getWay() == wrongSegment.getPTWays().get(0).getWays().get(0)) { 799 for (PTWay ptway : wrongSegment.getFixVariants().get(0)) { // FIXME870 for (PTWay ptway : fix) { 800 871 if (ptway.getRole().equals("forward") || ptway.getRole().equals("backward")) { 801 872 modifiedRelationMembers.add(new RelationMember("", ptway.getMember())); … … 814 885 } 815 886 } 816 887 817 888 modifiedRelation.setMembers(modifiedRelationMembers); 818 889 // TODO: change the data model too 819 890 wrongSegments.remove(testError); 820 891 wrongSegment.setPTWays(wrongSegment.getFixVariants().get(0)); 821 correctSegments.add(wrongSegment);892 addCorrectSegment(wrongSegment); 822 893 ChangeCommand changeCommand = new ChangeCommand(originalRelation, modifiedRelation); 823 894 return changeCommand; … … 825 896 } 826 897 898 // if there is no fix: 899 return fixErrorByZooming(testError); 900 901 } 902 903 /** 904 * 905 * @param segments 906 */ 907 private static List<PTWay> displayCorrectSegmentVariants(List<PTRouteSegment> segments, TestError testError) { 908 List<List<PTWay>> fixVariantList = new ArrayList<>(); 909 for (PTRouteSegment segment : segments) { 910 fixVariantList.add(segment.getPTWays()); 911 } 912 return displayFixVariants(fixVariantList, testError); 913 } 914 915 /** 916 * 917 * @param fixVariants 918 */ 919 private static List<PTWay> displayFixVariants(List<List<PTWay>> fixVariants, TestError testError) { 920 // find the letters of the fix variants: 921 char alphabet = 'A'; 922 List<Character> allowedCharacters = new ArrayList<>(); 923 for (int i = 0; i < fixVariants.size(); i++) { 924 allowedCharacters.add(alphabet); 925 alphabet++; 926 } 927 928 // zoom to problem: 929 final Collection<OsmPrimitive> waysToZoom = new ArrayList<>(); 930 // for (List<PTWay> fix : fixVariants) { 931 // for (PTWay ptway : fix) { 932 // waysToZoom.addAll(ptway.getWays()); 933 // } 934 // } 935 for (Object highlightedPrimitive: testError.getHighlighted()) { 936 waysToZoom.add((OsmPrimitive)highlightedPrimitive); 937 } 938 if (SwingUtilities.isEventDispatchThread()) { 939 AutoScaleAction.zoomTo(waysToZoom); 940 } else { 941 SwingUtilities.invokeLater(new Runnable() { 942 @Override 943 public void run() { 944 AutoScaleAction.zoomTo(waysToZoom); 945 } 946 }); 947 } 948 949 // display the fix variants: 950 PTAssistantValidatorTest test = (PTAssistantValidatorTest) testError.getTester(); 951 test.addFixVariants(fixVariants); 952 PTAssistantLayer.getLayer().repaint((Relation) testError.getPrimitives().iterator().next()); 953 954 // get user input: 955 Character userInput = getUserInput(allowedCharacters); 956 if (userInput == null) { 957 test.clearFixVariants(); 958 return null; 959 } 960 List<PTWay> selectedFix = test.getFixVariant(userInput); 961 test.clearFixVariants(); 962 return selectedFix; 963 } 964 965 /** 966 * Asks user to choose the fix variant and returns the choice 967 * 968 * @param allowedCharacters 969 * @return 970 */ 971 private static Character getUserInput(List<Character> allowedCharacters) { 972 final String[] userInput = { "" }; 973 974 while (userInput[0] == null || userInput[0].length() != 1 || userInput[0].equals("") 975 || !allowedCharacters.contains(userInput[0].toUpperCase().toCharArray()[0])) { 976 if (SwingUtilities.isEventDispatchThread()) { 977 978 userInput[0] = JOptionPane.showInputDialog("Enter a letter to select the fix variant: "); 979 980 } else { 981 982 try { 983 SwingUtilities.invokeAndWait(new Runnable() { 984 @Override 985 public void run() { 986 987 userInput[0] = JOptionPane.showInputDialog("Enter a letter to select the fix variant: "); 988 989 } 990 }); 991 } catch (InvocationTargetException | InterruptedException e1) { 992 break; 993 } 994 995 } 996 if (userInput[0] == null) { 997 break; 998 } 999 } 1000 1001 if (userInput[0] == null) { 1002 return null; 1003 } 1004 return userInput[0].toCharArray()[0]; 1005 1006 } 1007 1008 /** 1009 * 1010 * @param testError 1011 * @return 1012 */ 1013 protected static Command fixErrorByZooming(TestError testError) { 1014 1015 if (testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_STOP_BY_STOP) { 1016 return null; 1017 } 1018 1019 Collection<? extends OsmPrimitive> primitives = testError.getPrimitives(); 1020 Relation originalRelation = (Relation) primitives.iterator().next(); 1021 ArrayList<OsmPrimitive> primitivesToZoom = new ArrayList<>(); 1022 for (Object primitiveToZoom : testError.getHighlighted()) { 1023 primitivesToZoom.add((OsmPrimitive) primitiveToZoom); 1024 } 1025 1026 SelectCommand command = new SelectCommand(primitivesToZoom); 1027 1028 List<OsmDataLayer> listOfLayers = Main.getLayerManager().getLayersOfType(OsmDataLayer.class); 1029 for (OsmDataLayer osmDataLayer : listOfLayers) { 1030 if (osmDataLayer.data == originalRelation.getDataSet()) { 1031 1032 final OsmDataLayer layerParameter = osmDataLayer; 1033 final Relation relationParameter = originalRelation; 1034 final Collection<OsmPrimitive> zoomParameter = primitivesToZoom; 1035 1036 if (SwingUtilities.isEventDispatchThread()) { 1037 1038 showRelationEditorAndZoom(layerParameter, relationParameter, zoomParameter); 1039 1040 } else { 1041 1042 SwingUtilities.invokeLater(new Runnable() { 1043 @Override 1044 public void run() { 1045 1046 showRelationEditorAndZoom(layerParameter, relationParameter, zoomParameter); 1047 1048 } 1049 }); 1050 1051 } 1052 1053 return command; 1054 } 1055 } 1056 827 1057 return null; 1058 1059 } 1060 1061 private static void showRelationEditorAndZoom(OsmDataLayer layer, Relation r, Collection<OsmPrimitive> primitives) { 1062 1063 // zoom to problem: 1064 AutoScaleAction.zoomTo(primitives); 1065 1066 // put stop-related members to the front and edit roles if necessary: 1067 List<RelationMember> sortedRelationMembers = listStopMembers(r); 1068 sortedRelationMembers.addAll(listNotStopMembers(r)); 1069 r.setMembers(sortedRelationMembers); 1070 1071 // create editor: 1072 GenericRelationEditor editor = (GenericRelationEditor) RelationEditor.getEditor(layer, r, 1073 r.getMembersFor(primitives)); 1074 1075 // open editor: 1076 editor.setVisible(true); 1077 1078 // make the current relation purple in the pt_assistant layer: 1079 PTAssistantLayer.getLayer().repaint(r); 1080 828 1081 } 829 1082
Note:
See TracChangeset
for help on using the changeset viewer.