Changeset 24832 in osm for applications/editors/josm
- Timestamp:
- 2010-12-21T19:09:24+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/smed/plugs
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed/plugs/harbour/src/harbour/dialogs/HarbourAction.java
r24677 r24832 25 25 import org.openstreetmap.josm.gui.layer.Layer; 26 26 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 27 import javax.swing.SwingConstants; 27 28 28 29 public class HarbourAction implements PropertyChangeListener, LayerChangeListener, EditLayerChangeListener, ComponentListener { … … 61 62 private JPanel curPanel = null; 62 63 private PanelSearchPois panelSearchPois = null; 63 private static LayerHarbour curLayer = n ew LayerHarbour("Harbour");64 private static LayerHarbour curLayer = null; 64 65 65 66 public HarbourAction() { … … 90 91 panelSearchPois.setBounds(rect); 91 92 panelSearchPois.setVisible(false); 93 94 curLayer = new LayerHarbour("Harbour", panelSearchPois); 95 panelSearchPois.setLayerHarbour(curLayer); 92 96 } 93 97 … … 190 194 relButton.setEnabled(true); 191 195 196 Main.map.mapView.removeLayerChangeListener(curLayer); 192 197 Main.main.removeLayer(curLayer); 193 198 curPanel = panelGeneral; … … 224 229 relButton.setEnabled(true); 225 230 231 Main.map.mapView.removeLayerChangeListener(curLayer); 226 232 Main.main.removeLayer(curLayer); 227 233 curPanel = panelLimits; … … 258 264 relButton.setEnabled(true); 259 265 260 266 Main.map.mapView.removeLayerChangeListener(curLayer); 261 267 Main.main.removeLayer(curLayer); 262 268 curPanel = panelServices; … … 280 286 envButton.addActionListener(new java.awt.event.ActionListener() { 281 287 public void actionPerformed(java.awt.event.ActionEvent e) { 288 String name = null; 289 282 290 panelGeneral.setVisible(false); 283 291 panelLimits.setVisible(false); … … 293 301 relButton.setEnabled(true); 294 302 303 panelSearchPois.iniLayer(); 304 305 name = panelSearchPois.getActiveLayer(); 306 if(name != null) curLayer.setName("Harbour - " + name); 307 else curLayer.setName("Harbour"); 308 309 Layer tmp = Main.map.mapView.getActiveLayer(); 310 311 Main.map.mapView.addLayerChangeListener(curLayer); 295 312 Main.main.addLayer(curLayer); 313 314 Main.map.mapView.setActiveLayer(tmp); 315 296 316 curPanel = panelEnv; 297 317 } … … 327 347 relButton.setEnabled(false); 328 348 349 Main.map.mapView.removeLayerChangeListener(curLayer); 329 350 Main.main.removeLayer(curLayer); 330 351 curPanel = panelRelations; … … 507 528 if (chartButton == null) { 508 529 chartButton = new JToggleButton(); 509 chartButton.setBounds(new Rectangle(3 67, 5, 28, 18));530 chartButton.setBounds(new Rectangle(375, 4, 20, 20)); 510 531 chartButton.setSelected(false); 532 chartButton.setIcon(new ImageIcon(getClass().getResource("/images/oseam_20x20.png"))); 533 chartButton.setHorizontalTextPosition(SwingConstants.LEADING); 511 534 chartButton.setEnabled(false); 512 535 chartButton.addActionListener(new java.awt.event.ActionListener() { … … 519 542 envButton.setEnabled(false); 520 543 relButton.setEnabled(false); 544 panelSearchPois.setVisible(true); 521 545 522 if(curPanel == panelEnv) { 523 panelEnv.setVisible(false); 524 panelSearchPois.setVisible(true); 525 } else if(curPanel == panelRelations) panelRelations.setVisible(false); 546 if(curPanel == panelEnv) panelEnv.setVisible(false); 547 else if(curPanel == panelRelations) panelRelations.setVisible(false); 548 526 549 } else { 527 550 comButton.setEnabled(true); 528 551 restButton.setEnabled(true); 529 552 servButton.setEnabled(true); 530 envButton.setEnabled(true); 531 relButton.setEnabled(true); 553 panelSearchPois.setVisible(false); 532 554 533 555 if(curPanel == panelEnv) { 534 556 panelEnv.setVisible(true); 535 panelSearchPois.setVisible(false); 536 } else if(curPanel == panelRelations) panelRelations.setVisible(true); 557 relButton.setEnabled(true); 558 } else if(curPanel == panelRelations) { 559 panelRelations.setVisible(true); 560 envButton.setEnabled(true); 561 } 537 562 } 538 563 } -
applications/editors/josm/plugins/smed/plugs/harbour/src/harbour/layers/LayerHarbour.java
r24574 r24832 1 1 package harbour.layers; 2 2 3 import static java.lang.Math.sin; 4 import static java.lang.Math.cos; 5 6 import harbour.panels.PanelSearchPois; 7 8 import java.awt.BasicStroke; 9 import java.awt.Color; 3 10 import java.awt.Graphics2D; 11 import java.awt.Point; 4 12 5 13 import javax.swing.Action; 6 14 import javax.swing.Icon; 15 import javax.swing.JComboBox; 7 16 17 import org.openstreetmap.josm.Main; 8 18 import org.openstreetmap.josm.data.Bounds; 19 import org.openstreetmap.josm.data.coor.LatLon; 20 import org.openstreetmap.josm.data.osm.DataSet; 21 import org.openstreetmap.josm.data.osm.Node; 9 22 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 10 23 import org.openstreetmap.josm.gui.MapView; 24 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 11 25 import org.openstreetmap.josm.gui.layer.Layer; 26 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 12 27 import org.openstreetmap.josm.tools.ImageProvider; 13 28 14 public class LayerHarbour extends Layer { 15 16 public LayerHarbour(String name) { 17 super(name); 29 public class LayerHarbour extends OsmDataLayer implements LayerChangeListener { 30 31 private JComboBox layerBox = null; 32 private PanelSearchPois panel = null; 33 private static DataSet ds = new DataSet(); 34 private double radius = -1.0; 35 private LatLon lm = null; 36 private boolean isChanged = true; 37 38 public LayerHarbour(String name,PanelSearchPois panel) { 39 super(ds, name, null); 40 41 this.panel = panel; 42 panel.setPois(ds); 43 layerBox = panel.getLayerComboBox(); 18 44 } 19 45 … … 54 80 55 81 @Override 56 public void paint(Graphics2D arg0, MapView arg1, Bounds arg2) {57 // TODO Auto-generated method stub82 public void paint(Graphics2D g, MapView mv, Bounds box) { 83 isChanged = false; 58 84 85 Point mp = null; 86 Point mx = null; 87 88 if(radius > 0.0 && lm != null) { 89 LatLon lx = new LatLon(lm.lat(), lm.lon() + radius/65.0); 90 91 mp = mv.getPoint(lm); 92 mx = mv.getPoint(lx); 93 94 int r = mx.x - mp.x; 95 96 g.setColor(Color.RED); 97 g.setStroke(new BasicStroke(3)); 98 99 g.drawOval(mp.x-r, mp.y-r, 2*r, 2*r); 100 101 g.setStroke(new BasicStroke(1)); 102 } 103 104 super.paint(g, mv, box); 59 105 } 60 106 … … 65 111 } 66 112 113 @Override 114 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 115 if(newLayer instanceof OsmDataLayer) { 116 String n = newLayer.getName(); 117 118 setName("Harbour - " + n); 119 layerBox.setSelectedItem(n); 120 } 121 else setName("Harbour"); 122 } 123 124 @Override 125 public void layerAdded(Layer arg0) { 126 // TODO Auto-generated method stub 127 128 } 129 130 @Override 131 public void layerRemoved(Layer arg0) { 132 // TODO Auto-generated method stub 133 134 } 135 136 public void setRadius(double r) { 137 if(radius != r){ 138 radius = r; 139 140 isChanged = true; 141 Main.map.repaint(); 142 } 143 } 144 145 public boolean isChanged() { return isChanged; } 146 147 public void setCenter(LatLon coor) { 148 if(lm != coor) { 149 lm = coor; 150 151 isChanged = true; 152 Main.map.repaint(); 153 } 154 } 155 156 public boolean isNodeinCircle(Node n) { 157 if(radius < 0.0) return true; 158 159 LatLon coor = n.getCoor(); 160 161 if(coor == null) return false; 162 return coor.greatCircleDistance(lm) < radius * 1000; 163 } 67 164 } -
applications/editors/josm/plugins/smed/plugs/harbour/src/harbour/models/SearchTableModel.java
r24751 r24832 12 12 "Show"}; 13 13 private Object[][] data = { 14 {"amenity","", new Boolean(false) },15 14 {"amenity","bank", new Boolean(false) }, 16 15 {"amenity","cafe", new Boolean(false) }, … … 25 24 {"amenity","telephone", new Boolean(false) }, 26 25 {"amenity","toilets", new Boolean(false) }, 27 {"information","", new Boolean(false) },28 26 {"information","board", new Boolean(false) }, 29 27 {"information","citymap", new Boolean(false) }, … … 75 73 } 76 74 75 public Boolean isWanted(int i) { return (Boolean) data[i][2]; } 76 public String getKey(int i) { return (String) data[i][0]; } 77 public String getValue(int i) { return (String) data[i][1]; } 77 78 } -
applications/editors/josm/plugins/smed/plugs/harbour/src/harbour/panels/PanelSearchPois.java
r24751 r24832 9 9 import java.awt.Rectangle; 10 10 import java.awt.Font; 11 import java.awt.event.FocusEvent; 12 import java.awt.event.FocusListener; 13 import java.awt.event.KeyEvent; 14 import java.beans.PropertyChangeEvent; 15 import java.beans.PropertyChangeListener; 16 import java.util.ArrayList; 17 import java.util.Collection; 18 import java.util.Iterator; 19 import java.util.List; 20 import java.util.Map; 21 11 22 import javax.swing.JTextField; 12 23 import javax.swing.JButton; … … 14 25 import javax.swing.JTable; 15 26 import javax.swing.JComboBox; 27 import javax.swing.table.TableModel; 28 29 import org.openstreetmap.josm.Main; 30 import org.openstreetmap.josm.data.coor.LatLon; 31 import org.openstreetmap.josm.data.gpx.WayPoint; 32 import org.openstreetmap.josm.data.osm.DataSet; 33 import org.openstreetmap.josm.data.osm.Node; 34 import org.openstreetmap.josm.gui.MapView; 35 import org.openstreetmap.josm.gui.layer.Layer; 36 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 37 38 import harbour.layers.LayerHarbour; 16 39 import harbour.models.SearchTableModel; 17 40 18 public class PanelSearchPois extends JPanel {41 public class PanelSearchPois extends JPanel implements PropertyChangeListener{ 19 42 20 43 private static final long serialVersionUID = 1L; 21 private JLabel radLabel = null; 22 private JTextField radTextField = null; 23 private JLabel unitLabel = null; 24 private JButton jButton = null; 25 private JScrollPane jScrollPane = null; 26 private JTable jTable = null; 27 private JLabel layerLabel = null; 28 private JComboBox layerComboBox = null; 29 44 private JLabel radLabel = null; 45 private JTextField radTextField = null; 46 private JLabel unitLabel = null; 47 private JButton searchButton = null; 48 private JScrollPane jScrollPane = null; 49 private JTable searchTable = null; 50 private JLabel layerLabel = null; 51 private JComboBox layerComboBox = null; 52 private String activeLayer = null; 53 private LayerHarbour layerHarbour = null; // @jve:decl-index=0: 54 private List<Layer> layers = new ArrayList<Layer>(); // @jve:decl-index=0: 55 private JButton setButton = null; 56 private DataSet pois = null; 57 30 58 /** 31 59 * This is the default constructor … … 49 77 unitLabel.setBounds(new Rectangle(130, 240, 20, 21)); 50 78 unitLabel.setFont(new Font("Dialog", Font.PLAIN, 12)); 51 unitLabel.setText(" m");79 unitLabel.setText("km"); 52 80 radLabel = new JLabel(); 53 81 radLabel.setBounds(new Rectangle(5, 240, 55, 20)); … … 60 88 this.add(getRadTextField(), null); 61 89 this.add(unitLabel, null); 62 this.add(get JButton(), null);90 this.add(getSearchButton(), null); 63 91 this.add(getJScrollPane(), null); 64 92 this.add(layerLabel, null); 65 93 this.add(getLayerComboBox(), null); 94 this.add(getSetButton(), null); 66 95 } 67 96 … … 75 104 radTextField = new JTextField(); 76 105 radTextField.setBounds(new Rectangle(60, 240, 70, 20)); 106 radTextField.addFocusListener(new FocusListener() { 107 108 @Override 109 public void focusGained(FocusEvent arg0) { 110 // nothing to do yet 111 } 112 113 @Override 114 public void focusLost(FocusEvent arg0) { 115 double r = Double.parseDouble(radTextField.getText()); 116 117 layerHarbour.setRadius(r); 118 } 119 120 }); 121 122 radTextField.addKeyListener(new java.awt.event.KeyAdapter() { 123 public void keyTyped(java.awt.event.KeyEvent e) { 124 if(e.getKeyChar() == KeyEvent.VK_ENTER) { 125 double r = Double.parseDouble(radTextField.getText()); 126 127 layerHarbour.setRadius(r); 128 } 129 } 130 }); 77 131 } 78 132 return radTextField; … … 80 134 81 135 /** 82 * This method initializes jButton136 * This method initializes searchButton 83 137 * 84 138 * @return javax.swing.JButton 85 139 */ 86 private JButton getJButton() { 87 if (jButton == null) { 88 jButton = new JButton(); 89 jButton.setBounds(new Rectangle(240, 240, 80, 20)); 90 jButton.setText("Suche"); 91 } 92 return jButton; 140 private JButton getSearchButton() { 141 if (searchButton == null) { 142 searchButton = new JButton(); 143 searchButton.setBounds(new Rectangle(240, 240, 80, 20)); 144 searchButton.setFont(new Font("Dialog", Font.PLAIN, 12)); 145 searchButton.setText("Suche"); 146 searchButton.addActionListener(new java.awt.event.ActionListener() { 147 public void actionPerformed(java.awt.event.ActionEvent e) { 148 searchPois(); 149 } 150 }); 151 } 152 153 return searchButton; 93 154 } 94 155 … … 102 163 jScrollPane = new JScrollPane(); 103 164 jScrollPane.setBounds(new Rectangle(10, 35, 310, 195)); 104 jScrollPane.setViewportView(get JTable());165 jScrollPane.setViewportView(getSearchTable()); 105 166 } 106 167 return jScrollPane; … … 108 169 109 170 /** 110 * This method initializes jTable171 * This method initializes searchTable 111 172 * 112 173 * @return javax.swing.JTable 113 174 */ 114 private JTable get JTable() {115 if ( jTable == null) {116 jTable = new JTable();117 jTable.setModel(new SearchTableModel());118 } 119 return jTable;175 private JTable getSearchTable() { 176 if (searchTable == null) { 177 searchTable = new JTable(); 178 searchTable.setModel(new SearchTableModel()); 179 } 180 return searchTable; 120 181 } 121 182 … … 125 186 * @return javax.swing.JComboBox 126 187 */ 127 p rivateJComboBox getLayerComboBox() {188 public JComboBox getLayerComboBox() { 128 189 if (layerComboBox == null) { 129 190 layerComboBox = new JComboBox(); 130 191 layerComboBox.setBounds(new Rectangle(70, 5, 250, 20)); 192 layerComboBox.addActionListener(new java.awt.event.ActionListener() { 193 public void actionPerformed(java.awt.event.ActionEvent e) { 194 int i = layerComboBox.getSelectedIndex(); 195 196 if(i >= 0) { 197 Main.map.mapView.setActiveLayer(layers.get(i)); 198 } 199 } 200 }); 131 201 } 132 202 return layerComboBox; 133 203 } 134 204 205 @Override 206 public void propertyChange(PropertyChangeEvent event) { 207 Object src = event.getSource(); 208 209 System.out.println("Hello, world"); 210 211 if (src instanceof MapView) { 212 MapView mapView = (MapView) src; 213 214 for (Layer l: mapView.getAllLayers()) { 215 if(l instanceof OsmDataLayer) layerComboBox.addItem(l.getName()); 216 } 217 } 218 219 } 220 221 public void iniLayer() { 222 Layer a = Main.map.mapView.getActiveLayer(); 223 String name = null; 224 225 layerComboBox.removeAllItems(); 226 layers.clear(); 227 228 for (Layer l: Main.map.mapView.getAllLayers()) { 229 if(l instanceof OsmDataLayer) { 230 name = l.getName(); 231 layers.add(l); 232 233 layerComboBox.addItem(name); 234 if(l.equals(a)) activeLayer = name; 235 } 236 } 237 } 238 239 public String getActiveLayer() { return activeLayer; } 240 public void setLayerHarbour(LayerHarbour layer) { layerHarbour = layer; } 241 242 /** 243 * This method initializes setButton 244 * 245 * @return javax.swing.JButton 246 */ 247 private JButton getSetButton() { 248 if (setButton == null) { 249 setButton = new JButton(); 250 setButton.setBounds(new Rectangle(160, 240, 55, 20)); 251 setButton.setFont(new Font("Dialog", Font.PLAIN, 12)); 252 setButton.setText("Set"); 253 setButton.addActionListener(new java.awt.event.ActionListener() { 254 public void actionPerformed(java.awt.event.ActionEvent e) { 255 DataSet ds = Main.main.getCurrentDataSet(); 256 Collection<Node> selection = ds.getSelectedNodes(); 257 int nodes = selection.size(); 258 259 if(nodes != 0) { 260 Iterator<Node> it = selection.iterator(); 261 Node node = it.next(); 262 263 layerHarbour.setCenter(node.getCoor()); 264 } 265 } 266 }); 267 } 268 return setButton; 269 } 270 271 public void searchPois() { 272 DataSet data = Main.main.getCurrentDataSet(); 273 Collection<Node> nodes = data.getNodes(); 274 SearchTableModel searchModel = (SearchTableModel) searchTable.getModel(); 275 276 pois.clear(); 277 278 for(Node n : nodes) { 279 if(layerHarbour.isNodeinCircle(n)) { 280 Map<String, String> keys = n.getKeys(); 281 282 for(int i = 0; i < searchTable.getRowCount(); i++){ 283 if(searchModel.isWanted(i)) { 284 String key = searchModel.getKey(i); 285 286 if(keys.containsKey(key)) { 287 String type = keys.get(key); 288 if(type.equals(searchModel.getValue(i))) { 289 Node nc = new Node(1); 290 291 nc.cloneFrom(n); 292 pois.addPrimitive(nc); 293 } 294 } 295 } 296 } 297 } 298 } 299 } 300 301 public void setPois(DataSet pois) { this.pois = pois; } 302 135 303 } -
applications/editors/josm/plugins/smed/plugs/harbour/src/harbour/panels/PanelServices.java
r24751 r24832 1 1 package harbour.panels; 2 2 3 3 4 import harbour.widgets.CraneTable; … … 92 93 DLLabel = new JLabel(); 93 94 DLLabel.setBounds(new Rectangle(3, 165, 147, 20)); 95 DLLabel.setFont(new Font("Dialog", Font.PLAIN, 12)); 94 96 DLLabel.setText("weitere Dienstleistungen"); 95 97 moorLabel = new JLabel(); … … 99 101 loadLabel = new JLabel(); 100 102 loadLabel.setBounds(new Rectangle(3, 50, 97, 16)); 103 loadLabel.setFont(new Font("Dialog", Font.PLAIN, 12)); 101 104 loadLabel.setText("Laden / Entladen"); 102 105 airLabel = new JLabel(); … … 614 617 if (craneScrollPane == null) { 615 618 craneScrollPane = new CraneTable(); 616 craneScrollPane.setBounds(new Rectangle(3, 90, 207, 66));619 craneScrollPane.setBounds(new Rectangle(3, 90, 207, 71)); 617 620 } 618 621 return craneScrollPane; -
applications/editors/josm/plugins/smed/plugs/smed_about/src/smed_about/SmedAbout.java
r24632 r24832 91 91 aboutCopyright.setBounds(new Rectangle(125, 0, 245, 55)); 92 92 aboutCopyright.setText("<HTML><BODY>Copyright (c) 2009 / 2010<BR><center>by" + 93 "<BR>Werner K nig & Malcolm Herring</BODY></HTML>");93 "<BR>Werner König & Malcolm Herring</BODY></HTML>"); 94 94 95 95 aboutAuthors = new JLabel(); 96 96 aboutAuthors.setBounds(new Rectangle(30, 50 97 97 , 340, 30)); 98 aboutAuthors.setText("Authors: Werner K nig and Malcolm Herring");98 aboutAuthors.setText("Authors: Werner König and Malcolm Herring"); 99 99 100 100 aboutVersion = new JLabel();
Note:
See TracChangeset
for help on using the changeset viewer.