Changeset 6717 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2014-01-17T21:33:44+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r6639 r6717 26 26 import org.openstreetmap.josm.tools.CheckParameterUtil; 27 27 import org.openstreetmap.josm.tools.Predicate; 28 import org.openstreetmap.josm.tools.Utils; 28 29 import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider; 29 30 … … 924 925 /** 925 926 * Add new referrer. If referrer is already included then no action is taken 926 * @param referrer 927 * @param referrer The referrer to add 927 928 */ 928 929 protected void addReferrer(OsmPrimitive referrer) { 929 // Based on methods from josm-ng930 930 if (referrers == null) { 931 931 referrers = referrer; … … 939 939 return; 940 940 } 941 OsmPrimitive[] orig = (OsmPrimitive[])referrers; 942 OsmPrimitive[] bigger = new OsmPrimitive[orig.length+1]; 943 System.arraycopy(orig, 0, bigger, 0, orig.length); 944 bigger[orig.length] = referrer; 945 referrers = bigger; 941 referrers = Utils.addInArrayCopy((OsmPrimitive[])referrers, referrer); 946 942 } 947 943 } … … 949 945 /** 950 946 * Remove referrer. No action is taken if referrer is not registered 951 * @param referrer 947 * @param referrer The referrer to remove 952 948 */ 953 949 protected void removeReferrer(OsmPrimitive referrer) { 954 // Based on methods from josm-ng955 950 if (referrers instanceof OsmPrimitive) { 956 951 if (referrers == referrer) { -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r6639 r6717 82 82 boolean locked = writeLock(); 83 83 try { 84 RelationMember[] newMembers = new RelationMember[members.length + 1]; 85 System.arraycopy(members, 0, newMembers, 0, members.length); 86 newMembers[members.length] = member; 87 members = newMembers; 84 members = Utils.addInArrayCopy(members, member); 88 85 member.getMember().addReferrer(this); 89 86 member.getMember().clearCachedStyle(); … … 480 477 } 481 478 482 private void checkMembers() {479 private void checkMembers() throws DataIntegrityProblemException { 483 480 DataSet dataSet = getDataSet(); 484 481 if (dataSet != null) { … … 497 494 } 498 495 499 private void fireMembersChanged() {496 private void fireMembersChanged() throws DataIntegrityProblemException { 500 497 checkMembers(); 501 498 if (getDataSet() != null) { -
trunk/src/org/openstreetmap/josm/data/osm/Storage.java
r6380 r6717 3 3 4 4 import java.util.AbstractSet; 5 import java.util.Arrays; 5 6 import java.util.Collection; 6 7 import java.util.ConcurrentModificationException; … … 147 148 private void copyArray() { 148 149 if (arrayCopyNecessary) { 149 @SuppressWarnings("unchecked") T[] newData = (T[]) new Object[data.length]; 150 System.arraycopy(data, 0, newData, 0, data.length); 151 data = newData; 150 data = Arrays.copyOf(data, data.length); 152 151 arrayCopyNecessary = false; 153 152 } -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r6639 r6717 17 17 import org.openstreetmap.josm.tools.CopyList; 18 18 import org.openstreetmap.josm.tools.Pair; 19 import org.openstreetmap.josm.tools.Utils; 19 20 20 21 /** … … 425 426 clearCachedStyle(); 426 427 n.addReferrer(this); 427 Node[] newNodes = new Node[nodes.length + 1]; 428 System.arraycopy(nodes, 0, newNodes, 0, nodes.length); 429 newNodes[nodes.length] = n; 430 nodes = newNodes; 428 nodes = Utils.addInArrayCopy(nodes, n); 431 429 n.clearCachedStyle(); 432 430 fireNodesChanged(); -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r6708 r6717 17 17 import java.text.DateFormat; 18 18 import java.util.ArrayList; 19 import java.util.Arrays; 19 20 import java.util.Collection; 20 21 import java.util.Date; … … 814 815 final private void ensureTrackVisibilityLength() { 815 816 final int l = data.tracks.size(); 816 if (l == trackVisibility.length)817 if (l == trackVisibility.length) 817 818 return; 818 final boolean[] back = trackVisibility.clone(); 819 final int m = Math.min(l, back.length); 820 trackVisibility = new boolean[l]; 821 System.arraycopy(back, 0, trackVisibility, 0, m); 822 for(int i=m; i < l; i++) { 819 final int m = Math.min(l, trackVisibility.length); 820 trackVisibility = Arrays.copyOf(trackVisibility, l); 821 for (int i = m; i < l; i++) { 823 822 trackVisibility[i] = true; 824 823 } -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java
r6228 r6717 13 13 import java.awt.event.MouseEvent; 14 14 import java.awt.event.MouseListener; 15 import java.util.Arrays; 15 16 import java.util.Map; 16 17 … … 221 222 // cancel for unknown buttons and copy back original settings 222 223 if (v != 1 && v != 2) { 223 System.arraycopy(trackVisibilityBackup, 0, layer.trackVisibility, 0, layer.trackVisibility.length);224 layer.trackVisibility = Arrays.copyOf(trackVisibilityBackup, layer.trackVisibility.length); 224 225 Main.map.repaint(); 225 226 return; -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/PuwgProjectionChoice.java
r6228 r6717 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.util.Arrays; 6 7 import java.util.Collection; 7 8 import java.util.Collections; … … 44 45 @Override 45 46 public String[] allCodes() { 46 String[] zones = new String[CODES.length]; 47 System.arraycopy(CODES, 0, zones, 0, CODES.length); 48 return zones; 47 return Arrays.copyOf(CODES, CODES.length); 49 48 } 50 49 -
trunk/src/org/openstreetmap/josm/tools/CopyList.java
r6380 r6717 3 3 4 4 import java.util.AbstractList; 5 import java.util.Arrays; 5 6 import java.util.ConcurrentModificationException; 6 7 import java.util.Iterator; … … 129 130 } 130 131 131 @SuppressWarnings("unchecked")132 132 private void ensureCapacity(int target) { 133 133 modCount++; 134 134 if (target > array.length) { 135 E[] old = array;136 137 135 int newCapacity = Math.max(target, (array.length * 3)/2 + 1); 138 array = (E[]) new Object[newCapacity]; 139 System.arraycopy(old, 0, array, 0, size); 136 array = Arrays.copyOf(array, newCapacity); 140 137 pristine = false; 141 138 } -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r6661 r6717 952 952 return result; 953 953 } 954 955 /** 956 * Adds the given item at the end of a new copy of given array. 957 * @param array The source array 958 * @param item The item to add 959 * @return An extended copy of {@code array} containing {@code item} as additional last element 960 * @since 6717 961 */ 962 public static <T> T[] addInArrayCopy(T[] array, T item) { 963 T[] biggerCopy = Arrays.copyOf(array, array.length + 1); 964 biggerCopy[array.length] = item; 965 return biggerCopy; 966 } 954 967 }
Note:
See TracChangeset
for help on using the changeset viewer.