14
14
import java .awt .RenderingHints ;
15
15
import java .awt .Stroke ;
16
16
import java .awt .geom .AffineTransform ;
17
- import java .awt .geom .Ellipse2D ;
18
- import java .awt .geom .Line2D ;
19
17
import java .awt .geom .Point2D ;
20
18
import java .time .Instant ;
21
19
import java .time .temporal .ChronoUnit ;
22
- import java .time .temporal .TemporalUnit ;
23
- import java .util .ArrayList ;
24
20
import java .util .Collection ;
25
21
import java .util .Collections ;
26
22
import java .util .Comparator ;
@@ -137,9 +133,6 @@ public final class MapillaryLayer extends MVTLayer implements ActiveLayerChangeL
137
133
private static final ImageIcon SELECTED_IMAGE = new ImageProvider (IMAGE_SPRITE_DIR , "current-ca" )
138
134
.setMaxWidth (ImageProvider .ImageSizes .MAP .getAdjustedHeight ()).get ();
139
135
140
- private static final Ellipse2D IMAGE_CIRCLE = new Ellipse2D .Double (-IMG_MARKER_RADIUS , -IMG_MARKER_RADIUS ,
141
- 2 * IMG_MARKER_RADIUS , 2 * IMG_MARKER_RADIUS );
142
-
143
136
/** The color scale used when drawing using velocity */
144
137
private final ColorScale velocityScale = ColorScale .createHSBScale (256 );
145
138
/** The color scale used when drawing using date */
@@ -152,12 +145,11 @@ public final class MapillaryLayer extends MVTLayer implements ActiveLayerChangeL
152
145
153
146
/** The color scale used when drawing using direction */
154
147
private final ColorScale directionScale = ColorScale .createCyclicScale (256 ).setIntervalCount (4 )
155
- .addTitle (tr ("Direction" ));;
148
+ .addTitle (tr ("Direction" ));
156
149
157
150
/** The nearest images to the selected image from different sequences sorted by distance from selection. */
158
151
// Use ArrayList instead of an array, since there will not be thousands of instances, and allows for better
159
152
// synchronization
160
- private final List <INode > nearestImages = Collections .synchronizedList (new ArrayList <>(2 ));
161
153
162
154
/** The images that have been viewed since the last upload */
163
155
private final ConcurrentHashMap <DataSet , Set <INode >> imageViewedMap = new ConcurrentHashMap <>(1 );
@@ -198,7 +190,8 @@ private MapillaryLayer() {
198
190
private void setupColorScales () {
199
191
this .dateScale .setNoDataColor (MapillaryColorScheme .SEQ_UNSELECTED );
200
192
// ChronoUnit.YEARS isn't supported since a year can be either 365 or 366.
201
- this .dateScale .setRange (Instant .now ().minus (4 * 365L , ChronoUnit .DAYS ).toEpochMilli (), Instant .now ().toEpochMilli ());
193
+ this .dateScale .setRange (Instant .now ().minus (4 * 365L , ChronoUnit .DAYS ).toEpochMilli (),
194
+ Instant .now ().toEpochMilli ());
202
195
this .directionScale .setNoDataColor (MapillaryColorScheme .SEQ_UNSELECTED );
203
196
this .velocityScale .setNoDataColor (MapillaryColorScheme .SEQ_UNSELECTED );
204
197
}
@@ -347,20 +340,6 @@ private void paintWithLock(final Graphics2D g, final MapView mv, final Bounds bo
347
340
MapillaryProperties .UNSELECTED_OPACITY .get ().floatValue ());
348
341
349
342
final INode selectedImage = this .image ;
350
- synchronized (this ) {
351
- for (int i = 0 ; i < this .nearestImages .size (); i ++) {
352
- if (i % 2 == 0 ) {
353
- g .setColor (Color .RED );
354
- } else {
355
- g .setColor (Color .BLUE );
356
- }
357
- if (selectedImage != null ) {
358
- final Point selected = mv .getPoint (selectedImage );
359
- final Point p = mv .getPoint (this .nearestImages .get (i ));
360
- g .draw (new Line2D .Double (p .getX (), p .getY (), selected .getX (), selected .getY ()));
361
- }
362
- }
363
- }
364
343
365
344
// Draw sequence line
366
345
g .setStroke (new BasicStroke (2 ));
@@ -398,31 +377,19 @@ private void drawSequence(final Graphics2D g, final MapView mv, final IWay<?> se
398
377
if (selectedImage != null && !nodes .contains (selectedImage )) {
399
378
g .setComposite (fadeComposite );
400
379
}
401
- // START OLD IMAGE BITS FIXME
380
+ final Color forcedColor ;
402
381
if (sequence .getNodes ().contains (selectedImage )) {
403
- g . setColor ( !MapillarySequenceUtils .hasKey (sequence ) ? MapillaryColorScheme .SEQ_IMPORTED_SELECTED
404
- : MapillaryColorScheme .SEQ_SELECTED ) ;
382
+ forcedColor = !MapillarySequenceUtils .hasKey (sequence ) ? MapillaryColorScheme .SEQ_IMPORTED_SELECTED
383
+ : MapillaryColorScheme .SEQ_SELECTED ;
405
384
} else {
406
- final Color color ;
407
- if (MapillarySequenceUtils .hasKey (sequence )) {
408
- final INode toCheck = sequence .getNodes ().stream ()
409
- .filter (inode -> !Instant .EPOCH .equals (MapillaryImageUtils .getDate (inode ))).map (INode .class ::cast )
410
- .findFirst ().orElse (sequence .firstNode ());
411
- color = getColor (toCheck );
412
- } else {
413
- color = MapillaryColorScheme .SEQ_IMPORTED_UNSELECTED ;
414
- }
415
- g .setColor (color );
416
- if (selectedImage != null ) {
417
- g .setComposite (fadeComposite );
418
- }
385
+ forcedColor = null ;
419
386
}
420
- // END OLD IMAGE BITS FIXME
421
387
final int zoom = getZoomLevel ();
422
388
INode previous = null ;
423
389
Point previousPoint = null ;
424
390
for (INode current : nodes ) {
425
391
final Point currentPoint = mv .getPoint (current );
392
+ g .setColor (forcedColor != null ? forcedColor : getColor (current ));
426
393
if (previous != null && (mv .contains (currentPoint ) || mv .contains (previousPoint ))) {
427
394
// FIXME get the right color for the line segment
428
395
g .drawLine (previousPoint .x , previousPoint .y , currentPoint .x , currentPoint .y );
@@ -493,7 +460,7 @@ private static double calculateVelocity(@Nonnull INode node) {
493
460
final long dt = MapillaryImageUtils .getDate (second ).toEpochMilli ()
494
461
- MapillaryImageUtils .getDate (first ).toEpochMilli ();
495
462
final double dd = second .greatCircleDistance (first );
496
- return dd / dt ;
463
+ return dd / ( dt / 1000d ) ;
497
464
}
498
465
}
499
466
return Double .NaN ;
@@ -588,13 +555,13 @@ private static void paintDirectionIndicator(Graphics2D g, Color directionC, INod
588
555
scale .scale (2 , 2 );
589
556
g .setTransform (scale );
590
557
g .setComposite (fadeComposite );
591
- g .fill ( IMAGE_CIRCLE );
558
+ g .fillOval (- IMG_MARKER_RADIUS , - IMG_MARKER_RADIUS , 2 * IMG_MARKER_RADIUS , 2 * IMG_MARKER_RADIUS );
592
559
g .setComposite (currentComposite );
593
560
}
594
561
final AffineTransform translate = AffineTransform .getTranslateInstance (p .x , p .y );
595
562
translate .preConcatenate (originalTransform );
596
563
g .setTransform (translate );
597
- g .fill ( IMAGE_CIRCLE );
564
+ g .fillOval (- IMG_MARKER_RADIUS , - IMG_MARKER_RADIUS , 2 * IMG_MARKER_RADIUS , 2 * IMG_MARKER_RADIUS );
598
565
if (i != null ) {
599
566
// This _must_ be set after operations complete (see JOSM #19516 for more information)
600
567
// convert the angle to radians from degrees
0 commit comments