Changeset 13636 in josm for trunk/src/org
- Timestamp:
- 2018-04-15T18:58:21+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/IPrimitive.java
r13564 r13636 11 11 * @since 4098 12 12 */ 13 public interface IPrimitive extends Tagged, PrimitiveId {13 public interface IPrimitive extends Tagged, PrimitiveId, Stylable { 14 14 15 15 /** -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r13564 r13636 193 193 * MAPPAINT 194 194 *--------*/ 195 p ublicStyleCache mappaintStyle;195 private StyleCache mappaintStyle; 196 196 private short mappaintCacheIdx; 197 197 198 /* This should not be called from outside. Fixing the UI to add relevant 199 get/set functions calling this implicitely is preferred, so we can have 200 transparent cache handling in the future. */ 201 public void clearCachedStyle() { 202 mappaintStyle = null; 203 } 204 205 /** 206 * Check if the cached style for this primitive is up to date. 207 * @return true if the cached style for this primitive is up to date 208 * @since 13420 209 */ 198 @Override 199 public final StyleCache getCachedStyle() { 200 return mappaintStyle; 201 } 202 203 @Override 204 public final void setCachedStyle(StyleCache mappaintStyle) { 205 this.mappaintStyle = mappaintStyle; 206 } 207 208 @Override 210 209 public final boolean isCachedStyleUpToDate() { 211 210 return mappaintStyle != null && mappaintCacheIdx == dataSet.getMappaintCacheIndex(); 212 211 } 213 212 214 /** 215 * Declare that the cached style for this primitive is up to date. 216 * @since 13420 217 */ 213 @Override 218 214 public final void declareCachedStyleUpToDate() { 219 215 this.mappaintCacheIdx = dataSet.getMappaintCacheIndex(); 220 }221 222 /**223 * Returns mappaint cache index.224 * @return mappaint cache index225 * @deprecated no longer supported (see also {@link #isCachedStyleUpToDate()})226 */227 @Deprecated228 public final short getMappaintCacheIdx() {229 return mappaintCacheIdx;230 }231 232 /**233 * Sets the mappaint cache index.234 * @param mappaintCacheIdx mappaint cache index235 * @deprecated no longer supported (see also {@link #declareCachedStyleUpToDate()})236 */237 @Deprecated238 public final void setMappaintCacheIdx(short mappaintCacheIdx) {239 this.mappaintCacheIdx = mappaintCacheIdx;240 216 } 241 217 -
trunk/src/org/openstreetmap/josm/data/osm/PrimitiveData.java
r12017 r13636 11 11 import java.util.List; 12 12 import java.util.Map; 13 14 import org.openstreetmap.josm.gui.mappaint.StyleCache; 13 15 14 16 /** … … 130 132 ois.defaultReadObject(); 131 133 } 134 135 @Override 136 public StyleCache getCachedStyle() { 137 return null; 138 } 139 140 @Override 141 public void setCachedStyle(StyleCache mappaintStyle) { 142 // Override if needed 143 } 144 145 @Override 146 public boolean isCachedStyleUpToDate() { 147 return false; 148 } 149 150 @Override 151 public void declareCachedStyleUpToDate() { 152 // Override if needed 153 } 132 154 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java
r13434 r13636 151 151 if (sel.size() == 2) { 152 152 List<OsmPrimitive> selList = new ArrayList<>(sel); 153 StyleCache sc1 = selList.get(0). mappaintStyle;154 StyleCache sc2 = selList.get(1). mappaintStyle;153 StyleCache sc1 = selList.get(0).getCachedStyle(); 154 StyleCache sc2 = selList.get(1).getCachedStyle(); 155 155 if (sc1 == sc2) { 156 156 txtMappaint.append(tr("The 2 selected objects have identical style caches.")); -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r13420 r13636 105 105 } 106 106 107 /** 108 * Returns the background color. 109 * @return the background color 110 */ 107 111 public Color getBackgroundColor() { 108 112 if (backgroundColorCache != null) … … 144 148 public Pair<StyleElementList, Range> getStyleCacheWithRange(OsmPrimitive osm, double scale, NavigatableComponent nc) { 145 149 if (!osm.isCachedStyleUpToDate() || scale <= 0) { 146 osm. mappaintStyle = StyleCache.EMPTY_STYLECACHE;150 osm.setCachedStyle(StyleCache.EMPTY_STYLECACHE); 147 151 } else { 148 Pair<StyleElementList, Range> lst = osm. mappaintStyle.getWithRange(scale, osm.isSelected());152 Pair<StyleElementList, Range> lst = osm.getCachedStyle().getWithRange(scale, osm.isSelected()); 149 153 if (lst.a != null) 150 154 return lst; … … 191 195 } 192 196 } 193 StyleCache style = osm. mappaintStyle != null ? osm.mappaintStyle: StyleCache.EMPTY_STYLECACHE;197 StyleCache style = osm.getCachedStyle() != null ? osm.getCachedStyle() : StyleCache.EMPTY_STYLECACHE; 194 198 try { 195 osm. mappaintStyle = style.put(p.a, p.b, osm.isSelected());199 osm.setCachedStyle(style.put(p.a, p.b, osm.isSelected())); 196 200 } catch (RangeViolatedError e) { 197 201 throw new AssertionError("Range violated: " + e.getMessage() 198 + " (object: " + osm.getPrimitiveId() + ", current style: "+osm. mappaintStyle202 + " (object: " + osm.getPrimitiveId() + ", current style: "+osm.getCachedStyle() 199 203 + ", scale: " + scale + ", new stylelist: " + p.a + ", new range: " + p.b + ')', e); 200 204 } … … 462 466 } 463 467 468 /** 469 * Determines whether multipolygons must be drawn. 470 * @return whether multipolygons must be drawn. 471 */ 464 472 public boolean isDrawMultipolygon() { 465 473 return drawMultipolygon; 466 474 } 467 475 476 /** 477 * Sets whether multipolygons must be drawn. 478 * @param drawMultipolygon whether multipolygons must be drawn 479 */ 468 480 public void setDrawMultipolygon(boolean drawMultipolygon) { 469 481 this.drawMultipolygon = drawMultipolygon;
Note:
See TracChangeset
for help on using the changeset viewer.