Changeset 33345 in osm for applications/editors
- Timestamp:
- 2017-05-30T23:16:08+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantLayer.java
r33055 r33345 8 8 import java.beans.PropertyChangeListener; 9 9 import java.util.ArrayList; 10 import java.util.Collection ;10 import java.util.Collections; 11 11 import java.util.HashMap; 12 12 import java.util.List; … … 18 18 import org.openstreetmap.josm.actions.RenameLayerAction; 19 19 import org.openstreetmap.josm.data.Bounds; 20 import org.openstreetmap.josm.data.SelectionChangedListener;21 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;23 21 import org.openstreetmap.josm.data.osm.Relation; 24 22 import org.openstreetmap.josm.data.osm.Way; … … 46 44 */ 47 45 public final class PTAssistantLayer extends Layer 48 implements SelectionChangedListener, PropertyChangeListener, LayerChangeListener { 49 50 private static PTAssistantLayer layer; 46 implements PropertyChangeListener, LayerChangeListener { 47 51 48 private List<OsmPrimitive> primitives = new ArrayList<>(); 52 49 private PTAssistantPaintVisitor paintVisitor; … … 54 51 private HashMap<Way, List<Character>> wayColoring = new HashMap<>(); 55 52 56 p rivatePTAssistantLayer() {53 public PTAssistantLayer() { 57 54 super("pt_assistant layer"); 58 55 KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(this); 59 56 Main.getLayerManager().addLayerChangeListener(this); 60 layer = this; 61 } 62 63 public static PTAssistantLayer getLayer() { 64 if (layer == null) { 65 new PTAssistantLayer(); 66 } 67 return layer; 57 Main.getLayerManager().addLayer(this); 68 58 } 69 59 … … 135 125 } 136 126 127 public void setPrimitives(List<OsmPrimitive> primitives) 128 { 129 this.primitives.clear(); 130 this.primitives.addAll(primitives); 131 } 132 137 133 @Override 138 134 public void paint(final Graphics2D g, final MapView mv, Bounds bounds) { … … 193 189 194 190 /** 195 * Listens to a selection change196 */197 @Override198 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {199 200 ArrayList<Relation> routes = new ArrayList<>();201 202 for (OsmPrimitive primitive : newSelection) {203 if (primitive.getType().equals(OsmPrimitiveType.RELATION)) {204 Relation relation = (Relation) primitive;205 if (RouteUtils.isTwoDirectionRoute(relation)) {206 routes.add(relation);207 }208 209 }210 }211 212 if (!routes.isEmpty()) {213 this.primitives.clear();214 this.primitives.addAll(routes);215 if (!Main.getLayerManager().containsLayer(this)) {216 Main.getLayerManager().addLayer(this);217 }218 }219 220 }221 222 /**223 191 * Listens to a focus change, sets the primitives attribute to the route 224 192 * relation in the top Relation Editor and repaints the map … … 239 207 240 208 if (RouteUtils.isTwoDirectionRoute(relation)) { 241 242 209 this.repaint(relation); 243 210 244 211 } 245 246 212 } 247 213 } … … 296 262 } 297 263 264 if (event.getRemovedLayer() instanceof OsmDataLayer && event.getSource().getLayersOfType(OsmDataLayer.class).size() < 1) 265 event.scheduleRemoval(Collections.singleton(this)); 266 267 if(event.getRemovedLayer() == this) 268 PTAssistantLayerManager.PTLM.resetLayer(); 269 } 270 271 @Override 272 public synchronized void destroy() { 273 KeyboardFocusManager.getCurrentKeyboardFocusManager().removePropertyChangeListener(this); 274 Main.getLayerManager().removeLayerChangeListener(this); 275 super.destroy(); 298 276 } 299 277 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/Checker.java
r33055 r33345 21 21 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 22 22 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 23 import org.openstreetmap.josm.plugins.pt_assistant.gui.PTAssistantLayer ;23 import org.openstreetmap.josm.plugins.pt_assistant.gui.PTAssistantLayerManager; 24 24 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; 25 25 … … 197 197 198 198 // make the current relation purple in the pt_assistant layer: 199 PTAssistantLayer .getLayer().repaint(r);199 PTAssistantLayerManager.PTLM.getLayer().repaint(r); 200 200 201 201 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/PTAssistantValidatorTest.java
r33321 r33345 36 36 import org.openstreetmap.josm.plugins.pt_assistant.data.PTWay; 37 37 import org.openstreetmap.josm.plugins.pt_assistant.gui.IncompleteMembersDownloadDialog; 38 import org.openstreetmap.josm.plugins.pt_assistant.gui.PTAssistantLayer ;38 import org.openstreetmap.josm.plugins.pt_assistant.gui.PTAssistantLayerManager; 39 39 import org.openstreetmap.josm.plugins.pt_assistant.gui.ProceedDialog; 40 40 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; … … 60 60 public static final int ERROR_CODE_STOP_AREA_COMPARE_RELATIONS = 3764; 61 61 62 private PTAssistantLayer layer;63 64 62 public PTAssistantValidatorTest() { 65 63 super(tr("Public Transport Assistant tests"), 66 64 tr("Check if route relations are compatible with public transport version 2")); 67 65 68 layer = PTAssistantLayer.getLayer(); 69 DataSet.addSelectionListener(layer); 66 DataSet.addSelectionListener(PTAssistantLayerManager.PTLM); 70 67 71 68 } … … 491 488 if (testError.getPrimitives().iterator().next().getType().equals(OsmPrimitiveType.RELATION)) { 492 489 Relation relationToBeFixed = (Relation) testError.getPrimitives().iterator().next(); 493 this.layer.repaint(relationToBeFixed);490 PTAssistantLayerManager.PTLM.getLayer().repaint(relationToBeFixed); 494 491 } 495 492 … … 568 565 569 566 public void addFixVariants(List<List<PTWay>> fixVariants) { 570 layer.addFixVariants(fixVariants);567 PTAssistantLayerManager.PTLM.getLayer().addFixVariants(fixVariants); 571 568 } 572 569 573 570 public void clearFixVariants() { 574 layer.clearFixVariants();571 PTAssistantLayerManager.PTLM.getLayer().clearFixVariants(); 575 572 } 576 573 577 574 public List<PTWay> getFixVariant(Character c) { 578 return layer.getFixVariant(c);575 return PTAssistantLayerManager.PTLM.getLayer().getFixVariant(c); 579 576 } 580 577 -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentChecker.java
r33108 r33345 37 37 import org.openstreetmap.josm.plugins.pt_assistant.data.PTStop; 38 38 import org.openstreetmap.josm.plugins.pt_assistant.data.PTWay; 39 import org.openstreetmap.josm.plugins.pt_assistant.gui.PTAssistantLayer ;39 import org.openstreetmap.josm.plugins.pt_assistant.gui.PTAssistantLayerManager; 40 40 import org.openstreetmap.josm.plugins.pt_assistant.utils.StopToWayAssigner; 41 41 … … 114 114 /** 115 115 * Used for unit tests 116 * 116 * 117 117 * @param error 118 118 * test error … … 637 637 638 638 /** 639 * Finds fixes using sorting and removal. 639 * Finds fixes using sorting and removal. 640 640 */ 641 641 protected void findFixes() { … … 897 897 final PTAssistantValidatorTest test = (PTAssistantValidatorTest) testError.getTester(); 898 898 test.addFixVariants(fixVariants); 899 PTAssistantLayer .getLayer().repaint((Relation) testError.getPrimitives().iterator().next());899 PTAssistantLayerManager.PTLM.getLayer().repaint((Relation) testError.getPrimitives().iterator().next()); 900 900 901 901 // prepare the variables for the key listener: … … 906 906 Main.map.mapView.addKeyListener(new KeyListener() { 907 907 908 @Override 908 909 public void keyTyped(KeyEvent e) { 909 910 // TODO Auto-generated method stub 910 911 } 911 912 913 @Override 912 914 public void keyPressed(KeyEvent e) { 913 915 Character typedKey = e.getKeyChar(); … … 925 927 } 926 928 929 @Override 927 930 public void keyReleased(KeyEvent e) { 928 931 // TODO Auto-generated method stub
Note:
See TracChangeset
for help on using the changeset viewer.