Changeset 32620 in osm for applications
- Timestamp:
- 2016-07-10T20:44:13+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/graphview
- Files:
-
- 2 added
- 85 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/graphview/.project
r32286 r32620 16 16 </arguments> 17 17 </buildCommand> 18 <buildCommand> 19 <name>net.sf.eclipsecs.core.CheckstyleBuilder</name> 20 <arguments> 21 </arguments> 22 </buildCommand> 18 23 </buildSpec> 19 24 <natures> 20 25 <nature>org.eclipse.jdt.core.javanature</nature> 26 <nature>net.sf.eclipsecs.core.CheckstyleNature</nature> 21 27 </natures> 22 28 </projectDescription> -
applications/editors/josm/plugins/graphview/build.xml
r32344 r32620 2 2 <project name="graphview" default="dist" basedir="."> 3 3 <property name="commit.message" value="option to change graph colors; closes ticket 5523 in JOSM Trac"/> 4 <property name="plugin.main.version" value="10 279"/>4 <property name="plugin.main.version" value="10420"/> 5 5 6 6 <!-- Configure these properties (replace "..." accordingly). -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/access/AccessEvaluator.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.access; 2 3 … … 27 28 * != null 28 29 */ 29 publicboolean wayUsable(W way, boolean forward,30 boolean wayUsable(W way, boolean forward, 30 31 Map<RoadPropertyType<?>, Object> roadPropertyValues); 31 32 … … 38 39 * property type; != null 39 40 */ 40 public boolean nodeUsable(N node, Map<RoadPropertyType<?>, Object> roadPropertyValues); 41 41 boolean nodeUsable(N node, Map<RoadPropertyType<?>, Object> roadPropertyValues); 42 42 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/access/AccessParameters.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.access; 2 3 … … 11 12 public interface AccessParameters { 12 13 13 publicString getAccessClass();14 String getAccessClass(); 14 15 15 16 /** … … 17 18 * @param accessType access type to check usablitly for; != null 18 19 */ 19 publicboolean getAccessTypeUsable(AccessType accessType);20 boolean getAccessTypeUsable(AccessType accessType); 20 21 21 22 /** … … 24 25 * @return collection of property types; != null 25 26 */ 26 publicCollection<VehiclePropertyType<?>> getAvailableVehicleProperties();27 Collection<VehiclePropertyType<?>> getAvailableVehicleProperties(); 27 28 28 29 /** … … 35 36 * {@link VehiclePropertyType#isValidValue(Object)} method. 36 37 */ 37 public <V> V getVehiclePropertyValue(VehiclePropertyType<V> vehicleProperty); 38 38 <V> V getVehiclePropertyValue(VehiclePropertyType<V> vehicleProperty); 39 39 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/access/AccessRuleset.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.access; 2 3 … … 21 22 * empty if the parameter was no known mode of transport; != null 22 23 */ 23 publicList<String> getAccessHierarchyAncestors(String transportMode);24 List<String> getAccessHierarchyAncestors(String transportMode); 24 25 25 26 /** … … 28 29 * (commonly things like highway=* or barrier=*) 29 30 */ 30 publicCollection<Tag> getBaseTags();31 Collection<Tag> getBaseTags(); 31 32 32 33 /** … … 34 35 * @return list of implications in the order they are expected to be applied; != null 35 36 */ 36 public List<Implication> getImplications(); 37 37 List<Implication> getImplications(); 38 38 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/access/AccessRulesetReader.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.access; 2 3 … … 20 21 * utility class that can read access rulesets from xml files 21 22 */ 22 public class AccessRulesetReader { 23 public final class AccessRulesetReader { 23 24 24 25 public static class AccessRulesetSyntaxException extends IOException { … … 26 27 public AccessRulesetSyntaxException(String message) { 27 28 super(message); 28 }; 29 } 30 29 31 public AccessRulesetSyntaxException(Throwable t) { 30 32 super(t.toString()); … … 58 60 final String name; 59 61 final AccessClass parent; 60 public AccessClass(String name, AccessClass parent) { 62 63 AccessClass(String name, AccessClass parent) { 61 64 this.name = name; 62 65 this.parent = parent; 63 66 } 67 64 68 List<String> getAncestorHierarchy() { 65 69 List<String> names; … … 77 81 private final Collection<Tag> baseTags = new LinkedList<>(); 78 82 79 private static enum Section {NONE, CLASSES, BASETAGS, IMPLICATIONS}; 83 private enum Section { NONE, CLASSES, BASETAGS, IMPLICATIONS } 84 80 85 private Section currentSection = Section.NONE; 81 86 … … 90 95 return new AccessRuleset() { 91 96 97 @Override 92 98 public List<String> getAccessHierarchyAncestors(String transportMode) { 93 99 for (AccessClass accessClass : accessClasses) { … … 99 105 } 100 106 107 @Override 101 108 public Collection<Tag> getBaseTags() { 102 109 return baseTags; 103 110 } 104 111 112 @Override 105 113 public List<Implication> getImplications() { 106 114 return implications; … … 234 242 } 235 243 236 } ;244 } 237 245 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/access/AccessType.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.access; 2 3 … … 15 16 16 17 private String[] valueStrings; 17 privateAccessType(String... valueStrings) {18 AccessType(String... valueStrings) { 18 19 this.valueStrings = valueStrings; 19 20 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/access/Implication.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.access; 2 3 -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/access/ImplicationXMLReader.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.access; 2 3 … … 21 22 private final List<Implication> implications = new LinkedList<>(); 22 23 23 private static enum State {BEFORE_IMPLICATION, BEFORE_CONDITION, CONDITION, BEFORE_IMPLIES, IMPLIES, AFTER_IMPLIES}; 24 private enum State { BEFORE_IMPLICATION, BEFORE_CONDITION, CONDITION, BEFORE_IMPLIES, IMPLIES, AFTER_IMPLIES } 25 24 26 private State state = State.BEFORE_IMPLICATION; 25 27 -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/access/RulesetAccessEvaluator.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.access; 2 3 … … 37 38 } 38 39 40 @Override 39 41 public boolean wayUsable(W way, boolean forward, 40 42 Map<RoadPropertyType<?>, Object> segmentPropertyValues) { … … 63 65 /* evaluate one-way tagging */ 64 66 65 String onewayValue = 67 String onewayValue = wayTagsWithImplications.getValue("oneway"); 66 68 67 69 if (forward && "-1".equals(onewayValue) … … 81 83 } 82 84 83 public boolean nodeUsable(N node, Map<RoadPropertyType<?>,Object> roadPropertyValues) { 85 @Override 86 public boolean nodeUsable(N node, Map<RoadPropertyType<?>, Object> roadPropertyValues) { 84 87 85 88 TagGroup nodeTags = dataSource.getTagsN(node); 86 89 87 90 return objectUsable(roadPropertyValues, nodeTags); 88 } ;91 } 89 92 90 93 private boolean objectUsable(Map<RoadPropertyType<?>, Object> roadPropertyValues, … … 110 113 for (String accessClass : ruleset.getAccessHierarchyAncestors(parameters.getAccessClass())) { 111 114 accessType = accessTypePerClass.get(accessClass); 112 if (accessType != UNDEFINED) { break; } 115 if (accessType != UNDEFINED) { 116 break; 117 } 113 118 } 114 119 -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/data/DataSource.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.data; 2 3 … … 11 12 12 13 /** returns all nodes */ 13 publicIterable<N> getNodes();14 Iterable<N> getNodes(); 14 15 15 16 /** returns all ways */ 16 publicIterable<W> getWays();17 Iterable<W> getWays(); 17 18 18 19 /** returns all relations */ 19 publicIterable<R> getRelations();20 Iterable<R> getRelations(); 20 21 21 22 /** returns a node's latitude */ 22 publicdouble getLat(N node);23 double getLat(N node); 23 24 24 25 /** returns a node's longitude */ 25 publicdouble getLon(N node);26 double getLon(N node); 26 27 27 28 /** returns a way's nodes */ 28 publicIterable<N> getNodes(W way);29 Iterable<N> getNodes(W way); 29 30 30 31 /** returns a relation's members */ 31 publicIterable<M> getMembers(R relation);32 Iterable<M> getMembers(R relation); 32 33 33 34 /** returns a node's tags */ 34 publicTagGroup getTagsN(N node);35 TagGroup getTagsN(N node); 35 36 36 37 /** returns a way's tags */ 37 publicTagGroup getTagsW(W way);38 TagGroup getTagsW(W way); 38 39 39 40 /** returns a relation's tags */ 40 publicTagGroup getTagsR(R relation);41 TagGroup getTagsR(R relation); 41 42 42 43 /** returns a relation member's role */ 43 publicString getRole(M member);44 String getRole(M member); 44 45 45 46 /** returns a relation member's member object */ 46 publicObject getMember(M member);47 Object getMember(M member); 47 48 48 49 /** returns whether a relation member is a node */ 49 publicboolean isNMember(M member);50 boolean isNMember(M member); 50 51 51 52 /** returns whether a relation member is a way */ 52 publicboolean isWMember(M member);53 boolean isWMember(M member); 53 54 54 55 /** returns whether a relation member is a relation */ 55 publicboolean isRMember(M member);56 boolean isRMember(M member); 56 57 57 58 /** … … 61 62 * @param observer observer object, != null 62 63 */ 63 publicvoid addObserver(DataSourceObserver observer);64 void addObserver(DataSourceObserver observer); 64 65 65 66 /** … … 69 70 * @param observer observer object, != null 70 71 */ 71 public void deleteObserver(DataSourceObserver observer); 72 72 void deleteObserver(DataSourceObserver observer); 73 73 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/data/DataSourceObserver.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.data; 2 3 … … 12 13 * @param dataSource observed data source that has changed; != null 13 14 */ 14 public void update(DataSource<?, ?, ?, ?> dataSource); 15 15 void update(DataSource<?, ?, ?, ?> dataSource); 16 16 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/data/MapBasedTagGroup.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.data; 2 3 … … 58 59 } 59 60 61 @Override 60 62 public String getValue(String key) { 61 63 assert key != null; … … 63 65 } 64 66 67 @Override 65 68 public boolean containsKey(String key) { 66 69 assert key != null; … … 68 71 } 69 72 73 @Override 70 74 public boolean containsValue(String value) { 71 75 assert value != null; … … 73 77 } 74 78 79 @Override 75 80 public boolean contains(Tag tag) { 76 81 assert tag != null; … … 78 83 } 79 84 85 @Override 80 86 public int size() { 81 87 return tagMap.size(); … … 86 92 * The Iterator does not support the {@link Iterator#remove()} method. 87 93 */ 94 @Override 88 95 public Iterator<Tag> iterator() { 89 96 -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/data/Tag.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.data; 2 3 … … 23 24 return false; 24 25 } else { 25 Tag otherTag = (Tag)obj; 26 Tag otherTag = (Tag) obj; 26 27 return key.equals(otherTag.key) && value.equals(otherTag.value); 27 28 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/data/TagGroup.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.data; 2 3 … … 12 13 * @param key key whose value will be returned; != null 13 14 */ 14 publicString getValue(String key);15 String getValue(String key); 15 16 16 17 /** … … 18 19 * @param key key to check for; != null 19 20 */ 20 publicboolean containsKey(String key);21 boolean containsKey(String key); 21 22 22 23 /** … … 24 25 * @param value value to check for; != null 25 26 */ 26 publicboolean containsValue(String value);27 boolean containsValue(String value); 27 28 28 29 /** … … 30 31 * @param tag tag to check for; != null 31 32 */ 32 publicboolean contains(Tag tag);33 boolean contains(Tag tag); 33 34 34 35 /** 35 36 * returns the number of tags in this group 36 37 */ 37 public int size(); 38 38 int size(); 39 39 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/graph/ConnectorEvaluationGroup.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.graph; 2 3 … … 62 63 assert targetNode != null && borderNodes.contains(targetNode); 63 64 64 if (!evaluated) { throw new IllegalStateException(tr("Group not yet evaluated")); } 65 if (!evaluated) { 66 throw new IllegalStateException(tr("Group not yet evaluated")); 67 } 65 68 66 69 int inboundIndex = borderNodes.indexOf(startNode); … … 78 81 List<Segment>[][] sequenceArray = new List[borderNodes.size()][borderNodes.size()]; 79 82 80 for (int startIndex = 0; startIndex < borderNodes.size(); startIndex 81 for (int targetIndex = 0; targetIndex < borderNodes.size(); targetIndex 83 for (int startIndex = 0; startIndex < borderNodes.size(); startIndex++) { 84 for (int targetIndex = 0; targetIndex < borderNodes.size(); targetIndex++) { 82 85 83 86 List<Segment> sequence = … … 108 111 return "ConnectorEG " + segments; 109 112 } 110 111 113 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/graph/EvaluationGroup.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.graph; 2 3 … … 263 264 public final void evaluate(Collection<Restriction> restrictions) { 264 265 265 if (evaluated) { return; } 266 if (evaluated) { 267 return; 268 } 266 269 267 270 evaluateImpl(restrictions); … … 278 281 * will not be modified; != null 279 282 */ 280 abstractprotected void evaluateImpl(Collection<Restriction> restrictions);283 protected abstract void evaluateImpl(Collection<Restriction> restrictions); 281 284 282 285 /** … … 284 287 * @param node node to check; != null 285 288 */ 286 abstractprotected boolean isUsableNode(SegmentNode node);289 protected abstract boolean isUsableNode(SegmentNode node); 287 290 288 291 /** … … 290 293 * @param segment segment to check; != null 291 294 */ 292 abstract protected boolean isUsableSegment(Segment segment); 293 295 protected abstract boolean isUsableSegment(Segment segment); 294 296 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/graph/GraphEdge.java
r29854 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.graph; 2 3 -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/graph/GraphNode.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.graph; 2 3 … … 16 17 * returns all edges that lead to this GraphNode; != null 17 18 */ 18 publicCollection<GraphEdge> getInboundEdges();19 Collection<GraphEdge> getInboundEdges(); 19 20 20 21 /** 21 22 * returns all edges that start at this GraphNode; != null 22 23 */ 23 publicCollection<GraphEdge> getOutboundEdges();24 Collection<GraphEdge> getOutboundEdges(); 24 25 25 26 /** … … 29 30 * by {@link #getSegment()}; != null 30 31 */ 31 publicSegmentNode getSegmentNode();32 SegmentNode getSegmentNode(); 32 33 33 34 /** … … 36 37 * @return Segment; != null 37 38 */ 38 public Segment getSegment(); 39 39 Segment getSegment(); 40 40 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/graph/JunctionEvaluationGroup.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.graph; 2 3 … … 38 39 */ 39 40 public Collection<Segment> getInboundSegments() { 40 if (!evaluated) { throw new IllegalStateException(tr("Group not yet evaluated")); } 41 if (!evaluated) { 42 throw new IllegalStateException(tr("Group not yet evaluated")); 43 } 41 44 return inboundSegments; 42 45 } … … 49 52 */ 50 53 public Collection<Segment> getOutboundSegments() { 51 if (!evaluated) { throw new IllegalStateException(tr("Group not yet evaluated")); } 54 if (!evaluated) { 55 throw new IllegalStateException(tr("Group not yet evaluated")); 56 } 52 57 return outboundSegments; 53 58 } … … 68 73 assert outboundSegment != null && outboundSegments.contains(outboundSegment); 69 74 70 if (!evaluated) { throw new IllegalStateException(tr("Group not yet evaluated")); } 75 if (!evaluated) { 76 throw new IllegalStateException(tr("Group not yet evaluated")); 77 } 71 78 72 79 int inboundIndex = inboundSegments.indexOf(inboundSegment); … … 105 112 List<Segment>[][] sequenceArray = new List[inboundSegments.size()][outboundSegments.size()]; 106 113 107 for (int inboundIndex = 0; inboundIndex < inboundSegments.size(); inboundIndex 108 for (int outboundIndex = 0; outboundIndex < outboundSegments.size(); outboundIndex 114 for (int inboundIndex = 0; inboundIndex < inboundSegments.size(); inboundIndex++) { 115 for (int outboundIndex = 0; outboundIndex < outboundSegments.size(); outboundIndex++) { 109 116 110 117 List<Segment> sequence = … … 118 125 119 126 segmentSequences = sequenceArray; 120 121 127 } 122 128 -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/graph/TSBasedWayGraph.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.graph; 2 3 … … 32 33 private final List<GraphEdge> incomingEdges = new ArrayList<>(); 33 34 private final List<GraphEdge> outgoingEdges = new ArrayList<>(); 34 public GraphNodeImpl(SegmentNode node, Segment segment) { 35 36 GraphNodeImpl(SegmentNode node, Segment segment) { 35 37 assert node != null && segment != null; 36 38 assert segment.getNode1() == node || segment.getNode2() == node; … … 38 40 this.segment = segment; 39 41 } 42 43 @Override 40 44 public SegmentNode getSegmentNode() { 41 45 return node; 42 46 } 47 48 @Override 43 49 public Segment getSegment() { 44 50 return segment; 45 51 } 52 46 53 public void addIncomingEdge(GraphEdge edge) { 47 54 assert edge != null; 48 55 incomingEdges.add(edge); 49 56 } 57 58 @Override 50 59 public Collection<GraphEdge> getInboundEdges() { 51 60 return incomingEdges; 52 61 } 62 53 63 public void addOutgoingEdge(GraphEdge edge) { 54 64 assert edge != null; 55 65 outgoingEdges.add(edge); 56 66 } 67 68 @Override 57 69 public Collection<GraphEdge> getOutboundEdges() { 58 70 return outgoingEdges; 59 71 } 72 60 73 @Override 61 74 public String toString() { … … 70 83 private final Map<GraphEdgePropertyType<?>, Object> properties; 71 84 72 publicGraphEdgeImpl(GraphNode startNode, GraphNode targetNode,85 GraphEdgeImpl(GraphNode startNode, GraphNode targetNode, 73 86 Map<GraphEdgePropertyType<?>, Object> properties) { 74 87 assert startNode != null && targetNode != null && properties != null; … … 78 91 } 79 92 93 @Override 80 94 public GraphNode getStartNode() { 81 95 return startNode; 82 96 } 97 98 @Override 83 99 public GraphNode getTargetNode() { 84 100 return targetNode; 85 101 } 86 102 103 @Override 87 104 public Collection<GraphEdgePropertyType<?>> getAvailableProperties() { 88 105 return properties.keySet(); 89 106 } 107 108 @Override 90 109 public <V> V getPropertyValue(GraphEdgePropertyType<V> property) { 91 110 @SuppressWarnings("unchecked") … … 99 118 } 100 119 101 } ;120 } 102 121 103 122 private final Set<WayGraphObserver> observers = new HashSet<>(); … … 121 140 } 122 141 142 @Override 123 143 public Collection<GraphEdge> getEdges() { 124 144 return edges; 125 145 } 126 146 147 @Override 127 148 public Collection<GraphNode> getNodes() { 128 149 return nodes; … … 478 499 } 479 500 501 @Override 480 502 public void update(TransitionStructure transitionStructure) { 481 503 createNodesAndEdges(); … … 483 505 } 484 506 507 @Override 485 508 public void addObserver(WayGraphObserver observer) { 486 509 observers.add(observer); 487 510 } 488 511 512 @Override 489 513 public void deleteObserver(WayGraphObserver observer) { 490 514 observers.remove(observer); … … 496 520 } 497 521 } 498 499 522 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/graph/WayGraph.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.graph; 2 3 … … 9 10 10 11 Collection<GraphNode> getNodes(); 12 11 13 Collection<GraphEdge> getEdges(); 12 14 … … 17 19 * @param observer observer object, != null 18 20 */ 19 publicvoid addObserver(WayGraphObserver observer);21 void addObserver(WayGraphObserver observer); 20 22 21 23 /** … … 25 27 * @param observer observer object, != null 26 28 */ 27 publicvoid deleteObserver(WayGraphObserver observer);29 void deleteObserver(WayGraphObserver observer); 28 30 29 31 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/graph/WayGraphObserver.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.graph; 2 3 … … 11 12 * @param wayGraph observed graph that has changed; != null 12 13 */ 13 public void update(WayGraph wayGraph); 14 14 void update(WayGraph wayGraph); 15 15 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/property/GraphEdgePropertyType.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 21 22 * determines the property value for segments created from junction groups 22 23 */ 23 publicV evaluate(JunctionEvaluationGroup junctionGroup,24 V evaluate(JunctionEvaluationGroup junctionGroup, 24 25 List<Segment> segmentSequence, 25 26 TransitionStructure transitionStructure); … … 28 29 * determines the property value for segments created from connector groups 29 30 */ 30 publicV evaluate(ConnectorEvaluationGroup connectorGroup,31 V evaluate(ConnectorEvaluationGroup connectorGroup, 31 32 List<Segment> segmentSequence, 32 33 TransitionStructure transitionStructure); 33 34 34 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/property/GraphEdgeSegments.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 25 26 private GraphEdgeSegments() { } 26 27 28 @Override 27 29 public List<Segment> evaluate(JunctionEvaluationGroup junctionGroup, 28 30 List<Segment> segmentSequence, TransitionStructure transitionStructure) { … … 30 32 } 31 33 34 @Override 32 35 public List<Segment> evaluate(ConnectorEvaluationGroup connectorGroup, 33 36 List<Segment> segmentSequence, TransitionStructure transitionStructure) { 34 37 return segmentSequence; 35 38 } 36 37 39 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/property/RoadIncline.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 8 9 public class RoadIncline implements RoadPropertyType<Float> { 9 10 11 @Override 10 12 public <N, W, R, M> Float evaluateN(N node, AccessParameters accessParameters, 11 DataSource<N, W,R,M> dataSource) {13 DataSource<N, W, R, M> dataSource) { 12 14 return null; 13 } ;15 } 14 16 17 @Override 15 18 public <N, W, R, M> Float evaluateW(W way, boolean forward, AccessParameters accessParameters, 16 DataSource<N, W,R,M> dataSource) {19 DataSource<N, W, R, M> dataSource) { 17 20 assert way != null && accessParameters != null && dataSource != null; 18 21 … … 31 34 32 35 return null; 33 } ;36 } 34 37 38 @Override 35 39 public boolean isUsable(Object propertyValue, AccessParameters accessParameters) { 36 40 assert propertyValue instanceof Float; 37 41 38 float incline = (Float)propertyValue; 42 float incline = (Float) propertyValue; 39 43 40 44 Float maxInclineUp = -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/property/RoadMaxaxleload.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 9 10 super("maxaxleload", AXLELOAD, LimitType.MAXIMUM); 10 11 } 12 11 13 @Override 12 14 protected Float parse(String valueString) { -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/property/RoadMaxheight.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 9 10 super("maxheight", HEIGHT, LimitType.MAXIMUM); 10 11 } 12 11 13 @Override 12 14 protected Float parse(String valueString) { -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/property/RoadMaxlength.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 9 10 super("maxlength", LENGTH, LimitType.MAXIMUM); 10 11 } 12 11 13 @Override 12 14 protected Float parse(String valueString) { -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/property/RoadMaxspeed.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 30 31 } 31 32 33 @Override 32 34 public <N, W, R, M> Float evaluateN(N node, AccessParameters accessParameters, 33 35 DataSource<N, W, R, M> dataSource) { … … 39 41 } 40 42 43 @Override 41 44 public <N, W, R, M> Float evaluateW(W way, boolean forward, AccessParameters accessParameters, 42 45 DataSource<N, W, R, M> dataSource) { … … 63 66 } 64 67 68 @Override 65 69 public boolean isUsable(Object propertyValue, AccessParameters accessParameters) { 66 70 assert propertyValue instanceof Float; -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/property/RoadMaxweight.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 9 10 super("maxweight", WEIGHT, LimitType.MAXIMUM); 10 11 } 12 11 13 @Override 12 14 protected Float parse(String valueString) { -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/property/RoadMaxwidth.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 9 10 super("maxwidth", WIDTH, LimitType.MAXIMUM); 10 11 } 12 11 13 @Override 12 14 protected Float parse(String valueString) { -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/property/RoadMinspeed.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 9 10 super("minspeed", SPEED, LimitType.MINIMUM); 10 11 } 12 11 13 @Override 12 14 protected Float parse(String valueString) { -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/property/RoadPropertyType.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 26 27 * null if property cannot be determined / does not apply 27 28 */ 28 public<N, W, R, M> V evaluateW(W way, boolean forward,29 <N, W, R, M> V evaluateW(W way, boolean forward, 29 30 AccessParameters accessParameters, DataSource<N, W, R, M> dataSource); 30 31 … … 39 40 * null if property cannot be determined / does not apply 40 41 */ 41 public<N, W, R, M> V evaluateN(N node,42 <N, W, R, M> V evaluateN(N node, 42 43 AccessParameters accessParameters, DataSource<N, W, R, M> dataSource); 43 44 … … 49 50 * MUST be of type V; != null 50 51 */ 51 public boolean isUsable(Object object, AccessParameters accessParameters); 52 52 boolean isUsable(Object object, AccessParameters accessParameters); 53 53 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/property/RoadSurface.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 9 10 public class RoadSurface implements RoadPropertyType<String> { 10 11 12 @Override 11 13 public <N, W, R, M> String evaluateN(N node, AccessParameters accessParameters, 12 DataSource<N, W,R,M> dataSource) {14 DataSource<N, W, R, M> dataSource) { 13 15 return null; 14 } ;16 } 15 17 18 @Override 16 19 public <N, W, R, M> String evaluateW(W way, boolean forward, AccessParameters accessParameters, 17 DataSource<N, W,R,M> dataSource) {20 DataSource<N, W, R, M> dataSource) { 18 21 assert way != null && accessParameters != null && dataSource != null; 19 22 … … 21 24 return tags.getValue("surface"); 22 25 23 } ;26 } 24 27 28 @Override 25 29 public boolean isUsable(Object propertyValue, AccessParameters accessParameters) { 26 30 assert propertyValue instanceof String; 27 31 28 String surface = (String)propertyValue; 32 String surface = (String) propertyValue; 29 33 30 34 Collection<String> surfaceBlacklist = -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/property/RoadTracktype.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 7 8 public class RoadTracktype implements RoadPropertyType<Integer> { 8 9 10 @Override 9 11 public <N, W, R, M> Integer evaluateN(N node, AccessParameters accessParameters, 10 DataSource<N, W,R,M> dataSource) {12 DataSource<N, W, R, M> dataSource) { 11 13 return null; 12 } ;14 } 13 15 16 @Override 14 17 public <N, W, R, M> Integer evaluateW(W way, boolean forward, AccessParameters accessParameters, 15 DataSource<N, W,R,M> dataSource) {18 DataSource<N, W, R, M> dataSource) { 16 19 assert way != null && accessParameters != null && dataSource != null; 17 20 … … 34 37 35 38 return null; 36 } ;39 } 37 40 41 @Override 38 42 public boolean isUsable(Object propertyValue, AccessParameters accessParameters) { 39 43 assert propertyValue instanceof Integer; 40 44 41 int tracktype = (Integer)propertyValue; 45 int tracktype = (Integer) propertyValue; 42 46 43 47 Integer maxTracktype = … … 50 54 } 51 55 } 52 53 56 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/property/RoadValueLimit.java
r26174 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 9 10 * abstract superclass for road property types that define a limit for a vehicle property 10 11 */ 11 abstract publicclass RoadValueLimit implements RoadPropertyType<Float> {12 public abstract class RoadValueLimit implements RoadPropertyType<Float> { 12 13 13 protected staticenum LimitType {MINIMUM, MAXIMUM};14 protected enum LimitType { MINIMUM, MAXIMUM } 14 15 15 16 private final String keyName; … … 36 37 protected abstract Float parse(String valueString); 37 38 39 @Override 38 40 public <N, W, R, M> Float evaluateW(W way, boolean forward, 39 41 AccessParameters accessParameters, DataSource<N, W, R, M> dataSource) { … … 42 44 } 43 45 46 @Override 44 47 public <N, W, R, M> Float evaluateN(N node, 45 48 AccessParameters accessParameters, DataSource<N, W, R, M> dataSource) { … … 48 51 } 49 52 50 private finalFloat evaluateTags(TagGroup tags) {53 private Float evaluateTags(TagGroup tags) { 51 54 String valueString = tags.getValue(keyName); 52 55 if (valueString != null) { … … 58 61 } 59 62 63 @Override 60 64 public boolean isUsable(Object propertyValue, AccessParameters accessParameters) { 61 65 assert propertyValue instanceof Float; -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/property/RoadWidth.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 9 10 super("width", WIDTH, LimitType.MAXIMUM); 10 11 } 12 11 13 @Override 12 14 protected Float parse(String valueString) { -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/property/VehiclePropertyType.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 15 16 * null is never a valid value and must not be used as parameter. 16 17 */ 17 public boolean isValidValue(Object value); 18 18 boolean isValidValue(Object value); 19 19 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/property/VehiclePropertyTypes.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 13 14 14 15 private static final class NonnegativeFloatProperty implements VehiclePropertyType<Float> { 16 @Override 15 17 public boolean isValidValue(Object value) { 16 return value instanceof Float && (Float)value >= 0; 18 return value instanceof Float && (Float) value >= 0; 17 19 } 18 20 } … … 44 46 /** surface types ("surface" key values) the vehicle cannot use */ 45 47 public static final VehiclePropertyType<Collection<String>> SURFACE_BLACKLIST = new VehiclePropertyType<Collection<String>>() { 48 @Override 46 49 public boolean isValidValue(Object value) { 47 50 … … 50 53 } 51 54 52 for (Object contentObject : (Collection<?>)value) { 55 for (Object contentObject : (Collection<?>) value) { 53 56 if (!(contentObject instanceof String)) { 54 57 return false; … … 66 69 */ 67 70 public static final VehiclePropertyType<Integer> MAX_TRACKTYPE = new VehiclePropertyType<Integer>() { 71 @Override 68 72 public boolean isValidValue(Object value) { 69 return value instanceof Integer && (Integer)value >= 0 && (Integer)value <= 5; 73 return value instanceof Integer && (Integer) value >= 0 && (Integer) value <= 5; 70 74 } 71 75 }; -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/transition/GenericTransitionStructure.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.transition; 2 3 … … 41 42 private final List<Segment> outboundSegments = new LinkedList<>(); 42 43 private final Map<RoadPropertyType<?>, Object> properties; 43 public SegmentNodeImpl(double lat, double lon, Map<RoadPropertyType<?>, Object> properties) { 44 45 SegmentNodeImpl(double lat, double lon, Map<RoadPropertyType<?>, Object> properties) { 44 46 assert properties != null; 45 47 this.lat = lat; … … 47 49 this.properties = properties; 48 50 } 51 52 @Override 49 53 public double getLat() { 50 54 return lat; 51 55 } 56 57 @Override 52 58 public double getLon() { 53 59 return lon; 54 60 } 61 55 62 public void addInboundSegment(Segment segment) { 56 63 inboundSegments.add(segment); 57 64 } 65 58 66 public void addOutboundSegment(Segment segment) { 59 67 outboundSegments.add(segment); 60 68 } 69 70 @Override 61 71 public Collection<Segment> getOutboundSegments() { 62 72 return outboundSegments; 63 73 } 74 75 @Override 64 76 public Collection<Segment> getInboundSegments() { 65 77 return inboundSegments; … … 69 81 properties.put(property, value); 70 82 }*/ 83 @Override 71 84 public Collection<RoadPropertyType<?>> getAvailableProperties() { 72 85 return properties.keySet(); 73 86 } 87 88 @Override 74 89 public <P> P getPropertyValue(RoadPropertyType<P> property) { 75 90 @SuppressWarnings("unchecked") //cast is safe due to type parameter of setProperty … … 77 92 return result; 78 93 } 94 79 95 public Map<RoadPropertyType<?>, Object> getProperties() { 80 96 return properties; … … 91 107 private final SegmentNode node2; 92 108 private final Map<RoadPropertyType<?>, Object> properties; 93 public SegmentImpl(SegmentNode node1, SegmentNode node2, Map<RoadPropertyType<?>, Object> properties) { 109 110 SegmentImpl(SegmentNode node1, SegmentNode node2, Map<RoadPropertyType<?>, Object> properties) { 94 111 this.node1 = node1; 95 112 this.node2 = node2; 96 113 this.properties = properties; 97 114 } 115 116 @Override 98 117 public SegmentNode getNode1() { 99 118 return node1; 100 119 } 120 121 @Override 101 122 public SegmentNode getNode2() { 102 123 return node2; 103 124 } 125 104 126 /*public <P> void setProperty(RoadPropertyType<P> property, P value) { 105 127 properties.put(property, value); 106 128 }*/ 129 130 @Override 107 131 public Collection<RoadPropertyType<?>> getAvailableProperties() { 108 132 return properties.keySet(); 109 133 } 134 135 @Override 110 136 public <P> P getPropertyValue(RoadPropertyType<P> property) { 111 137 @SuppressWarnings("unchecked") //cast is safe due to type parameter of setProperty … … 126 152 127 153 /** constructor, will directly use collection references, collections must not be changed after usage as constructor param */ 128 publicRestrictionImpl(Segment from, Collection<Segment> vias, Collection<Segment> tos) {154 RestrictionImpl(Segment from, Collection<Segment> vias, Collection<Segment> tos) { 129 155 this.from = from; 130 156 this.vias = Collections.unmodifiableCollection(vias); … … 132 158 } 133 159 160 @Override 134 161 public Segment getFrom() { 135 162 return from; 136 163 } 164 165 @Override 137 166 public Collection<Segment> getVias() { 138 167 return vias; 139 168 } 169 170 @Override 140 171 public Collection<Segment> getTos() { 141 172 return tos; … … 213 244 } 214 245 246 @Override 215 247 public Collection<SegmentNode> getNodes() { 216 248 return nodes; 217 249 } 218 250 251 @Override 219 252 public Collection<Segment> getSegments() { 220 253 return segments; 221 254 } 222 255 256 @Override 223 257 public Collection<Restriction> getRestrictions() { 224 258 return restrictions; … … 278 312 Map<N, SegmentNodeImpl> nodeCreationMap, Map<W, List<Segment>> waySegmentMap) { 279 313 280 assert way != null && wayAccessEvaluator != null && nodes != null && segments != null && nodeCreationMap != null && waySegmentMap != null; 314 assert way != null && wayAccessEvaluator != null && nodes != null 315 && segments != null && nodeCreationMap != null && waySegmentMap != null; 281 316 282 317 /* calculate property values */ … … 379 414 380 415 if ("restriction".equals(tags.getValue("type")) 381 && tags.getValue("restriction") != null 416 && tags.getValue("restriction") != null) { 382 417 383 418 //evaluate relation … … 415 450 return EMPTY_RESTRICTION_COLLECTION; 416 451 } else { 417 fromWay = (W)dataSource.getMember(member); 452 fromWay = (W) dataSource.getMember(member); 418 453 } 419 454 } else if ("to".equals(dataSource.getRole(member))) { … … 422 457 return EMPTY_RESTRICTION_COLLECTION; 423 458 } else { 424 toWays.add((W)dataSource.getMember(member)); 459 toWays.add((W) dataSource.getMember(member)); 425 460 } 426 461 } else if ("via".equals(dataSource.getRole(member))) { 427 462 if (dataSource.isWMember(member)) { 428 viaWays.add((W)dataSource.getMember(member)); 463 viaWays.add((W) dataSource.getMember(member)); 429 464 } else if (dataSource.isNMember(member)) { 430 viaNodes.add((N)dataSource.getMember(member)); 465 viaNodes.add((N) dataSource.getMember(member)); 431 466 } 432 467 } … … 671 706 } 672 707 708 @Override 673 709 public void update(DataSource<?, ?, ?, ?> dataSource) { 674 710 assert this.dataSource == dataSource; … … 676 712 } 677 713 714 @Override 678 715 public void addObserver(TransitionStructureObserver observer) { 679 716 observers.add(observer); 680 717 } 681 718 719 @Override 682 720 public void deleteObserver(TransitionStructureObserver observer) { 683 721 observers.remove(observer); … … 689 727 } 690 728 } 691 692 729 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/transition/Restriction.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.transition; 2 3 … … 14 15 * != null 15 16 */ 16 publicSegment getFrom();17 Segment getFrom(); 17 18 18 19 /** … … 22 23 * @return unmodifiable collection of segments; != null 23 24 */ 24 publicCollection<Segment> getVias();25 Collection<Segment> getVias(); 25 26 26 27 /** … … 30 31 * @return unmodifiable collection of segments; != null 31 32 */ 32 public Collection<Segment> getTos(); 33 33 Collection<Segment> getTos(); 34 34 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/transition/Segment.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.transition; 2 3 … … 9 10 * returns the node this segment starts at; != null 10 11 */ 11 publicSegmentNode getNode1();12 SegmentNode getNode1(); 12 13 13 14 /** 14 15 * returns the node this segment leads to; != null 15 16 */ 16 public SegmentNode getNode2(); 17 17 SegmentNode getNode2(); 18 18 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/transition/SegmentNode.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.transition; 2 3 … … 9 10 10 11 /** returns the node's latitude */ 11 publicdouble getLat();12 double getLat(); 12 13 13 14 /** returns the node's longitude */ 14 publicdouble getLon();15 double getLon(); 15 16 16 17 /** returns all segments that end at this node */ … … 19 20 /** returns all segments that start at this node */ 20 21 Collection<Segment> getOutboundSegments(); 21 22 22 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/transition/TransitionStructure.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.transition; 2 3 … … 9 10 public interface TransitionStructure { 10 11 11 public Collection<SegmentNode> getNodes(); 12 public Collection<Segment> getSegments(); 13 public Collection<Restriction> getRestrictions(); 12 Collection<SegmentNode> getNodes(); 13 14 Collection<Segment> getSegments(); 15 16 Collection<Restriction> getRestrictions(); 14 17 15 18 /** … … 19 22 * @param observer observer object, != null 20 23 */ 21 publicvoid addObserver(TransitionStructureObserver observer);24 void addObserver(TransitionStructureObserver observer); 22 25 23 26 /** … … 27 30 * @param observer observer object, != null 28 31 */ 29 publicvoid deleteObserver(TransitionStructureObserver observer);32 void deleteObserver(TransitionStructureObserver observer); 30 33 31 34 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/transition/TransitionStructureElement.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.transition; 2 3 … … 15 16 * @return property type collection; != null 16 17 */ 17 publicCollection<RoadPropertyType<?>> getAvailableProperties();18 Collection<RoadPropertyType<?>> getAvailableProperties(); 18 19 19 20 /** … … 23 24 * @return property value of the property for this segment; null if not available 24 25 */ 25 public <P> P getPropertyValue(RoadPropertyType<P> propertyType); 26 26 <P> P getPropertyValue(RoadPropertyType<P> propertyType); 27 27 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/transition/TransitionStructureObserver.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.transition; 2 3 … … 11 12 * @param transitionStructure observed transition structure that has changed; != null 12 13 */ 13 public void update(TransitionStructure transitionStructure); 14 14 void update(TransitionStructure transitionStructure); 15 15 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/util/GraphUtil.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.util; 2 3 … … 18 19 * (a node whose {@link SegmentNode} is connected to at most one other {@link SegmentNode}) 19 20 */ 20 public static finalboolean isEndNode(GraphNode node) {21 public static boolean isEndNode(GraphNode node) { 21 22 22 23 SegmentNode ownSegmentNode = node.getSegmentNode(); -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/util/TagCondition.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.util; 2 3 -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/util/TagConditionLogic.java
r26174 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.util; 2 3 … … 24 25 assert tag != null; 25 26 return new TagCondition() { 27 @Override 26 28 public boolean matches(TagGroup tags) { 27 29 return tags.contains(tag); 28 30 } 31 29 32 @Override 30 33 public String toString() { … … 42 45 assert key != null; 43 46 return new TagCondition() { 47 @Override 44 48 public boolean matches(TagGroup tags) { 45 49 return tags.containsKey(key); 46 50 } 51 47 52 @Override 48 53 public String toString() { … … 60 65 public static TagCondition and(final TagCondition condition, final TagCondition... conditions) { 61 66 return new TagCondition() { 67 @Override 62 68 public boolean matches(TagGroup tags) { 63 69 for (TagCondition c : conditions) { … … 68 74 return condition.matches(tags); 69 75 } 76 70 77 @Override 71 78 public String toString() { … … 93 100 } 94 101 return new TagCondition() { 102 @Override 95 103 public boolean matches(TagGroup tags) { 96 104 for (TagCondition c : conditions) { … … 101 109 return true; 102 110 } 111 103 112 @Override 104 113 public String toString() { … … 127 136 public static TagCondition or(final TagCondition condition, final TagCondition... conditions) { 128 137 return new TagCondition() { 138 @Override 129 139 public boolean matches(TagGroup tags) { 130 140 for (TagCondition c : conditions) { … … 135 145 return condition.matches(tags); 136 146 } 147 137 148 @Override 138 149 public String toString() { … … 160 171 } 161 172 return new TagCondition() { 173 @Override 162 174 public boolean matches(TagGroup tags) { 163 175 for (TagCondition c : conditions) { … … 168 180 return false; 169 181 } 182 170 183 @Override 171 184 public String toString() { … … 193 206 public static TagCondition not(final TagCondition condition) { 194 207 return new TagCondition() { 208 @Override 195 209 public boolean matches(TagGroup tags) { 196 210 return !condition.matches(tags); 197 211 } 212 198 213 @Override 199 214 public String toString() { -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/util/ValueStringParser.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.util; 2 3 … … 4 5 import java.util.regex.Pattern; 5 6 7 import org.openstreetmap.josm.Main; 8 6 9 public final class ValueStringParser { 7 10 … … 12 15 private static final Pattern DEC_POINT_PATTERN = Pattern.compile("^(\\-?\\d+)\\.(\\d+)$"); 13 16 14 public static finalFloat parseOsmDecimal(String value, boolean allowNegative) {17 public static Float parseOsmDecimal(String value, boolean allowNegative) { 15 18 16 19 /* positive integer */ … … 20 23 int weight = Integer.parseInt(value); 21 24 if (weight >= 0 || allowNegative) { 22 return (float)weight; 23 } 24 25 } catch (NumberFormatException nfe) {} 25 return (float) weight; 26 } 27 28 } catch (NumberFormatException nfe) { 29 Main.trace(nfe); 30 } 26 31 27 32 /* positive number with decimal point */ … … 46 51 47 52 if (result >= 0 || allowNegative) { 48 return (float)result; 53 return (float) result; 49 54 } 50 55 51 } catch (NumberFormatException nfe) {} 52 56 } catch (NumberFormatException nfe) { 57 Main.trace(nfe); 58 } 53 59 } 54 60 } … … 67 73 * @return speed in km/h; null if value had syntax errors 68 74 */ 69 public static finalFloat parseSpeed(String value) {75 public static Float parseSpeed(String value) { 70 76 71 77 /* try numeric speed (implied km/h) */ … … 82 88 String kmhString = kmhMatcher.group(1); 83 89 try { 84 return (float)Integer.parseInt(kmhString); 85 } catch (NumberFormatException nfe) {} 90 return (float) Integer.parseInt(kmhString); 91 } catch (NumberFormatException nfe) { 92 Main.trace(nfe); 93 } 86 94 } 87 95 … … 94 102 int mph = Integer.parseInt(mphString); 95 103 return KM_PER_MILE * mph; 96 } catch (NumberFormatException nfe) {} 104 } catch (NumberFormatException nfe) { 105 Main.trace(nfe); 106 } 97 107 } 98 108 … … 115 125 * @return measure in m; null if value had syntax errors 116 126 */ 117 public static finalFloat parseMeasure(String value) {127 public static Float parseMeasure(String value) { 118 128 119 129 /* try numeric measure (implied m) */ … … 147 157 String miString = miMatcher.group(1); 148 158 float mi = parseOsmDecimal(miString, false); 149 return (float)(M_PER_MI * mi); 159 return (float) (M_PER_MI * mi); 150 160 } 151 161 … … 160 170 int inches = Integer.parseInt(inchesString); 161 171 if (feet >= 0 && inches >= 0 && inches < 12) { 162 return (float)(M_PER_INCH * (12 * feet + inches)); 172 return (float) (M_PER_INCH * (12 * feet + inches)); 163 173 } 164 } catch (NumberFormatException nfe) {} 174 } catch (NumberFormatException nfe) { 175 Main.trace(nfe); 176 } 165 177 } 166 178 … … 207 219 * @return incline in percents; null if value had syntax errors 208 220 */ 209 public static finalFloat parseIncline(String value) {221 public static Float parseIncline(String value) { 210 222 211 223 Matcher inclineMatcher = INCLINE_PATTERN.matcher(value); -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/visualisation/ColorScheme.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.visualisation; 2 3 … … 15 16 * @param edge GraphNode to determine the color for; != null 16 17 */ 17 publicColor getNodeColor(GraphNode node);18 Color getNodeColor(GraphNode node); 18 19 19 20 /** … … 21 22 * @param segment segment to determine the color for; != null 22 23 */ 23 public Color getSegmentColor(Segment segment); 24 24 Color getSegmentColor(Segment segment); 25 25 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/visualisation/DefaultNodePositioner.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.visualisation; 2 3 … … 11 12 public class DefaultNodePositioner implements NodePositioner { 12 13 14 @Override 13 15 public LatLonCoords getPosition(GraphNode node) { 14 16 … … 16 18 17 19 if (2 >= segmentNode.getInboundSegments().size() 18 + segmentNode.getOutboundSegments().size() 20 + segmentNode.getOutboundSegments().size()) { 19 21 20 22 return new LatLonCoords( -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/visualisation/EndNodeColorScheme.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.visualisation; 2 3 … … 22 23 } 23 24 25 @Override 24 26 public Color getNodeColor(GraphNode node) { 25 27 return GraphUtil.isEndNode(node) ? endNodeColor : nodeColor; 26 28 } 27 29 30 @Override 28 31 public Color getSegmentColor(Segment segment) { 29 32 return segmentColor; -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/visualisation/FloatPropertyColorScheme.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.visualisation; 2 3 … … 42 43 } 43 44 45 @Override 44 46 public Color getSegmentColor(Segment segment) { 45 47 assert segment != null; … … 50 52 if (propertyClass.isInstance(property)) { 51 53 @SuppressWarnings("unchecked") //has been checked using isInstance 52 RoadPropertyType<Float> floatProperty = (RoadPropertyType<Float>)property; 54 RoadPropertyType<Float> floatProperty = (RoadPropertyType<Float>) property; 53 55 propertyValue = segment.getPropertyValue(floatProperty); 54 56 break; … … 63 65 } 64 66 67 @Override 65 68 public Color getNodeColor(GraphNode node) { 66 69 67 70 List<Color> segmentColors = new ArrayList<>(); 68 69 70 71 71 72 for (GraphEdge edge : node.getInboundEdges()) { … … 158 159 float weightPerColor = 1.0f / colors.size(); 159 160 160 Color average = new Color(0, 0,0);161 Color average = new Color(0, 0, 0); 161 162 162 163 for (Color color : colors) { -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/visualisation/InclineColorScheme.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.visualisation; 2 3 -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/visualisation/LatLonCoords.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.visualisation; 2 3 -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/visualisation/MaxheightColorScheme.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.visualisation; 2 3 -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/visualisation/MaxspeedColorScheme.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.visualisation; 2 3 -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/visualisation/MaxweightColorScheme.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.visualisation; 2 3 -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/visualisation/NodePositioner.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.visualisation; 2 3 -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/visualisation/NonMovingNodePositioner.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.visualisation; 2 3 … … 5 6 public class NonMovingNodePositioner implements NodePositioner { 6 7 8 @Override 7 9 public LatLonCoords getPosition(GraphNode node) { 8 10 return new LatLonCoords( -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/visualisation/SingleColorScheme.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.visualisation; 2 3 … … 20 21 } 21 22 23 @Override 22 24 public Color getNodeColor(GraphNode node) { 23 25 return nodeColor; 24 26 } 25 27 28 @Override 26 29 public Color getSegmentColor(Segment segment) { 27 30 return segmentColor; -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/GraphViewPlugin.java
r32344 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.plugin; 2 3 … … 175 176 * @return ruleset read from a source as specified by preferences, null if the preferences 176 177 * don't specify a ruleset source 177 * @throws AccessRulesetSyntaxException178 * @throws IOException179 * @throws FileNotFoundException180 178 */ 181 179 private AccessRuleset getAccessRuleset() -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/data/JOSMDataSource.java
r32344 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.plugin.data; 2 3 … … 26 27 public class JOSMDataSource implements DataSource<Node, Way, Relation, RelationMember> { 27 28 29 @Override 28 30 public double getLat(Node node) { 29 31 return node.getCoor().lat(); 30 32 } 31 33 34 @Override 32 35 public double getLon(Node node) { 33 36 return node.getCoor().lon(); 34 37 } 35 38 39 @Override 36 40 public Iterable<RelationMember> getMembers(Relation relation) { 37 41 return relation.getMembers(); 38 42 } 39 43 44 @Override 40 45 public Iterable<Node> getNodes(Way way) { 41 46 return new FilteredOsmPrimitiveIterable<>(way.getNodes()); 42 47 } 43 48 49 @Override 44 50 public Iterable<Node> getNodes() { 45 51 return new FilteredOsmPrimitiveIterable<>(Main.getLayerManager().getEditDataSet().getNodes()); 46 52 } 47 53 54 @Override 48 55 public Iterable<Relation> getRelations() { 49 56 return new FilteredRelationIterable(Main.getLayerManager().getEditDataSet().getRelations()); 50 57 } 51 58 59 @Override 52 60 public Iterable<Way> getWays() { 53 61 return new FilteredOsmPrimitiveIterable<>(Main.getLayerManager().getEditDataSet().getWays()); 54 62 } 55 63 64 @Override 56 65 public TagGroup getTagsN(Node node) { 57 66 return getTags(node); 58 67 } 59 68 69 @Override 60 70 public TagGroup getTagsW(Way way) { 61 71 return getTags(way); 62 72 } 63 73 74 @Override 64 75 public TagGroup getTagsR(Relation relation) { 65 76 return getTags(relation); … … 74 85 } 75 86 87 @Override 76 88 public Object getMember(RelationMember member) { 77 89 return member.getMember(); 78 90 } 79 91 92 @Override 80 93 public String getRole(RelationMember member) { 81 94 return member.getRole(); 82 95 } 83 96 97 @Override 84 98 public boolean isNMember(RelationMember member) { 85 99 return member.getMember() instanceof Node; 86 100 } 87 101 102 @Override 88 103 public boolean isWMember(RelationMember member) { 89 104 return member.getMember() instanceof Way; 90 105 } 91 106 107 @Override 92 108 public boolean isRMember(RelationMember member) { 93 109 return member.getMember() instanceof Relation; … … 116 132 117 133 /** returns an iterator. The iterator does not support {@link Iterator#remove()}. */ 134 @Override 118 135 public Iterator<P> iterator() { 119 136 return new FilteredIterator(originalIterable.iterator()); … … 126 143 private P next; 127 144 128 publicFilteredIterator(Iterator<P> originalIterator) {145 FilteredIterator(Iterator<P> originalIterator) { 129 146 this.originalIterator = originalIterator; 130 147 updateNext(); 131 148 } 132 149 150 @Override 133 151 public boolean hasNext() { 134 152 return next != null; 135 153 } 136 154 155 @Override 137 156 public P next() { 138 157 if (next != null) { … … 145 164 } 146 165 166 @Override 147 167 public void remove() { 148 168 throw new UnsupportedOperationException(); … … 192 212 private final String role; 193 213 private final Object member; 194 public RelationMemberImpl(org.openstreetmap.josm.data.osm.RelationMember originalMember) { 214 215 RelationMemberImpl(org.openstreetmap.josm.data.osm.RelationMember originalMember) { 195 216 this.role = originalMember.getRole(); 196 217 this.member = originalMember.getMember(); 197 218 } 219 198 220 public String getRole() { 199 221 return role; 200 222 } 223 201 224 public Object getMember() { 202 225 return member; … … 206 229 private final Set<DataSourceObserver> observers = new HashSet<>(); 207 230 231 @Override 208 232 public void addObserver(DataSourceObserver observer) { 209 233 observers.add(observer); 210 234 } 211 235 236 @Override 212 237 public void deleteObserver(DataSourceObserver observer) { 213 238 observers.remove(observer); -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/data/JOSMTransitionStructure.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.plugin.data; 2 3 -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/dialogs/AccessParameterDialog.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.plugin.dialogs; 2 3 … … 39 40 public class AccessParameterDialog extends JDialog { 40 41 41 public staticinterface BookmarkAction {42 publicvoid execute(String name, PreferenceAccessParameters parameters);42 public interface BookmarkAction { 43 void execute(String name, PreferenceAccessParameters parameters); 43 44 } 44 45 … … 66 67 private final JTextField bookmarkNameTextField; 67 68 68 publicBookmarkNamePanel(String initialName) {69 BookmarkNamePanel(String initialName) { 69 70 super(); 70 71 this.setBorder(BorderFactory.createTitledBorder(tr("Bookmark name"))); … … 101 102 private final JTextField accessClassTextField; 102 103 103 publicAccessClassPanel(PreferenceAccessParameters initialParameters) {104 AccessClassPanel(PreferenceAccessParameters initialParameters) { 104 105 super(); 105 106 this.setBorder(BorderFactory.createTitledBorder(tr("Access class"))); … … 134 135 new EnumMap<>(AccessType.class); 135 136 136 publicAccessTypesPanel(PreferenceAccessParameters initialParameters) {137 AccessTypesPanel(PreferenceAccessParameters initialParameters) { 137 138 super(); 138 139 this.setBorder(BorderFactory.createTitledBorder(tr("Access types"))); … … 171 172 new HashMap<>(); 172 173 173 publicVehiclePropertiesPanel(PreferenceAccessParameters initialParameters) {174 VehiclePropertiesPanel(PreferenceAccessParameters initialParameters) { 174 175 super(); 175 176 this.setBorder(BorderFactory.createTitledBorder(tr("Vehicle properties"))); … … 220 221 private JTextField tracktypeTextField; 221 222 222 public RoadQualityPanel(PreferenceAccessParameters initialParameters) { 223 super(); 223 RoadQualityPanel(PreferenceAccessParameters initialParameters) { 224 224 this.setBorder(BorderFactory.createTitledBorder(tr("Road requirements"))); 225 226 225 227 226 this.setLayout(new GridLayout(4, 2)); … … 338 337 private class OkCancelPanel extends JPanel { 339 338 340 publicOkCancelPanel() {339 OkCancelPanel() { 341 340 342 341 new BoxLayout(this, BoxLayout.X_AXIS); 343 342 344 JButton okButton = new JButton(existingBookmark ?tr("Change bookmark"):tr("Create bookmark"));343 JButton okButton = new JButton(existingBookmark ? tr("Change bookmark") : tr("Create bookmark")); 345 344 okButton.addActionListener(new ActionListener() { 345 @Override 346 346 public void actionPerformed(ActionEvent e) { 347 347 String bookmarkName = bookmarkNamePanel.getBookmarkName(); … … 359 359 JButton cancelButton = new JButton(tr("Cancel")); 360 360 cancelButton.addActionListener(new ActionListener() { 361 @Override 361 362 public void actionPerformed(ActionEvent e) { 362 363 AccessParameterDialog.this.dispose(); … … 364 365 }); 365 366 this.add(cancelButton); 366 367 } 368 367 } 369 368 } 370 369 -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/dialogs/GraphViewDialog.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.plugin.dialogs; 2 3 … … 27 28 import javax.swing.JPanel; 28 29 30 import org.openstreetmap.josm.Main; 29 31 import org.openstreetmap.josm.gui.SideButton; 30 32 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; … … 68 70 69 71 super(tr("Graph View Dialog"), "graphview", 70 tr("Open the dialog for graph view configuration."), (Shortcut)null, HEIGHT); 72 tr("Open the dialog for graph view configuration."), (Shortcut) null, HEIGHT); 71 73 72 74 this.preferences = GraphViewPreferences.getInstance(); … … 154 156 createLayout(selectionPanel, true, Arrays.asList(new SideButton[] { 155 157 new SideButton(new AbstractAction(tr("Create/update graph")) { 158 @Override 156 159 public void actionPerformed(ActionEvent e) { 157 160 plugin.createGraphViewLayer(); … … 165 168 166 169 private final ActionListener rulesetActionListener = new ActionListener() { 170 @Override 167 171 public void actionPerformed(ActionEvent e) { 168 172 if (rulesetComboBox.getSelectedItem() != null) { … … 186 190 187 191 private final ActionListener bookmarkActionListener = new ActionListener() { 192 @Override 188 193 public void actionPerformed(ActionEvent e) { 189 String selectedBookmarkName = (String)bookmarkComboBox.getSelectedItem(); 194 String selectedBookmarkName = (String) bookmarkComboBox.getSelectedItem(); 190 195 if (selectedBookmarkName != null) { 191 196 preferences.setCurrentParameterBookmarkName(selectedBookmarkName); … … 197 202 198 203 private final ActionListener colorSchemeActionListener = new ActionListener() { 204 @Override 199 205 public void actionPerformed(ActionEvent e) { 200 206 assert availableColorSchemes.containsKey(colorSchemeComboBox.getSelectedItem()); 201 String colorSchemeLabel = (String)colorSchemeComboBox.getSelectedItem(); 207 String colorSchemeLabel = (String) colorSchemeComboBox.getSelectedItem(); 202 208 preferences.setCurrentColorScheme(availableColorSchemes.get(colorSchemeLabel)); 203 209 preferences.distributeChanges(); … … 206 212 }; 207 213 214 @Override 208 215 public void update(Observable observable, Object param) { 209 216 if (observable == preferences) { … … 223 230 224 231 rulesetComboBox.removeAllItems(); 225 for (int i =0; i < InternalRuleset.values().length; i++) {232 for (int i = 0; i < InternalRuleset.values().length; i++) { 226 233 InternalRuleset ruleset = InternalRuleset.values()[i]; 227 234 rulesetComboBox.addItem(ruleset.toString()); … … 249 256 } catch (IOException ioe) { 250 257 //don't add to rulesetFiles 258 Main.debug(ioe); 251 259 } 252 260 } … … 256 264 257 265 rulesetComboBox.removeAllItems(); 258 for (int i =0; i < rulesetFiles.size(); i++) {266 for (int i = 0; i < rulesetFiles.size(); i++) { 259 267 File rulesetFile = rulesetFiles.get(i); 260 268 rulesetComboBox.addItem(rulesetFile.getName()); -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/dialogs/GraphViewPreferenceEditor.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.plugin.dialogs; 2 3 … … 76 77 } 77 78 79 @Override 78 80 public void addGui(PreferenceTabbedPane gui) { 79 81 … … 203 205 private JPanel createVisualizationPanel() { 204 206 205 JPanel visualizationPanel = new JPanel(); 206 visualizationPanel.setBorder(BorderFactory.createTitledBorder(tr("Visualization"))); 207 visualizationPanel.setLayout(new BoxLayout(visualizationPanel, BoxLayout.Y_AXIS)); 208 209 separateDirectionsCheckBox = new JCheckBox(tr("Draw directions separately")); 210 separateDirectionsCheckBox.setSelected(GraphViewPreferences.getInstance().getSeparateDirections()); 211 visualizationPanel.add(separateDirectionsCheckBox); 212 213 { // create color chooser panel 214 215 JPanel colorPanel = new JPanel(); 216 colorPanel.setLayout(new GridLayout(3, 2)); 217 218 Color nodeColor = GraphViewPreferences.getInstance().getNodeColor(); 219 220 nodeColorButton = new JButton(tr("Node color")); 221 nodeColorButton.addActionListener(chooseNodeColorActionListener); 222 colorPanel.add(nodeColorButton); 223 nodeColorField = new JPanel(); 224 nodeColorField.setBackground(nodeColor); 225 colorPanel.add(nodeColorField); 226 227 Color segmentColor = GraphViewPreferences.getInstance().getSegmentColor(); 228 229 segmentColorButton = new JButton(tr("Arrow color")); 230 segmentColorButton.addActionListener(chooseSegmentColorActionListener); 231 colorPanel.add(segmentColorButton); 232 segmentColorField = new JPanel(); 233 segmentColorField.setBackground(segmentColor); 234 colorPanel.add(segmentColorField); 235 236 Color arrowheadFillColor = GraphViewPreferences.getInstance().getArrowheadFillColor(); 237 238 arrowheadFillColorButton = new JButton(tr("Arrowhead fill color")); 239 arrowheadFillColorButton.addActionListener(chooseArrowheadFillColorActionListener); 240 colorPanel.add(arrowheadFillColorButton); 241 arrowheadFillColorField = new JPanel(); 242 arrowheadFillColorField.setBackground(arrowheadFillColor); 243 colorPanel.add(arrowheadFillColorField); 244 245 visualizationPanel.add(colorPanel); 246 247 } 248 249 arrowheadPlacementSlider = new JSlider(0, 100); 250 arrowheadPlacementSlider.setToolTipText(tr("Arrowhead placement")); 251 arrowheadPlacementSlider.setMajorTickSpacing(10); 252 arrowheadPlacementSlider.setPaintTicks(true); 253 arrowheadPlacementSlider.setName("name"); 254 arrowheadPlacementSlider.setLabelTable(null); 255 arrowheadPlacementSlider.setValue((int)Math.round( 256 100 * GraphViewPreferences.getInstance().getArrowheadPlacement())); 257 arrowheadPlacementSlider.addChangeListener(arrowheadPlacementChangeListener); 258 visualizationPanel.add(arrowheadPlacementSlider); 259 260 arrowPreviewPanel = new ArrowPreviewPanel(); 261 visualizationPanel.add(arrowPreviewPanel); 262 263 return visualizationPanel; 264 } 265 207 JPanel visualizationPanel = new JPanel(); 208 visualizationPanel.setBorder(BorderFactory.createTitledBorder(tr("Visualization"))); 209 visualizationPanel.setLayout(new BoxLayout(visualizationPanel, BoxLayout.Y_AXIS)); 210 211 separateDirectionsCheckBox = new JCheckBox(tr("Draw directions separately")); 212 separateDirectionsCheckBox.setSelected(GraphViewPreferences.getInstance().getSeparateDirections()); 213 visualizationPanel.add(separateDirectionsCheckBox); 214 215 { // create color chooser panel 216 217 JPanel colorPanel = new JPanel(); 218 colorPanel.setLayout(new GridLayout(3, 2)); 219 220 Color nodeColor = GraphViewPreferences.getInstance().getNodeColor(); 221 222 nodeColorButton = new JButton(tr("Node color")); 223 nodeColorButton.addActionListener(chooseNodeColorActionListener); 224 colorPanel.add(nodeColorButton); 225 nodeColorField = new JPanel(); 226 nodeColorField.setBackground(nodeColor); 227 colorPanel.add(nodeColorField); 228 229 Color segmentColor = GraphViewPreferences.getInstance().getSegmentColor(); 230 231 segmentColorButton = new JButton(tr("Arrow color")); 232 segmentColorButton.addActionListener(chooseSegmentColorActionListener); 233 colorPanel.add(segmentColorButton); 234 segmentColorField = new JPanel(); 235 segmentColorField.setBackground(segmentColor); 236 colorPanel.add(segmentColorField); 237 238 Color arrowheadFillColor = GraphViewPreferences.getInstance().getArrowheadFillColor(); 239 240 arrowheadFillColorButton = new JButton(tr("Arrowhead fill color")); 241 arrowheadFillColorButton.addActionListener(chooseArrowheadFillColorActionListener); 242 colorPanel.add(arrowheadFillColorButton); 243 arrowheadFillColorField = new JPanel(); 244 arrowheadFillColorField.setBackground(arrowheadFillColor); 245 colorPanel.add(arrowheadFillColorField); 246 247 visualizationPanel.add(colorPanel); 248 249 } 250 251 arrowheadPlacementSlider = new JSlider(0, 100); 252 arrowheadPlacementSlider.setToolTipText(tr("Arrowhead placement")); 253 arrowheadPlacementSlider.setMajorTickSpacing(10); 254 arrowheadPlacementSlider.setPaintTicks(true); 255 arrowheadPlacementSlider.setName("name"); 256 arrowheadPlacementSlider.setLabelTable(null); 257 arrowheadPlacementSlider.setValue((int) Math.round( 258 100 * GraphViewPreferences.getInstance().getArrowheadPlacement())); 259 arrowheadPlacementSlider.addChangeListener(arrowheadPlacementChangeListener); 260 visualizationPanel.add(arrowheadPlacementSlider); 261 262 arrowPreviewPanel = new ArrowPreviewPanel(); 263 visualizationPanel.add(arrowPreviewPanel); 264 265 return visualizationPanel; 266 } 267 268 @Override 266 269 public boolean ok() { 267 270 … … 273 276 preferences.setParameterBookmarks(parameterBookmarks); 274 277 275 String selectedBookmarkName = (String)bookmarkComboBox.getSelectedItem(); 278 String selectedBookmarkName = (String) bookmarkComboBox.getSelectedItem(); 276 279 preferences.setCurrentParameterBookmarkName(selectedBookmarkName); 277 280 … … 283 286 284 287 preferences.setArrowheadPlacement( 285 288 arrowheadPlacementSlider.getValue() / 100f); 286 289 287 290 preferences.distributeChanges(); … … 291 294 292 295 private final ActionListener internalRulesetActionListener = new ActionListener() { 296 @Override 293 297 public void actionPerformed(ActionEvent e) { 294 298 updateRulesetPanel(); … … 297 301 298 302 private final ActionListener selectRulesetFolderActionListener = new ActionListener() { 303 @Override 299 304 public void actionPerformed(ActionEvent e) { 300 305 … … 319 324 320 325 private final ActionListener createVehicleActionListener = new ActionListener() { 326 @Override 321 327 public void actionPerformed(ActionEvent e) { 322 328 … … 331 337 defaultBookmarkParameters, 332 338 new BookmarkAction() { 339 @Override 333 340 public void execute(String name, PreferenceAccessParameters parameters) { 334 341 parameterBookmarks.put(name, parameters); … … 342 349 343 350 private final ActionListener editVehicleActionListener = new ActionListener() { 351 @Override 344 352 public void actionPerformed(ActionEvent e) { 345 353 if (bookmarkComboBox.getSelectedItem() != null) { 346 354 347 final String selectedBookmarkName = (String)bookmarkComboBox.getSelectedItem(); 355 final String selectedBookmarkName = (String) bookmarkComboBox.getSelectedItem(); 348 356 PreferenceAccessParameters parameters = 349 357 parameterBookmarks.get(selectedBookmarkName); … … 363 371 parameters, 364 372 new BookmarkAction() { 373 @Override 365 374 public void execute(String name, PreferenceAccessParameters parameters) { 366 375 parameterBookmarks.remove(selectedBookmarkName); … … 372 381 apd.setVisible(true); 373 382 } 374 375 383 } 376 384 }; 377 385 378 386 private final ActionListener deleteVehicleActionListener = new ActionListener() { 387 @Override 379 388 public void actionPerformed(ActionEvent e) { 380 389 if (bookmarkComboBox.getSelectedItem() != null) { 381 390 382 String selectedBookmarkName = (String)bookmarkComboBox.getSelectedItem(); 391 String selectedBookmarkName = (String) bookmarkComboBox.getSelectedItem(); 383 392 384 393 int userChoice = JOptionPane.showConfirmDialog( … … 392 401 updateVehiclePanel(null); 393 402 } 394 395 403 } 396 404 } … … 398 406 399 407 private final ActionListener restoreVehicleDefaultsActionListener = new ActionListener() { 408 @Override 400 409 public void actionPerformed(ActionEvent e) { 401 410 … … 418 427 419 428 private final ActionListener chooseNodeColorActionListener = new ActionListener() { 420 public void actionPerformed(ActionEvent e) { 421 422 Color selectedColor = JColorChooser.showDialog( 423 preferencePanel, tr("Choose node color"), nodeColorField.getBackground()); 424 425 if (selectedColor != null) { 426 nodeColorField.setBackground(selectedColor); 427 } 428 429 arrowPreviewPanel.repaint(); 429 @Override 430 public void actionPerformed(ActionEvent e) { 431 432 Color selectedColor = JColorChooser.showDialog( 433 preferencePanel, tr("Choose node color"), nodeColorField.getBackground()); 434 435 if (selectedColor != null) { 436 nodeColorField.setBackground(selectedColor); 437 } 438 439 arrowPreviewPanel.repaint(); 430 440 431 441 } … … 433 443 434 444 private final ActionListener chooseSegmentColorActionListener = new ActionListener() { 435 public void actionPerformed(ActionEvent e) { 436 437 Color selectedColor = JColorChooser.showDialog( 438 preferencePanel, tr("Choose arrow color"), segmentColorField.getBackground()); 439 440 if (selectedColor != null) { 441 segmentColorField.setBackground(selectedColor); 442 } 443 444 arrowPreviewPanel.repaint(); 445 @Override 446 public void actionPerformed(ActionEvent e) { 447 448 Color selectedColor = JColorChooser.showDialog( 449 preferencePanel, tr("Choose arrow color"), segmentColorField.getBackground()); 450 451 if (selectedColor != null) { 452 segmentColorField.setBackground(selectedColor); 453 } 454 455 arrowPreviewPanel.repaint(); 445 456 446 457 } … … 448 459 449 460 private final ActionListener chooseArrowheadFillColorActionListener = new ActionListener() { 450 public void actionPerformed(ActionEvent e) { 451 452 Color selectedColor = JColorChooser.showDialog( 453 preferencePanel, tr("Choose arrowhead fill color"), segmentColorField.getBackground()); 454 455 if (selectedColor != null) { 456 arrowheadFillColorField.setBackground(selectedColor); 457 } 458 459 arrowPreviewPanel.repaint(); 461 @Override 462 public void actionPerformed(ActionEvent e) { 463 464 Color selectedColor = JColorChooser.showDialog( 465 preferencePanel, tr("Choose arrowhead fill color"), segmentColorField.getBackground()); 466 467 if (selectedColor != null) { 468 arrowheadFillColorField.setBackground(selectedColor); 469 } 470 471 arrowPreviewPanel.repaint(); 460 472 461 473 } … … 463 475 464 476 private final ChangeListener arrowheadPlacementChangeListener = new ChangeListener() { 465 public void stateChanged(ChangeEvent e) { 466 arrowPreviewPanel.repaint(); 477 @Override 478 public void stateChanged(ChangeEvent e) { 479 arrowPreviewPanel.repaint(); 467 480 } 468 481 }; … … 493 506 editBookmarkButton.setEnabled(parameterBookmarks.size() > 0); 494 507 deleteBookmarkButton.setEnabled(parameterBookmarks.size() > 0); 495 496 508 } 497 509 498 510 private class ArrowPreviewPanel extends JPanel { 499 511 500 public ArrowPreviewPanel() { 501 setPreferredSize(new Dimension(100, 50)); 502 setBackground(Color.DARK_GRAY); 503 } 504 505 @Override 506 public void paint(Graphics g) { 507 508 super.paint(g); 509 510 Graphics2D g2D = (Graphics2D)g; 511 512 Point p1 = new Point(15, this.getHeight() / 2); 513 Point p2 = new Point(this.getWidth()-15, this.getHeight() / 2); 514 515 g2D.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); 516 g2D.setColor(segmentColorField.getBackground()); 517 g2D.draw(new Line2D.Float(p1.x, p1.y, p2.x, p2.y)); 518 519 GraphViewLayer.paintNode(g, p1, nodeColorField.getBackground()); 520 GraphViewLayer.paintNode(g, p2, nodeColorField.getBackground()); 521 522 GraphViewLayer.paintArrowhead(g2D, p1, p2, 523 arrowheadPlacementSlider.getValue() / 100.0, 524 segmentColorField.getBackground(), 525 arrowheadFillColorField.getBackground()); 526 527 } 528 529 } 530 512 ArrowPreviewPanel() { 513 setPreferredSize(new Dimension(100, 50)); 514 setBackground(Color.DARK_GRAY); 515 } 516 517 @Override 518 public void paint(Graphics g) { 519 520 super.paint(g); 521 522 Graphics2D g2D = (Graphics2D) g; 523 524 Point p1 = new Point(15, this.getHeight() / 2); 525 Point p2 = new Point(this.getWidth()-15, this.getHeight() / 2); 526 527 g2D.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); 528 g2D.setColor(segmentColorField.getBackground()); 529 g2D.draw(new Line2D.Float(p1.x, p1.y, p2.x, p2.y)); 530 531 GraphViewLayer.paintNode(g, p1, nodeColorField.getBackground()); 532 GraphViewLayer.paintNode(g, p2, nodeColorField.getBackground()); 533 534 GraphViewLayer.paintArrowhead(g2D, p1, p2, 535 arrowheadPlacementSlider.getValue() / 100.0, 536 segmentColorField.getBackground(), 537 arrowheadFillColorField.getBackground()); 538 } 539 } 531 540 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/layer/GraphViewLayer.java
r32488 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.plugin.layer; 2 3 … … 118 119 /** sets the arrowhead placement (relative offset from edge start) */ 119 120 public void setArrowheadPlacement(double arrowheadPlacement) { 120 121 assert arrowheadPlacement >= 0 && arrowheadPlacement <= 1; 121 122 this.arrowheadPlacement = arrowheadPlacement; 122 123 invalidate(); … … 149 150 } 150 151 151 152 152 public static void paintNode(final Graphics g, Point p, Color color) { 153 g.setColor(color); 153 154 g.fillOval(p.x - NODE_RADIUS, p.y - NODE_RADIUS, 2 * NODE_RADIUS, 2 * NODE_RADIUS); 154 155 } 155 156 156 157 private void paintGraphEdge(final GraphEdge e, final Graphics2D g2D, final MapView mv, 157 158 boolean drawLine, boolean drawDirectionIndicator) { 158 159 159 160 if (!CONNECT_ALL_NODE_PAIRS && GraphViewPreferences.getInstance().getSeparateDirections()) { … … 200 201 201 202 if (drawLine) { 202 203 g2D.draw(new Line2D.Float(p1.x, p1.y, p2.x, p2.y)); 203 204 } 204 205 … … 207 208 } else { 208 209 209 210 Color color = GraphViewPreferences.getInstance().getSegmentColor(); 210 211 g2D.setColor(color); 211 212 … … 214 215 215 216 if (drawLine) { 216 217 g2D.draw(new Line2D.Float(p1.x, p1.y, p2.x, p2.y)); 217 218 } 218 219 … … 232 233 if (drawDirectionIndicator) { 233 234 234 paintArrowhead(g2D, p1, p2, arrowheadPlacement, null, 235 GraphViewPreferences.getInstance().getArrowheadFillColor()); 236 237 } 238 239 } 240 } 241 242 public static void paintArrowhead(Graphics2D g2D, 243 Point p1, Point p2, Double arrowheadPlacement2, 244 Color casingColor, Color fillColor) { 245 246 Point pTip = new Point( 247 (int)(p1.x + arrowheadPlacement2 * (p2.x - p1.x)), 248 (int)(p1.y + arrowheadPlacement2 * (p2.y - p1.y))); 249 250 double angle = angleFromXAxis(p1, p2); // angle between x-axis and [p1,p2] 251 252 { //draw head shape 253 254 if (casingColor != null) { 255 g2D.setColor(casingColor); 256 } 257 258 Shape head = ARROW_HEAD; 259 head = AffineTransform.getRotateInstance(angle).createTransformedShape(head); 260 head = AffineTransform.getTranslateInstance(pTip.x, pTip.y).createTransformedShape(head); 261 g2D.fill(head); 262 } 263 264 { //draw head core shape 265 266 if (fillColor != null) { 267 g2D.setColor(fillColor); 268 } 269 270 Shape headCore = ARROW_HEAD_CORE; 271 headCore = AffineTransform.getRotateInstance(angle).createTransformedShape(headCore); 272 headCore = AffineTransform.getTranslateInstance(pTip.x, pTip.y).createTransformedShape(headCore); 273 g2D.fill(headCore); 274 } 275 276 } 235 paintArrowhead(g2D, p1, p2, arrowheadPlacement, null, 236 GraphViewPreferences.getInstance().getArrowheadFillColor()); 237 238 } 239 240 } 241 } 242 243 public static void paintArrowhead(Graphics2D g2D, 244 Point p1, Point p2, Double arrowheadPlacement2, 245 Color casingColor, Color fillColor) { 246 247 Point pTip = new Point( 248 (int) (p1.x + arrowheadPlacement2 * (p2.x - p1.x)), 249 (int) (p1.y + arrowheadPlacement2 * (p2.y - p1.y))); 250 251 double angle = angleFromXAxis(p1, p2); // angle between x-axis and [p1,p2] 252 253 { //draw head shape 254 255 if (casingColor != null) { 256 g2D.setColor(casingColor); 257 } 258 259 Shape head = ARROW_HEAD; 260 head = AffineTransform.getRotateInstance(angle).createTransformedShape(head); 261 head = AffineTransform.getTranslateInstance(pTip.x, pTip.y).createTransformedShape(head); 262 g2D.fill(head); 263 } 264 265 { //draw head core shape 266 267 if (fillColor != null) { 268 g2D.setColor(fillColor); 269 } 270 271 Shape headCore = ARROW_HEAD_CORE; 272 headCore = AffineTransform.getRotateInstance(angle).createTransformedShape(headCore); 273 headCore = AffineTransform.getTranslateInstance(pTip.x, pTip.y).createTransformedShape(headCore); 274 g2D.fill(headCore); 275 } 276 } 277 277 278 278 private Point getNodePoint(GraphNode node, MapView mv) { … … 311 311 return nodePoint; 312 312 } 313 313 314 private static Point getNodePoint(SegmentNode node, MapView mv) { 314 315 LatLonCoords coords = new LatLonCoords(node.getLat(), node.getLon()); 315 316 return getNodePoint(coords, mv); 316 317 } 318 317 319 private static Point getNodePoint(LatLonCoords coords, MapView mv) { 318 320 LatLon latLon = new LatLon(coords.getLat(), coords.getLon()); … … 333 335 final float vecY = p2.y - p1.y; 334 336 335 final float vecLength = (float)Math.sqrt(vecX*vecX + vecY*vecY); 337 final float vecLength = (float) Math.sqrt(vecX*vecX + vecY*vecY); 336 338 337 339 final float dotProductVecAxis = vecX; 338 340 339 float angle = (float)Math.acos(dotProductVecAxis / vecLength); 341 float angle = (float) Math.acos(dotProductVecAxis / vecLength); 340 342 341 343 if (p2.y < p1.y) { … … 361 363 362 364 for (GraphEdge e : wayGraph.getEdges()) { 363 365 //draw arrowheads last to make sure they end up on top 364 366 paintGraphEdge(e, g, mv, false, true); 365 367 } … … 404 406 } 405 407 408 @Override 406 409 public void update(WayGraph wayGraph) { 407 410 assert wayGraph == this.wayGraph; -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/layer/PreferencesColorScheme.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.plugin.layer; 2 3 … … 19 20 } 20 21 22 @Override 21 23 public Color getNodeColor(GraphNode node) { 22 24 return preferences.getNodeColor(); 23 25 } 24 26 27 @Override 25 28 public Color getSegmentColor(Segment segment) { 26 29 return preferences.getSegmentColor(); -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/preferences/GraphViewPreferenceDefaults.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.plugin.preferences; 2 3 -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/preferences/GraphViewPreferences.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.plugin.preferences; 2 3 import static org.openstreetmap.josm.tools.I18n.marktr;4 3 5 4 import static org.openstreetmap.josm.plugins.graphview.core.property.VehiclePropertyTypes.AXLELOAD; … … 13 12 import static org.openstreetmap.josm.plugins.graphview.core.property.VehiclePropertyTypes.WEIGHT; 14 13 import static org.openstreetmap.josm.plugins.graphview.core.property.VehiclePropertyTypes.WIDTH; 14 import static org.openstreetmap.josm.tools.I18n.marktr; 15 15 16 16 import java.awt.Color; … … 42 42 * because this class isn't registered as a preference listener. 43 43 */ 44 public class GraphViewPreferences extends Observable { 44 public final class GraphViewPreferences extends Observable { 45 45 46 46 private static GraphViewPreferences instance; … … 48 48 /** 49 49 * returns the single instance of GraphViewPreferences. 50 * @param ignoreSyntaxErrors51 * @return52 50 */ 53 51 public static GraphViewPreferences getInstance() { … … 78 76 return useInternalRulesets; 79 77 } 78 80 79 public synchronized void setUseInternalRulesets(boolean useInternalRulesets) { 81 80 this.useInternalRulesets = useInternalRulesets; … … 85 84 return rulesetFolder; 86 85 } 86 87 87 public synchronized void setRulesetFolder(File rulesetFolder) { 88 88 this.rulesetFolder = rulesetFolder; … … 92 92 return currentRulesetFile; 93 93 } 94 94 95 public synchronized void setCurrentRulesetFile(File currentRulesetFile) { 95 96 this.currentRulesetFile = currentRulesetFile; … … 99 100 return currentInternalRuleset; 100 101 } 102 101 103 public synchronized void setCurrentInternalRuleset(InternalRuleset internalRuleset) { 102 104 this.currentInternalRuleset = internalRuleset; … … 141 143 return Collections.unmodifiableMap(parameterBookmarks); 142 144 } 145 143 146 public synchronized void setParameterBookmarks( 144 147 Map<String, PreferenceAccessParameters> parameterBookmarks) { … … 152 155 return currentColorScheme; 153 156 } 157 154 158 public synchronized void setCurrentColorScheme(ColorScheme currentColorScheme) { 155 159 this.currentColorScheme = currentColorScheme; … … 159 163 return nodeColor; 160 164 } 165 161 166 public synchronized void setNodeColor(Color nodeColor) { 162 167 this.nodeColor = nodeColor; … … 166 171 return segmentColor; 167 172 } 173 168 174 public synchronized void setSegmentColor(Color segmentColor) { 169 175 this.segmentColor = segmentColor; … … 171 177 172 178 public synchronized Color getArrowheadFillColor() { 173 return arrowheadFillColor; 174 } 175 public synchronized void setArrowheadFillColor(Color arrowheadFillColor) { 176 this.arrowheadFillColor = arrowheadFillColor; 177 } 178 179 public synchronized boolean getSeparateDirections() { 179 return arrowheadFillColor; 180 } 181 182 public synchronized void setArrowheadFillColor(Color arrowheadFillColor) { 183 this.arrowheadFillColor = arrowheadFillColor; 184 } 185 186 public synchronized boolean getSeparateDirections() { 180 187 return separateDirections; 181 188 } 189 182 190 public synchronized void setSeparateDirections(boolean separateDirections) { 183 191 this.separateDirections = separateDirections; … … 185 193 186 194 public synchronized double getArrowheadPlacement() { 187 return arrowheadPlacement; 188 } 195 return arrowheadPlacement; 196 } 197 189 198 public synchronized void setArrowheadPlacement(double arrowheadPlacement) { 190 199 this.arrowheadPlacement = arrowheadPlacement; … … 315 324 arrowheadPlacement = Main.pref.getDouble("graphview.arrowheadPlacement", 1.0); 316 325 if (arrowheadPlacement < 0.0 || arrowheadPlacement >= 1.0) { 317 326 arrowheadPlacement = 1.0; 318 327 } 319 328 … … 326 335 private static final Map<VehiclePropertyType<?>, String> VEHICLE_PROPERTY_TYPE_NAME_MAP = 327 336 new HashMap<>(); 328 329 337 330 338 static { … … 381 389 } 382 390 383 if(stringBuilder.charAt(stringBuilder.length()-1) == ',') { 391 if (stringBuilder.charAt(stringBuilder.length()-1) == ',') { 384 392 stringBuilder.deleteCharAt(stringBuilder.length()-1); 385 393 } … … 398 406 } 399 407 400 if(stringBuilder.charAt(stringBuilder.length()-1) == ',') { 408 if (stringBuilder.charAt(stringBuilder.length()-1) == ',') { 401 409 stringBuilder.deleteCharAt(stringBuilder.length()-1); 402 410 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/preferences/InternalRuleset.java
r30550 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.plugin.preferences; 2 3 … … 7 8 8 9 private String resourceName; 9 private InternalRuleset(String resourceName) { 10 11 InternalRuleset(String resourceName) { 10 12 this.resourceName = resourceName; 11 13 } 14 12 15 public String getResourceName() { 13 16 return resourceName; -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/preferences/PreferenceAccessParameters.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.plugin.preferences; 2 3 … … 22 23 private final Map<VehiclePropertyType<?>, Object> vehiclePropertyValues; 23 24 25 @Override 24 26 public String getAccessClass() { 25 27 return accessClass; 26 28 } 27 29 30 @Override 28 31 public boolean getAccessTypeUsable(AccessType accessType) { 29 32 assert accessType != null; … … 31 34 } 32 35 36 @Override 33 37 public Collection<VehiclePropertyType<?>> getAvailableVehicleProperties() { 34 38 return vehiclePropertyValues.keySet(); … … 44 48 * {@link VehiclePropertyType#isValidValue(Object)} method. 45 49 */ 50 @Override 46 51 public <D> D getVehiclePropertyValue(VehiclePropertyType<D> vehicleProperty) { 47 52 assert vehicleProperty != null; 48 53 49 54 @SuppressWarnings("unchecked") 50 D value = (D)vehiclePropertyValues.get(vehicleProperty); 55 D value = (D) vehiclePropertyValues.get(vehicleProperty); 51 56 return value; 52 57 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/preferences/VehiclePropertyStringParser.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.plugin.preferences; 2 3 … … 9 10 import java.util.List; 10 11 12 import org.openstreetmap.josm.Main; 11 13 import org.openstreetmap.josm.plugins.graphview.core.property.VehiclePropertyType; 12 14 import org.openstreetmap.josm.plugins.graphview.core.property.VehiclePropertyTypes; … … 53 55 * returns the value represented by the propertyValueString 54 56 * 55 * @throws PropertyValueSyntaxException if the string has syntax errors that prevent parsing56 * @throws InvalidParameterException if an unknown property type was passed57 *58 57 * @param propertyType type of the property; != null 59 58 * @param propertyValueString string to parse; != null … … 61 60 * Guaranteed to be valid according to propertyType's 62 61 * {@link VehiclePropertyType#isValidValue(Object)} method. 62 * 63 * @throws PropertyValueSyntaxException if the string has syntax errors that prevent parsing 64 * @throws InvalidParameterException if an unknown property type was passed 63 65 */ 64 public static final<V> V parsePropertyValue(66 public static <V> V parsePropertyValue( 65 67 VehiclePropertyType<V> propertyType, String propertyValueString) 66 68 throws PropertyValueSyntaxException { … … 74 76 if (value != null && propertyType.isValidValue(value)) { 75 77 @SuppressWarnings("unchecked") //V must be float because of propertyType condition 76 V result = (V)value; 78 V result = (V) value; 77 79 return result; 78 80 } else { … … 87 89 if (value != null && propertyType.isValidValue(value)) { 88 90 @SuppressWarnings("unchecked") //V must be float because of propertyType condition 89 V result = (V)value; 91 V result = (V) value; 90 92 return result; 91 93 } else { … … 98 100 if (value != null && propertyType.isValidValue(value)) { 99 101 @SuppressWarnings("unchecked") //V must be float because of propertyType condition 100 V result = (V)value; 102 V result = (V) value; 101 103 return result; 102 104 } else { … … 110 112 if (value != null && propertyType.isValidValue(value)) { 111 113 @SuppressWarnings("unchecked") //V must be float because of propertyType condition 112 V result = (V)value; 114 V result = (V) value; 113 115 return result; 114 116 } else { … … 122 124 if (0 <= value && value <= 5) { 123 125 @SuppressWarnings("unchecked") //V must be int because of propertyType condition 124 V result = (V)(Integer)value; 126 V result = (V) (Integer) value; 125 127 return result; 126 128 } 127 } catch (NumberFormatException e) {} 129 } catch (NumberFormatException e) { 130 Main.trace(e); 131 } 128 132 129 133 throw new PropertyValueSyntaxException(ERROR_TRACKTYPE); … … 143 147 144 148 @SuppressWarnings("unchecked") //V must be Collection because of propertyType condition 145 V result = (V)surfaceBlacklist; 149 V result = (V) surfaceBlacklist; 146 150 return result; 147 151 -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/FullGraphCreationTest.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core; 2 3 … … 4 5 5 6 import java.util.Arrays; 7 import java.util.Collection; 6 8 import java.util.HashMap; 7 9 import java.util.Iterator; 8 10 import java.util.LinkedList; 11 import java.util.List; 9 12 import java.util.Map; 10 13 … … 49 52 50 53 private static final AccessRuleset TEST_RULESET = new AccessRuleset() { 54 @Override 51 55 public java.util.List<String> getAccessHierarchyAncestors(String transportMode) { 52 56 return Arrays.asList(transportMode); 53 57 } 54 public java.util.Collection<Tag> getBaseTags() { 58 59 @Override 60 public Collection<Tag> getBaseTags() { 55 61 return Arrays.asList(new Tag("highway", "test")); 56 62 } 57 public java.util.List<Implication> getImplications() { 63 64 @Override 65 public List<Implication> getImplications() { 58 66 return new LinkedList<>(); 59 67 } … … 174 182 while (iterator.hasNext()) { 175 183 iterator.next(); 176 size 184 size++; 177 185 } 178 186 return size; -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/TestDataSource.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core; 2 3 … … 12 13 import org.openstreetmap.josm.plugins.graphview.core.data.TagGroup; 13 14 14 public class TestDataSource implements DataSource<TestDataSource.TestNode, TestDataSource.TestWay, TestDataSource.TestRelation, TestDataSource.TestRelationMember> { 15 public class TestDataSource 16 implements DataSource<TestDataSource.TestNode, TestDataSource.TestWay, TestDataSource.TestRelation, TestDataSource.TestRelationMember> { 15 17 16 18 public static class TestPrimitive { 17 19 public final Map<String, String> tags = new HashMap<>(); 18 } ;20 } 19 21 20 22 public static class TestNode extends TestPrimitive { … … 24 26 this(0, 0); 25 27 } 28 26 29 public TestNode(double lat, double lon) { 27 30 this.lat = lat; 28 31 this.lon = lon; 29 32 } 33 30 34 @Override 31 35 public String toString() { … … 57 61 this.member = member; 58 62 } 63 59 64 public TestPrimitive getMember() { 60 65 return member; 61 66 } 67 62 68 public String getRole() { 63 69 return role; 64 70 } 71 65 72 @Override 66 73 public String toString() { … … 74 81 public final Collection<TestRelation> relations = new LinkedList<>(); 75 82 76 83 @Override 77 84 public double getLat(TestNode node) { 78 85 return node.lat; 79 86 } 87 88 @Override 80 89 public double getLon(TestNode node) { 81 90 return node.lon; 82 91 } 83 92 93 @Override 84 94 public Iterable<TestRelationMember> getMembers(TestRelation relation) { 85 95 return relation.members; 86 96 } 87 97 98 @Override 88 99 public Iterable<TestNode> getNodes() { 89 100 return nodes; 90 101 } 91 102 103 @Override 92 104 public Iterable<TestNode> getNodes(TestWay way) { 93 105 return way.nodes; 94 106 } 95 107 108 @Override 96 109 public Iterable<TestWay> getWays() { 97 110 return ways; 98 111 } 99 112 113 @Override 100 114 public Iterable<TestRelation> getRelations() { 101 115 return relations; 102 116 } 103 117 118 @Override 104 119 public TagGroup getTagsN(TestNode node) { 105 120 return new MapBasedTagGroup(node.tags); 106 121 } 107 122 123 @Override 108 124 public TagGroup getTagsW(TestWay way) { 109 125 return new MapBasedTagGroup(way.tags); 110 126 } 111 127 128 @Override 112 129 public TagGroup getTagsR(TestRelation relation) { 113 130 return new MapBasedTagGroup(relation.tags); 114 131 } 115 132 133 @Override 116 134 public Object getMember(TestRelationMember member) { 117 135 return member.getMember(); 118 136 } 119 137 138 @Override 120 139 public String getRole(TestRelationMember member) { 121 140 return member.getRole(); 122 141 } 123 142 143 @Override 124 144 public boolean isNMember(TestRelationMember member) { 125 145 return member.getMember() instanceof TestNode; 126 146 } 127 147 148 @Override 128 149 public boolean isWMember(TestRelationMember member) { 129 150 return member.getMember() instanceof TestWay; 130 151 } 131 152 153 @Override 132 154 public boolean isRMember(TestRelationMember member) { 133 155 return member.getMember() instanceof TestRelation; 134 156 } 135 157 158 @Override 136 159 public void addObserver(DataSourceObserver observer) { 137 160 // not needed for test 138 161 } 139 162 163 @Override 140 164 public void deleteObserver(DataSourceObserver observer) { 141 165 // not needed for test -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/access/AccessRulesetReaderTest.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.access; 2 3 -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/property/RoadInclineTest.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/property/RoadMaxspeedTest.java
r23189 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 7 8 8 9 private static void testMaxspeed(float expectedMaxspeed, String maxspeedString) { 9 testEvaluateBoth(new RoadMaxspeed(), 10 testEvaluateBoth(new RoadMaxspeed(), expectedMaxspeed, new Tag("maxspeed", maxspeedString)); 10 11 } 11 12 … … 29 30 testMaxspeed(24.14016f, "15 mph"); 30 31 } 31 32 32 } -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/property/RoadPropertyTest.java
r30560 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.property; 2 3 … … 8 9 9 10 @Ignore("no test") 10 abstract publicclass RoadPropertyTest {11 public abstract class RoadPropertyTest { 11 12 12 13 protected static <P> void testEvaluateW(RoadPropertyType<P> property, P expectedForward, P expectedBackward, Tag... wayTags) { -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/util/TagConditionLogicTest.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.util; 2 3 import static org.junit.Assert.assertFalse; -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/util/ValueStringParserTest.java
r30550 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.util; 2 3 … … 88 89 } 89 90 90 private static finalvoid assertClose(float expected, float actual) {91 private static void assertClose(float expected, float actual) { 91 92 if (Math.abs(expected - actual) > 0.001) { 92 93 throw new AssertionError("expected " + expected + ", was " + actual); -
applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/visualisation/FloatPropertyColorSchemeTest.java
r30737 r32620 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.graphview.core.visualisation; 2 3
Note:
See TracChangeset
for help on using the changeset viewer.