Ticket #21922: 21922.patch
| File 21922.patch, 3.8 KB (added by , 4 years ago) |
|---|
-
src/org/openstreetmap/josm/data/gpx/GpxData.java
1094 1094 1095 1095 @Override 1096 1096 public void put(String key, Object value) { 1097 put(key, value, true); 1098 } 1099 1100 /** 1101 * Put a key / value pair as a new attribute. Overrides key / value pair with the same key (if present). 1102 * Only sets the modified state when setModified is true. 1103 * 1104 * @param key the key 1105 * @param value the value 1106 * @param setModified whether to change the modified state 1107 */ 1108 public void put(String key, Object value, boolean setModified) { 1097 1109 super.put(key, value); 1098 invalidate();1110 fireInvalidate(setModified); 1099 1111 } 1100 1112 1101 1113 /** … … 1132 1144 } 1133 1145 1134 1146 private void fireInvalidate(boolean setModified) { 1147 if (setModified) { 1148 setModified(true); 1149 } 1135 1150 if (updating || initializing) { 1136 1151 suppressedInvalidate = true; 1137 1152 } else { 1138 if (setModified) {1139 setModified(true);1140 }1141 1153 if (listeners.hasListeners()) { 1142 1154 GpxDataChangeEvent e = new GpxDataChangeEvent(this); 1143 1155 listeners.fireEvent(l -> l.gpxDataChanged(e)); … … 1158 1170 * @since 15496 1159 1171 */ 1160 1172 public void endUpdate() { 1161 boolean setModified = updating;1162 1173 updating = initializing = false; 1163 1174 if (suppressedInvalidate) { 1164 fireInvalidate( setModified);1175 fireInvalidate(false); 1165 1176 suppressedInvalidate = false; 1166 1177 } 1167 1178 } -
src/org/openstreetmap/josm/data/gpx/GpxTrack.java
82 82 83 83 @Override 84 84 public void setColor(Color color) { 85 setColorExtension (color);85 setColorExtensionGPXD(color, true); 86 86 colorCache = color; 87 87 } 88 88 89 private void setColorExtension (Color color) {89 private void setColorExtensionGPXD(Color color, boolean invalidate) { 90 90 getExtensions().findAndRemove("gpxx", "DisplayColor"); 91 91 if (color == null) { 92 92 getExtensions().findAndRemove("gpxd", "color"); 93 93 } else { 94 94 getExtensions().addOrUpdate("gpxd", "color", String.format("#%02X%02X%02X", color.getRed(), color.getGreen(), color.getBlue())); 95 95 } 96 fireInvalidate(); 96 colorFormat = ColorFormat.GPXD; 97 if (invalidate) { 98 fireInvalidate(); 99 } 97 100 } 98 101 99 102 @Override … … 167 170 closestGarminColorCache.put(c, colorString); 168 171 getExtensions().addIfNotPresent("gpxx", "TrackExtension").getExtensions().addOrUpdate("gpxx", "DisplayColor", colorString); 169 172 } else if (cFormat == ColorFormat.GPXD) { 170 setColor (c);173 setColorExtensionGPXD(c, false); 171 174 } 172 175 colorFormat = cFormat; 173 176 } -
src/org/openstreetmap/josm/io/GpxWriter.java
123 123 e.put("value", entry.getValue()); 124 124 }); 125 125 } 126 data.put(META_TIME, (metaTime != null ? metaTime : Instant.now()).toString() );126 data.put(META_TIME, (metaTime != null ? metaTime : Instant.now()).toString(), false); 127 127 data.endUpdate(); 128 128 129 129 Collection<IWithAttributes> all = new ArrayList<>();
