Changeset 23749 in osm for applications/editors/josm/plugins/ElevationProfile
- Timestamp:
- 2010-10-22T20:21:39+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java
r23736 r23749 20 20 import java.awt.Font; 21 21 import java.awt.GridBagConstraints; 22 import java.awt.GridBagLayout; 22 import java.awt.GridLayout; 23 import java.awt.Insets; 23 24 import java.awt.event.ActionEvent; 24 25 import java.awt.event.ActionListener; … … 122 123 super(name, iconName, tooltip, shortcut, preferredHeight, defShow); 123 124 124 JPanel dataPanel = new JPanel(new GridBagLayout()); 125 GridBagConstraints c = new GridBagConstraints(); 126 c.fill = GridBagConstraints.HORIZONTAL; 127 c.weightx = 0.5; 128 129 // first row 130 c.gridx = 0; 131 c.gridy = 0; 132 dataPanel.add(new JLabel(tr("")), c); // filler 133 c.gridx = 1; 134 c.gridy = 0; 135 dataPanel.add(new JLabel(tr("Min")), c); 136 c.gridx = 2; 137 c.gridy = 0; 138 dataPanel.add(new JLabel(tr("Avrg")), c); 139 c.gridx = 3; 140 c.gridy = 0; 141 dataPanel.add(new JLabel(tr("Max")), c); 142 c.gridx = 4; 143 c.gridy = 0; 144 dataPanel.add(new JLabel(tr("Dist")), c); 145 c.gridx = 5; 146 c.gridy = 0; 147 dataPanel.add(new JLabel(tr("Gain")), c); 148 c.gridx = 6; 149 c.gridy = 0; 150 dataPanel.add(new JLabel(tr("Time")), c); 125 JPanel dataPanel = new JPanel(); 126 GridLayout gridLayout = new GridLayout(3, 6); 127 dataPanel.setLayout(gridLayout); 128 129 // first row: Headlines with bold font 130 JLabel lbl = new JLabel(tr("Min")); 131 lbl.setFont(getFont().deriveFont(Font.BOLD)); 132 dataPanel.add(lbl); 133 lbl = new JLabel(tr("Avrg")); 134 lbl.setFont(getFont().deriveFont(Font.BOLD)); 135 dataPanel.add(lbl); 136 lbl = new JLabel(tr("Max")); 137 lbl.setFont(getFont().deriveFont(Font.BOLD)); 138 dataPanel.add(lbl); 139 lbl = new JLabel(tr("Dist")); 140 lbl.setFont(getFont().deriveFont(Font.BOLD)); 141 dataPanel.add(lbl); 142 lbl = new JLabel(tr("Gain")); 143 lbl.setFont(getFont().deriveFont(Font.BOLD)); 144 dataPanel.add(lbl); 145 lbl = new JLabel(tr("Time")); 146 lbl.setFont(getFont().deriveFont(Font.BOLD)); 147 dataPanel.add(lbl); 151 148 152 149 // second row 153 c.gridx = 0;154 c.gridy = 1;155 dataPanel.add(new JLabel(tr("Ele")), c);156 c.gridx = 1;157 c.gridy = 1;158 150 minHeightLabel = new JLabel("0 m"); 159 dataPanel.add(minHeightLabel, c); 160 161 c.gridx = 2; 162 c.gridy = 1; 151 dataPanel.add(minHeightLabel); 163 152 avrgHeightLabel = new JLabel("0 m"); 164 dataPanel.add(avrgHeightLabel, c); 165 166 c.gridx = 3; 167 c.gridy = 1; 153 dataPanel.add(avrgHeightLabel); 168 154 maxHeightLabel = new JLabel("0 m"); 169 dataPanel.add(maxHeightLabel, c); 170 171 c.gridx = 4; 172 c.gridy = 1; 155 dataPanel.add(maxHeightLabel); 173 156 distLabel = new JLabel("0 km"); 174 dataPanel.add(distLabel, c); 175 176 c.gridx = 5; 177 c.gridy = 1; 157 dataPanel.add(distLabel); 178 158 elevationGainLabel = new JLabel("0 m"); 179 dataPanel.add(elevationGainLabel, c); 180 181 c.gridx = 6; 182 c.gridy = 1; 159 dataPanel.add(elevationGainLabel); 183 160 totalTimeLabel = new JLabel("0"); 184 dataPanel.add(totalTimeLabel, c); 185 186 // sep 187 c.gridx = 0; 188 c.gridy = 2; 189 c.gridwidth = 7; 190 dataPanel.add(new JSeparator(), c); 161 dataPanel.add(totalTimeLabel); 191 162 192 163 // Geoid 193 JLabel geoidHead = new JLabel(tr("Geoid Correction"));164 JLabel geoidHead = new JLabel(tr("Geoid")); 194 165 geoidHead.setFont(getFont().deriveFont(Font.BOLD)); 195 c.gridx = 0; 196 c.gridy = 3; 197 c.gridwidth = 5; 198 dataPanel.add(geoidHead, c); 166 dataPanel.add(geoidHead); 199 167 200 168 geoidNone = new JRadioButton(tr("None")); … … 240 208 grp.add(geoidFixed); 241 209 242 c.gridwidth = 1; 243 c.gridx = 0; 244 c.gridy = 4; 245 dataPanel.add(geoidNone, c); 246 c.gridx = 1; 247 c.gridy = 4; 248 dataPanel.add(geoidAuto, c); 249 c.gridx = 2; 250 c.gridy = 4; 251 dataPanel.add(geoidFixed, c); 252 c.gridx = 3; 253 c.gridy = 4; 254 dataPanel.add(geoidFixedValue, c); 255 c.gridx = 4; 256 c.gridy = 4; 257 dataPanel.add(new JLabel(" m"), c); 210 dataPanel.add(geoidNone); 211 dataPanel.add(geoidAuto); 212 dataPanel.add(geoidFixed); 213 dataPanel.add(geoidFixedValue); 214 dataPanel.add(new JLabel(" m")); 258 215 259 216 add(dataPanel, BorderLayout.PAGE_END); … … 270 227 geoidFixed.setSelected(true); 271 228 } 272 } 273 229 230 dock(); 231 } 232 233 /** 234 * Gets the elevation model instance. 235 * @return 236 */ 274 237 public IElevationProfile getModel() { 275 238 return profile; 276 239 } 277 240 241 /** 242 * Sets the elevation model instance. 243 * @param model The new model. 244 */ 278 245 public void setModel(IElevationProfile model) { 279 246 if (this.profile != model) { … … 287 254 } 288 255 256 /** 257 * Gets the associated layer instance of the elevation profile. 258 * @return 259 */ 289 260 public ElevationProfileLayer getProfileLayer() { 290 261 return profileLayer; 291 262 } 292 263 264 /** 265 * Sets the associated layer instance of the elevation profile. 266 * @param profileLayer The elevation profile layer. 267 */ 293 268 public void setProfileLayer(ElevationProfileLayer profileLayer) { 294 269 if (this.profileLayer != profileLayer) { … … 302 277 303 278 /** 304 * Refreshes the dialog when model data have changed. 305 * 306 * @param model 279 * Refreshes the dialog when model data have changed and notifies clients 280 * that the model has changed. 307 281 */ 308 282 private void updateView() { 309 283 // TODO: Offer also ft here 310 284 if (profile.hasElevationData()) { 311 long diff = profile.getTimeDifference();312 long minutes = diff / (1000 * 60);313 long hours = minutes / 60;314 minutes = minutes % 60;315 316 285 minHeightLabel.setText(String.format("%d m", profile.getMinHeight())); 317 286 maxHeightLabel.setText(String.format("%d m", profile.getMaxHeight())); 318 avrgHeightLabel.setText(String.format("%d m", profile 319 .getAverageHeight())); 287 avrgHeightLabel.setText(String.format("%d m", profile.getAverageHeight())); 320 288 elevationGainLabel.setText(String.format("%d m", profile 321 289 .getGain())); 322 totalTimeLabel.setText(String.format("%d:%d h", hours, minutes)); 323 distLabel.setText(String.format("%5.2f km", profile 324 .getDistance())); 325 } else { 290 } else { // no elevation data 326 291 minHeightLabel.setText("-"); 327 292 maxHeightLabel.setText("-"); 328 293 avrgHeightLabel.setText("-"); 329 294 elevationGainLabel.setText("-"); 330 totalTimeLabel.setText("-"); 331 distLabel.setText("-"); 332 } 295 } 296 297 // compute values for time and distance 298 long diff = profile.getTimeDifference(); 299 long minutes = diff / (1000 * 60); 300 long hours = minutes / 60; 301 minutes = minutes % 60; 302 303 double dist = profile.getDistance(); 304 305 totalTimeLabel.setText(String.format("%d:%d h", hours, minutes)); 306 distLabel.setText(String.format("%5.2f km", dist)); 333 307 334 308 fireModelChanged();
Note:
See TracChangeset
for help on using the changeset viewer.