Changeset 19528 in josm for trunk/src/org
- Timestamp:
- 2026-02-14T12:50:29+01:00 (4 days ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 6 edited
-
data/osm/OsmPrimitive.java (modified) (3 diffs)
-
data/osm/PrimitiveData.java (modified) (2 diffs)
-
data/osm/Stylable.java (modified) (3 diffs)
-
data/vector/VectorPrimitive.java (modified) (4 diffs)
-
gui/dialogs/InspectPrimitiveDialog.java (modified) (1 diff)
-
gui/mappaint/ElemStyles.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r19331 r19528 13 13 import java.util.Objects; 14 14 import java.util.Set; 15 import java.util.HashMap; 15 16 import java.util.function.Consumer; 16 17 import java.util.stream.Collectors; … … 23 24 import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor; 24 25 import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor; 26 import org.openstreetmap.josm.gui.mappaint.ElemStyles; 25 27 import org.openstreetmap.josm.gui.mappaint.StyleCache; 26 28 import org.openstreetmap.josm.spi.preferences.Config; … … 144 146 * MAPPAINT 145 147 *--------*/ 146 private StyleCache mappaintStyle; 147 148 @Override 149 public final StyleCache getCachedStyle() { 150 return mappaintStyle; 151 } 152 153 @Override 154 public final void setCachedStyle(StyleCache mappaintStyle) { 155 this.mappaintStyle =mappaintStyle;156 } 157 158 @Override 159 public final boolean isCachedStyleUpToDate() { 160 return mappaintStyle != null && mappaintCacheIdx == dataSet.getMappaintCacheIndex(); 161 } 162 163 @Override 164 public final void declareCachedStyleUpToDate() { 148 private final Map<ElemStyles, StyleCache> mappaintStyle = new HashMap<>(); 149 150 @Override 151 public final StyleCache getCachedStyle(ElemStyles elemStyles) { 152 return mappaintStyle.get(elemStyles); 153 } 154 155 @Override 156 public final void setCachedStyle(ElemStyles elemStyles, StyleCache mappaintStyle) { 157 this.mappaintStyle.put(elemStyles, mappaintStyle); 158 } 159 160 @Override 161 public final boolean isCachedStyleUpToDate(ElemStyles elemStyles) { 162 return mappaintStyle.get(elemStyles) != null && mappaintCacheIdx == dataSet.getMappaintCacheIndex(); 163 } 164 165 @Override 166 public final void declareCachedStyleUpToDate(ElemStyles styles) { 165 167 this.mappaintCacheIdx = dataSet.getMappaintCacheIndex(); 168 } 169 170 @Override 171 public void clearCachedStyle() { 172 this.mappaintStyle.clear(); 166 173 } 167 174 -
trunk/src/org/openstreetmap/josm/data/osm/PrimitiveData.java
r19096 r19528 12 12 13 13 import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor; 14 import org.openstreetmap.josm.gui.mappaint.ElemStyles; 14 15 import org.openstreetmap.josm.gui.mappaint.StyleCache; 15 16 … … 152 153 153 154 @Override 154 public StyleCache getCachedStyle() { 155 public StyleCache getCachedStyle(ElemStyles styles) { 155 156 return null; 156 157 } 157 158 158 159 @Override 159 public void setCachedStyle(StyleCache mappaintStyle) { 160 public void setCachedStyle(ElemStyles styles, StyleCache mappaintStyle) { 160 161 // Override if needed 161 162 } 162 163 163 164 @Override 164 public boolean isCachedStyleUpToDate() { 165 public boolean isCachedStyleUpToDate(ElemStyles styles) { 165 166 return false; 166 167 } 167 168 168 169 @Override 169 public void declareCachedStyleUpToDate() { 170 public void declareCachedStyleUpToDate(ElemStyles styles) { 171 // Override if needed 172 } 173 174 @Override 175 public void clearCachedStyle(){ 170 176 // Override if needed 171 177 } -
trunk/src/org/openstreetmap/josm/data/osm/Stylable.java
r17333 r19528 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import org.openstreetmap.josm.gui.mappaint.ElemStyles; 4 5 import org.openstreetmap.josm.gui.mappaint.StyleCache; 5 6 … … 12 13 /** 13 14 * Returns the cached style. 15 * @param styles styles for which the data is retrieved 14 16 * @return the cached style 17 * @since 19528 (added param styles) 15 18 */ 16 StyleCache getCachedStyle(); 19 StyleCache getCachedStyle(ElemStyles styles); 17 20 18 21 /** 19 22 * Sets the cached style. 23 * @param styles styles for which the data is stored 20 24 * @param mappaintStyle the cached style 25 * @since 19528 (added param styles) 21 26 */ 22 void setCachedStyle(StyleCache mappaintStyle); 27 void setCachedStyle(ElemStyles styles, StyleCache mappaintStyle); 23 28 24 29 /** … … 28 33 * transparent cache handling in the future. 29 34 */ 30 default void clearCachedStyle() { 31 setCachedStyle(null); 32 } 35 void clearCachedStyle(); 33 36 34 37 /** 35 38 * Check if the cached style for this primitive is up to date. 39 * @param styles styles for which the data is checked 36 40 * @return true if the cached style for this primitive is up to date 37 41 * @since 13420 42 * @since 19528 (added param styles) 38 43 */ 39 boolean isCachedStyleUpToDate(); 44 boolean isCachedStyleUpToDate(ElemStyles styles); 40 45 41 46 /** 42 47 * Declare that the cached style for this primitive is up to date. 48 * @param styles styles for which the data is handled 43 49 * @since 13420 50 * @since 19528 (added param styles) 44 51 */ 45 void declareCachedStyleUpToDate(); 52 void declareCachedStyleUpToDate(ElemStyles styles); 46 53 } -
trunk/src/org/openstreetmap/josm/data/vector/VectorPrimitive.java
r19519 r19528 6 6 import java.util.List; 7 7 import java.util.Map; 8 import java.util.HashMap; 8 9 import java.util.function.Consumer; 9 10 import java.util.stream.Collectors; … … 14 15 import org.openstreetmap.josm.data.osm.IPrimitive; 15 16 import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor; 17 import org.openstreetmap.josm.gui.mappaint.ElemStyles; 16 18 import org.openstreetmap.josm.gui.mappaint.StyleCache; 17 19 import org.openstreetmap.josm.tools.Utils; … … 25 27 private VectorDataSet dataSet; 26 28 private boolean highlighted; 27 private StyleCache mappaintStyle; 29 private final Map<ElemStyles, StyleCache> mappaintStyle = new HashMap<>(); 28 30 private final String layer; 29 31 … … 78 80 79 81 @Override 80 public final StyleCache getCachedStyle() { 81 return mappaintStyle; 82 } 83 84 @Override 85 public final void setCachedStyle(StyleCache mappaintStyle) { 86 this.mappaintStyle =mappaintStyle;87 } 88 89 @Override 90 public final boolean isCachedStyleUpToDate() { 91 return mappaintStyle != null && mappaintCacheIdx == dataSet.getMappaintCacheIndex(); 92 } 93 94 @Override 95 public final void declareCachedStyleUpToDate() { 82 public final StyleCache getCachedStyle(ElemStyles elemStyles) { 83 return mappaintStyle.get(elemStyles); 84 } 85 86 @Override 87 public final void setCachedStyle(ElemStyles elemStyles, StyleCache mappaintStyle) { 88 this.mappaintStyle.put(elemStyles, mappaintStyle); 89 } 90 91 @Override 92 public final boolean isCachedStyleUpToDate(ElemStyles elemStyles) { 93 return mappaintStyle.get(elemStyles) != null && mappaintCacheIdx == dataSet.getMappaintCacheIndex(); 94 } 95 96 @Override 97 public final void declareCachedStyleUpToDate(ElemStyles elemStyles) { 96 98 this.mappaintCacheIdx = dataSet.getMappaintCacheIndex(); 99 } 100 101 public void clearCachedStyle() { 102 this.mappaintStyle.clear(); 97 103 } 98 104 -
trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java
r19120 r19528 164 164 if (sel.size() == 2) { 165 165 List<IPrimitive> selList = new ArrayList<>(sel); 166 StyleCache sc1 = selList.get(0).getCachedStyle(); 167 StyleCache sc2 = selList.get(1).getCachedStyle(); 166 StyleCache sc1 = selList.get(0).getCachedStyle(elemstyles); 167 StyleCache sc2 = selList.get(1).getCachedStyle(elemstyles); 168 168 if (sc1 == sc2) { 169 169 txtMappaint.println(tr("The 2 selected objects have identical style caches.")); -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r17867 r19528 164 164 public Pair<StyleElementList, Range> getStyleCacheWithRange(IPrimitive osm, double scale, NavigatableComponent nc) { 165 165 synchronized (osm.getStyleCacheSyncObject()) { 166 if (!osm.isCachedStyleUpToDate() || scale <= 0) { 167 osm.setCachedStyle(StyleCache.EMPTY_STYLECACHE); 166 if (!osm.isCachedStyleUpToDate(this) || scale <= 0) { 167 osm.setCachedStyle(this, StyleCache.EMPTY_STYLECACHE); 168 168 } else { 169 Pair<StyleElementList, Range> lst = osm.getCachedStyle().getWithRange(scale, osm.isSelected()); 169 Pair<StyleElementList, Range> lst = osm.getCachedStyle(this).getWithRange(scale, osm.isSelected()); 170 170 if (lst.a != null) 171 171 return lst; … … 217 217 } 218 218 } 219 StyleCache style = osm.getCachedStyle() != null ? osm.getCachedStyle() : StyleCache.EMPTY_STYLECACHE; 219 StyleCache style = osm.getCachedStyle(this) != null ? osm.getCachedStyle(this) : StyleCache.EMPTY_STYLECACHE; 220 220 try { 221 osm.setCachedStyle(style.put(p.a, p.b, osm.isSelected())); 221 osm.setCachedStyle(this, style.put(p.a, p.b, osm.isSelected())); 222 222 } catch (RangeViolatedError e) { 223 223 throw new AssertionError("Range violated: " + e.getMessage() 224 + " (object: " + osm.getPrimitiveId() + ", current style: " + osm.getCachedStyle() 224 + " (object: " + osm.getPrimitiveId() + ", current style: " + osm.getCachedStyle(this) 225 225 + ", scale: " + scale + ", new stylelist: " + p.a + ", new range: " + p.b + ')', e); 226 226 } 227 osm.declareCachedStyleUpToDate(); 227 osm.declareCachedStyleUpToDate(this); 228 228 return p; 229 229 }
Note:
See TracChangeset
for help on using the changeset viewer.
