Changeset 4990 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2012-02-19T02:20:18+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/history/CoordinateInfoViewer.java
r3083 r4990 17 17 import org.openstreetmap.josm.data.osm.history.HistoryNode; 18 18 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive; 19 import org.openstreetmap.josm.gui.NavigatableComponent; 19 20 import org.openstreetmap.josm.tools.CheckParameterUtil; 20 21 … … 39 40 /** the info panel for coordinates for the node in role CURRENT_POINT_IN_TIME */ 40 41 private LatLonViewer currentLatLonViewer; 42 /** the info panel for distance between the two coordinates */ 43 private DistanceViewer distanceViewer; 41 44 42 45 protected void build() { … … 83 86 gc.anchor = GridBagConstraints.NORTHWEST; 84 87 add(currentLatLonViewer = new LatLonViewer(model, PointInTimeType.CURRENT_POINT_IN_TIME), gc); 88 89 // -------------------- 90 // the distance panel 91 gc.gridx = 0; 92 gc.gridy = 2; 93 gc.gridwidth = 2; 94 gc.fill = GridBagConstraints.HORIZONTAL; 95 gc.weightx = 1.0; 96 gc.weighty = 0.0; 97 add(distanceViewer = new DistanceViewer(model), gc); 85 98 } 86 99 … … 110 123 model.deleteObserver(referenceLatLonViewer); 111 124 } 125 if (distanceViewer != null) { 126 model.deleteObserver(distanceViewer); 127 } 112 128 } 113 129 … … 124 140 if (referenceLatLonViewer != null) { 125 141 model.addObserver(referenceLatLonViewer); 142 } 143 if (distanceViewer != null) { 144 model.addObserver(distanceViewer); 126 145 } 127 146 } … … 261 280 } 262 281 } 282 283 private static class DistanceViewer extends LatLonViewer { 284 285 private JLabel lblDistance; 286 287 public DistanceViewer(HistoryBrowserModel model) { 288 super(model, PointInTimeType.REFERENCE_POINT_IN_TIME); 289 } 290 291 protected void build() { 292 setLayout(new GridBagLayout()); 293 setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY)); 294 GridBagConstraints gc = new GridBagConstraints(); 295 296 // -------- 297 gc.gridx = 0; 298 gc.gridy = 0; 299 gc.fill = GridBagConstraints.NONE; 300 gc.weightx = 0.0; 301 gc.insets = new Insets(5,5,5,5); 302 gc.anchor = GridBagConstraints.NORTHWEST; 303 add(new JLabel(tr("Distance: ")), gc); 304 305 // -------- 306 gc.gridx = 1; 307 gc.gridy = 0; 308 gc.fill = GridBagConstraints.HORIZONTAL; 309 gc.weightx = 1.0; 310 add(lblDistance = new JLabel(), gc); 311 lblDistance.setBackground(Color.WHITE); 312 lblDistance.setOpaque(true); 313 lblDistance.setBorder(BorderFactory.createEmptyBorder(2,2,2,2)); 314 } 315 316 protected void refresh() { 317 HistoryOsmPrimitive p = getPrimitive(); 318 HistoryOsmPrimitive opposite = getOppositePrimitive(); 319 if (p == null || ! ( p instanceof HistoryNode)) return; 320 if (opposite == null || ! (opposite instanceof HistoryNode)) return; 321 HistoryNode node = (HistoryNode) p; 322 HistoryNode oppositeNode = (HistoryNode) opposite; 323 324 // update distance 325 // 326 double distance = node.getCoords().greatCircleDistance(oppositeNode.getCoords()); 327 if (distance > 0) { 328 lblDistance.setBackground(BGCOLOR_DIFFERENCE); 329 } else { 330 lblDistance.setBackground(Color.WHITE); 331 } 332 lblDistance.setText(NavigatableComponent.getDistText(distance)); 333 } 334 } 263 335 }
Note:
See TracChangeset
for help on using the changeset viewer.