Changeset 18130 in osm
- Timestamp:
- 2009-10-13T23:30:54+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/graph/ConnectorEvaluationGroup.java
r16520 r18130 14 14 * {@link JunctionEvaluationGroup}s. 15 15 */ 16 class ConnectorEvaluationGroup extends EvaluationGroup {16 public class ConnectorEvaluationGroup extends EvaluationGroup { 17 17 18 18 private final Set<Segment> segments; -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/graph/GraphEdge.java
r16520 r18130 1 1 package org.openstreetmap.josm.plugins.graphview.core.graph; 2 2 3 import java.util.Collection; 3 4 import java.util.List; 4 5 6 import org.openstreetmap.josm.plugins.graphview.core.property.GraphEdgePropertyType; 5 7 import org.openstreetmap.josm.plugins.graphview.core.transition.Segment; 6 8 … … 16 18 GraphNode getTargetNode(); 17 19 18 /** returns the series of segments that are represented by this edge; != null */ 19 List<Segment> getSegments(); 20 20 /** returns all property types for which property values are available */ 21 Collection<GraphEdgePropertyType<?>> getAvailableProperties(); 22 23 /** TODO */ 24 <V> V getPropertyValue(GraphEdgePropertyType<V> property); 25 21 26 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/graph/JunctionEvaluationGroup.java
r16520 r18130 13 13 * group of nodes that will be evaluated independently from other groups 14 14 */ 15 class JunctionEvaluationGroup extends EvaluationGroup {15 public class JunctionEvaluationGroup extends EvaluationGroup { 16 16 17 17 private final Set<SegmentNode> segmentNodes; -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/graph/TSBasedWayGraph.java
r16520 r18130 10 10 import java.util.Set; 11 11 12 import org.openstreetmap.josm.plugins.graphview.core.property.GraphEdgePropertyType; 13 import org.openstreetmap.josm.plugins.graphview.core.property.GraphEdgeSegments; 12 14 import org.openstreetmap.josm.plugins.graphview.core.transition.Restriction; 13 15 import org.openstreetmap.josm.plugins.graphview.core.transition.Segment; … … 21 23 public class TSBasedWayGraph implements WayGraph, TransitionStructureObserver { 22 24 25 private static final GraphEdgePropertyType<?>[] PROPERTY_TYPES = 26 {GraphEdgeSegments.PROPERTY}; 27 //TODO: -> parameter 28 23 29 private static class GraphNodeImpl implements GraphNode { 24 30 private final SegmentNode node; … … 59 65 60 66 private static class GraphEdgeImpl implements GraphEdge { 67 61 68 private final GraphNode startNode; 62 69 private final GraphNode targetNode; 63 private final List<Segment> segments; 64 public GraphEdgeImpl(GraphNode startNode, GraphNode targetNode, List<Segment> segments) { 65 assert startNode != null && targetNode != null && segments != null; 70 private final Map<GraphEdgePropertyType<?>, Object> properties; 71 72 public GraphEdgeImpl(GraphNode startNode, GraphNode targetNode, 73 Map<GraphEdgePropertyType<?>, Object> properties) { 74 assert startNode != null && targetNode != null && properties != null; 66 75 this.startNode = startNode; 67 76 this.targetNode = targetNode; 68 this.segments = segments; 69 } 77 this.properties = properties; 78 } 79 70 80 public GraphNode getStartNode() { 71 81 return startNode; … … 74 84 return targetNode; 75 85 } 76 public List<Segment> getSegments() { 77 return segments; 78 } 86 87 public Collection<GraphEdgePropertyType<?>> getAvailableProperties() { 88 return properties.keySet(); 89 } 90 public <V> V getPropertyValue(GraphEdgePropertyType<V> property) { 91 V result = (V) properties.get(property); 92 return result; 93 } 94 79 95 @Override 80 96 public String toString() { 81 97 return "(" + startNode + "-->" + targetNode + ")"; 82 98 } 99 83 100 }; 84 101 … … 285 302 segment2GNMap_approaching.get(inboundSegment), 286 303 segment2GNMap_leaving.get(outboundSegment), 287 segmentSequence); 304 segmentSequence, 305 junctionEG); 288 306 289 307 } … … 323 341 startGraphNode, 324 342 targetGraphNode, 325 segmentSequence); 343 segmentSequence, 344 connectorEG); 326 345 } 327 346 … … 338 357 } 339 358 } 359 360 } 361 362 private void createGraphEdge( 363 GraphNodeImpl startNode, GraphNodeImpl targetNode, 364 List<Segment> segments, ConnectorEvaluationGroup evaluationGroup) { 365 366 Map<GraphEdgePropertyType<?>, Object> properties = 367 new HashMap<GraphEdgePropertyType<?>, Object>(); //TODO: replace HashMap with List-based solution 368 369 for (GraphEdgePropertyType<?> propertyType : PROPERTY_TYPES) { 370 Object value = propertyType.evaluate(evaluationGroup, segments, transitionStructure); 371 properties.put(propertyType, value); 372 } 373 374 createGraphEdge(startNode, targetNode, properties); 375 376 } 377 378 private void createGraphEdge( 379 GraphNodeImpl startNode, GraphNodeImpl targetNode, 380 List<Segment> segments, JunctionEvaluationGroup evaluationGroup) { 381 382 Map<GraphEdgePropertyType<?>, Object> properties = 383 new HashMap<GraphEdgePropertyType<?>, Object>(); //TODO: replace HashMap with List-based solution 384 385 for (GraphEdgePropertyType<?> propertyType : PROPERTY_TYPES) { 386 Object value = propertyType.evaluate(evaluationGroup, segments, transitionStructure); 387 properties.put(propertyType, value); 388 } 389 390 createGraphEdge(startNode, targetNode, properties); 340 391 341 392 } … … 345 396 * adds it to its nodes' collections and {@link #edges} collection. 346 397 */ 347 private void createGraphEdge( 348 GraphNodeImpl startNode, GraphNodeImpl targetNode, List<Segment> segments) {349 350 GraphEdge newEdge = new GraphEdgeImpl(startNode, targetNode, segments);398 private void createGraphEdge(GraphNodeImpl startNode, GraphNodeImpl targetNode, 399 Map<GraphEdgePropertyType<?>, Object> properties) { 400 401 GraphEdge newEdge = new GraphEdgeImpl(startNode, targetNode, properties); 351 402 352 403 startNode.addOutgoingEdge(newEdge); … … 356 407 357 408 } 358 409 359 410 private static boolean isConnectedWithExactly2Nodes(SegmentNode node) { 360 411 -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/core/visualisation/FloatPropertyColorScheme.java
r16520 r18130 12 12 import org.openstreetmap.josm.plugins.graphview.core.graph.GraphEdge; 13 13 import org.openstreetmap.josm.plugins.graphview.core.graph.GraphNode; 14 import org.openstreetmap.josm.plugins.graphview.core.property.GraphEdgeSegments; 14 15 import org.openstreetmap.josm.plugins.graphview.core.property.RoadPropertyType; 15 16 import org.openstreetmap.josm.plugins.graphview.core.transition.Segment; … … 66 67 List<Color> segmentColors = new ArrayList<Color>(); 67 68 69 70 68 71 for (GraphEdge edge : node.getInboundEdges()) { 69 if (edge.getSegments().size() > 0) { 70 Segment firstSegment = edge.getSegments().get(0); 72 List<Segment> edgeSegments = edge.getPropertyValue(GraphEdgeSegments.PROPERTY); 73 if (edgeSegments.size() > 0) { 74 Segment firstSegment = edgeSegments.get(0); 71 75 segmentColors.add(getSegmentColor(firstSegment)); 72 76 } 73 77 } 74 78 for (GraphEdge edge : node.getOutboundEdges()) { 75 if (edge.getSegments().size() > 0) { 76 Segment lastSegment = edge.getSegments().get(edge.getSegments().size()-1); 79 List<Segment> edgeSegments = edge.getPropertyValue(GraphEdgeSegments.PROPERTY); 80 if (edgeSegments.size() > 0) { 81 Segment lastSegment = edgeSegments.get(edgeSegments.size()-1); 77 82 segmentColors.add(getSegmentColor(lastSegment)); 78 83 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/layer/GraphViewLayer.java
r16836 r18130 11 11 import java.awt.geom.AffineTransform; 12 12 import java.awt.geom.Line2D; 13 import java.util.List; 13 14 14 15 import javax.swing.Icon; … … 30 31 import org.openstreetmap.josm.plugins.graphview.core.graph.WayGraph; 31 32 import org.openstreetmap.josm.plugins.graphview.core.graph.WayGraphObserver; 33 import org.openstreetmap.josm.plugins.graphview.core.property.GraphEdgeSegments; 32 34 import org.openstreetmap.josm.plugins.graphview.core.transition.Segment; 33 35 import org.openstreetmap.josm.plugins.graphview.core.transition.SegmentNode; … … 145 147 g2D.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); 146 148 147 if (e.getSegments().size() > 0) { 148 149 Segment firstSegment = e.getSegments().get(0); 150 Segment lastSegment = e.getSegments().get(e.getSegments().size() - 1); 149 List<Segment> edgeSegments = e.getPropertyValue(GraphEdgeSegments.PROPERTY); 150 151 if (edgeSegments.size() > 0) { 152 153 Segment firstSegment = edgeSegments.get(0); 154 Segment lastSegment = edgeSegments.get(edgeSegments.size() - 1); 151 155 152 156 //draw segments 153 157 154 for (Segment segment : e .getSegments()) {158 for (Segment segment : edgeSegments) { 155 159 156 160 Color color = Color.WHITE; … … 191 195 Point p2 = getNodePoint(e.getTargetNode(), mv); 192 196 193 if (e .getSegments().size() > 0) {194 Segment lastSegment = e .getSegments().get(e.getSegments().size() - 1);197 if (edgeSegments.size() > 0) { 198 Segment lastSegment = edgeSegments.get(edgeSegments.size() - 1); 195 199 p1 = getNodePoint(lastSegment.getNode1(), mv); 196 200 }
Note:
See TracChangeset
for help on using the changeset viewer.