Changeset 16894 in josm for trunk/src/org/openstreetmap/josm/gui/MapScaler.java
- Timestamp:
- 2020-08-15T00:15:18+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapScaler.java
r12987 r16894 9 9 import java.awt.Graphics; 10 10 import java.awt.geom.Rectangle2D; 11 import java.util.function.DoubleSupplier; 12 import java.util.function.Supplier; 11 13 12 14 import javax.accessibility.Accessible; … … 24 26 public class MapScaler extends JComponent implements Helpful, Accessible { 25 27 26 private final NavigatableComponent mv; 28 private final DoubleSupplier getDist100Pixel; 29 private final Supplier<Color> colorSupplier; 27 30 28 31 private static final int PADDING_LEFT = 5; … … 36 39 */ 37 40 public MapScaler(NavigatableComponent mv) { 38 this.mv = mv; 41 this(() -> mv.getDist100Pixel(true), MapScaler::getColor); 42 } 43 44 /** 45 * Constructs a new {@code MapScaler}. 46 * @param getDist100Pixel supplier for distance in meter that correspond to 100 px on screen 47 * @param colorSupplier supplier for color 48 */ 49 public MapScaler(DoubleSupplier getDist100Pixel, Supplier<Color> colorSupplier) { 50 this.getDist100Pixel = getDist100Pixel; 51 this.colorSupplier = colorSupplier; 39 52 setPreferredLineLength(100); 40 53 setOpaque(false); … … 51 64 @Override 52 65 public void paint(Graphics g) { 53 g.setColor(getColor()); 54 55 double dist100Pixel = mv.getDist100Pixel(true); 66 g.setColor(colorSupplier.get()); 67 double dist100Pixel = getDist100Pixel.getAsDouble(); 56 68 TickMarks tickMarks = new TickMarks(dist100Pixel, getWidth() - PADDING_LEFT - PADDING_RIGHT); 57 69 tickMarks.paintTicks(g); … … 83 95 @Override 84 96 public Number getCurrentAccessibleValue() { 85 return mv.getDist100Pixel();97 return getDist100Pixel.getAsDouble(); 86 98 } 87 99
Note:
See TracChangeset
for help on using the changeset viewer.