Changeset 2626 in josm
- Timestamp:
- 2009-12-13T11:48:12+01:00 (15 years ago)
- Location:
- trunk
- Files:
-
- 52 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AddNodeAction.java
r2548 r2626 19 19 import java.text.ParsePosition; 20 20 import java.util.Locale; 21 import java.util.logging.Logger;22 21 23 22 import javax.swing.AbstractAction; … … 52 51 */ 53 52 public final class AddNodeAction extends JosmAction { 54 static private final Logger logger = Logger.getLogger(AddNodeAction.class.getName());53 //static private final Logger logger = Logger.getLogger(AddNodeAction.class.getName()); 55 54 56 55 public AddNodeAction() { … … 311 310 } 312 311 313 class TextFieldFocusHandler implements FocusListener {312 static class TextFieldFocusHandler implements FocusListener { 314 313 public void focusGained(FocusEvent e) { 315 314 Component c = e.getComponent(); -
trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java
r2610 r2626 56 56 // HelperClass 57 57 // Saves a node and two positions where to insert the node into the ways 58 private class NodeToSegs implements Comparable<NodeToSegs> {58 private static class NodeToSegs implements Comparable<NodeToSegs> { 59 59 public int pos; 60 60 public Node n; … … 71 71 return this.pos - o.pos; 72 72 } 73 74 @Override 75 public int hashCode() { 76 return pos; 77 } 78 79 @Override 80 public boolean equals(Object o) { 81 if (o instanceof NodeToSegs) 82 return compareTo((NodeToSegs) o) == 0; 83 else 84 return false; 85 } 73 86 } 74 87 75 88 // HelperClass 76 89 // Saves a relation and a role an OsmPrimitve was part of until it was stripped from all relations 77 private class RelationRole {90 private static class RelationRole { 78 91 public final Relation rel; 79 92 public final String role; -
trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
r2596 r2626 37 37 public final class OrthogonalizeAction extends JosmAction { 38 38 String USAGE = "<h3>"+ 39 40 41 42 39 "When one or more ways are selected, the shape is adjusted, such that all angles are 90 or 180 degrees.<h3>"+ 40 "You can add two nodes to the selection. Then the direction is fixed by these two reference nodes.<h3>"+ 41 "(Afterwards, you can undo the movement for certain nodes:<br>"+ 42 "Select them and press the shortcut for Orthogonalize / Undo. The default is Shift-Q.)"; 43 43 44 44 public OrthogonalizeAction() { … … 72 72 * This action can be triggered by shortcut only. 73 73 */ 74 public class Undo extends JosmAction {74 public static class Undo extends JosmAction { 75 75 public Undo() { 76 76 super(tr("Orthogonalize Shape / Undo"), 77 "ortho",78 tr("Undo orthogonalization for certain nodes"),79 Shortcut.registerShortcut("tools:orthogonalizeUndo", tr("Tool: {0}", tr("Orthogonalize Shape / Undo")),80 KeyEvent.VK_Q,81 Shortcut.GROUP_EDIT, Shortcut.SHIFT_DEFAULT), true);77 "ortho", 78 tr("Undo orthogonalization for certain nodes"), 79 Shortcut.registerShortcut("tools:orthogonalizeUndo", tr("Tool: {0}", tr("Orthogonalize Shape / Undo")), 80 KeyEvent.VK_Q, 81 Shortcut.GROUP_EDIT, Shortcut.SHIFT_DEFAULT), true); 82 82 } 83 83 public void actionPerformed(ActionEvent e) { … … 103 103 catch (InvalidUserInputException ex) { 104 104 JOptionPane.showMessageDialog( 105 Main.parent,106 tr("Orthogonalize Shape / Undo\n"+105 Main.parent, 106 tr("Orthogonalize Shape / Undo\n"+ 107 107 "Please select nodes that were moved by the previous Orthogonalize Shape action!"), 108 tr("Undo Orthogonalize Shape"),109 JOptionPane.INFORMATION_MESSAGE);108 tr("Undo Orthogonalize Shape"), 109 JOptionPane.INFORMATION_MESSAGE); 110 110 } 111 111 } … … 143 143 else if (p instanceof Way) { 144 144 wayDataList.add(new WayData((Way) p)); 145 } 146 else { // maybe a relation got selected... 145 } else 147 146 throw new InvalidUserInputException("Selection must consist only of ways and nodes."); 148 } 149 } 150 if (wayDataList.isEmpty()) { 147 } 148 if (wayDataList.isEmpty()) 151 149 throw new InvalidUserInputException("usage"); 152 }153 150 else { 154 151 if (nodeList.size() == 2 || nodeList.isEmpty()) { … … 186 183 } else 187 184 throw new IllegalStateException(); 188 185 189 186 Main.main.undoRedo.add(new SequenceCommand(tr("Orthogonalize"), commands)); 190 187 Main.map.repaint(); 191 188 192 189 } else 193 190 throw new InvalidUserInputException("usage"); … … 196 193 if (ex.getMessage().equals("usage")) { 197 194 JOptionPane.showMessageDialog( 198 Main.parent,199 "<html><h2>"+tr("Usage")+tr(USAGE),200 tr("Orthogonalize Shape"),201 JOptionPane.INFORMATION_MESSAGE);195 Main.parent, 196 "<html><h2>"+tr("Usage")+tr(USAGE), 197 tr("Orthogonalize Shape"), 198 JOptionPane.INFORMATION_MESSAGE); 202 199 } 203 200 else { 204 201 JOptionPane.showMessageDialog( 205 Main.parent,206 "<html><h3>"+tr(ex.getMessage())+"<br><hr><h3>"+tr("Usage")+tr(USAGE),207 tr("Selected Elements cannot be orthogonalized"),208 JOptionPane.INFORMATION_MESSAGE);202 Main.parent, 203 "<html><h3>"+tr(ex.getMessage())+"<br><hr><h3>"+tr("Usage")+tr(USAGE), 204 tr("Selected Elements cannot be orthogonalized"), 205 JOptionPane.INFORMATION_MESSAGE); 209 206 } 210 207 } … … 232 229 **/ 233 230 private static Collection<Command> orthogonalize(ArrayList<WayData> wayDataList, ArrayList<Node> headingNodes) 234 231 throws InvalidUserInputException 235 232 { 236 233 // find average heading … … 263 260 } catch (RejectedAngleException ex) { 264 261 throw new InvalidUserInputException( 265 "<html>Please make sure all selected ways head in a similar direction<br>"+266 262 "<html>Please make sure all selected ways head in a similar direction<br>"+ 263 "or orthogonalize them one by one."); 267 264 } 268 265 … … 302 299 int s_size = s.size(); 303 300 for (int dummy = 0; dummy < s_size; ++ dummy) { 304 if (s.isEmpty()) break; 301 if (s.isEmpty()) { 302 break; 303 } 305 304 final Node dummy_n = s.iterator().next(); // pick arbitrary element of s 306 305 … … 357 356 // rotate back and log the change 358 357 final Collection<Command> commands = new LinkedList<Command>(); 359 // OrthogonalizeAction.rememberMovements.clear();358 // OrthogonalizeAction.rememberMovements.clear(); 360 359 for (Node n: allNodes) { 361 360 EastNorth tmp = new EastNorth(nX.get(n), nY.get(n)); … … 366 365 final double EPSILON = 1E-6; 367 366 if (Math.abs(dx) > Math.abs(EPSILON * tmp.east()) || 368 Math.abs(dy) > Math.abs(EPSILON * tmp.east())) {367 Math.abs(dy) > Math.abs(EPSILON * tmp.east())) 369 368 throw new AssertionError(); 370 }371 369 } 372 370 else { … … 386 384 final public int nNode; // Number of Nodes of the Way 387 385 public Direction[] segDirections; // Direction of the segments 388 386 // segment i goes from node i to node (i+1) 389 387 public EastNorth segSum; // (Vector-)sum of all horizontal segments plus the sum of all vertical 390 388 // segments turned by 90 degrees 391 389 public double heading; // heading of segSum == approximate heading of the way 392 390 public WayData(Way pWay) { … … 422 420 // sum up segments 423 421 EastNorth h = new EastNorth(0.,0.); 424 double lh = EN.abs(h);422 //double lh = EN.abs(h); 425 423 EastNorth v = new EastNorth(0.,0.); 426 double lv = EN.abs(v);424 //double lv = EN.abs(v); 427 425 for (int i = 0; i < nSeg; ++i) { 428 426 EastNorth segment = EN.diff(en[i+1], en[i]); 429 if (segDirections[i] == Direction.RIGHT) h = EN.sum(h,segment); 430 else if (segDirections[i] == Direction.UP) v = EN.sum(v,segment); 431 else if (segDirections[i] == Direction.LEFT) h = EN.diff(h,segment); 432 else if (segDirections[i] == Direction.DOWN) v = EN.diff(v,segment); 433 else throw new IllegalStateException(); 427 if (segDirections[i] == Direction.RIGHT) { 428 h = EN.sum(h,segment); 429 } else if (segDirections[i] == Direction.UP) { 430 v = EN.sum(v,segment); 431 } else if (segDirections[i] == Direction.LEFT) { 432 h = EN.diff(h,segment); 433 } else if (segDirections[i] == Direction.DOWN) { 434 v = EN.diff(v,segment); 435 } else throw new IllegalStateException(); 434 436 /** 435 437 * When summing up the length of the sum vector should increase. … … 437 439 * So only uncomment this for testing 438 440 **/ 439 // if (segDirections[i].ordinal() % 2 == 0) {440 // if (EN.abs(h) < lh) throw new AssertionError();441 // lh = EN.abs(h);442 // } else {443 // if (EN.abs(v) < lv) throw new AssertionError();444 // lv = EN.abs(v);445 // }441 // if (segDirections[i].ordinal() % 2 == 0) { 442 // if (EN.abs(h) < lh) throw new AssertionError(); 443 // lh = EN.abs(h); 444 // } else { 445 // if (EN.abs(v) < lv) throw new AssertionError(); 446 // lv = EN.abs(v); 447 // } 446 448 } 447 449 // rotate the vertical vector by 90 degrees (clockwise) and add it to the horizontal vector 448 450 segSum = EN.sum(h, new EastNorth(v.north(), - v.east())); 449 // if (EN.abs(segSum) < lh) throw new AssertionError();451 // if (EN.abs(segSum) < lh) throw new AssertionError(); 450 452 this.heading = EN.polar(new EastNorth(0.,0.), segSum); 451 453 } … … 456 458 public Direction changeBy(int directionChange) { 457 459 int tmp = (this.ordinal() + directionChange) % 4; 458 if (tmp < 0) tmp += 4; // the % operator can return negative value 460 if (tmp < 0) { 461 tmp += 4; // the % operator can return negative value 462 } 459 463 return Direction.values()[tmp]; 460 464 } … … 465 469 */ 466 470 private static double standard_angle_0_to_2PI(double a) { 467 while (a >= 2 * Math.PI) a -= 2 * Math.PI; 468 while (a < 0) a += 2 * Math.PI; 471 while (a >= 2 * Math.PI) { 472 a -= 2 * Math.PI; 473 } 474 while (a < 0) { 475 a += 2 * Math.PI; 476 } 469 477 return a; 470 478 } … … 474 482 */ 475 483 private static double standard_angle_mPI_to_PI(double a) { 476 while (a > Math.PI) a -= 2 * Math.PI; 477 while (a <= - Math.PI) a += 2 * Math.PI; 484 while (a > Math.PI) { 485 a -= 2 * Math.PI; 486 } 487 while (a <= - Math.PI) { 488 a += 2 * Math.PI; 489 } 478 490 return a; 479 491 } … … 499 511 return new EastNorth(en1.east() - en2.east(), en1.north() - en2.north()); 500 512 } 501 public static double abs(EastNorth en) {502 return Math.sqrt(en.east() * en.east() + en.north() * en.north());503 }504 public static String toString(EastNorth en) {505 return "["+u(en.east())+","+u(en.north())+"]";506 }507 public static long u(double d) {508 return Math.round(d * 1000000.);509 }510 513 public static double polar(EastNorth en1, EastNorth en2) { 511 514 return Math.atan2(en2.north() - en1.north(), en2.east() - en1.east()); … … 523 526 double d_m90 = Math.abs(a + Math.PI / 2); 524 527 int dirChange; 525 if (d0 < deltaMax) dirChange = 0; 526 else if (d90 < deltaMax) dirChange = 1; 527 else if (d_m90 < deltaMax) dirChange = -1; 528 else { 528 if (d0 < deltaMax) { 529 dirChange = 0; 530 } else if (d90 < deltaMax) { 531 dirChange = 1; 532 } else if (d_m90 < deltaMax) { 533 dirChange = -1; 534 } else { 529 535 a = standard_angle_0_to_2PI(a); 530 536 double d180 = Math.abs(a - Math.PI); 531 if (d180 < deltaMax) dirChange = 2; 532 else { 537 if (d180 < deltaMax) { 538 dirChange = 2; 539 } else 533 540 throw new RejectedAngleException(); 534 }535 541 } 536 542 return dirChange; -
trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
r2598 r2626 38 38 MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader(); 39 39 reader.append(getCurrentDataSet(),id, type); 40 DataSet ds = null;41 40 try { 42 ds = reader.parseOsm(NullProgressMonitor.INSTANCE); 41 DataSet ds = reader.parseOsm(NullProgressMonitor.INSTANCE); 42 Main.map.mapView.getEditLayer().mergeFrom(ds); 43 43 } catch(Exception e) { 44 44 ExceptionDialogUtil.explainException(e); 45 45 } 46 Main.map.mapView.getEditLayer().mergeFrom(ds);47 46 } 48 47 -
trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java
r2609 r2626 244 244 OsmPrimitive targetMember = getMergeTarget(sourceMember.getMember()); 245 245 if (targetMember == null) 246 throw new IllegalStateException(tr("Missing merge target of type {0} with id {1}", targetMember.getType(), targetMember.getUniqueId()));246 throw new IllegalStateException(tr("Missing merge target of type {0} with id {1}", sourceMember.getType(), sourceMember.getUniqueId())); 247 247 if (! targetMember.isDeleted() && targetMember.isVisible()) { 248 248 RelationMember newMember = new RelationMember(sourceMember.getRole(), targetMember); -
trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java
r2512 r2626 636 636 } 637 637 if (!canRemove()) { 638 abort("attempt to remove non-empty child: " + this.content + " " + this.children);638 abort("attempt to remove non-empty child: " + this.content + " " + Arrays.toString(this.children)); 639 639 } 640 640 parent.children[i] = null; -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryOsmPrimitive.java
r2512 r2626 113 113 if (this.id != o.id) 114 114 throw new ClassCastException(tr("Can''t compare primitive with ID ''{0}'' to primitive with ID ''{1}''.", o.id, this.id)); 115 return new Long(this.version).compareTo(o.version);115 return Long.valueOf(this.version).compareTo(o.version); 116 116 } 117 117 … … 159 159 if (this == obj) 160 160 return true; 161 if ( obj == null)161 if (!(obj instanceof HistoryOsmPrimitive)) 162 162 return false; 163 163 // equal semantics is valid for subclasses like {@see HistoryOsmNode} etc. too. -
trunk/src/org/openstreetmap/josm/gui/BookmarkList.java
r2512 r2626 83 83 } 84 84 85 class BookmarkCellRenderer extends JLabel implements ListCellRenderer {85 static class BookmarkCellRenderer extends JLabel implements ListCellRenderer { 86 86 87 87 private ImageIcon icon; -
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r2602 r2626 282 282 protected Dimension findMaxDialogSize() { 283 283 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 284 Dimension x = new Dimension(Math.round(screenSize.width*2/3), 285 Math.round(screenSize.height*2/3)); 284 Dimension x = new Dimension(screenSize.width*2/3, screenSize.height*2/3); 286 285 try { 287 286 if(parent != null) { … … 420 419 // Make it not wider than 1/2 of the screen 421 420 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 422 lbl.setMaxWidth( Math.round(screenSize.width*1/2));421 lbl.setMaxWidth(screenSize.width/2); 423 422 return lbl; 424 423 } -
trunk/src/org/openstreetmap/josm/gui/FileDrop.java
r2512 r2626 16 16 import org.openstreetmap.josm.Main; 17 17 import org.openstreetmap.josm.actions.OpenFileAction; 18 19 import org.openstreetmap.josm.gui.FileDrop.TransferableObject;20 18 21 19 /** … … 438 436 { support = false; 439 437 } // end catch 440 supportsDnD = new Boolean( support );438 supportsDnD = support; 441 439 } // end if: first time through 442 440 return supportsDnD.booleanValue(); -
trunk/src/org/openstreetmap/josm/gui/GettingStarted.java
r2358 r2626 27 27 + "body { font-family: sans-serif; font-weight: bold; }\n" + "h1 {text-align: center;}\n" + "</style>\n"; 28 28 29 public class LinkGeneral extends JEditorPane implements HyperlinkListener {29 public static class LinkGeneral extends JEditorPane implements HyperlinkListener { 30 30 public LinkGeneral(String text) { 31 31 setContentType("text/html"); … … 46 46 * Grabs current MOTD from cache or webpage and parses it. 47 47 */ 48 private class MotdContent extends CacheCustomContent {48 private static class MotdContent extends CacheCustomContent { 49 49 public MotdContent() { 50 50 super("motd.html", CacheCustomContent.INTERVAL_DAILY); -
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r2621 r2626 69 69 import org.openstreetmap.josm.actions.ZoomInAction; 70 70 import org.openstreetmap.josm.actions.ZoomOutAction; 71 import org.openstreetmap.josm.actions.OrthogonalizeAction.Undo; 71 72 import org.openstreetmap.josm.actions.audio.AudioBackAction; 72 73 import org.openstreetmap.josm.actions.audio.AudioFasterAction; … … 132 133 public final JosmAction distribute = new DistributeAction(); 133 134 public final OrthogonalizeAction ortho = new OrthogonalizeAction(); 134 public final JosmAction orthoUndo = ortho.new Undo(); // action is not shown in the menu. Only triggered by shortcut135 public final JosmAction orthoUndo = new Undo(); // action is not shown in the menu. Only triggered by shortcut 135 136 public final JosmAction mirror = new MirrorAction(); 136 137 public final AddNodeAction addnode = new AddNodeAction(); … … 306 307 } 307 308 308 class PresetsMenuEnabler implements MapView.LayerChangeListener {309 static class PresetsMenuEnabler implements MapView.LayerChangeListener { 309 310 private JMenu presetsMenu; 310 311 public PresetsMenuEnabler(JMenu presetsMenu) { -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r2575 r2626 74 74 * a fixed text content to the right of the image. 75 75 */ 76 class ImageLabel extends JPanel {76 static class ImageLabel extends JPanel { 77 77 private JLabel tf; 78 78 private int chars; … … 486 486 * @author imi 487 487 */ 488 class MouseState {488 static class MouseState { 489 489 Point mousePos; 490 490 int modifiers; -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r2622 r2626 398 398 if (l1 == getActiveLayer()) return -1; 399 399 if (l2 == getActiveLayer()) return 1; 400 return new Integer(layers.indexOf(l1)).compareTo(layers.indexOf(l2));400 return Integer.valueOf(layers.indexOf(l1)).compareTo(layers.indexOf(l2)); 401 401 } else 402 return new Integer(layers.indexOf(l1)).compareTo(layers.indexOf(l2));402 return Integer.valueOf(layers.indexOf(l1)).compareTo(layers.indexOf(l2)); 403 403 } 404 404 } -
trunk/src/org/openstreetmap/josm/gui/actionsupport/DeleteFromRelationConfirmationDialog.java
r2565 r2626 220 220 cmp = o1.getParent().getDisplayName(nf).compareTo(o2.getParent().getDisplayName(nf)); 221 221 if (cmp != 0) return cmp; 222 return new Integer(o1.getPosition()).compareTo(o2.getPosition());222 return Integer.valueOf(o1.getPosition()).compareTo(o2.getPosition()); 223 223 } 224 224 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMerger.java
r2512 r2626 20 20 import java.util.Observable; 21 21 import java.util.Observer; 22 import java.util.logging.Logger;23 22 24 23 import javax.swing.AbstractAction; … … 774 773 mergedEntriesTable.getSelectionModel().clearSelection(); 775 774 mergedEntriesTable.setEnabled(!newValue); 776 if (freezeAction != null) { 777 freezeAction.putValue(FreezeActionProperties.PROP_SELECTED, newValue); 778 } 775 freezeAction.putValue(FreezeActionProperties.PROP_SELECTED, newValue); 779 776 if (newValue) { 780 777 lblFrozenState.setText( -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMerger.java
r2512 r2626 307 307 * 308 308 */ 309 class AdjustmentSynchronizer implements AdjustmentListener {309 static class AdjustmentSynchronizer implements AdjustmentListener { 310 310 private final ArrayList<Adjustable> synchronizedAdjustables; 311 311 -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolverDialog.java
r2512 r2626 1 1 package org.openstreetmap.josm.gui.conflict.tags; 2 2 3 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;5 5 6 6 import java.awt.BorderLayout; … … 399 399 } 400 400 401 class AutoAdjustingSplitPane extends JSplitPane implements PropertyChangeListener, HierarchyBoundsListener {401 static class AutoAdjustingSplitPane extends JSplitPane implements PropertyChangeListener, HierarchyBoundsListener { 402 402 private double dividerLocation; 403 403 -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverModel.java
r2565 r2626 160 160 references = references == null ? new LinkedList<RelationToChildReference>() : references; 161 161 decisions.clear(); 162 if (references.isEmpty()) { 163 this.relations = new HashSet<Relation>(references.size()); 164 } else { 165 this.relations = new HashSet<Relation>(references.size()); 166 } 162 this.relations = new HashSet<Relation>(references.size()); 167 163 for (RelationToChildReference reference: references) { 168 164 decisions.add(new RelationMemberConflictDecision(reference.getParent(), reference.getPosition())); -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java
r2621 r2626 179 179 * Action for canceling conflict resolution 180 180 */ 181 class HelpAction extends AbstractAction {181 static class HelpAction extends AbstractAction { 182 182 public HelpAction() { 183 183 putValue(Action.SHORT_DESCRIPTION, tr("Show help information")); -
trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java
r2621 r2626 30 30 import org.openstreetmap.josm.gui.MapView; 31 31 import org.openstreetmap.josm.gui.SideButton; 32 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;33 32 import org.openstreetmap.josm.gui.layer.DataChangeListener; 34 33 import org.openstreetmap.josm.gui.layer.Layer; … … 204 203 } 205 204 206 class StringRenderer extends DefaultTableCellRenderer {205 static class StringRenderer extends DefaultTableCellRenderer { 207 206 @Override 208 207 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row,int column) { … … 214 213 } 215 214 216 class BooleanRenderer extends JCheckBox implements TableCellRenderer {215 static class BooleanRenderer extends JCheckBox implements TableCellRenderer { 217 216 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row,int column) { 218 217 Filters model = (Filters)table.getModel(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r2621 r2626 43 43 import org.openstreetmap.josm.gui.MapView; 44 44 import org.openstreetmap.josm.gui.SideButton; 45 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;46 45 import org.openstreetmap.josm.gui.io.SaveLayersDialog; 47 46 import org.openstreetmap.josm.gui.layer.Layer; … … 497 496 * 498 497 */ 499 class LayerListCellRenderer extends DefaultListCellRenderer {498 static class LayerListCellRenderer extends DefaultListCellRenderer { 500 499 501 500 protected boolean isActiveLayer(Layer layer) { … … 621 620 * the properties {@see Layer#VISIBLE_PROP} and {@see Layer#NAME_PROP}. 622 621 */ 623 public class LayerListModel extends DefaultListModel implements MapView.LayerChangeListener, PropertyChangeListener{622 public static class LayerListModel extends DefaultListModel implements MapView.LayerChangeListener, PropertyChangeListener{ 624 623 625 624 /** manages list selection state*/ … … 1010 1009 } 1011 1010 1012 class LayerList extends JList {1011 static class LayerList extends JList { 1013 1012 public LayerList(ListModel dataModel) { 1014 1013 super(dataModel); -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r2623 r2626 339 339 * 340 340 */ 341 class NewAction extends AbstractAction implements MapView.LayerChangeListener{341 static class NewAction extends AbstractAction implements MapView.LayerChangeListener{ 342 342 public NewAction() { 343 343 putValue(SHORT_DESCRIPTION,tr("Create a new relation")); -
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r2621 r2626 46 46 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 47 47 import org.openstreetmap.josm.gui.SideButton; 48 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;49 48 import org.openstreetmap.josm.gui.layer.Layer; 50 49 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 356 355 * @author Jan Peter Stotz 357 356 */ 358 protected class SearchMenuItem extends JMenuItem implements ActionListener {357 protected static class SearchMenuItem extends JMenuItem implements ActionListener { 359 358 protected SearchSetting s; 360 359 -
trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
r2621 r2626 43 43 import org.openstreetmap.josm.gui.MapView; 44 44 import org.openstreetmap.josm.gui.SideButton; 45 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;46 45 import org.openstreetmap.josm.gui.layer.Layer; 47 46 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 273 272 * 274 273 */ 275 class UserTableModel extends DefaultTableModel {274 static class UserTableModel extends DefaultTableModel { 276 275 private ArrayList<UserInfo> data; 277 276 -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetInSelectionListModel.java
r2621 r2626 9 9 import org.openstreetmap.josm.data.osm.OsmPrimitive; 10 10 import org.openstreetmap.josm.gui.MapView; 11 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;12 11 import org.openstreetmap.josm.gui.layer.Layer; 13 12 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 31 30 if (newLayer == null || ! (newLayer instanceof OsmDataLayer)) { 32 31 setChangesets(null); 33 } else if (newLayer instanceof OsmDataLayer){32 } else { 34 33 initFromPrimitives(((OsmDataLayer) newLayer).data.getSelected()); 35 34 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r2621 r2626 582 582 } 583 583 584 class AddAbortException extends Exception {584 static class AddAbortException extends Exception { 585 585 } 586 586 -
trunk/src/org/openstreetmap/josm/gui/download/BookmarkSelection.java
r2512 r2626 152 152 currentArea.getMax().latToString(CoordinateFormat.DECIMAL_DEGREES), 153 153 currentArea.getMax().lonToString(CoordinateFormat.DECIMAL_DEGREES) 154 154 ) 155 155 ); 156 156 } … … 167 167 bookmarks.clearSelection(); 168 168 updateDownloadAreaLabel(); 169 actAdd.setEnabled( area != null);169 actAdd.setEnabled(true); 170 170 } 171 171 … … 194 194 b.setName( 195 195 JOptionPane.showInputDialog( 196 Main.parent,tr("Please enter a name for the bookmarked download area."),197 tr("Name of location"),198 JOptionPane.QUESTION_MESSAGE)196 Main.parent,tr("Please enter a name for the bookmarked download area."), 197 tr("Name of location"), 198 JOptionPane.QUESTION_MESSAGE) 199 199 ); 200 200 b.setArea(currentArea); … … 208 208 class RemoveAction extends AbstractAction implements ListSelectionListener{ 209 209 public RemoveAction() { 210 //putValue(NAME, tr("Remove"));210 //putValue(NAME, tr("Remove")); 211 211 putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete")); 212 212 putValue(SHORT_DESCRIPTION, tr("Remove the currently selected bookmarks")); … … 216 216 public void actionPerformed(ActionEvent e) { 217 217 Object[] sels = bookmarks.getSelectedValues(); 218 if (sels == null || sels.length == 0) { 219 return; 220 } 218 if (sels == null || sels.length == 0) 219 return; 221 220 for (Object sel: sels) { 222 221 ((DefaultListModel)bookmarks.getModel()).removeElement(sel); … … 234 233 class RenameAction extends AbstractAction implements ListSelectionListener{ 235 234 public RenameAction() { 236 //putValue(NAME, tr("Remove"));235 //putValue(NAME, tr("Remove")); 237 236 putValue(SMALL_ICON, ImageProvider.get("dialogs", "edit")); 238 237 putValue(SHORT_DESCRIPTION, tr("Rename the currently selected bookmark")); … … 242 241 public void actionPerformed(ActionEvent e) { 243 242 Object[] sels = bookmarks.getSelectedValues(); 244 if (sels == null || sels.length != 1) { 245 return; 246 } 243 if (sels == null || sels.length != 1) 244 return; 247 245 Bookmark b = (Bookmark)sels[0]; 248 246 Object value = 249 250 Main.parent,tr("Please enter a name for the bookmarked download area."),251 tr("Name of location"),252 JOptionPane.QUESTION_MESSAGE,253 null,254 null,255 b.getName()256 247 JOptionPane.showInputDialog( 248 Main.parent,tr("Please enter a name for the bookmarked download area."), 249 tr("Name of location"), 250 JOptionPane.QUESTION_MESSAGE, 251 null, 252 null, 253 b.getName() 254 ); 257 255 if (value != null) { 258 256 b.setName(value.toString()); -
trunk/src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java
r2512 r2626 269 269 } 270 270 271 class SelectAllOnFocusHandler extends FocusAdapter {271 static class SelectAllOnFocusHandler extends FocusAdapter { 272 272 private JTextComponent tfTarget; 273 273 public SelectAllOnFocusHandler(JTextComponent tfTarget) { -
trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java
r2512 r2626 144 144 145 145 public void setDownloadArea(Bounds area) { 146 tblSearchResults.clearSelection();146 tblSearchResults.clearSelection(); 147 147 } 148 148 … … 166 166 new LatLon(lat - size / 2, lon - size), 167 167 new LatLon(lat + size / 2, lon+ size) 168 168 ); 169 169 return b; 170 170 } … … 176 176 * 177 177 */ 178 private class NameFinderResultParser extends DefaultHandler {178 private static class NameFinderResultParser extends DefaultHandler { 179 179 private SearchResult currentResult = null; 180 180 private StringBuffer description = null; … … 188 188 @Override 189 189 public void startElement(String namespaceURI, String localName, String qName, Attributes atts) 190 190 throws SAXException { 191 191 depth++; 192 192 try { … … 323 323 try { 324 324 getProgressMonitor().indeterminateSubTask(tr("Querying name server ...")); 325 326 327 328 329 330 331 332 333 334 335 325 URL url = new URL("http://gazetteer.openstreetmap.org/namefinder/search.xml?find=" 326 +java.net.URLEncoder.encode(searchExpression, "UTF-8")); 327 synchronized(this) { 328 connection = (HttpURLConnection)url.openConnection(); 329 } 330 connection.setConnectTimeout(15000); 331 InputStream inputStream = connection.getInputStream(); 332 InputSource inputSource = new InputSource(new InputStreamReader(inputStream, "UTF-8")); 333 NameFinderResultParser parser = new NameFinderResultParser(); 334 SAXParserFactory.newInstance().newSAXParser().parse(inputSource, parser); 335 this.data = parser.getResult(); 336 336 } catch(Exception e) { 337 if (canceled) {337 if (canceled) 338 338 // ignore exception 339 339 return; 340 }341 340 lastException = e; 342 341 } … … 344 343 } 345 344 346 class NamedResultTableModel extends DefaultTableModel {345 static class NamedResultTableModel extends DefaultTableModel { 347 346 private ArrayList<SearchResult> data; 348 347 private ListSelectionModel selectionModel; … … 378 377 379 378 public SearchResult getSelectedSearchResult() { 380 if (selectionModel.getMinSelectionIndex() < 0) {379 if (selectionModel.getMinSelectionIndex() < 0) 381 380 return null; 382 }383 381 return data.get(selectionModel.getMinSelectionIndex()); 384 382 } … … 442 440 } 443 441 444 class NamedResultCellRenderer extends JLabel implements TableCellRenderer {442 static class NamedResultCellRenderer extends JLabel implements TableCellRenderer { 445 443 446 444 public NamedResultCellRenderer() { -
trunk/src/org/openstreetmap/josm/gui/help/HelpBrowser.java
r2512 r2626 399 399 } 400 400 401 class BackAction extends AbstractAction implements Observer {401 static class BackAction extends AbstractAction implements Observer { 402 402 private HelpBrowserHistory history; 403 403 public BackAction(HelpBrowserHistory history) { … … 419 419 } 420 420 421 class ForwardAction extends AbstractAction implements Observer {421 static class ForwardAction extends AbstractAction implements Observer { 422 422 private HelpBrowserHistory history; 423 423 public ForwardAction(HelpBrowserHistory history) { -
trunk/src/org/openstreetmap/josm/gui/help/HelpUtil.java
r2512 r2626 157 157 ret += "/" + topic; 158 158 } 159 ret .replaceAll("\\/+", "\\/"); // just in case, collapse sequences of //159 ret = ret.replaceAll("\\/+", "\\/"); // just in case, collapse sequences of // 160 160 return ret; 161 161 } -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
r2622 r2626 881 881 * 882 882 */ 883 class HistoryPrimitiveBuilder extends AbstractVisitor {883 static class HistoryPrimitiveBuilder extends AbstractVisitor { 884 884 private HistoryOsmPrimitive clone; 885 885 -
trunk/src/org/openstreetmap/josm/gui/history/NodeListViewer.java
r2512 r2626 169 169 } 170 170 171 class NodeListPopupMenu extends JPopupMenu {171 static class NodeListPopupMenu extends JPopupMenu { 172 172 private ZoomToNodeAction zoomToNodeAction; 173 173 private ShowHistoryAction showHistoryAction; … … 189 189 } 190 190 191 class ZoomToNodeAction extends AbstractAction {191 static class ZoomToNodeAction extends AbstractAction { 192 192 private PrimitiveId primitiveId; 193 193 … … 235 235 } 236 236 237 class ShowHistoryAction extends AbstractAction {237 static class ShowHistoryAction extends AbstractAction { 238 238 private PrimitiveId primitiveId; 239 239 … … 302 302 } 303 303 304 class DoubleClickAdapter extends MouseAdapter {304 static class DoubleClickAdapter extends MouseAdapter { 305 305 private JTable table; 306 306 private ShowHistoryAction showHistoryAction; -
trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java
r2556 r2626 9 9 import java.util.Observable; 10 10 import java.util.Observer; 11 import java.util.logging.Logger;12 11 13 12 import javax.swing.DefaultListSelectionModel; … … 28 27 */ 29 28 public class VersionTable extends JTable implements Observer{ 29 //private static Logger logger = Logger.getLogger(VersionTable.class.getName()); 30 30 31 private static Logger logger = Logger.getLogger(VersionTable.class.getName());32 31 private VersionTablePopupMenu popupMenu; 33 32 … … 114 113 } 115 114 116 class ChangesetInfoAction extends AbstractInfoAction {115 static class ChangesetInfoAction extends AbstractInfoAction { 117 116 private HistoryOsmPrimitive primitive; 118 117 … … 143 142 } 144 143 145 class VersionTablePopupMenu extends JPopupMenu {144 static class VersionTablePopupMenu extends JPopupMenu { 146 145 147 146 private ChangesetInfoAction changesetInfoAction; -
trunk/src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java
r2614 r2626 235 235 if (strategy == null) return; 236 236 rbStrategy.get(strategy.getStrategy()).setSelected(true); 237 tfChunkSize.setEnabled(strategy. equals(UploadStrategy.CHUNKED_DATASET_STRATEGY));237 tfChunkSize.setEnabled(strategy.getStrategy() == UploadStrategy.CHUNKED_DATASET_STRATEGY); 238 238 if (strategy.getStrategy().equals(UploadStrategy.CHUNKED_DATASET_STRATEGY)) { 239 239 if (strategy.getChunkSize() != UploadStrategySpecification.UNSPECIFIED_CHUNK_SIZE) { … … 380 380 } 381 381 382 class TextFieldFocusHandler implements FocusListener {382 static class TextFieldFocusHandler implements FocusListener { 383 383 public void focusGained(FocusEvent e) { 384 384 Component c = e.getComponent(); -
trunk/src/org/openstreetmap/josm/gui/io/UploadedObjectsSummaryPanel.java
r2599 r2626 154 154 * 155 155 */ 156 class PrimitiveListModel extends AbstractListModel{156 static class PrimitiveListModel extends AbstractListModel{ 157 157 private List<OsmPrimitive> primitives; 158 158 -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r2592 r2626 85 85 private boolean isLocalFile; 86 86 87 private class Markers {87 private static class Markers { 88 88 public boolean timedMarkersOmitted = false; 89 89 public boolean untimedMarkersOmitted = false; -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
r2617 r2626 63 63 import org.openstreetmap.josm.gui.layer.GpxLayer; 64 64 import org.openstreetmap.josm.gui.layer.Layer; 65 import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer.ImageEntry; 65 66 import org.openstreetmap.josm.io.GpxReader; 66 import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer.ImageEntry;67 67 import org.openstreetmap.josm.tools.ExifReader; 68 68 import org.openstreetmap.josm.tools.GBC; … … 98 98 } 99 99 100 @Override 100 101 public String toString() { 101 102 return name; … … 154 155 tr("Error"), 155 156 JOptionPane.ERROR_MESSAGE 156 157 ); 157 158 } 158 159 return; … … 178 179 tr("Error"), 179 180 JOptionPane.ERROR_MESSAGE 180 181 ); 181 182 return; 182 183 } catch (IOException x) { … … 187 188 tr("Error"), 188 189 JOptionPane.ERROR_MESSAGE 189 190 ); 190 191 return; 191 192 } … … 224 225 panel.setLayout(new BorderLayout()); 225 226 panel.add(new JLabel(tr("<html>Take a photo of your GPS receiver while it displays the time.<br>" 226 227 228 227 + "Display that photo here.<br>" 228 + "And then, simply capture the time you read on the photo and select a timezone<hr></html>")), 229 BorderLayout.NORTH); 229 230 230 231 imgDisp = new ImageDisplay(); … … 285 286 286 287 String tzDesc = new StringBuffer(tzStr).append(" (") 287 288 288 .append(formatTimezone(tz.getRawOffset() / 3600000.0)) 289 .append(')').toString(); 289 290 vtTimezones.add(tzDesc); 290 291 } … … 359 360 fc.showOpenDialog(Main.parent); 360 361 File sel = fc.getSelectedFile(); 361 if (sel == null) {362 if (sel == null) 362 363 return; 363 }364 364 365 365 imgDisp.setImage(sel); … … 392 392 JOptionPane.OK_CANCEL_OPTION, 393 393 JOptionPane.QUESTION_MESSAGE 394 395 if (answer == JOptionPane.CANCEL_OPTION) {394 ); 395 if (answer == JOptionPane.CANCEL_OPTION) 396 396 return; 397 }398 397 399 398 long delta; … … 401 400 try { 402 401 delta = dateFormat.parse(lbExifTime.getText()).getTime() 403 402 - dateFormat.parse(tfGpsTime.getText()).getTime(); 404 403 } catch(ParseException e) { 405 404 JOptionPane.showMessageDialog(Main.parent, tr("Error while parsing the date.\n" … … 437 436 if (cur instanceof GpxLayer) { 438 437 gpxLst.add(new GpxDataWrapper(((GpxLayer) cur).getName(), 439 440 438 ((GpxLayer) cur).data, 439 ((GpxLayer) cur).data.storageFile)); 441 440 } 442 441 } 443 442 for (GpxData data : loadedGpxData) { 444 443 gpxLst.add(new GpxDataWrapper(data.storageFile.getName(), 445 446 444 data, 445 data.storageFile)); 447 446 } 448 447 … … 510 509 511 510 JButton buttonViewGpsPhoto = new JButton(tr("<html>I can take a picture of my GPS receiver.<br>" 512 511 + "Can this help?</html>")); 513 512 buttonViewGpsPhoto.addActionListener(new SetOffsetActionListener()); 514 513 gc.gridx = 2; … … 586 585 ExtendedDialog dialog = new ExtendedDialog( 587 586 Main.parent, 588 tr("Correlate images with GPX track"),589 new String[] { tr("Correlate"), tr("Auto-Guess"), tr("Cancel") }590 587 tr("Correlate images with GPX track"), 588 new String[] { tr("Correlate"), tr("Auto-Guess"), tr("Cancel") } 589 ); 591 590 592 591 dialog.setContent(panel); … … 602 601 if (item == null || ! (item instanceof GpxDataWrapper)) { 603 602 JOptionPane.showMessageDialog(Main.parent, tr("You should select a GPX track"), 604 603 tr("No selected GPX track"), JOptionPane.ERROR_MESSAGE ); 605 604 continue; 606 605 } … … 623 622 if (deltaText.length() > 0) { 624 623 try { 625 if(deltaText.startsWith("+")) 624 if(deltaText.startsWith("+")) { 626 625 deltaText = deltaText.substring(1); 626 } 627 627 delta = Long.parseLong(deltaText); 628 628 } catch(NumberFormatException nfe) { … … 681 681 tr("GPX Track loaded"), 682 682 ((dateImgLst.size() > 0 && matched == 0) ? JOptionPane.WARNING_MESSAGE 683 683 : JOptionPane.INFORMATION_MESSAGE)); 684 684 685 685 } … … 714 714 if(autoImgs.size() <= 0) { 715 715 JOptionPane.showMessageDialog(Main.parent, 716 tr("The selected photos don't contain time information."),717 tr("Photos don't contain time information"), JOptionPane.WARNING_MESSAGE);716 tr("The selected photos don't contain time information."), 717 tr("Photos don't contain time information"), JOptionPane.WARNING_MESSAGE); 718 718 return; 719 719 } … … 722 722 dialog.showDialog(); 723 723 // Will show first photo if none is selected yet 724 if(!dialog.hasImage()) 724 if(!dialog.hasImage()) { 725 725 yLayer.showNextPhoto(); 726 // FIXME: If the dialog is minimized it will not be maximized. ToggleDialog is 727 // in need of a complete re-write to allow this in a reasonable way. 726 // FIXME: If the dialog is minimized it will not be maximized. ToggleDialog is 727 // in need of a complete re-write to allow this in a reasonable way. 728 } 728 729 729 730 // Init variables … … 736 737 for (WayPoint curWp : segment) { 737 738 String curDateWpStr = (String) curWp.attr.get("time"); 738 if (curDateWpStr == null) continue; 739 if (curDateWpStr == null) { 740 continue; 741 } 739 742 740 743 try { … … 749 752 if(firstGPXDate < 0) { 750 753 JOptionPane.showMessageDialog(Main.parent, 751 tr("The selected GPX track doesn't contain timestamps. Please select another one."),752 tr("GPX Track has no time information"), JOptionPane.WARNING_MESSAGE);754 tr("The selected GPX track doesn't contain timestamps. Please select another one."), 755 tr("GPX Track has no time information"), JOptionPane.WARNING_MESSAGE); 753 756 return; 754 757 } … … 756 759 // seconds 757 760 long diff = (yLayer.hasTimeoffset) 758 759 : firstExifDate - firstGPXDate;761 ? yLayer.timeoffset 762 : firstExifDate - firstGPXDate; 760 763 yLayer.timeoffset = diff; 761 764 yLayer.hasTimeoffset = true; … … 791 794 double tz = Math.abs(sldTimezone.getValue()); 792 795 String zone = tz % 2 == 0 793 ? (int)Math.floor(tz/2) + ":00" 794 : (int)Math.floor(tz/2) + ":30"; 795 if(sldTimezone.getValue() < 0) zone = "-" + zone; 796 ? (int)Math.floor(tz/2) + ":00" 797 : (int)Math.floor(tz/2) + ":30"; 798 if(sldTimezone.getValue() < 0) { 799 zone = "-" + zone; 800 } 796 801 797 802 lblTimezone.setText(tr("Timezone: {0}", zone)); … … 807 812 808 813 long timediff = (long) (gpstimezone * 3600) 809 810 811 814 + dayOffset*24*60*60 815 + sldMinutes.getValue()*60 816 + sldSeconds.getValue(); 812 817 813 818 int matched = matchGpxTrack(autoImgs, autoGpx, timediff); 814 819 815 820 lblMatches.setText( 816 tr("Matched {0} of {1} photos to GPX track.", matched, autoImgs.size())817 + ((Math.abs(dayOffset) == 0)818 ? ""819 : " " + tr("(Time difference of {0} days)", Math.abs(dayOffset))820 )821 tr("Matched {0} of {1} photos to GPX track.", matched, autoImgs.size()) 822 + ((Math.abs(dayOffset) == 0) 823 ? "" 824 : " " + tr("(Time difference of {0} days)", Math.abs(dayOffset)) 825 ) 821 826 ); 822 827 … … 824 829 int o = Math.abs(offset); 825 830 lblOffset.setText( 826 tr("Offset between track and photos: {0}m {1}s",827 (offset < 0 ? "-" : "") + Long.toString(Math.round(o/60)),828 Long.toString(Math.round(o%60))829 )831 tr("Offset between track and photos: {0}m {1}s", 832 (offset < 0 ? "-" : "") + Long.toString(o/60), 833 Long.toString(o%60) 834 ) 830 835 ); 831 836 … … 886 891 } catch(Exception e) { 887 892 JOptionPane.showMessageDialog(Main.parent, 888 tr("An error occurred while trying to match the photos to the GPX track."889 +" You can adjust the sliders to manually match the photos."),890 tr("Matching photos to track failed"),891 JOptionPane.WARNING_MESSAGE);893 tr("An error occurred while trying to match the photos to the GPX track." 894 +" You can adjust the sliders to manually match the photos."), 895 tr("Matching photos to track failed"), 896 JOptionPane.WARNING_MESSAGE); 892 897 } 893 898 … … 904 909 // Settings are only saved temporarily to the layer. 905 910 ExtendedDialog d = new ExtendedDialog(Main.parent, 906 tr("Adjust timezone and offset"),907 new String[] { tr("Close"), tr("Default Values") }911 tr("Adjust timezone and offset"), 912 new String[] { tr("Close"), tr("Default Values") } 908 913 ); 909 914 … … 1001 1006 1002 1007 private int matchPoints(ArrayList<ImageEntry> dateImgLst, WayPoint prevWp, long prevDateWp, 1003 1008 WayPoint curWp, long curDateWp) { 1004 1009 // Time between the track point and the previous one, 5 sec if first point, i.e. photos take 1005 1010 // 5 sec before the first track point can be assumed to be take at the starting position … … 1021 1026 double distance = prevWp.getCoor().greatCircleDistance(curWp.getCoor()); 1022 1027 // This is in km/h, 3.6 * m/s 1023 if (curDateWp > prevDateWp) 1028 if (curDateWp > prevDateWp) { 1024 1029 speed = 3.6 * distance / (curDateWp - prevDateWp); 1030 } 1025 1031 try { 1026 1032 prevElevation = new Double((String) prevWp.attr.get("ele")); … … 1036 1042 if(prevDateWp == 0 || curDateWp <= prevDateWp) { 1037 1043 while(i >= 0 && (dateImgLst.get(i).time.getTime()/1000) <= curDateWp 1038 1044 && (dateImgLst.get(i).time.getTime()/1000) >= (curDateWp - interval)) { 1039 1045 if(dateImgLst.get(i).pos == null) { 1040 1046 dateImgLst.get(i).setCoor(curWp.getCoor()); … … 1060 1066 dateImgLst.get(i).speed = speed; 1061 1067 1062 if (curElevation != null && prevElevation != null) 1068 if (curElevation != null && prevElevation != null) { 1063 1069 dateImgLst.get(i).elevation = prevElevation + (curElevation - prevElevation) * timeDiff; 1070 } 1064 1071 1065 1072 ret++; … … 1087 1094 while (endIndex - startIndex > 1) { 1088 1095 curIndex= (int) Math.round((double)(endIndex + startIndex)/2); 1089 if (searchedDate > dateImgLst.get(curIndex).time.getTime()/1000) 1096 if (searchedDate > dateImgLst.get(curIndex).time.getTime()/1000) { 1090 1097 startIndex= curIndex; 1091 else1098 } else { 1092 1099 endIndex= curIndex; 1100 } 1093 1101 } 1094 1102 if (searchedDate < dateImgLst.get(endIndex).time.getTime()/1000) … … 1097 1105 // This final loop is to check if photos with the exact same EXIF time follows 1098 1106 while ((endIndex < (lstSize-1)) && (dateImgLst.get(endIndex).time.getTime() 1099 == dateImgLst.get(endIndex + 1).time.getTime()))1107 == dateImgLst.get(endIndex + 1).time.getTime())) { 1100 1108 endIndex++; 1109 } 1101 1110 return endIndex; 1102 1111 } … … 1123 1132 1124 1133 private Float parseTimezone(String timezone) { 1125 if (timezone.length() == 0) {1134 if (timezone.length() == 0) 1126 1135 return new Float(0); 1127 }1128 1136 1129 1137 char sgnTimezone = '+'; … … 1135 1143 switch (c) { 1136 1144 case ' ' : 1137 if (state != 2 || hTimezone.length() != 0) {1145 if (state != 2 || hTimezone.length() != 0) 1138 1146 return null; 1139 }1140 1147 break; 1141 1148 case '+' : … … 1144 1151 sgnTimezone = c; 1145 1152 state = 2; 1146 } else {1153 } else 1147 1154 return null; 1148 }1149 1155 break; 1150 1156 case ':' : … … 1152 1158 if (state == 2) { 1153 1159 state = 3; 1154 } else {1160 } else 1155 1161 return null; 1156 }1157 1162 break; 1158 1163 case '0' : case '1' : case '2' : case '3' : case '4' : … … 1188 1193 } 1189 1194 1190 if (h > 12 || m > 59 ) {1195 if (h > 12 || m > 59 ) 1191 1196 return null; 1192 } else {1197 else 1193 1198 return new Float((h + m / 60.0) * (sgnTimezone == '-' ? -1 : 1)); 1194 }1195 1199 } 1196 1200 } -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
r2512 r2626 446 446 } 447 447 448 public finalclass ShowHideMarkerText extends AbstractAction {448 public static final class ShowHideMarkerText extends AbstractAction { 449 449 private final Layer layer; 450 450 -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyleHandler.java
r2017 r2626 20 20 RuleElem rule = new RuleElem(); 21 21 22 class RuleElem {22 static class RuleElem { 23 23 Rule rule = new Rule(); 24 24 Collection<Rule> rules; … … 53 53 int i = colString.indexOf("#"); 54 54 Color ret; 55 if(i < 0) // name only55 if(i < 0) { 56 56 ret = Main.pref.getColor("mappaint."+styleName+"."+colString, Color.red); 57 else if(i == 0) // value only57 } else if(i == 0) { 58 58 ret = ColorHelper.html2color(colString); 59 else // value and name59 } else { 60 60 ret = Main.pref.getColor("mappaint."+styleName+"."+colString.substring(0,i), 61 ColorHelper.html2color(colString.substring(i))); 61 ColorHelper.html2color(colString.substring(i))); 62 } 62 63 return ret; 63 64 } … … 95 96 line.width = Integer.parseInt(val.substring(0, val.length()-1)); 96 97 line.widthMode = LineElemStyle.WidthMode.PERCENT; 97 } 98 else 98 } else { 99 99 line.width = Integer.parseInt(val); 100 } 101 else if (atts.getQName(count).equals("colour")) 100 } 101 } 102 else if (atts.getQName(count).equals("colour")) { 102 103 line.color=convertColor(atts.getValue(count)); 103 else if (atts.getQName(count).equals("realwidth"))104 } else if (atts.getQName(count).equals("realwidth")) { 104 105 line.realWidth=Integer.parseInt(atts.getValue(count)); 105 else if (atts.getQName(count).equals("dashed")) {106 } else if (atts.getQName(count).equals("dashed")) { 106 107 try 107 108 { … … 109 110 line.dashed = new float[parts.length]; 110 111 for (int i = 0; i < parts.length; i++) { 111 line.dashed[i] = ( float)(Integer.parseInt(parts[i]));112 line.dashed[i] = (Integer.parseInt(parts[i])); 112 113 } 113 114 } catch (NumberFormatException nfe) { … … 117 118 } 118 119 } 119 } else if (atts.getQName(count).equals("dashedcolour")) 120 } else if (atts.getQName(count).equals("dashedcolour")) { 120 121 line.dashedColor=convertColor(atts.getValue(count)); 121 else if(atts.getQName(count).equals("priority"))122 } else if(atts.getQName(count).equals("priority")) { 122 123 line.priority = Integer.parseInt(atts.getValue(count)); 123 else if(atts.getQName(count).equals("mode"))124 } else if(atts.getQName(count).equals("mode")) { 124 125 line.over = !atts.getValue(count).equals("under"); 125 else126 } else { 126 127 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 128 } 127 129 } 128 130 } … … 131 133 if (inDoc==true) 132 134 { 133 if (qName.equals("rule")) 135 if (qName.equals("rule")) { 134 136 inRule=true; 135 else if (qName.equals("rules"))137 } else if (qName.equals("rules")) 136 138 { 137 139 if(styleName == null) 138 140 { 139 141 String n = atts.getValue("name"); 140 if(n == null) n = "standard"; 142 if(n == null) { 143 n = "standard"; 144 } 141 145 styleName = n; 142 146 } 143 147 } 144 else if (qName.equals("scale_max")) 148 else if (qName.equals("scale_max")) { 145 149 inScaleMax = true; 146 else if (qName.equals("scale_min"))150 } else if (qName.equals("scale_min")) { 147 151 inScaleMin = true; 148 else if (qName.equals("condition") && inRule)152 } else if (qName.equals("condition") && inRule) 149 153 { 150 154 inCondition=true; … … 152 156 if(r.key != null) 153 157 { 154 if(rule.rules == null) 158 if(rule.rules == null) { 155 159 rule.rules = new LinkedList<Rule>(); 160 } 156 161 rule.rules.add(new Rule(rule.rule)); 157 162 r = new Rule(); … … 160 165 for (int count=0; count<atts.getLength(); count++) 161 166 { 162 if(atts.getQName(count).equals("k")) 167 if(atts.getQName(count).equals("k")) { 163 168 r.key = atts.getValue(count); 164 else if(atts.getQName(count).equals("v"))169 } else if(atts.getQName(count).equals("v")) { 165 170 r.value = atts.getValue(count); 166 else if(atts.getQName(count).equals("b"))171 } else if(atts.getQName(count).equals("b")) { 167 172 r.boolValue = atts.getValue(count); 168 else173 } else { 169 174 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 170 } 171 if(r.key == null) 175 } 176 } 177 if(r.key == null) { 172 178 error("The condition has no key!"); 179 } 173 180 } 174 181 else if (qName.equals("line")) … … 195 202 hadIcon = (icon != null); 196 203 rule.icon.icon = icon; 197 } else if (atts.getQName(count).equals("annotate")) 204 } else if (atts.getQName(count).equals("annotate")) { 198 205 rule.icon.annotate = Boolean.parseBoolean (atts.getValue(count)); 199 else if(atts.getQName(count).equals("priority"))206 } else if(atts.getQName(count).equals("priority")) { 200 207 rule.icon.priority = Integer.parseInt(atts.getValue(count)); 201 else208 } else { 202 209 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 210 } 203 211 } 204 212 } … … 208 216 for (int count=0; count<atts.getLength(); count++) 209 217 { 210 if (atts.getQName(count).equals("colour")) 218 if (atts.getQName(count).equals("colour")) { 211 219 rule.area.color=convertColor(atts.getValue(count)); 212 else if (atts.getQName(count).equals("closed"))220 } else if (atts.getQName(count).equals("closed")) { 213 221 rule.area.closed=Boolean.parseBoolean(atts.getValue(count)); 214 else if(atts.getQName(count).equals("priority"))222 } else if(atts.getQName(count).equals("priority")) { 215 223 rule.area.priority = Integer.parseInt(atts.getValue(count)); 216 else224 } else { 217 225 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 218 }219 }220 else226 } 227 } 228 } else { 221 229 error("The element \"" + qName + "\" is unknown!"); 230 } 222 231 } 223 232 } … … 230 239 { 231 240 styles.add(styleName, rule.rule, rule.rules, 232 new LineElemStyle(rule.line, rule.scaleMax, rule.scaleMin));241 new LineElemStyle(rule.line, rule.scaleMax, rule.scaleMin)); 233 242 } 234 243 if(hadLineMod) 235 244 { 236 245 styles.addModifier(styleName, rule.rule, rule.rules, 237 new LineElemStyle(rule.linemod, rule.scaleMax, rule.scaleMin));246 new LineElemStyle(rule.linemod, rule.scaleMax, rule.scaleMin)); 238 247 } 239 248 if(hadIcon) 240 249 { 241 250 styles.add(styleName, rule.rule, rule.rules, 242 new IconElemStyle(rule.icon, rule.scaleMax, rule.scaleMin));251 new IconElemStyle(rule.icon, rule.scaleMax, rule.scaleMin)); 243 252 } 244 253 if(hadArea) 245 254 { 246 255 styles.add(styleName, rule.rule, rule.rules, 247 new AreaElemStyle(rule.area, rule.scaleMax, rule.scaleMin));256 new AreaElemStyle(rule.area, rule.scaleMax, rule.scaleMin)); 248 257 } 249 258 inRule = false; … … 251 260 rule.init(); 252 261 } 253 else if (inCondition && qName.equals("condition")) 262 else if (inCondition && qName.equals("condition")) { 254 263 inCondition = false; 255 else if (inLine && qName.equals("line"))264 } else if (inLine && qName.equals("line")) { 256 265 inLine = false; 257 else if (inLineMod && qName.equals("linemod"))266 } else if (inLineMod && qName.equals("linemod")) { 258 267 inLineMod = false; 259 else if (inIcon && qName.equals("icon"))268 } else if (inIcon && qName.equals("icon")) { 260 269 inIcon = false; 261 else if (inArea && qName.equals("area"))270 } else if (inArea && qName.equals("area")) { 262 271 inArea = false; 263 else if (qName.equals("scale_max"))272 } else if (qName.equals("scale_max")) { 264 273 inScaleMax = false; 265 else if (qName.equals("scale_min"))274 } else if (qName.equals("scale_min")) { 266 275 inScaleMin = false; 276 } 267 277 } 268 278 269 279 @Override public void characters(char ch[], int start, int length) 270 280 { 271 if (inScaleMax == true) 281 if (inScaleMax == true) { 272 282 rule.scaleMax = Long.parseLong(new String(ch, start, length)); 273 else if (inScaleMin == true)283 } else if (inScaleMin == true) { 274 284 rule.scaleMin = Long.parseLong(new String(ch, start, length)); 285 } 275 286 } 276 287 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r1971 r2626 17 17 public class ElemStyles 18 18 { 19 public class StyleSet {19 public static class StyleSet { 20 20 private HashMap<String, IconElemStyle> icons; 21 21 private HashMap<String, LineElemStyle> lines; … … 46 46 if((style = icons.get("n" + key + "=" + val)) != null) 47 47 { 48 if(ret == null || style.priority > ret.priority) 48 if(ret == null || style.priority > ret.priority) { 49 49 ret = style; 50 } 50 51 } 51 52 if((style = icons.get("b" + key + "=" + OsmUtils.getNamedOsmBoolean(val))) != null) 52 53 { 53 if(ret == null || style.priority > ret.priority) 54 if(ret == null || style.priority > ret.priority) { 54 55 ret = style; 56 } 55 57 } 56 58 if((style = icons.get("x" + key)) != null) 57 59 { 58 if(ret == null || style.priority > ret.priority) 60 if(ret == null || style.priority > ret.priority) { 59 61 ret = style; 62 } 60 63 } 61 64 } 62 65 for(IconElemStyle s : iconsList) 63 66 { 64 if((ret == null || s.priority > ret.priority) && s.check(primitive)) 67 if((ret == null || s.priority > ret.priority) && s.check(primitive)) { 65 68 ret = s; 69 } 66 70 } 67 71 return ret; … … 80 84 String idx = "n" + key + "=" + val; 81 85 if((styleArea = areas.get(idx)) != null && (retArea == null 82 || styleArea.priority > retArea.priority) && (!noclosed83 || !styleArea.closed))86 || styleArea.priority > retArea.priority) && (!noclosed 87 || !styleArea.closed)) { 84 88 retArea = styleArea; 89 } 85 90 if((styleLine = lines.get(idx)) != null && (retLine == null 86 || styleLine.priority > retLine.priority))91 || styleLine.priority > retLine.priority)) 87 92 { 88 93 retLine = styleLine; 89 94 linestring = idx; 90 95 } 91 if((styleLine = modifiers.get(idx)) != null) 96 if((styleLine = modifiers.get(idx)) != null) { 92 97 over.put(idx, styleLine); 98 } 93 99 idx = "b" + key + "=" + OsmUtils.getNamedOsmBoolean(val); 94 100 if((styleArea = areas.get(idx)) != null && (retArea == null 95 || styleArea.priority > retArea.priority) && (!noclosed96 || !styleArea.closed))101 || styleArea.priority > retArea.priority) && (!noclosed 102 || !styleArea.closed)) { 97 103 retArea = styleArea; 104 } 98 105 if((styleLine = lines.get(idx)) != null && (retLine == null 99 || styleLine.priority > retLine.priority))106 || styleLine.priority > retLine.priority)) 100 107 { 101 108 retLine = styleLine; 102 109 linestring = idx; 103 110 } 104 if((styleLine = modifiers.get(idx)) != null) 111 if((styleLine = modifiers.get(idx)) != null) { 105 112 over.put(idx, styleLine); 113 } 106 114 idx = "x" + key; 107 115 if((styleArea = areas.get(idx)) != null && (retArea == null 108 || styleArea.priority > retArea.priority) && (!noclosed109 || !styleArea.closed))116 || styleArea.priority > retArea.priority) && (!noclosed 117 || !styleArea.closed)) { 110 118 retArea = styleArea; 119 } 111 120 if((styleLine = lines.get(idx)) != null && (retLine == null 112 || styleLine.priority > retLine.priority))121 || styleLine.priority > retLine.priority)) 113 122 { 114 123 retLine = styleLine; 115 124 linestring = idx; 116 125 } 117 if((styleLine = modifiers.get(idx)) != null) 126 if((styleLine = modifiers.get(idx)) != null) { 118 127 over.put(idx, styleLine); 128 } 119 129 } 120 130 for(AreaElemStyle s : areasList) 121 131 { 122 132 if((retArea == null || s.priority > retArea.priority) 123 && (!noclosed || !s.closed) && s.check(primitive))133 && (!noclosed || !s.closed) && s.check(primitive)) { 124 134 retArea = s; 135 } 125 136 } 126 137 for(LineElemStyle s : linesList) 127 138 { 128 139 if((retLine == null || s.priority > retLine.priority) 129 && s.check(primitive))140 && s.check(primitive)) { 130 141 retLine = s; 142 } 131 143 } 132 144 for(LineElemStyle s : modifiersList) 133 145 { 134 if(s.check(primitive)) 146 if(s.check(primitive)) { 135 147 over.put(s.getCode(), s); 148 } 136 149 } 137 150 over.remove(linestring); … … 155 168 { 156 169 return (!osm.hasKeys()) ? null : 157 ((osm instanceof Node) ? getNode(osm) : get(osm,158 osm instanceof Way && !((Way)osm).isClosed()));170 ((osm instanceof Node) ? getNode(osm) : get(osm, 171 osm instanceof Way && !((Way)osm).isClosed())); 159 172 } 160 173 … … 187 200 String val = o.get(key); 188 201 AreaElemStyle s = areas.get("n" + key + "=" + val); 189 if(s == null || (s.closed && noclosed)) 202 if(s == null || (s.closed && noclosed)) { 190 203 s = areas.get("b" + key + "=" + OsmUtils.getNamedOsmBoolean(val)); 191 if(s == null || (s.closed && noclosed)) 204 } 205 if(s == null || (s.closed && noclosed)) { 192 206 s = areas.get("x" + key); 207 } 193 208 if(s != null && !(s.closed && noclosed)) 194 209 return true; … … 277 292 private StyleSet getStyleSet(String name, boolean create) 278 293 { 279 if(name == null) 294 if(name == null) { 280 295 name = Main.pref.get("mappaint.style", "standard"); 296 } 281 297 282 298 StyleSet s = styleSet.get(name); -
trunk/src/org/openstreetmap/josm/gui/preferences/StyleSourceEditor.java
r2512 r2626 217 217 } 218 218 219 class AvailableStylesListModel extends DefaultListModel {219 static class AvailableStylesListModel extends DefaultListModel { 220 220 private ArrayList<StyleSourceInfo> data; 221 221 private DefaultListSelectionModel selectionModel; … … 269 269 } 270 270 271 class ActiveStylesModel extends AbstractTableModel {271 static class ActiveStylesModel extends AbstractTableModel { 272 272 private ArrayList<String> data; 273 273 private DefaultListSelectionModel selectionModel; … … 385 385 } 386 386 387 public class StyleSourceInfo {387 public static class StyleSourceInfo { 388 388 String version; 389 389 String name; … … 522 522 } 523 523 524 class IconPathTableModel extends AbstractTableModel {524 static class IconPathTableModel extends AbstractTableModel { 525 525 private ArrayList<String> data; 526 526 private DefaultListSelectionModel selectionModel; … … 675 675 } 676 676 677 class StyleSourceCellRenderer extends JLabel implements ListCellRenderer {677 static class StyleSourceCellRenderer extends JLabel implements ListCellRenderer { 678 678 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, 679 679 boolean cellHasFocus) { -
trunk/src/org/openstreetmap/josm/gui/tagging/TagTable.java
r2512 r2626 30 30 import javax.swing.table.DefaultTableColumnModel; 31 31 import javax.swing.table.TableColumn; 32 import javax.swing.table.TableColumnModel;33 32 import javax.swing.table.TableModel; 34 33 … … 394 393 if (editor == null) { 395 394 logger.warning("editor is null. cannot register OK accelator listener."); 396 } 397 editor.getEditor().addKeyListener(l); 395 } else { 396 editor.getEditor().addKeyListener(l); 397 } 398 398 } 399 399 -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r2621 r2626 667 667 } 668 668 669 private class PresetPanel extends JPanel {669 private static class PresetPanel extends JPanel { 670 670 boolean hasElements = false; 671 671 PresetPanel() -
trunk/src/org/openstreetmap/josm/io/MultiPartFormOutputStream.java
r2512 r2626 8 8 are permitted provided that the following conditions are met: 9 9 10 10 * Redistribution of source code must retain the above copyright notice, this list 11 11 of conditions and the following disclaimer. 12 12 13 13 * Redistribution in binary form must reproduce the above copyright notice, this 14 14 list of conditions and the following disclaimer in the documentation and/or other 15 15 materials provided with the distribution. … … 31 31 You acknowledge that this software is not designed, licensed or intended for use in the 32 32 design, construction, operation or maintenance of any nuclear facility. 33 */33 */ 34 34 35 35 package org.openstreetmap.josm.io; … … 86 86 */ 87 87 public MultiPartFormOutputStream(OutputStream os, String boundary) { 88 if(os == null) {88 if(os == null) 89 89 throw new IllegalArgumentException("Output stream is required."); 90 } 91 if(boundary == null || boundary.length() == 0) { 90 if(boundary == null || boundary.length() == 0) 92 91 throw new IllegalArgumentException("Boundary stream is required."); 93 }94 92 this.out = new DataOutputStream(os); 95 93 this.boundary = boundary; … … 106 104 public void writeField(String name, boolean value) 107 105 throws java.io.IOException { 108 writeField(name, new Boolean(value).toString());106 writeField(name, Boolean.valueOf(value).toString()); 109 107 } 110 108 … … 178 176 public void writeField(String name, char value) 179 177 throws java.io.IOException { 180 writeField(name, new Character(value).toString());178 writeField(name, Character.valueOf(value).toString()); 181 179 } 182 180 … … 191 189 public void writeField(String name, String value) 192 190 throws java.io.IOException { 193 if(name == null) {191 if(name == null) 194 192 throw new IllegalArgumentException("Name cannot be null or empty."); 195 }196 193 if(value == null) { 197 194 value = ""; … … 229 226 public void writeFile(String name, String mimeType, java.io.File file) 230 227 throws java.io.IOException { 231 if(file == null) {228 if(file == null) 232 229 throw new IllegalArgumentException("File cannot be null."); 233 } 234 if(!file.exists()) { 230 if(!file.exists()) 235 231 throw new IllegalArgumentException("File does not exist."); 236 } 237 if(file.isDirectory()) { 232 if(file.isDirectory()) 238 233 throw new IllegalArgumentException("File cannot be a directory."); 239 }240 234 writeFile(name, mimeType, file.getCanonicalPath(), new FileInputStream(file)); 241 235 } … … 254 248 String fileName, InputStream is) 255 249 throws java.io.IOException { 256 if(is == null) {250 if(is == null) 257 251 throw new IllegalArgumentException("Input stream cannot be null."); 258 } 259 if(fileName == null || fileName.length() == 0) { 252 if(fileName == null || fileName.length() == 0) 260 253 throw new IllegalArgumentException("File name cannot be null or empty."); 261 }262 254 /* 263 255 --boundary\r\n … … 308 300 String fileName, byte[] data) 309 301 throws java.io.IOException { 310 if(data == null) {302 if(data == null) 311 303 throw new IllegalArgumentException("Data cannot be null."); 312 } 313 if(fileName == null || fileName.length() == 0) { 304 if(fileName == null || fileName.length() == 0) 314 305 throw new IllegalArgumentException("File name cannot be null or empty."); 315 }316 306 /* 317 307 --boundary\r\n -
trunk/src/org/openstreetmap/josm/io/NmeaReader.java
r1724 r2626 132 132 public GpxData data; 133 133 134 // private final static SimpleDateFormat GGATIMEFMT =135 // new SimpleDateFormat("HHmmss.SSS");134 // private final static SimpleDateFormat GGATIMEFMT = 135 // new SimpleDateFormat("HHmmss.SSS"); 136 136 private final static SimpleDateFormat RMCTIMEFMT = 137 137 new SimpleDateFormat("ddMMyyHHmmss.SSS"); … … 142 142 { 143 143 Date d = RMCTIMEFMT.parse(p, new ParsePosition(0)); 144 if (d == null) { 145 d = RMCTIMEFMTSTD.parse(p, new ParsePosition(0)); 146 } 144 147 if (d == null) 145 d = RMCTIMEFMTSTD.parse(p, new ParsePosition(0)); 146 if (d == null) throw(null); // malformed 148 throw new RuntimeException("Date is malformed"); // malformed 147 149 return d; 148 150 } … … 181 183 int loopstart_char = rd.read(); 182 184 ps = new NMEAParserState(); 183 if(loopstart_char == -1) {// zero size file185 if(loopstart_char == -1) 184 186 //TODO tell user about the problem? 185 187 return; 186 }187 188 sb.append((char)loopstart_char); 188 189 ps.p_Date="010100"; // TODO date problem 189 190 while(true) { 190 191 // don't load unparsable files completely to memory 191 if(sb.length()>=1020) sb.delete(0, sb.length()-1); 192 if(sb.length()>=1020) { 193 sb.delete(0, sb.length()-1); 194 } 192 195 int c = rd.read(); 193 196 if(c=='$') { … … 199 202 ParseNMEASentence(sb.toString(),ps); 200 203 break; 201 } else sb.append((char)c); 204 } else { 205 sb.append((char)c); 206 } 202 207 } 203 208 rd.close(); … … 209 214 } 210 215 } 211 private class NMEAParserState {216 private static class NMEAParserState { 212 217 protected Collection<WayPoint> waypoints = new ArrayList<WayPoint>(); 213 218 protected String p_Time; … … 239 244 byte[] chb = chkstrings[0].getBytes(); 240 245 int chk=0; 241 for(int i = 1; i < chb.length; i++) chk ^= chb[i]; 246 for(int i = 1; i < chb.length; i++) { 247 chk ^= chb[i]; 248 } 242 249 if(Integer.parseInt(chkstrings[1].substring(0,2),16) != chk) { 243 250 //System.out.println("Checksum error"); … … 246 253 return false; 247 254 } 255 } else { 256 ps.no_checksum++; 248 257 } 249 else250 ps.no_checksum++;251 258 // now for the content 252 259 String[] e = chkstrings[0].split(","); … … 264 271 e[GPGGA.LATITUDE.position], 265 272 e[GPGGA.LONGITUDE.position] 266 273 ); 267 274 if(latLon==null) throw(null); // malformed 268 275 … … 291 298 accu=e[GPGGA.HEIGHT_UNTIS.position]; 292 299 if(accu.equals("M")) { 293 294 295 300 // Ignore heights that are not in meters for now 301 accu=e[GPGGA.HEIGHT.position]; 302 if(!accu.equals("")) { 296 303 Double.parseDouble(accu); 297 304 // if it throws it's malformed; this should only happen if the 298 305 // device sends nonstandard data. 299 if(!accu.equals("")) currentwp.attr.put("ele", accu); 306 if(!accu.equals("")) { 307 currentwp.attr.put("ele", accu); 308 } 300 309 } 301 310 } … … 309 318 // h-dilution 310 319 accu=e[GPGGA.HDOP.position]; 311 if(!accu.equals("")) 320 if(!accu.equals("")) { 312 321 currentwp.attr.put("hdop", Float.parseFloat(accu)); 322 } 313 323 // fix 314 324 accu=e[GPGGA.QUALITY.position]; … … 320 330 break; 321 331 case 1: 322 if(sat < 4) currentwp.attr.put("fix", "2d"); 323 else currentwp.attr.put("fix", "3d"); 332 if(sat < 4) { 333 currentwp.attr.put("fix", "2d"); 334 } else { 335 currentwp.attr.put("fix", "3d"); 336 } 324 337 break; 325 338 case 2: … … 354 367 // vdop 355 368 accu=e[GPGSA.VDOP.position]; 356 if(!accu.equals("")) 369 if(!accu.equals("")) { 357 370 currentwp.attr.put("vdop", Float.parseFloat(accu)); 371 } 358 372 // hdop 359 373 accu=e[GPGSA.HDOP.position]; 360 if(!accu.equals("")) 374 if(!accu.equals("")) { 361 375 currentwp.attr.put("hdop", Float.parseFloat(accu)); 376 } 362 377 // pdop 363 378 accu=e[GPGSA.PDOP.position]; 364 if(!accu.equals("")) 379 if(!accu.equals("")) { 365 380 currentwp.attr.put("pdop", Float.parseFloat(accu)); 381 } 366 382 } 367 383 else if(e[0].equals("$GPRMC")) { … … 372 388 e[GPRMC.WIDTH_NORTH.position], 373 389 e[GPRMC.LENGTH_EAST.position] 374 ); 375 if(latLon==null) throw(null); 390 ); 376 391 if((latLon.lat()==0.0) && (latLon.lon()==0.0)) { 377 392 ps.zero_coord++; … … 439 454 440 455 private LatLon parseLatLon(String ns, String ew, String dlat, String dlon) 441 456 throws NumberFormatException { 442 457 String widthNorth = dlat.trim(); 443 458 String lengthEast = dlon.trim(); … … 456 471 int latdeg = Integer.parseInt(widthNorth.substring(0, latdegsep)); 457 472 double latmin = Double.parseDouble(widthNorth.substring(latdegsep)); 458 if(latdeg < 0) // strange data with '-' sign473 if(latdeg < 0) { 459 474 latmin *= -1.0; 475 } 460 476 double lat = latdeg + latmin / 60; 461 477 if ("S".equals(ns)) { … … 468 484 int londeg = Integer.parseInt(lengthEast.substring(0, londegsep)); 469 485 double lonmin = Double.parseDouble(lengthEast.substring(londegsep)); 470 if(londeg < 0) // strange data with '-' sign486 if(londeg < 0) { 471 487 lonmin *= -1.0; 488 } 472 489 double lon = londeg + lonmin / 60; 473 490 if ("W".equals(ew)) { -
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r2609 r2626 557 557 } else if (rm.type.equals("relation")) { 558 558 primitive = new Relation(rm.id); 559 } else {559 } else 560 560 // can't happen, we've been testing for valid member types 561 561 // at the beginning of this method 562 562 // 563 }563 throw new AssertionError(); 564 564 ds.addPrimitive(primitive); 565 565 externalIdMap.put(new SimplePrimitiveId(rm.id, OsmPrimitiveType.fromApiTypeName(rm.type)), primitive); -
trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java
r2540 r2626 31 31 String bbox[] = map.get("bbox").split(","); 32 32 b = new Bounds( 33 new LatLon(Double.parseDouble(bbox[1]), Double.parseDouble(bbox[0])),34 new LatLon(Double.parseDouble(bbox[3]), Double.parseDouble(bbox[2])));33 new LatLon(Double.parseDouble(bbox[1]), Double.parseDouble(bbox[0])), 34 new LatLon(Double.parseDouble(bbox[3]), Double.parseDouble(bbox[2]))); 35 35 } else if (map.containsKey("minlat")) { 36 36 String s = map.get("minlat"); … … 45 45 } else { 46 46 b = positionToBounds(parseDouble(map, "lat"), 47 48 47 parseDouble(map, "lon"), 48 Integer.parseInt(map.get("zoom"))); 49 49 } 50 50 } catch (NumberFormatException x) { … … 81 81 */ 82 82 private static Bounds parseShortLink(final String url) { 83 if (!url.startsWith(SHORTLINK_PREFIX)) {83 if (!url.startsWith(SHORTLINK_PREFIX)) 84 84 return null; 85 }86 85 final String shortLink = url.substring(SHORTLINK_PREFIX.length()); 87 86 … … 125 124 // 2**32 == 4294967296 126 125 return positionToBounds(y * 180.0 / 4294967296.0 - 90.0, 127 128 129 126 x * 360.0 / 4294967296.0 - 180.0, 127 // TODO: -2 was not in ruby code 128 zoom - 8 - (zoomOffset % 3) - 2); 130 129 } 131 130 … … 133 132 final double size = 180.0 / Math.pow(2, zoom); 134 133 return new Bounds( 135 136 134 new LatLon(lat - size/2, lon - size), 135 new LatLon(lat + size/2, lon + size)); 137 136 } 138 137 … … 144 143 int zoom = 0; 145 144 while (zoom <= 20) { 146 if (size >= 180) 145 if (size >= 180) { 147 146 break; 147 } 148 148 size *= 2; 149 149 zoom++; … … 163 163 double lon = (Math.round(pos.lon() * decimals)); 164 164 lon /= decimals; 165 return new String("http://www.openstreetmap.org/?lat="+lat+"&lon="+lon+"&zoom="+zoom);165 return "http://www.openstreetmap.org/?lat="+lat+"&lon="+lon+"&zoom="+zoom; 166 166 } 167 167 } -
trunk/src/org/openstreetmap/josm/tools/Pair.java
r1169 r2626 18 18 } 19 19 20 @Override public boolean equals(Object o) { 21 return o == null ? o == null : o instanceof Pair 22 && a.equals(((Pair<?,?>) o).a) && b.equals(((Pair<?,?>) o).b); 20 @Override public boolean equals(Object other) { 21 if (other instanceof Pair<?, ?>) { 22 Pair<?, ?> o = (Pair<?, ?>)other; 23 return a.equals(o.a) && b.equals(o.b); 24 } else 25 return false; 23 26 } 24 27 -
trunk/src/org/openstreetmap/josm/tools/Shortcut.java
r2017 r2626 273 273 // pull in the groups 274 274 for (int i = GROUP_NONE; i < GROUP__MAX+GROUPS_ALT2*2; i++) { // fill more groups, so registering with e.g. ALT2+MNEMONIC won't NPE 275 groups.put( new Integer(i), new Integer(Main.pref.getInteger("shortcut.groups."+i, -1)));275 groups.put(i, Main.pref.getInteger("shortcut.groups."+i, -1)); 276 276 } 277 277 // (1) System reserved shortcuts -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/nodes/NodeListMergeModelTest.java
r2620 r2626 11 11 import java.beans.PropertyChangeListener; 12 12 import java.util.ArrayList; 13 import java.util.Arrays; 13 14 import java.util.List; 14 15 … … 46 47 int rows[] = (int[])idx[i]; 47 48 if (rows == null || rows.length != 2) { 48 fail("illegal selection range. Either null or not length 2: " + rows);49 fail("illegal selection range. Either null or not length 2: " + Arrays.toString(rows)); 49 50 } 50 51 if (rows[0] > rows[1]) {
Note:
See TracChangeset
for help on using the changeset viewer.