Skip to content

Commit ed434b7

Browse files
authored
API uplift for JOSM v19528 (#249)
1 parent 55848d3 commit ed434b7

3 files changed

Lines changed: 21 additions & 12 deletions

File tree

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<property name="plugin.description" value="Allows the user to work with pictures hosted at mapillary.com"/>
99
<property name="plugin.icon" value="images/mapillary-logo.svg"/>
1010
<property name="plugin.link" value="https://wiki.openstreetmap.org/wiki/JOSM/Plugins/Mapillary"/>
11-
<property name="plugin.main.version" value="19387"/>
11+
<property name="plugin.main.version" value="19528"/>
1212
<!-- The datepicker plugin is currently in the source tree. TODO fix -->
1313
<property name="plugin.requires" value="apache-commons"/>
1414
<property name="plugin.minimum.java.version" value="17"/>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<java.lang.version>17</java.lang.version>
2727
<plugin.src.dir>src/main/java</plugin.src.dir>
2828
<plugin.resources.dir>src/main/resources</plugin.resources.dir>
29-
<plugin.main.version>19387</plugin.main.version>
29+
<plugin.main.version>19528</plugin.main.version>
3030
<plugin.author>nokutu, floscher, taylor.smock &lt;tsmock@meta.com&gt;</plugin.author>
3131
<plugin.class>org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin</plugin.class>
3232
<plugin.description>Allows the user to work with pictures hosted at mapillary.com</plugin.description>

src/main/java/org/openstreetmap/josm/plugins/mapillary/data/mapillary/MapillaryPrimitive.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
package org.openstreetmap.josm.plugins.mapillary.data.mapillary;
33

44
import java.util.Map;
5+
import java.util.HashMap;
56

67
import org.openstreetmap.josm.data.osm.AbstractPrimitive;
78
import org.openstreetmap.josm.data.osm.INode;
@@ -11,13 +12,13 @@
1112
import org.openstreetmap.josm.data.osm.NameFormatter;
1213
import org.openstreetmap.josm.data.osm.OsmData;
1314
import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
15+
import org.openstreetmap.josm.gui.mappaint.ElemStyles;
1416
import org.openstreetmap.josm.gui.mappaint.StyleCache;
1517

1618
abstract class MapillaryPrimitive extends AbstractPrimitive {
1719

1820
private boolean highlighted;
19-
private StyleCache styleCache;
20-
private boolean styleCacheIsUpToDate;
21+
private final Map<ElemStyles, StyleCache> styleCaches = new HashMap<>();
2122

2223
@Override
2324
protected void keysChangedImpl(Map<String, String> originalKeys) {
@@ -83,23 +84,31 @@ public int compareTo(IPrimitive o) {
8384
throw new UnsupportedOperationException("Not yet implemented");
8485
}
8586

87+
// Methods required for the JOSM mappaint style engine.
8688
@Override
87-
public StyleCache getCachedStyle() {
88-
return this.styleCache;
89+
public StyleCache getCachedStyle(ElemStyles elemStyles) {
90+
return styleCaches.get(elemStyles);
8991
}
9092

9193
@Override
92-
public void setCachedStyle(StyleCache mappaintStyle) {
93-
this.styleCache = mappaintStyle;
94+
public void setCachedStyle(ElemStyles elemStyles, StyleCache mappaintStyle) {
95+
this.styleCaches.put(elemStyles, mappaintStyle);
9496
}
9597

9698
@Override
97-
public boolean isCachedStyleUpToDate() {
98-
return this.styleCacheIsUpToDate;
99+
public boolean isCachedStyleUpToDate(ElemStyles elemStyles) {
100+
// This primitive type does not have a dataSet to sync with, so we can't use a cache index.
101+
// Invalidation is handled manually by calling clearCachedStyle().
102+
return styleCaches.get(elemStyles) != null;
99103
}
100104

101105
@Override
102-
public void declareCachedStyleUpToDate() {
103-
this.styleCacheIsUpToDate = true;
106+
public void declareCachedStyleUpToDate(ElemStyles elemStyles) {
107+
// This primitive type does not have a dataSet to sync with, so there is nothing to do here.
104108
}
109+
110+
@Override
111+
public void clearCachedStyle(){
112+
this.styleCaches.clear();
113+
};
105114
}

0 commit comments

Comments
 (0)