Changeset 9 in josm for src/org/openstreetmap/josm/gui/MapView.java
- Timestamp:
- 2005-10-04T00:09:32+02:00 (21 years ago)
- File:
-
- 1 edited
-
src/org/openstreetmap/josm/gui/MapView.java (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/gui/MapView.java
r8 r9 84 84 85 85 /** 86 * Construct a MapView and attach it to a frame.86 * Construct a MapView. 87 87 */ 88 88 public MapView(DataSet dataSet) { 89 89 this.dataSet = dataSet; 90 90 addComponentListener(this); 91 91 92 92 // initialize the movement listener 93 93 new MapMover(this); 94 94 95 95 // initialize the projection 96 96 setProjection(Main.pref.projection.clone()); 97 98 // initialize the engine 97 98 // initialize the drawing engine 99 99 engine = new SimpleEngine(this); 100 100 } … … 222 222 } 223 223 224 224 225 /** 225 226 * Zoom to the given coordinate. … … 247 248 248 249 /** 250 * Draw the component. 251 */ 252 @Override 253 public void paint(Graphics g) { 254 engine.init(g); 255 engine.drawBackground(getPoint(0,0,true), getPoint(getWidth(), getHeight(), true)); 256 257 for (Track t : dataSet.tracks()) 258 engine.drawTrack(t); 259 for (LineSegment ls : dataSet.pendingLineSegments()) 260 engine.drawPendingLineSegment(ls); 261 for (Node n : dataSet.nodes) 262 engine.drawNode(n); 263 } 264 265 /** 266 * Notify from the projection, that something has changed. 267 * @param e 268 */ 269 public void stateChanged(ChangeEvent e) { 270 projection.init(dataSet); 271 recalculateCenterScale(); 272 } 273 274 /** 275 * Set a new projection method. This call is not cheap, as it will 276 * transform the whole underlying dataSet and repaint itself. 277 * 278 * @param projection The new projection method to set. 279 */ 280 public void setProjection(Projection projection) { 281 if (projection == this.projection) 282 return; 283 284 Projection oldProjection = this.projection; 285 286 if (this.projection != null) 287 this.projection.removeChangeListener(this); 288 this.projection = projection; 289 projection.addChangeListener(this); 290 291 stateChanged(new ChangeEvent(this)); 292 firePropertyChange("projection", oldProjection, projection); 293 } 294 295 /** 296 * Return the projection method for this map view. 297 * @return The projection method. 298 */ 299 public Projection getProjection() { 300 return projection; 301 } 302 303 /** 249 304 * Return the current scale value. 250 305 * @return The scale value currently used in display … … 254 309 } 255 310 311 /** 312 * @return Returns the autoScale. 313 */ 314 public boolean isAutoScale() { 315 return autoScale; 316 } 317 318 /** 319 * @param autoScale The autoScale to set. 320 */ 321 public void setAutoScale(boolean autoScale) { 322 if (this.autoScale != autoScale) { 323 this.autoScale = autoScale; 324 firePropertyChange("autoScale", !autoScale, autoScale); 325 } 326 } 327 /** 328 * @return Returns the center point. A copy is returned, so users cannot 329 * change the center by accessing the return value. Use zoomTo instead. 330 */ 331 public GeoPoint getCenter() { 332 return center.clone(); 333 } 334 335 336 256 337 /** 257 338 * Set the new dimension to the projection class. Also adjust the components … … 285 366 scale = Math.max(scaleX, scaleY); // minimum scale to see all of the screen 286 367 } 287 368 288 369 firePropertyChange("center", oldCenter, center); 289 370 if (oldAutoScale != autoScale) … … 303 384 304 385 /** 305 * Draw the component.306 */307 @Override308 public void paint(Graphics g) {309 engine.init(g);310 engine.drawBackground(getPoint(0,0,true), getPoint(getWidth(), getHeight(), true));311 312 for (Track t : dataSet.tracks())313 engine.drawTrack(t);314 for (LineSegment ls : dataSet.pendingLineSegments())315 engine.drawPendingLineSegment(ls);316 for (Node n : dataSet.nodes)317 engine.drawNode(n);318 }319 320 /**321 * Notify from the projection, that something has changed.322 * @param e323 */324 public void stateChanged(ChangeEvent e) {325 projection.init(dataSet);326 recalculateCenterScale();327 }328 329 /**330 * Set a new projection method. This call is not cheap, as it will331 * transform the whole underlying dataSet and repaint itself.332 *333 * @param projection The new projection method to set.334 */335 public void setProjection(Projection projection) {336 if (projection == this.projection)337 return;338 339 Projection oldProjection = this.projection;340 341 if (this.projection != null)342 this.projection.removeChangeListener(this);343 this.projection = projection;344 projection.addChangeListener(this);345 346 stateChanged(new ChangeEvent(this));347 firePropertyChange("projection", oldProjection, projection);348 }349 350 /**351 * Return the projection method for this map view.352 * @return The projection method.353 */354 public Projection getProjection() {355 return projection;356 }357 358 /**359 * @return Returns the autoScale.360 */361 public boolean isAutoScale() {362 return autoScale;363 }364 365 /**366 * @param autoScale The autoScale to set.367 */368 public void setAutoScale(boolean autoScale) {369 if (this.autoScale != autoScale) {370 this.autoScale = autoScale;371 firePropertyChange("autoScale", !autoScale, autoScale);372 }373 }374 /**375 * @return Returns the center point. A copy is returned, so users cannot376 * change the center by accessing the return value. Use zoomTo instead.377 */378 public GeoPoint getCenter() {379 return center.clone();380 }381 382 /**383 386 * Does nothing. Just to satisfy ComponentListener. 384 387 */
Note:
See TracChangeset
for help on using the changeset viewer.
