Changeset 6 in josm
- Timestamp:
- 2005-10-01T04:01:45+02:00 (19 years ago)
- Files:
-
- 4 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/mapmode/DebugAction.java
r4 r6 31 31 } 32 32 33 @Override 33 34 public void registerListener(MapView mapView) { 34 35 mapView.addMouseMotionListener(this); … … 37 38 } 38 39 40 @Override 39 41 public void unregisterListener(MapView mapView) { 40 42 mapView.removeMouseMotionListener(this); -
src/org/openstreetmap/josm/actions/mapmode/ZoomAction.java
r4 r6 17 17 * Holding down left and right let the user move the former selected rectangle. 18 18 * Releasing the left button zoom to the selection. 19 * 20 * Rectangle selections with either height or width smaller than 3 pixels 21 * are ignored. 19 22 * 20 23 * @author imi … … 47 50 */ 48 51 public void selectionEnded(Rectangle r, int modifier) { 49 double scale = mv.getScale() * r.getWidth()/mv.getWidth(); 50 GeoPoint newCenter = mv.getPoint(r.x+r.width/2, r.y+r.height/2, false); 51 mv.zoomTo(newCenter, scale); 52 if (r.width >= 3 && r.height >= 3) { 53 double scale = mv.getScale() * r.getWidth()/mv.getWidth(); 54 GeoPoint newCenter = mv.getPoint(r.x+r.width/2, r.y+r.height/2, false); 55 mv.zoomTo(newCenter, scale); 56 } 52 57 } 53 58 59 @Override 54 60 public void registerListener(MapView mapView) { 55 61 selectionManager.register(mapView); 56 62 } 57 63 64 @Override 58 65 public void unregisterListener(MapView mapView) { 59 66 selectionManager.unregister(mapView); -
src/org/openstreetmap/josm/data/GeoPoint.java
r1 r6 1 1 package org.openstreetmap.josm.data; 2 2 3 3 4 /** … … 44 45 return null; 45 46 } 47 48 /** 49 * GeoPoints are equal, if their lat/lon are equal or, if lat or lon are NaN, 50 * if their x/y are equal. 51 */ 52 @Override 53 public boolean equals(Object obj) { 54 if (!(obj instanceof GeoPoint)) 55 return false; 56 GeoPoint gp = (GeoPoint)obj; 57 58 if (Double.isNaN(lat) || Double.isNaN(lon)) 59 return x == gp.x && y == gp.y; 60 return lat == gp.lat && lon == gp.lon; 61 } 62 63 @Override 64 public int hashCode() { 65 return super.hashCode(); 66 } 67 68 46 69 } -
src/org/openstreetmap/josm/data/Preferences.java
r1 r6 4 4 import java.io.FileReader; 5 5 import java.io.FileWriter; 6 import java.util.List; 6 7 7 8 import javax.swing.UIManager; … … 34 35 public Projection projection = new UTM(); 35 36 37 36 38 /** 37 * The monitor geometry in meter per pixel. (How big is 1 pixel in meters) 38 * Example: 17" Sony flatscreen in 1280x1024 mode: 0.000264 ppm 39 * 40 * Remember: ppm = dpi/25400 39 * Whether nodes on the same place should be considered identical. 41 40 */ 42 public double ppm = 0.000264; 41 public boolean mergeNodes = true; 42 43 43 44 44 45 /** 46 * List of all available Projections. 47 */ 45 48 public static final Projection[] allProjections = new Projection[]{ 46 49 new UTM(), … … 85 88 86 89 projection = (Projection)Class.forName(root.getChildText("projection")).newInstance(); 90 mergeNodes = root.getChild("mergeNodes") != null; 87 91 } catch (Exception e) { 88 92 if (e instanceof PreferencesException) … … 100 104 Element root = new Element("josm-settings"); 101 105 102 root.getChildren().add(new Element("laf").setText(laf.getClassName())); 103 root.getChildren().add(new Element("projection").setText(projection.getClass().getName())); 106 List children = root.getChildren(); 107 children.add(new Element("laf").setText(laf.getClassName())); 108 children.add(new Element("projection").setText(projection.getClass().getName())); 109 if (mergeNodes) 110 children.add(new Element("mergeNodes")); 104 111 105 112 try { -
src/org/openstreetmap/josm/data/osm/DataSet.java
r2 r6 119 119 } 120 120 121 @Override 121 122 public DataSet clone() { 122 123 try {return (DataSet)super.clone();} catch (CloneNotSupportedException e) {} -
src/org/openstreetmap/josm/data/osm/Node.java
r1 r6 15 15 */ 16 16 public GeoPoint coor; 17 18 /** 19 * Nodes are equal when their coordinates are equal. 20 */ 21 @Override 22 public boolean equals(Object obj) { 23 if (!(obj instanceof Node)) 24 return false; 25 Node n = (Node)obj; 26 if (coor == null) 27 return n.coor == null; 28 return coor.equals(n.coor) && super.equals(obj); 29 } 30 31 /** 32 * Compute the hashcode from the OsmPrimitive's hash and the coor's hash. 33 */ 34 @Override 35 public int hashCode() { 36 return (coor == null ? 0 : coor.hashCode()) + super.hashCode(); 37 } 38 39 17 40 } -
src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r2 r6 20 20 * If set to true, this object has been modified in the current session. 21 21 */ 22 public boolean modified = false;22 transient public boolean modified = false; 23 23 24 24 /** 25 25 * If set to true, this object is currently selected. 26 26 */ 27 public boolean selected = false; 27 transient public boolean selected = false; 28 29 /** 30 * Osm primitives are equal, when their keys are equal. 31 */ 32 @Override 33 public boolean equals(Object obj) { 34 if (obj == null) 35 return false; 36 if (!(obj instanceof OsmPrimitive)) 37 return false; 38 OsmPrimitive osm = (OsmPrimitive)obj; 39 if (keys == null) 40 return osm.keys == null; 41 return keys.equals(osm.keys); 42 } 43 44 /** 45 * Compute the hashCode from the keys. 46 */ 47 @Override 48 public int hashCode() { 49 return keys == null ? 0 : keys.hashCode(); 50 } 51 52 28 53 } -
src/org/openstreetmap/josm/data/projection/Projection.java
r1 r6 45 45 * Describe the projection converter in one or two words. 46 46 */ 47 @Override 47 48 abstract public String toString(); 48 49 -
src/org/openstreetmap/josm/data/projection/UTM.java
r1 r6 49 49 this.ecc_squared = ecc_squared; 50 50 } 51 @Override 51 52 public String toString() { 52 53 return name; -
src/org/openstreetmap/josm/gui/MapMover.java
r3 r6 64 64 * Start the movement, if it was the 3rd button (right button). 65 65 */ 66 @Override 66 67 public void mousePressed(MouseEvent e) { 67 68 int offMask = MouseEvent.BUTTON1_DOWN_MASK | MouseEvent.BUTTON2_DOWN_MASK; … … 73 74 * Change the cursor back to it's pre-move cursor. 74 75 */ 76 @Override 75 77 public void mouseReleased(MouseEvent e) { 76 78 if (e.getButton() == MouseEvent.BUTTON3) -
src/org/openstreetmap/josm/gui/MapView.java
r4 r6 8 8 import java.awt.event.ComponentListener; 9 9 import java.awt.event.KeyEvent; 10 import java.util.HashSet; 10 11 import java.util.LinkedList; 11 12 import java.util.List; 13 import java.util.Set; 12 14 13 15 import javax.swing.AbstractAction; … … 246 248 g.setColor(Color.BLACK); 247 249 g.fillRect(0,0,getWidth(),getHeight()); 248 250 249 251 // draw tracks 250 252 if (dataSet.tracks != null) … … 257 259 258 260 // draw nodes 261 Set<Integer> alreadyDrawn = new HashSet<Integer>(); 262 int width = getWidth(); 259 263 for (Node w : dataSet.allNodes) { 260 264 g.setColor(w.selected ? Color.WHITE : Color.RED); 261 g.drawArc(toScreenX(w.coor.x), toScreenY(w.coor.y), 3, 3, 0, 360); 265 int x = toScreenX(w.coor.x); 266 int y = toScreenY(w.coor.y); 267 int size = 3; 268 if (alreadyDrawn.contains(y*width+x)) { 269 size = 7; 270 x -= 2; 271 y -= 2; 272 } else 273 alreadyDrawn.add(y*width+x); 274 g.drawArc(x, y, size, size, 0, 360); 262 275 } 263 276 } -
src/org/openstreetmap/josm/gui/PreferenceDialog.java
r1 r6 1 1 package org.openstreetmap.josm.gui; 2 2 3 import java.awt.BorderLayout;4 3 import java.awt.Component; 5 import java.awt.Container;6 4 import java.awt.Dimension; 5 import java.awt.Font; 6 import java.awt.GridBagLayout; 7 7 import java.awt.event.ActionEvent; 8 8 import java.awt.event.ActionListener; … … 11 11 12 12 import javax.swing.AbstractAction; 13 import javax.swing.BorderFactory;14 13 import javax.swing.Box; 15 14 import javax.swing.DefaultListCellRenderer; 16 15 import javax.swing.ImageIcon; 17 16 import javax.swing.JButton; 17 import javax.swing.JCheckBox; 18 18 import javax.swing.JComboBox; 19 19 import javax.swing.JDialog; … … 50 50 pref.laf = (LookAndFeelInfo)lafCombo.getSelectedItem(); 51 51 pref.projection = (Projection)projectionCombo.getSelectedItem(); 52 pref.mergeNodes = mergeNodes.isSelected(); 52 53 Main.pref.projection = pref.projection; 53 54 try { … … 85 86 private JComboBox lafCombo = new JComboBox(UIManager.getInstalledLookAndFeels()); 86 87 /** 87 * The tabbed pane to add tabulars to.88 */89 private JTabbedPane tabPanel = new JTabbedPane();90 /**91 88 * Combobox with all projections available 92 89 */ 93 private JComboBox projectionCombo = new JComboBox(Preferences.allProjections); 90 private JComboBox projectionCombo = new JComboBox(Preferences.allProjections.clone()); 91 /** 92 * The main tab panel. 93 */ 94 private JTabbedPane tabPane = new JTabbedPane(JTabbedPane.LEFT); 95 /** 96 * The checkbox stating whether nodes should be merged together. 97 */ 98 private JCheckBox mergeNodes = new JCheckBox("Merge nodes with equal latitude/longitude."); 94 99 95 100 … … 113 118 } 114 119 115 getContentPane().setLayout(new BorderLayout()); 116 getContentPane().add(tabPanel, BorderLayout.CENTER); 117 118 newTab("Display"); 119 // laf 120 JPanel p = newPanelLine(); 121 p.add(new JLabel("Look and Feel")); 120 // look and feel combo box 122 121 final ListCellRenderer oldRenderer = lafCombo.getRenderer(); 123 122 lafCombo.setRenderer(new DefaultListCellRenderer(){ 123 @Override 124 124 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 125 125 return oldRenderer.getListCellRendererComponent(list, ((LookAndFeelInfo)value).getName(), index, isSelected, cellHasFocus); … … 130 130 setRequiresRestart(); 131 131 }}); 132 p.add(lafCombo); 133 134 newTab("Projection"); 135 p = newPanelLine(); 136 p.add(new JLabel("Projection System")); 137 p.add(projectionCombo); 138 for (int i = 0; i < projectionCombo.getItemCount(); ++i) 132 133 // projection method combo box 134 for (int i = 0; i < projectionCombo.getItemCount(); ++i) { 139 135 if (projectionCombo.getItemAt(i).getClass().equals(pref.projection.getClass())) { 140 136 projectionCombo.setSelectedIndex(i); 141 137 break; 142 138 } 143 144 // OK/Cancel 145 JPanel okPanel = new JPanel(); 146 okPanel.add(new JButton(new OkAction())); 147 okPanel.add(new JButton(new CancelAction())); 148 getContentPane().add(okPanel, BorderLayout.SOUTH); 139 } 140 141 // Display tab 142 JPanel display = createPreferenceTab("display", "Display Settings", "Various settings than influence the visual representation of the whole Program."); 143 display.add(new JLabel("Look and Feel"), GBC.std()); 144 display.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 145 display.add(lafCombo, GBC.eol().fill(GBC.HORIZONTAL)); 146 display.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL)); 147 148 // Map tab 149 JPanel map = createPreferenceTab("map", "Map Settings", "Settings for the map projection and data interpretation."); 150 map.add(new JLabel("Projection method"), GBC.std()); 151 map.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 152 map.add(projectionCombo, GBC.eol().fill(GBC.HORIZONTAL)); 153 JLabel labelNoteProjection = new JLabel( 154 "<html>Note: This is the default projection method used for files, " + 155 "where the correct projection could not be determined. " + 156 "The actual used projection can be changed in the property " + 157 "settings of each map.</html>"); 158 labelNoteProjection.setMinimumSize(new Dimension(550, 50)); 159 labelNoteProjection.setPreferredSize(new Dimension(550, 50)); 160 map.add(labelNoteProjection, GBC.eol().insets(0,5,0,20)); 161 map.add(new JLabel("GPX import / export"), GBC.eol()); 162 mergeNodes.setSelected(pref.mergeNodes); 163 map.add(mergeNodes, GBC.eol()); 164 map.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL)); 165 166 167 tabPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); 168 169 // OK/Cancel panel at bottom 170 JPanel okPanel = new JPanel(new GridBagLayout()); 171 okPanel.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL)); 172 okPanel.add(new JButton(new OkAction()), GBC.std()); 173 okPanel.add(new JButton(new CancelAction()), GBC.std()); 174 175 // merging all in the content pane 176 getContentPane().setLayout(new GridBagLayout()); 177 getContentPane().add(tabPane, GBC.eol().fill()); 178 getContentPane().add(okPanel, GBC.eol().fill(GBC.HORIZONTAL)); 149 179 150 180 setModal(true); … … 155 185 156 186 /** 157 * Start a new tab with the given name 158 * @param tabName The name of the new tab. 159 */ 160 private void newTab(String tabName) { 161 Box tab = Box.createVerticalBox(); 162 tab.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); 163 tabPanel.addTab(tabName, tab); 164 } 165 187 * Construct a JPanel for the preference settings. Layout is GridBagLayout 188 * and a centered title label and the description are added. 189 * @param icon The name of the icon. 190 * @param title The title of this preference tab. 191 * @param desc A description in one sentence for this tab. Will be displayed 192 * italic under the title. 193 * @return The created panel ready to add other controls. 194 */ 195 private JPanel createPreferenceTab(String icon, String title, String desc) { 196 JPanel p = new JPanel(new GridBagLayout()); 197 p.add(new JLabel(title), GBC.eol().anchor(GBC.CENTER).insets(0,5,0,10)); 198 JLabel descLabel = new JLabel(desc); 199 descLabel.setFont(descLabel.getFont().deriveFont(Font.ITALIC)); 200 p.add(descLabel, GBC.eol().insets(5,0,5,20)); 201 202 tabPane.addTab(null, new ImageIcon("images/preferences/"+icon+".png"), p); 203 return p; 204 } 205 166 206 /** 167 207 * Remember, that the settings made requires a restart of the application. … … 171 211 requiresRestart = true; 172 212 } 173 174 private JPanel newPanelLine() {175 JPanel p;176 p = new JPanel();177 p.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));178 ((Container)tabPanel.getComponent(tabPanel.getTabCount()-1)).add(p);179 return p;180 }181 213 } -
src/org/openstreetmap/josm/io/GpxReader.java
r2 r6 15 15 import org.openstreetmap.josm.data.osm.Track; 16 16 import org.openstreetmap.josm.data.osm.LineSegment; 17 import org.openstreetmap.josm.gui.Main; 17 18 18 19 /** … … 70 71 data.allNodes = new LinkedList<Node>(); 71 72 for (Object o : e.getChildren("wpt", GPX)) 72 data.allNodes.add(parseWaypoint((Element)o));73 addNode(data, parseWaypoint((Element)o)); 73 74 74 75 // read tracks … … 79 80 for (Object w : ((Element)trackSegmentElement).getChildren("trkpt", GPX)) { 80 81 Node node = parseWaypoint((Element)w); 81 data.allNodes.add(node);82 node = addNode(data, node); 82 83 if (start == null) 83 84 start = node; … … 96 97 return data; 97 98 } 99 100 /** 101 * Adds the node to allNodes if it is not already listed. Does respect the 102 * preference setting "mergeNodes". Return the node in the list that correspond 103 * to the node in the list (either the new added or the old found). 104 * 105 * @param data The DataSet to add the node to. 106 * @param node The node that should be added. 107 * @return Either the parameter node or the old node found in the dataset. 108 */ 109 private Node addNode (DataSet data, Node node) { 110 if (Main.pref.mergeNodes) 111 for (Node n : data.allNodes) 112 if (node.equals(n)) 113 return n; 114 data.allNodes.add(node); 115 return node; 116 } 98 117 }
Note:
See TracChangeset
for help on using the changeset viewer.