Changeset 3116 in josm
- Timestamp:
- 2010-03-11T21:01:49+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r3108 r3116 172 172 oldHighlights.add(mouseOnExistingNode); 173 173 if(drawTargetHighlight) { 174 mouseOnExistingNode. highlighted = true;174 mouseOnExistingNode.setHighlighted(true); 175 175 } 176 176 return; … … 189 189 if (!drawTargetHighlight) return; 190 190 for (Way w : mouseOnExistingWays) { 191 w. highlighted = true;191 w.setHighlighted(true); 192 192 } 193 193 } … … 198 198 private void removeHighlighting() { 199 199 for(OsmPrimitive prim : oldHighlights) { 200 prim. highlighted = false;200 prim.setHighlighted(false); 201 201 } 202 202 oldHighlights = new HashSet<OsmPrimitive>(); -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r3102 r3116 58 58 // Number of open calls to beginUpdate 59 59 private int updateCount; 60 61 private int highlightUpdateCount; 62 63 /** 64 * This method can be used to detect changes in highlight state of primitives. If highlighting was changed 65 * then the method will return different number. 66 * @return 67 */ 68 public int getHighlightUpdateCount() { 69 return highlightUpdateCount; 70 } 60 71 61 72 /** … … 314 325 * Replies an unmodifiable collection of primitives currently selected 315 326 * in this dataset 316 * 327 * 317 328 * @return unmodifiable collection of primitives 318 329 */ … … 897 908 } 898 909 910 void fireHighlightingChanged(OsmPrimitive primitive) { 911 highlightUpdateCount++; 912 } 913 899 914 public void clenupDeletedPrimitives() { 900 915 if (cleanupDeleted(nodes.iterator()) -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r3056 r3116 229 229 * If allowNegativeId is not set, then id will have to be 0 (in that case new unique id will be generated) or 230 230 * positive number. 231 * 231 * 232 232 * If id is not > 0 version is ignored and set to 0. 233 233 * … … 475 475 * show which ways/nodes will connect 476 476 */ 477 p ublicvolatile boolean highlighted = false;477 private volatile boolean highlighted = false; 478 478 479 479 private int timestamp; … … 1288 1288 return dataSet != null && dataSet.isSelected(this); 1289 1289 } 1290 1291 public void setHighlighted(boolean highlighted) { 1292 if (this.highlighted != highlighted) { 1293 this.highlighted = highlighted; 1294 if (dataSet != null) { 1295 dataSet.fireHighlightingChanged(this); 1296 } 1297 } 1298 } 1299 1300 public boolean isHighlighted() { 1301 return highlighted; 1302 } 1290 1303 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/SimplePaintVisitor.java
r2725 r3116 227 227 if (inactive || n.isDisabled()) { 228 228 drawNode(n, inactiveColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode); 229 } else if (n. highlighted) {229 } else if (n.isHighlighted()) { 230 230 drawNode(n, highlightColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 231 231 } else if (ds.isSelected(n)) { … … 304 304 if (inactive || w.isDisabled()) { 305 305 wayColor = inactiveColor; 306 } else if(w. highlighted) {306 } else if(w.isHighlighted()) { 307 307 wayColor = highlightColor; 308 308 } else if(ds.isSelected(w)) { -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r3078 r3116 159 159 * A list of all layers currently loaded. 160 160 */ 161 private ArrayList<Layer> layers = new ArrayList<Layer>();161 private final List<Layer> layers = new ArrayList<Layer>(); 162 162 /** 163 163 * The play head marker: there is only one of these so it isn't in any specific layer … … 180 180 181 181 private BufferedImage offscreenBuffer; 182 // Layers that wasn't changed since last paint 183 private final List<Layer> nonChangedLayers = new ArrayList<Layer>(); 182 184 183 185 public MapView() { … … 458 460 return; // no data loaded yet. 459 461 460 // re-create offscreen-buffer if we've been resized, otherwise 461 // just re-use it. 462 if (null == offscreenBuffer || offscreenBuffer.getWidth() != getWidth() 463 || offscreenBuffer.getHeight() != getHeight()) { 464 offscreenBuffer = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_3BYTE_BGR); 465 } 466 467 Graphics2D tempG = offscreenBuffer.createGraphics(); 468 tempG.setClip(g.getClip()); 469 tempG.setColor(PaintColors.BACKGROUND.get()); 470 tempG.fillRect(0, 0, getWidth(), getHeight()); 471 462 List<Layer> visibleLayers = getVisibleLayersInZOrder(); 463 464 int nonChangedLayersCount = 0; 465 for (Layer l: visibleLayers) { 466 if (l.isChanged()) { 467 break; 468 } else { 469 nonChangedLayersCount++; 470 } 471 } 472 473 boolean canUseBuffer = nonChangedLayers.size() <= nonChangedLayersCount; 474 if (canUseBuffer) { 475 for (int i=0; i<nonChangedLayers.size(); i++) { 476 if (visibleLayers.get(i) != nonChangedLayers.get(i)) { 477 canUseBuffer = false; 478 break; 479 } 480 } 481 } 482 483 Graphics2D tempG = (Graphics2D) g; 472 484 Bounds box = getLatLonBounds(g.getClipBounds()); 473 485 474 for (Layer l: getVisibleLayersInZOrder()) { 475 l.paint(tempG, this, box); 476 } 486 if (!canUseBuffer || offscreenBuffer == null) { 487 if (null == offscreenBuffer || offscreenBuffer.getWidth() != getWidth() || offscreenBuffer.getHeight() != getHeight()) { 488 offscreenBuffer = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_3BYTE_BGR); 489 } 490 Graphics2D g2 = offscreenBuffer.createGraphics(); 491 g2.setColor(PaintColors.BACKGROUND.get()); 492 g2.fillRect(0, 0, getWidth(), getHeight()); 493 494 for (int i=0; i<nonChangedLayersCount; i++) { 495 visibleLayers.get(i).paint(g2, this, box); 496 } 497 } else { 498 // Maybe there were more unchanged layers then last time - draw them to buffer 499 if (nonChangedLayers.size() != nonChangedLayersCount) { 500 Graphics2D g2 = offscreenBuffer.createGraphics(); 501 for (int i=nonChangedLayers.size(); i<nonChangedLayersCount; i++) { 502 visibleLayers.get(i).paint(g2, this, box); 503 } 504 } 505 } 506 507 nonChangedLayers.clear(); 508 for (int i=0; i<nonChangedLayersCount; i++) { 509 nonChangedLayers.add(visibleLayers.get(i)); 510 } 511 512 tempG.drawImage(offscreenBuffer, 0, 0, null); 513 514 for (int i=nonChangedLayersCount; i<visibleLayers.size(); i++) { 515 visibleLayers.get(i).paint(tempG, this, box); 516 } 517 477 518 for (MapViewPaintable mvp : temporaryLayers) { 478 519 mvp.paint(tempG, this, box); … … 515 556 } 516 557 517 int w = offscreenBuffer.getWidth();518 int h = offscreenBuffer.getHeight();558 int w = getWidth(); 559 int h = getHeight(); 519 560 520 561 // Work around OpenJDK having problems when drawing out of bounds … … 530 571 } 531 572 532 g.drawImage(offscreenBuffer, 0, 0, null);533 573 super.paint(g); 534 574 } -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r2801 r3116 679 679 return n.substring(n.lastIndexOf('.')+1); 680 680 } 681 682 /** 683 * Return a ID which is unique as long as viewport dimensions are the same 684 */ 685 public int getViewID() { 686 String x = center.east() + "_" + center.north() + "_" + scale + "_" + 687 getWidth() + "_" + getHeight() + "_" + getProjection().toString(); 688 java.util.zip.CRC32 id = new java.util.zip.CRC32(); 689 id.update(x.getBytes()); 690 return (int)id.getValue(); 691 } 681 692 } -
trunk/src/org/openstreetmap/josm/gui/layer/Layer.java
r2621 r3116 229 229 230 230 /** 231 * 232 * 233 * @return True if layer was changed since last paint 234 */ 235 public boolean isChanged() { 236 return true; 237 } 238 239 /** 231 240 * The action to save a layer 232 241 * -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r3078 r3116 44 44 import org.openstreetmap.josm.command.PurgePrimitivesCommand; 45 45 import org.openstreetmap.josm.data.Bounds; 46 import org.openstreetmap.josm.data.SelectionChangedListener; 46 47 import org.openstreetmap.josm.data.conflict.Conflict; 47 48 import org.openstreetmap.josm.data.conflict.ConflictCollection; … … 59 60 import org.openstreetmap.josm.data.osm.Relation; 60 61 import org.openstreetmap.josm.data.osm.Way; 62 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent; 63 import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter; 64 import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter.Listener; 61 65 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor; 62 66 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; … … 79 83 * @author imi 80 84 */ 81 public class OsmDataLayer extends Layer {85 public class OsmDataLayer extends Layer implements Listener, SelectionChangedListener { 82 86 static public final String REQUIRES_SAVE_TO_DISK_PROP = OsmDataLayer.class.getName() + ".requiresSaveToDisk"; 83 87 static public final String REQUIRES_UPLOAD_TO_SERVER_PROP = OsmDataLayer.class.getName() + ".requiresUploadToServer"; … … 85 89 private boolean requiresSaveToFile = false; 86 90 private boolean requiresUploadToServer = false; 91 private boolean isChanged = true; 92 private int highlightUpdateCount; 93 private int viewId; 87 94 88 95 protected void setRequiresSaveToFile(boolean newValue) { … … 199 206 this.setAssociatedFile(associatedFile); 200 207 conflicts = new ConflictCollection(); 208 data.addDataSetListener(new DataSetListenerAdapter(this)); 209 DataSet.selListeners.add(this); 201 210 } 202 211 … … 215 224 */ 216 225 @Override public void paint(final Graphics2D g, final MapView mv, Bounds box) { 226 isChanged = false; 227 highlightUpdateCount = data.getHighlightUpdateCount(); 228 viewId = Main.map.mapView.getViewID(); 229 217 230 boolean active = mv.getActiveLayer() == this; 218 231 boolean inactive = !active && Main.pref.getBoolean("draw.data.inactive_color", true); … … 711 724 } 712 725 726 @Override 727 public boolean isChanged() { 728 return isChanged || highlightUpdateCount != data.getHighlightUpdateCount() || viewId != Main.map.mapView.getViewID(); 729 } 730 713 731 /** 714 732 * Initializes the layer after a successful save of OSM data to a file … … 752 770 753 771 } 772 773 public void processDatasetEvent(AbstractDatasetChangedEvent event) { 774 isChanged = true; 775 } 776 777 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 778 isChanged = true; 779 } 754 780 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java
r2890 r3116 177 177 } 178 178 179 if(w. highlighted) {179 if(w.isHighlighted()) { 180 180 myColor = paintSettings.getHighlightColor(); 181 181 } else if (selected) { -
trunk/src/org/openstreetmap/josm/gui/mappaint/SimpleNodeElemStyle.java
r3083 r3116 21 21 Node n = (Node)primitive; 22 22 String name = painter.isShowNames()?painter.getNodeName(n):null; 23 if (n. highlighted) {23 if (n.isHighlighted()) { 24 24 painter.drawNode(n, settings.getHighlightColor(), settings.getSelectedNodeSize(), settings.isFillSelectedNode(), name); 25 25 } else if (selected) {
Note:
See TracChangeset
for help on using the changeset viewer.