- Timestamp:
- 2006-03-29T19:11:37+02:00 (19 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/Main.java
r74 r75 35 35 import org.openstreetmap.josm.data.Preferences; 36 36 import org.openstreetmap.josm.data.osm.DataSet; 37 import org.openstreetmap.josm.data.projection.Epsg4263; 37 38 import org.openstreetmap.josm.data.projection.Projection; 38 39 import org.openstreetmap.josm.gui.MapFrame; … … 222 223 } else 223 224 pref.load(); 224 } catch (RuntimeException x) {225 //TODO: Temporary code to update user preferences.226 if (x.getMessage().equals("old version")) {227 int answer = JOptionPane.showConfirmDialog(228 null,229 "The preferences - file format has changed.\nThe settings will be reset to default.",230 "Information",231 JOptionPane.OK_CANCEL_OPTION);232 if (answer == JOptionPane.CANCEL_OPTION)233 System.exit(0);234 pref.resetToDefault();235 try {236 pref.save();237 } catch (IOException e) {238 e.printStackTrace();239 errMsg = "Preferences could not be loaded. Reverting to default.";240 }241 }242 225 } catch (IOException e1) { 243 226 e1.printStackTrace(); … … 258 241 } catch (Exception e) { 259 242 e.printStackTrace(); 260 JOptionPane.showMessageDialog(null, "The projection could not be initialized. Aborting.");261 System.exit(1);243 JOptionPane.showMessageDialog(null, "The projection could not be read from preferences. Using EPSG:4263."); 244 proj = new Epsg4263(); 262 245 } 263 246 -
src/org/openstreetmap/josm/actions/DownloadAction.java
r74 r75 55 55 public class DownloadAction extends JosmAction { 56 56 57 private enum DownloadStatus {FINISHED, REDISPLAY}58 59 57 /** 60 58 * minlat, minlon, maxlat, maxlon … … 77 75 public void actionPerformed(ActionEvent e) { 78 76 79 String osmDataServer = Main.pref.get("osm DataServer");77 String osmDataServer = Main.pref.get("osm-server.url"); 80 78 //TODO: Remove this in later versions (temporary only) 81 79 if (osmDataServer.endsWith("/0.2") || osmDataServer.endsWith("/0.2/")) { … … 90 88 return; 91 89 int cutPos = osmDataServer.endsWith("/0.2") ? 4 : 5; 92 Main.pref.put("osm DataServer", osmDataServer.substring(0, osmDataServer.length()-cutPos));90 Main.pref.put("osm-server.url", osmDataServer.substring(0, osmDataServer.length()-cutPos)); 93 91 try { 94 92 Main.pref.save(); … … 244 242 if (r != JOptionPane.OK_OPTION) 245 243 return; 246 if (startDownload() == DownloadStatus.FINISHED)244 if (startDownload()) 247 245 break; 248 246 } … … 251 249 /** 252 250 * Read the values from the edit fields and from the download. 253 */ 254 private DownloadStatus startDownload() { 251 * @return <code>true</code> for a success, <code>false</code> redisplay 252 */ 253 private boolean startDownload() { 255 254 Bookmark b = readBookmark(); 256 255 if (b == null) { 257 256 JOptionPane.showMessageDialog(Main.main, "Please enter the desired coordinates or click on a bookmark."); 258 return DownloadStatus.REDISPLAY;257 return false; 259 258 } 260 259 … … 264 263 double maxlat = b.latlon[3]; 265 264 download(rawGps.isSelected(), minlon, minlat, maxlon, maxlat); 266 return DownloadStatus.FINISHED;265 return true; 267 266 } 268 267 -
src/org/openstreetmap/josm/actions/UploadAction.java
r74 r75 40 40 public void actionPerformed(ActionEvent e) { 41 41 42 String osmDataServer = Main.pref.get("osm DataServer");42 String osmDataServer = Main.pref.get("osm-server.url"); 43 43 //TODO: Remove this in later versions (temporary only) 44 44 if (osmDataServer.endsWith("/0.2") || osmDataServer.endsWith("/0.2/")) { … … 53 53 return; 54 54 int cutPos = osmDataServer.endsWith("/0.2") ? 4 : 5; 55 Main.pref.put("osm DataServer", osmDataServer.substring(0, osmDataServer.length()-cutPos));55 Main.pref.put("osm-server.url", osmDataServer.substring(0, osmDataServer.length()-cutPos)); 56 56 try { 57 57 Main.pref.save(); -
src/org/openstreetmap/josm/data/Preferences.java
r74 r75 1 1 package org.openstreetmap.josm.data; 2 2 3 import java.awt.Color; 4 import java.io.BufferedReader; 3 5 import java.io.FileReader; 4 6 import java.io.FileWriter; … … 6 8 import java.io.PrintWriter; 7 9 import java.util.ArrayList; 10 import java.util.Collection; 11 import java.util.LinkedList; 8 12 import java.util.SortedMap; 9 13 import java.util.TreeMap; 10 14 import java.util.Map.Entry; 11 15 12 import org.openstreetmap.josm.tools.XmlWriter; 13 import org.xml.sax.Attributes; 14 import org.xml.sax.SAXException; 15 16 import uk.co.wilson.xml.MinML2; 16 import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor; 17 import org.openstreetmap.josm.tools.ColorHelper; 17 18 18 19 … … 59 60 return properties.get(key); 60 61 } 62 synchronized public String get(String key, String def) { 63 String prop = properties.get(key); 64 if (prop == null || prop.equals("")) 65 return def; 66 return prop; 67 } 68 synchronized public Collection<Entry<String, String>> getAllPrefix(String prefix) { 69 LinkedList<Entry<String,String>> all = new LinkedList<Entry<String,String>>(); 70 for (Entry<String,String> e : properties.entrySet()) 71 if (e.getKey().startsWith(prefix)) 72 all.add(e); 73 return all; 74 } 61 75 synchronized public boolean getBoolean(String key) { 62 76 return properties.containsKey(key) ? Boolean.parseBoolean(properties.get(key)) : false; 63 77 } 64 65 78 79 66 80 synchronized public void put(String key, String value) { 67 81 if (value == null) … … 83 97 public void save() throws IOException { 84 98 PrintWriter out = new PrintWriter(new FileWriter(getPreferencesDir()+"preferences")); 85 out.println(XmlWriter.header()); 86 out.println("<josm>"); 87 for (Entry<String, String> e : properties.entrySet()) { 88 out.print(" <"+e.getKey()); 99 for (Entry<String, String> e : properties.entrySet()) 89 100 if (!e.getValue().equals("")) 90 out.print(" value='"+XmlWriter.encode(e.getValue())+"'"); 91 out.println(" />"); 92 } 93 out.println("</josm>"); 101 out.println(e.getKey()+"="+e.getValue()); 94 102 out.close(); 95 103 } … … 97 105 98 106 public void load() throws IOException { 99 MinML2 reader = new MinML2(){ 100 @Override public void startElement(String ns, String name, String qName, Attributes attr) { 101 if (name.equals("josm-settings")) 102 throw new RuntimeException("old version"); 103 String v = attr.getValue("value"); 104 if (!name.equals("josm")) 105 properties.put(name, v == null ? "" : v); 106 } 107 }; 108 try { 109 reader.parse(new FileReader(getPreferencesDir()+"preferences")); 110 } catch (SAXException e) { 111 e.printStackTrace(); 112 throw new IOException("Error in preferences file"); 107 properties.clear(); 108 BufferedReader in = new BufferedReader(new FileReader(getPreferencesDir()+"preferences")); 109 int lineNumber = 0; 110 for (String line = in.readLine(); line != null; line = in.readLine(), lineNumber++) { 111 int i = line.indexOf('='); 112 if (i == -1 || i == 0) 113 throw new IOException("Malformed config file at line "+lineNumber); 114 properties.put(line.substring(0,i), line.substring(i+1)); 113 115 } 114 116 } … … 118 120 properties.put("laf", "javax.swing.plaf.metal.MetalLookAndFeel"); 119 121 properties.put("projection", "org.openstreetmap.josm.data.projection.Epsg4263"); 120 properties.put("osmDataServer", "http://www.openstreetmap.org/api"); 122 properties.put("osm-server.url", "http://www.openstreetmap.org/api"); 123 properties.put("color.node", ColorHelper.color2html(Color.red)); 124 properties.put("color.segment", ColorHelper.color2html(SimplePaintVisitor.darkgreen)); 125 properties.put("color.way", ColorHelper.color2html(SimplePaintVisitor.darkblue)); 126 properties.put("color.incomplete way", ColorHelper.color2html(SimplePaintVisitor.darkerblue)); 127 properties.put("color.selected", ColorHelper.color2html(Color.white)); 128 properties.put("color.gps point", ColorHelper.color2html(Color.gray)); 121 129 } 122 130 } -
src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r71 r75 5 5 import java.awt.Point; 6 6 7 import org.openstreetmap.josm.Main; 7 8 import org.openstreetmap.josm.data.osm.LineSegment; 8 9 import org.openstreetmap.josm.data.osm.Node; 9 10 import org.openstreetmap.josm.data.osm.Way; 10 11 import org.openstreetmap.josm.gui.NavigatableComponent; 12 import org.openstreetmap.josm.tools.ColorHelper; 11 13 12 14 /** … … 18 20 public class SimplePaintVisitor implements Visitor { 19 21 20 p rivatefinal static Color darkerblue = new Color(0,0,96);21 p rivatefinal static Color darkblue = new Color(0,0,128);22 p rivatefinal static Color darkgreen = new Color(0,128,0);22 public final static Color darkerblue = new Color(0,0,96); 23 public final static Color darkblue = new Color(0,0,128); 24 public final static Color darkgreen = new Color(0,128,0); 23 25 24 26 /** … … 48 50 */ 49 51 public void visit(Node n) { 50 drawNode(n, n.isSelected() ? Color.WHITE : Color.RED); 52 drawNode(n, n.isSelected() ? getPreferencesColor("selected", Color.WHITE) 53 : getPreferencesColor("node", Color.RED)); 51 54 } 52 55 … … 56 59 */ 57 60 public void visit(LineSegment ls) { 58 drawLineSegment(ls, darkgreen);61 drawLineSegment(ls, getPreferencesColor("segment", darkgreen)); 59 62 } 60 63 … … 65 68 public void visit(Way t) { 66 69 // only to overwrite with blue 67 Color wayColor = darkblue;70 Color wayColor = getPreferencesColor("way", darkblue); 68 71 for (LineSegment ls : t.segments) { 69 72 if (ls.incomplete) { 70 wayColor = darkerblue;73 wayColor = getPreferencesColor("incomplete way", darkerblue); 71 74 break; 72 75 } … … 74 77 for (LineSegment ls : t.segments) 75 78 if (!ls.isSelected()) // selected already in good color 76 drawLineSegment(ls, t.isSelected() ? Color.WHITE: wayColor);79 drawLineSegment(ls, t.isSelected() ? getPreferencesColor("selected", Color.WHITE) : wayColor); 77 80 } 78 81 … … 96 99 return; 97 100 if (ls.isSelected()) 98 col = Color.WHITE;101 col = getPreferencesColor("selected", Color.WHITE); 99 102 g.setColor(col); 100 103 Point p1 = nc.getPoint(ls.from.eastNorth); … … 102 105 g.drawLine(p1.x, p1.y, p2.x, p2.y); 103 106 } 107 108 private Color getPreferencesColor(String colName, Color def) { 109 String colStr = Main.pref.get("color."+colName); 110 if (colStr.equals("")) 111 return def; 112 return ColorHelper.html2color(colStr); 113 } 104 114 } -
src/org/openstreetmap/josm/gui/PreferenceDialog.java
r74 r75 1 1 package org.openstreetmap.josm.gui; 2 2 3 import java.awt.Color; 3 4 import java.awt.Component; 4 5 import java.awt.Dimension; … … 8 9 import java.awt.event.ActionListener; 9 10 import java.io.IOException; 11 import java.util.Collection; 12 import java.util.Vector; 13 import java.util.Map.Entry; 10 14 11 15 import javax.swing.AbstractAction; … … 15 19 import javax.swing.JButton; 16 20 import javax.swing.JCheckBox; 21 import javax.swing.JColorChooser; 17 22 import javax.swing.JComboBox; 18 23 import javax.swing.JDialog; … … 22 27 import javax.swing.JPanel; 23 28 import javax.swing.JPasswordField; 29 import javax.swing.JScrollPane; 24 30 import javax.swing.JTabbedPane; 31 import javax.swing.JTable; 25 32 import javax.swing.JTextField; 26 33 import javax.swing.ListCellRenderer; 34 import javax.swing.ListSelectionModel; 27 35 import javax.swing.UIManager; 28 36 import javax.swing.UIManager.LookAndFeelInfo; 37 import javax.swing.table.TableCellRenderer; 29 38 30 39 import org.openstreetmap.josm.Main; 31 40 import org.openstreetmap.josm.data.projection.Projection; 41 import org.openstreetmap.josm.tools.ColorHelper; 32 42 import org.openstreetmap.josm.tools.GBC; 33 43 import org.openstreetmap.josm.tools.ImageProvider; … … 52 62 Main.pref.put("laf", ((LookAndFeelInfo)lafCombo.getSelectedItem()).getClassName()); 53 63 Main.pref.put("projection", projectionCombo.getSelectedItem().getClass().getName()); 54 Main.pref.put("osm DataServer", osmDataServer.getText());55 Main.pref.put("osm DataUsername", osmDataUsername.getText());64 Main.pref.put("osm-server.url", osmDataServer.getText()); 65 Main.pref.put("osm-server.username", osmDataUsername.getText()); 56 66 String pwd = String.valueOf(osmDataPassword.getPassword()); 57 67 if (pwd.equals("")) 58 68 pwd = null; 59 Main.pref.put("osm DataPassword", pwd);69 Main.pref.put("osm-server.password", pwd); 60 70 Main.pref.put("csvImportString", csvImportString.getText()); 61 71 Main.pref.put("drawRawGpsLines", drawRawGpsLines.isSelected()); 62 72 Main.pref.put("forceRawGpsLines", forceRawGpsLines.isSelected()); 73 74 for (int i = 0; i < colors.getRowCount(); ++i) { 75 String name = (String)colors.getValueAt(i, 0); 76 Color col = (Color)colors.getValueAt(i, 1); 77 Main.pref.put("color."+name, ColorHelper.color2html(col)); 78 } 79 63 80 try { 64 81 Main.pref.save(); … … 69 86 if (requiresRestart) 70 87 JOptionPane.showMessageDialog(PreferenceDialog.this, "You have to restart JOSM for some settings to take effect."); 88 Main.main.repaint(); 71 89 setVisible(false); 72 90 } … … 130 148 JCheckBox forceRawGpsLines = new JCheckBox("Force lines if no line segments imported."); 131 149 150 JTable colors; 151 152 132 153 /** 133 154 * Create a preference setting dialog from an preferences-file. If the file does not … … 140 161 141 162 // look and feel combo box 142 lafCombo.setSelectedItem(Main.pref.get("laf")); 163 String laf = Main.pref.get("laf"); 164 for (int i = 0; i < lafCombo.getItemCount(); ++i) { 165 if (((LookAndFeelInfo)lafCombo.getItemAt(i)).getClassName().equals(laf)) { 166 lafCombo.setSelectedIndex(i); 167 break; 168 } 169 } 143 170 final ListCellRenderer oldRenderer = lafCombo.getRenderer(); 144 171 lafCombo.setRenderer(new DefaultListCellRenderer(){ … … 175 202 }); 176 203 177 204 osmDataServer.setText(Main.pref.get("osm-server.url")); 205 osmDataUsername.setText(Main.pref.get("osm-server.username")); 206 osmDataPassword.setText(Main.pref.get("osm-server.password")); 207 csvImportString.setText(Main.pref.get("csvImportString")); 208 drawRawGpsLines.setSelected(Main.pref.getBoolean("drawRawGpsLines")); 209 forceRawGpsLines.setToolTipText("Force drawing of lines if the imported data contain no line information."); 210 forceRawGpsLines.setSelected(Main.pref.getBoolean("forceRawGpsLines")); 211 forceRawGpsLines.setEnabled(drawRawGpsLines.isSelected()); 212 213 214 Collection<Entry<String,String>> c = Main.pref.getAllPrefix("color."); 215 Vector<Vector<Object>> rows = new Vector<Vector<Object>>(); 216 for (Entry<String,String> e : c) { 217 Vector<Object> row = new Vector<Object>(2); 218 row.add(e.getKey().substring("color.".length())); 219 row.add(ColorHelper.html2color(e.getValue())); 220 rows.add(row); 221 } 222 Vector<Object> cols = new Vector<Object>(2); 223 cols.add("Color"); 224 cols.add("Name"); 225 colors = new JTable(rows, cols){ 226 @Override public boolean isCellEditable(int row, int column) { 227 return false; 228 } 229 }; 230 colors.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 231 JButton colorEdit = new JButton("Choose"); 232 colorEdit.addActionListener(new ActionListener(){ 233 public void actionPerformed(ActionEvent e) { 234 if (colors.getSelectedRowCount() == 0) { 235 JOptionPane.showMessageDialog(PreferenceDialog.this, "Please select a color."); 236 return; 237 } 238 int sel = colors.getSelectedRow(); 239 JColorChooser chooser = new JColorChooser((Color)colors.getValueAt(sel, 1)); 240 int answer = JOptionPane.showConfirmDialog(PreferenceDialog.this, chooser, "Choose a color for "+colors.getValueAt(sel, 0), JOptionPane.OK_CANCEL_OPTION); 241 if (answer == JOptionPane.OK_OPTION) 242 colors.setValueAt(chooser.getColor(), sel, 1); 243 } 244 }); 245 final TableCellRenderer oldColorsRenderer = colors.getDefaultRenderer(Object.class); 246 colors.setDefaultRenderer(Object.class, new TableCellRenderer(){ 247 public Component getTableCellRendererComponent(JTable t, Object o, boolean selected, boolean focus, int row, int column) { 248 if (column == 1) { 249 JLabel l = new JLabel(ColorHelper.color2html((Color)o)); 250 l.setBackground((Color)o); 251 l.setOpaque(true); 252 return l; 253 } 254 return oldColorsRenderer.getTableCellRendererComponent(t,o,selected,focus,row,column); 255 } 256 }); 257 colors.getColumnModel().getColumn(1).setWidth(100); 258 259 // setting tooltips 178 260 osmDataServer.setToolTipText("The base URL to the OSM server (REST API)"); 179 261 osmDataUsername.setToolTipText("Login name (email) to the OSM account."); … … 186 268 "Other example: \"lat,lon\" will just read lat/lon values comma seperated.</html>"); 187 269 drawRawGpsLines.setToolTipText("If your gps device draw to few lines, select this to draw lines along your way."); 188 drawRawGpsLines.setSelected(Main.pref.getBoolean("drawRawGpsLines")); 189 forceRawGpsLines.setToolTipText("Force drawing of lines if the imported data contain no line information."); 190 forceRawGpsLines.setSelected(Main.pref.getBoolean("forceRawGpsLines")); 191 forceRawGpsLines.setEnabled(drawRawGpsLines.isSelected()); 192 193 osmDataServer.setText(Main.pref.get("osmDataServer")); 194 osmDataUsername.setText(Main.pref.get("osmDataUsername")); 195 osmDataPassword.setText(Main.pref.get("osmDataPassword")); 196 csvImportString.setText(Main.pref.get("csvImportString")); 197 270 colors.setToolTipText("Colors used by different objects in JOSM."); 271 272 // creating the gui 273 198 274 // Display tab 199 275 JPanel display = createPreferenceTab("display", "Display Settings", "Various settings that influence the visual representation of the whole program."); … … 202 278 display.add(lafCombo, GBC.eol().fill(GBC.HORIZONTAL)); 203 279 display.add(drawRawGpsLines, GBC.eol().insets(20,0,0,0)); 204 display.add(forceRawGpsLines, GBC.eol().insets(40,0,0,0)); 205 display.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL)); 280 display.add(forceRawGpsLines, GBC.eop().insets(40,0,0,0)); 281 display.add(new JLabel("Colors"), GBC.eol()); 282 colors.setPreferredScrollableViewportSize(new Dimension(100,112)); 283 display.add(new JScrollPane(colors), GBC.eol().fill(GBC.BOTH)); 284 display.add(colorEdit, GBC.eol().anchor(GBC.EAST)); 285 //display.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL)); 206 286 207 287 // Connection tab … … 221 301 con.add(new JLabel("CSV import specification (empty: read from first line in data)"), GBC.eol()); 222 302 con.add(csvImportString, GBC.eop().fill(GBC.HORIZONTAL)); 303 con.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL)); 223 304 224 305 // Map tab -
src/org/openstreetmap/josm/gui/dialogs/LayerList.java
r71 r75 30 30 import org.openstreetmap.josm.gui.layer.Layer; 31 31 import org.openstreetmap.josm.tools.ImageProvider; 32 import org.openstreetmap.josm.tools.ImageProvider.OverlayPosition; 32 33 33 34 /** … … 86 87 Icon icon = layer.getIcon(); 87 88 if (!layer.visible) 88 icon = ImageProvider.overlay(icon, invisible, ImageProvider.OverlayPosition.SOUTHEAST);89 icon = ImageProvider.overlay(icon, invisible, OverlayPosition.SOUTHEAST); 89 90 label.setIcon(icon); 90 91 label.setToolTipText(layer.getToolTipText()); -
src/org/openstreetmap/josm/gui/layer/RawGpsDataLayer.java
r74 r75 16 16 import org.openstreetmap.josm.data.projection.Projection; 17 17 import org.openstreetmap.josm.gui.MapView; 18 import org.openstreetmap.josm.tools.ColorHelper; 18 19 import org.openstreetmap.josm.tools.ImageProvider; 19 20 … … 62 63 @Override 63 64 public void paint(Graphics g, MapView mv) { 64 g.setColor(Color.GRAY); 65 String gpsCol = Main.pref.get("color.gps point"); 66 if (gpsCol.equals("")) 67 g.setColor(Color.GRAY); 68 else 69 g.setColor(ColorHelper.html2color(gpsCol)); 65 70 Point old = null; 66 71 for (Collection<EastNorth> c : eastNorth) { -
src/org/openstreetmap/josm/io/OsmConnection.java
r74 r75 39 39 @Override 40 40 protected PasswordAuthentication getPasswordAuthentication() { 41 String username = Main.pref.get("osm DataUsername");42 String password = Main.pref.get("osm DataPassword");41 String username = Main.pref.get("osm-server.username"); 42 String password = Main.pref.get("osm-server.password"); 43 43 if (passwordtried || username.equals("") || password.equals("")) { 44 44 JPanel p = new JPanel(new GridBagLayout()); -
src/org/openstreetmap/josm/io/OsmServerReader.java
r74 r75 48 48 */ 49 49 public Collection<Collection<LatLon>> parseRawGps() throws IOException, JDOMException { 50 String url = Main.pref.get("osm DataServer")+"/0.3/trackpoints?bbox="+lon1+","+lat1+","+lon2+","+lat2+"&page=";50 String url = Main.pref.get("osm-server.url")+"/0.3/trackpoints?bbox="+lon1+","+lat1+","+lon2+","+lat2+"&page="; 51 51 Collection<Collection<LatLon>> data = new LinkedList<Collection<LatLon>>(); 52 52 Collection<LatLon> list = new LinkedList<LatLon>(); … … 80 80 */ 81 81 public DataSet parseOsm() throws SAXException, IOException { 82 Reader r = getReader(Main.pref.get("osm DataServer")+"/0.3/map?bbox="+lon1+","+lat1+","+lon2+","+lat2);82 Reader r = getReader(Main.pref.get("osm-server.url")+"/0.3/map?bbox="+lon1+","+lat1+","+lon2+","+lat2); 83 83 if (r == null) 84 84 return null; -
src/org/openstreetmap/josm/io/OsmServerWriter.java
r74 r75 136 136 OsmPrimitive osm, boolean addBody) { 137 137 try { 138 URL url = new URL(Main.pref.get("osm DataServer") + "/0.3/" + urlSuffix + "/" + osm.id);138 URL url = new URL(Main.pref.get("osm-server.url") + "/0.3/" + urlSuffix + "/" + osm.id); 139 139 System.out.println("upload to: "+url); 140 140 HttpURLConnection con = (HttpURLConnection) url.openConnection(); -
src/org/openstreetmap/josm/tools/ImageProvider.java
r71 r75 25 25 * @author imi 26 26 */ 27 public enum OverlayPosition {NORTHWEST, NORTHEAST, SOUTHWEST, SOUTHEAST} 27 public final static class OverlayPosition { 28 private OverlayPosition() {} 29 public static OverlayPosition NORTHWEST = new OverlayPosition(); 30 public static OverlayPosition NORTHEAST = new OverlayPosition(); 31 public static OverlayPosition SOUTHWEST = new OverlayPosition(); 32 public static OverlayPosition SOUTHEAST = new OverlayPosition(); 33 } 34 28 35 29 36 /** … … 78 85 ground.paintIcon(null, g, 0, 0); 79 86 int x = 0, y = 0; 80 switch (pos) { 81 case NORTHWEST: x = 0; y = 0; break; 82 case NORTHEAST: x = w-wo; y = 0; break; 83 case SOUTHWEST: x = 0; y = h-ho; break; 84 case SOUTHEAST: x = w-wo; y = h-ho; break; 87 if (pos == OverlayPosition.NORTHWEST) { 88 x = 0; 89 y = 0; 90 } else if (pos == OverlayPosition.NORTHEAST) { 91 x = w-wo; 92 y = 0; 93 } else if (pos == OverlayPosition.SOUTHWEST) { 94 x = 0; 95 y = h-ho; 96 } else if (pos == OverlayPosition.SOUTHEAST) { 97 x = w-wo; 98 y = h-ho; 85 99 } 86 100 overlay.paintIcon(null, g, x, y);
Note:
See TracChangeset
for help on using the changeset viewer.