Changeset 116 in josm for src/org/openstreetmap/josm/gui
- Timestamp:
- 2006-07-20T00:43:51+02:00 (20 years ago)
- Location:
- src/org/openstreetmap/josm/gui
- Files:
-
- 1 added
- 5 edited
-
MapScaler.java (modified) (2 diffs)
-
MapView.java (modified) (1 diff)
-
PreferenceDialog.java (modified) (9 diffs)
-
WorldChooser.java (modified) (1 diff)
-
dialogs/AnnotationPreset.java (added)
-
dialogs/PropertiesDialog.java (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/gui/MapScaler.java
r115 r116 1 1 package org.openstreetmap.josm.gui; 2 2 3 import java.awt.Color;4 3 import java.awt.Graphics; 5 4 import java.awt.geom.Rectangle2D; 6 5 7 6 import javax.swing.JComponent; 7 8 import org.openstreetmap.josm.Main; 9 import org.openstreetmap.josm.tools.ColorHelper; 8 10 9 11 public class MapScaler extends JComponent { … … 18 20 19 21 @Override public void paint(Graphics g) { 20 double circum = mv.getScale()*100 /Math.PI/2*40041455; // circumference of the earth in meter22 double circum = mv.getScale()*100*Main.proj.scaleFactor()*40041455; // circumference of the earth in meter 21 23 String text = circum > 1000 ? (Math.round(circum/100)/10.0)+"km" : Math.round(circum)+"m"; 22 g.setColor(Color .white);24 g.setColor(ColorHelper.html2color(Main.pref.get("color.scale", "#ffffff"))); 23 25 g.drawLine(0, 5, 99, 5); 24 26 g.drawLine(0, 0, 0, 10); -
src/org/openstreetmap/josm/gui/MapView.java
r115 r116 98 98 MapSlider zoomSlider = new MapSlider(this); 99 99 add(zoomSlider); 100 zoomSlider.setBounds( 0,0, 100, 30);100 zoomSlider.setBounds(3, 0, 114, 30); 101 101 102 102 MapScaler scaler = new MapScaler(this); -
src/org/openstreetmap/josm/gui/PreferenceDialog.java
r115 r116 11 11 import java.awt.event.ActionListener; 12 12 import java.util.Map; 13 import java.util.StringTokenizer; 13 14 import java.util.TreeMap; 14 15 import java.util.Vector; … … 19 20 import javax.swing.Box; 20 21 import javax.swing.DefaultListCellRenderer; 22 import javax.swing.DefaultListModel; 21 23 import javax.swing.JButton; 22 24 import javax.swing.JCheckBox; … … 81 83 Main.pref.put("draw.segment.direction", directionHint.isSelected()); 82 84 85 if (annotationSources.getModel().getSize() > 0) { 86 StringBuilder sb = new StringBuilder(); 87 for (int i = 0; i < annotationSources.getModel().getSize(); ++i) 88 sb.append(";"+annotationSources.getModel().getElementAt(i)); 89 Main.pref.put("annotation.sources", sb.toString().substring(1)); 90 } 91 83 92 for (int i = 0; i < colors.getRowCount(); ++i) { 84 93 String name = (String)colors.getValueAt(i, 0); … … 121 130 private JComboBox lafCombo = new JComboBox(UIManager.getInstalledLookAndFeels()); 122 131 /** 123 * Combobox with all projections available124 */125 private JComboBox projectionCombo = new JComboBox(Projection.allProjections);126 /**127 132 * The main tab panel. 128 133 */ … … 161 166 private JCheckBox directionHint = new JCheckBox(tr("Draw Direction Arrows")); 162 167 private JTable colors; 168 169 /** 170 * Combobox with all projections available 171 */ 172 private JComboBox projectionCombo = new JComboBox(Projection.allProjections); 173 private JList annotationSources = new JList(new DefaultListModel()); 163 174 164 175 … … 227 238 directionHint.setSelected(Main.pref.getBoolean("draw.segment.direction")); 228 239 240 String annos = Main.pref.get("annotation.sources"); 241 StringTokenizer st = new StringTokenizer(annos, ";"); 242 while (st.hasMoreTokens()) 243 ((DefaultListModel)annotationSources.getModel()).addElement(st.nextToken()); 229 244 230 245 … … 275 290 } 276 291 }); 292 293 // Annotation source panels 294 JPanel annoButton = new JPanel(new GridBagLayout()); 295 JButton addAnno = new JButton(tr("Add")); 296 addAnno.addActionListener(new ActionListener(){ 297 public void actionPerformed(ActionEvent e) { 298 String source = JOptionPane.showInputDialog(Main.parent, tr("Annotation preset source")); 299 if (source == null) 300 return; 301 ((DefaultListModel)annotationSources.getModel()).addElement(source); 302 requiresRestart = true; 303 } 304 }); 305 GBC g = GBC.eol().fill(GBC.HORIZONTAL); 306 g.weightx = 0; 307 annoButton.add(addAnno,g); 308 309 JButton editAnno = new JButton(tr("Edit")); 310 editAnno.addActionListener(new ActionListener(){ 311 public void actionPerformed(ActionEvent e) { 312 if (annotationSources.getSelectedIndex() == -1) 313 JOptionPane.showMessageDialog(Main.parent, tr("Please select the row to edit.")); 314 else { 315 String source = JOptionPane.showInputDialog(Main.parent, tr("Annotation preset source"), annotationSources.getSelectedValue()); 316 if (source == null) 317 return; 318 ((DefaultListModel)annotationSources.getModel()).setElementAt(source, annotationSources.getSelectedIndex()); 319 requiresRestart = true; 320 } 321 } 322 }); 323 annoButton.add(GBC.glue(0, 2), GBC.eol()); 324 annoButton.add(editAnno,g); 325 326 JButton deleteAnno = new JButton(tr("Delete")); 327 deleteAnno.addActionListener(new ActionListener(){ 328 public void actionPerformed(ActionEvent e) { 329 if (annotationSources.getSelectedIndex() == -1) 330 JOptionPane.showMessageDialog(Main.parent, tr("Please select the row to delete.")); 331 else { 332 ((DefaultListModel)annotationSources.getModel()).remove(annotationSources.getSelectedIndex()); 333 requiresRestart = true; 334 } 335 } 336 }); 337 annoButton.add(GBC.glue(0, 2), GBC.eol()); 338 annoButton.add(deleteAnno,g); 339 annotationSources.setVisibleRowCount(5); 340 341 277 342 278 343 // setting tooltips … … 290 355 drawRawGpsLines.setToolTipText(tr("If your gps device draw to few lines, select this to draw lines along your way.")); 291 356 colors.setToolTipText(tr("Colors used by different objects in JOSM.")); 357 annotationSources.setToolTipText(tr("The sources (url or filename) of annotation preset definition files. See http://josm.eigenheimstrasse.de/wiki/AnnotationPresets for help.")); 358 addAnno.setToolTipText(tr("Add a new annotation preset source to the list.")); 359 deleteAnno.setToolTipText(tr("Delete the selected source from the list.")); 292 360 293 361 // creating the gui … … 333 401 map.add(new JLabel(tr("Projection method")), GBC.std()); 334 402 map.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 335 map.add(projectionCombo, GBC.eol().fill(GBC.HORIZONTAL).insets(0,0,0,5)); 403 map.add(projectionCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,0,0,5)); 404 map.add(new JLabel(tr("Annotation preset sources")), GBC.eol()); 405 map.add(new JScrollPane(annotationSources), GBC.std().fill(GBC.HORIZONTAL).insets(10,0,10,0)); 406 map.add(annoButton, GBC.eol()); 407 336 408 map.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL)); 337 409 -
src/org/openstreetmap/josm/gui/WorldChooser.java
r86 r116 77 77 public String getCacheDirectoryName() { 78 78 throw new UnsupportedOperationException(); 79 } 80 public double scaleFactor() { 81 return 1; 79 82 } 80 83 }; -
src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r115 r116 15 15 import java.awt.event.MouseAdapter; 16 16 import java.awt.event.MouseEvent; 17 import java.io.FileInputStream; 18 import java.io.IOException; 19 import java.io.InputStream; 20 import java.net.URL; 17 21 import java.util.Collection; 18 22 import java.util.HashMap; 19 23 import java.util.Map; 24 import java.util.StringTokenizer; 20 25 import java.util.TreeMap; 21 26 import java.util.TreeSet; … … 23 28 import java.util.Map.Entry; 24 29 30 import javax.swing.DefaultComboBoxModel; 25 31 import javax.swing.JButton; 26 32 import javax.swing.JComboBox; … … 42 48 import org.openstreetmap.josm.gui.MapFrame; 43 49 import org.openstreetmap.josm.tools.ImageProvider; 50 import org.xml.sax.SAXException; 44 51 45 52 /** … … 196 203 */ 197 204 private final JTable propertyTable = new JTable(data); 205 private JComboBox annotationPresets = new JComboBox(); 198 206 199 207 /** … … 202 210 public PropertiesDialog(MapFrame mapFrame) { 203 211 super(tr("Properties"), "propertiesdialog", tr("Property for selected objects."), KeyEvent.VK_P); 204 205 212 setPreferredSize(new Dimension(320,150)); 213 214 Vector<AnnotationPreset> allPresets = new Vector<AnnotationPreset>(); 215 String allAnnotations = Main.pref.get("annotation.sources"); 216 StringTokenizer st = new StringTokenizer(allAnnotations, ";"); 217 while (st.hasMoreTokens()) { 218 InputStream in = null; 219 String source = st.nextToken(); 220 try { 221 if (source.startsWith("http") || source.startsWith("ftp") || source.startsWith("file")) 222 in = new URL(source).openStream(); 223 else if (source.startsWith("resource://")) 224 in = Main.class.getResourceAsStream(source.substring("resource:/".length())); 225 else 226 in = new FileInputStream(source); 227 allPresets.addAll(AnnotationPreset.readAll(in)); 228 } catch (IOException e) { 229 e.printStackTrace(); 230 JOptionPane.showMessageDialog(Main.parent, tr("Could not read annotation preset source: {0}",source)); 231 } catch (SAXException e) { 232 e.printStackTrace(); 233 JOptionPane.showMessageDialog(Main.parent, tr("Error parsing {0}: ", source)+e.getMessage()); 234 } 235 } 236 if (allPresets.size() > 0) { 237 allPresets.add(0, new AnnotationPreset()); 238 annotationPresets.setModel(new DefaultComboBoxModel(allPresets)); 239 add(annotationPresets, BorderLayout.NORTH); 240 } 241 annotationPresets.addActionListener(new ActionListener(){ 242 public void actionPerformed(ActionEvent e) { 243 Collection<OsmPrimitive> sel = Main.ds.getSelected(); 244 AnnotationPreset preset = (AnnotationPreset)annotationPresets.getSelectedItem(); 245 JPanel p = preset.createPanel(); 246 if (p == null) 247 return; 248 int answer; 249 if (p.getComponentCount() == 0) 250 answer = JOptionPane.OK_OPTION; 251 else 252 answer = JOptionPane.showConfirmDialog(Main.parent, p, trn("Change {0} object", "Change {0} objects", sel.size(), sel.size()), JOptionPane.OK_CANCEL_OPTION); 253 if (answer == JOptionPane.OK_OPTION) { 254 Main.main.editLayer().add(preset.createCommand(sel)); 255 selectionChanged(sel); // update whole table 256 } 257 annotationPresets.setSelectedIndex(0); 258 } 259 }); 206 260 207 261 data.setColumnIdentifiers(new String[]{tr("Key"),tr("Value")});
Note:
See TracChangeset
for help on using the changeset viewer.
