Ticket #4142: flags.patch
File flags.patch, 6.4 KB (added by , 7 months ago) |
---|
-
src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.io.IOException; 7 import java.io.ObjectInputStream; 8 import java.io.ObjectOutputStream; 9 6 10 import java.text.MessageFormat; 7 11 import java.time.Instant; 8 12 import java.util.ArrayList; … … 132 136 133 137 /** 134 138 * Put several boolean flags to one short int field to save memory. 135 * Other bits of this field are used in subclasses.136 139 */ 137 pr otectedvolatile short flags = FLAG_VISIBLE; // visible per default140 private volatile short flags = FLAG_VISIBLE; // visible per default 138 141 139 142 /** 140 143 * The mappaint cache index for this primitive. … … 365 368 return oldFlags != flags; 366 369 } 367 370 371 protected void storeFlags(ObjectOutputStream oos) throws IOException { 372 oos.writeShort(flags); 373 } 374 375 protected void restoreFlags(ObjectInputStream ios) throws IOException { 376 flags = ios.readShort(); 377 } 378 368 379 @Override 369 380 public void setModified(boolean modified) { 370 381 updateFlags(FLAG_MODIFIED, modified); … … 418 429 } 419 430 420 431 @Override 432 public boolean hasDirectionKeys() { 433 return (flags & FLAG_HAS_DIRECTIONS) != 0; 434 } 435 436 @Override 437 public boolean reversedDirection() { 438 return (flags & FLAG_DIRECTION_REVERSED) != 0; 439 } 440 441 @Override 442 public boolean isTagged() { 443 return (flags & FLAG_TAGGED) != 0; 444 } 445 446 @Override 447 public boolean isAnnotated() { 448 return (flags & FLAG_ANNOTATED) != 0; 449 } 450 451 @Override 452 public boolean isHighlighted() { 453 return (flags & FLAG_HIGHLIGHTED) != 0; 454 } 455 456 @Override 457 public boolean isDisabled() { 458 return (flags & FLAG_DISABLED) != 0; 459 } 460 461 @Override 462 public boolean isDisabledAndHidden() { 463 return ((flags & FLAG_DISABLED) != 0) && ((flags & FLAG_HIDE_IF_DISABLED) != 0); 464 } 465 466 @Override 467 public boolean isPreserved() { 468 return (flags & FLAG_PRESERVED) != 0; 469 } 470 471 @Override 421 472 public boolean isIncomplete() { 422 473 return (flags & FLAG_INCOMPLETE) != 0; 423 474 } … … 458 509 updateFlags(FLAG_HIDDEN_TYPE, isExplicit); 459 510 } 460 511 512 public void copyFlagsFrom(AbstractPrimitive old) { 513 flags = old.flags; 514 } 515 461 516 @Override 462 517 public boolean isDrawable() { 463 518 return (flags & (FLAG_DELETED + FLAG_INCOMPLETE + FLAG_HIDE_IF_DISABLED)) == 0; -
src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
364 364 } 365 365 366 366 @Override 367 public boolean isDisabled() {368 return (flags & FLAG_DISABLED) != 0;369 }370 371 @Override372 public boolean isDisabledAndHidden() {373 return ((flags & FLAG_DISABLED) != 0) && ((flags & FLAG_HIDE_IF_DISABLED) != 0);374 }375 376 @Override377 public boolean isPreserved() {378 return (flags & FLAG_PRESERVED) != 0;379 }380 381 @Override382 367 public boolean isSelectable() { 383 368 // not synchronized -> check disabled twice just to be sure we did not have a race condition. 384 369 return !isDisabled() && isDrawable() && !isDisabled(); … … 492 477 } 493 478 } 494 479 495 @Override496 public boolean isHighlighted() {497 return (flags & FLAG_HIGHLIGHTED) != 0;498 }499 500 480 /*--------------- 501 481 * DIRECTION KEYS 502 482 *---------------*/ … … 526 506 updateFlagsNoLock(FLAG_ANNOTATED, hasKeys() && getWorkInProgressKeys().stream().anyMatch(this::hasKey)); 527 507 } 528 508 529 @Override530 public boolean isTagged() {531 return (flags & FLAG_TAGGED) != 0;532 }533 534 @Override535 public boolean isAnnotated() {536 return (flags & FLAG_ANNOTATED) != 0;537 }538 539 509 protected void updateDirectionFlags() { 540 510 boolean hasDirections = false; 541 511 boolean directionReversed = false; … … 551 521 updateFlagsNoLock(FLAG_HAS_DIRECTIONS, hasDirections); 552 522 } 553 523 554 @Override555 public boolean hasDirectionKeys() {556 return (flags & FLAG_HAS_DIRECTIONS) != 0;557 }558 559 @Override560 public boolean reversedDirection() {561 return (flags & FLAG_DIRECTION_REVERSED) != 0;562 }563 564 524 /*------------ 565 525 * Keys handling 566 526 ------------*/ … … 854 814 setKeys(other.hasKeys() ? other.getKeys() : null); 855 815 timestamp = other.timestamp; 856 816 version = other.version; 857 setIncomplete(other.isIncomplete()); 858 flags = other.flags;817 setIncomplete(other.isIncomplete()); /* hmm, why, it's done by copyFlagsFrom() */ 818 copyFlagsFrom(other); 859 819 user = other.user; 860 820 changesetId = other.changesetId; 861 821 } finally { -
src/org/openstreetmap/josm/data/osm/PrimitiveData.java
90 90 oos.writeInt(changesetId); 91 91 oos.writeInt(timestamp); 92 92 oos.writeObject(keys); 93 oos.writeShort(flags);93 storeFlags(oos); 94 94 oos.defaultWriteObject(); 95 95 } 96 96 … … 103 103 changesetId = ois.readInt(); 104 104 timestamp = ois.readInt(); 105 105 keys = (String[]) ois.readObject(); 106 flags = ois.readShort();106 restoreFlags(ois); 107 107 ois.defaultReadObject(); 108 108 } 109 109 -
src/org/openstreetmap/josm/data/vector/VectorPrimitive.java
59 59 } 60 60 61 61 @Override 62 public boolean isTagged() {63 return (flags & FLAG_TAGGED) != 0;64 }65 66 @Override67 62 public boolean isAnnotated() { 68 63 return this.getInterestingTags().size() - this.getKeys().size() > 0; 69 64 }