Changeset 17 in josm for src/org/openstreetmap/josm/data


Ignore:
Timestamp:
2005-10-09T04:14:40+02:00 (19 years ago)
Author:
imi
Message:
  • added Layer support
  • added support for raw GPS data
  • fixed tooltips
  • added options for loading gpx files
Location:
src/org/openstreetmap/josm/data
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/data/GeoPoint.java

    r9 r17  
    5959        }
    6060       
    61        
     61        /**
     62         * @return <code>true</code>, if the other GeoPoint has the same lat/lon values.
     63         */
     64        public boolean equalsLatLon(GeoPoint other) {
     65                return lat == other.lat && lon == other.lon;
     66        }
    6267}
  • src/org/openstreetmap/josm/data/Preferences.java

    r16 r17  
    11package org.openstreetmap.josm.data;
    22
     3import java.beans.PropertyChangeEvent;
     4import java.beans.PropertyChangeListener;
    35import java.io.File;
    46import java.io.FileReader;
     
    3840
    3941
     42        /**
     43         * Whether lines should be drawn between track points of raw gps data.
     44         */
     45        private boolean drawRawGpsLines = false;
    4046        /**
    4147         * Whether nodes on the same place should be considered identical.
     
    100106
    101107                        mergeNodes = root.getChild("mergeNodes") != null;
     108                        drawRawGpsLines = root.getChild("drawRawGpsLines") != null;
    102109                } catch (Exception e) {
    103110                        if (e instanceof PreferencesException)
     
    120127                if (mergeNodes)
    121128                        children.add(new Element("mergeNodes"));
     129                if (drawRawGpsLines)
     130                        children.add(new Element("drawRawGpsLines"));
    122131
    123132                try {
     
    134143       
    135144        /**
    136          * This interface notifies any interested about changes in the projection
    137          * @author imi
    138          */
    139         public interface ProjectionChangeListener {
    140                 void projectionChanged(Projection oldProjection, Projection newProjection);
    141         }
    142         /**
    143145         * The list of all listeners to projection changes.
    144146         */
    145         private Collection<ProjectionChangeListener> listener = new LinkedList<ProjectionChangeListener>();
     147        private Collection<PropertyChangeListener> listener = new LinkedList<PropertyChangeListener>();
    146148        /**
    147149         * Add a listener of projection changes to the list of listeners.
    148150         * @param listener The listerner to add.
    149151         */
    150         public void addProjectionChangeListener(ProjectionChangeListener listener) {
     152        public void addPropertyChangeListener(PropertyChangeListener listener) {
    151153                if (listener != null)
    152154                        this.listener.add(listener);
     
    155157         * Remove the listener from the list.
    156158         */
    157         public void removeProjectionChangeListener(ProjectionChangeListener listener) {
     159        public void removePropertyChangeListener(PropertyChangeListener listener) {
    158160                this.listener.remove(listener);
    159161        }
     162        /**
     163         * Fires a PropertyChangeEvent if the old value differs from the new value.
     164         */
     165        private <T> void firePropertyChanged(String name, T oldValue, T newValue) {
     166                if (oldValue == newValue)
     167                        return;
     168                PropertyChangeEvent evt = null;
     169                for (PropertyChangeListener l : listener) {
     170                        if (evt == null)
     171                                evt = new PropertyChangeEvent(this, name, oldValue, newValue);
     172                        l.propertyChange(evt);
     173                }
     174        }
     175
     176        // getter / setter
     177       
    160178        /**
    161179         * Set the projection and fire an event to all ProjectionChangeListener
     
    165183                Projection old = this.projection;
    166184                this.projection = projection;
    167                 if (old != projection)
    168                         for (ProjectionChangeListener l : listener)
    169                                 l.projectionChanged(old, projection);
     185                firePropertyChanged("projection", old, projection);
    170186        }
    171187        /**
     
    176192                return projection;
    177193        }
     194        public void setDrawRawGpsLines(boolean drawRawGpsLines) {
     195                boolean old = this.drawRawGpsLines;
     196                this.drawRawGpsLines = drawRawGpsLines;
     197                firePropertyChanged("drawRawGpsLines", old, drawRawGpsLines);
     198        }
     199        public boolean isDrawRawGpsLines() {
     200                return drawRawGpsLines;
     201        }
    178202}
  • src/org/openstreetmap/josm/data/osm/DataSet.java

    r16 r17  
    186186
    187187        /**
     188         * Import the given dataset by merging all data with this dataset.
     189         * The objects imported are not cloned, so from now on, these data belong
     190         * to both datasets. So use mergeFrom only if you are about to abandon the
     191         * other dataset or this dataset.
     192         *
     193         * @param ds    The DataSet to merge into this one.
     194         * @param mergeEqualNodes If <code>true</code>, nodes with the same lat/lon
     195         *              are merged together.
     196         */
     197        public void mergeFrom(DataSet ds, boolean mergeEqualNodes) {
     198                if (mergeEqualNodes) {
     199                        LinkedList<Node> nodesToAdd = new LinkedList<Node>();
     200                        for (Node n : ds.nodes)
     201                                for (Node mynode : nodes) {
     202                                        if (mynode.coor.equalsLatLon(n.coor))
     203                                                mynode.mergeFrom(n);
     204                                        else
     205                                                nodesToAdd.add(n);
     206                                }
     207                } else
     208                        nodes.addAll(ds.nodes);
     209                tracks.addAll(ds.tracks);
     210                pendingLineSegments.addAll(ds.pendingLineSegments);
     211        }
     212
     213        /**
    188214         * Remove the selection from every value in the collection.
    189215         * @param list The collection to remove the selection from.
  • src/org/openstreetmap/josm/data/osm/Node.java

    r9 r17  
    3333                return Collections.unmodifiableCollection(parentSegment);
    3434        }
     35
     36        /**
     37         * Merge the node given at parameter with this node.
     38         * All parents of the parameter-node become parents of this node.
     39         *
     40         * The argument node is not changed.
     41         *
     42         * @param node Merge the node to this.
     43         */
     44        public void mergeFrom(Node node) {
     45                parentSegment.addAll(node.parentSegment);
     46                if (keys == null)
     47                        keys = node.keys;
     48                else if (node.keys != null)
     49                        keys.putAll(node.keys);
     50        }
    3551       
    3652        /**
  • src/org/openstreetmap/josm/data/osm/visitor/SelectionComponentVisitor.java

    r11 r17  
    77
    88import javax.swing.Icon;
    9 import javax.swing.ImageIcon;
    109
    1110import org.openstreetmap.josm.data.osm.Key;
     
    1312import org.openstreetmap.josm.data.osm.Node;
    1413import org.openstreetmap.josm.data.osm.Track;
    15 import org.openstreetmap.josm.gui.Main;
     14import org.openstreetmap.josm.gui.ImageProvider;
    1615
    1716/**
     
    3837        public void visit(Key k) {
    3938                name = k.name;
    40                 icon = new ImageIcon(Main.class.getResource("/images/data/key.png"));
     39                icon = ImageProvider.get("data", "key");
    4140        }
    4241
     
    5352                       
    5453                this.name = name;
    55                 icon = new ImageIcon("images/data/linesegment.png");
     54                icon = ImageProvider.get("data", "linesegment");
    5655        }
    5756
     
    6766               
    6867                this.name = name;
    69                 icon = new ImageIcon("images/data/node.png");
     68                icon = ImageProvider.get("data", "node");
    7069        }
    7170
     
    8786               
    8887                this.name = name;
    89                 icon = new ImageIcon("images/data/track.png");
     88                icon = ImageProvider.get("data", "track");
    9089        }
    9190
  • src/org/openstreetmap/josm/data/projection/UTM.java

    r16 r17  
    9898         * Combobox with all ellipsoids for the configuration panel
    9999         */
    100         private JComboBox ellipsoidCombo = new JComboBox(allEllipsoids);
     100        private JComboBox ellipsoidCombo;
    101101        /**
    102102         * Spinner with all possible zones for the configuration panel
    103103         */
    104         private JSpinner zoneSpinner = new JSpinner(new SpinnerNumberModel(1,1,60,1));
     104        private JSpinner zoneSpinner;
    105105        /**
    106106         * Hemisphere combo for the configuration panel
    107107         */
    108         private JComboBox hemisphereCombo = new JComboBox(Hemisphere.values());
     108        private JComboBox hemisphereCombo;
    109109
    110110       
     
    248248               
    249249                // ellipsoid
     250                if (ellipsoidCombo == null)
     251                        ellipsoidCombo = new JComboBox(allEllipsoids);
    250252                panel.add(new JLabel("Ellipsoid"), gbc);
    251253                panel.add(ellipsoidCombo, GBC.eol());
     
    253255               
    254256                // zone
     257                if (zoneSpinner == null)
     258                        zoneSpinner = new JSpinner(new SpinnerNumberModel(1,1,60,1));
    255259                panel.add(new JLabel("Zone"), gbc);
    256260                panel.add(zoneSpinner, GBC.eol().insets(0,5,0,5));
     
    259263               
    260264                // hemisphere
     265                if (hemisphereCombo == null)
     266                        hemisphereCombo = new JComboBox(Hemisphere.values());
    261267                panel.add(new JLabel("Hemisphere"), gbc);
    262268                panel.add(hemisphereCombo, GBC.eop());
     
    268274                        public void actionPerformed(ActionEvent e) {
    269275                                if (Main.main.getMapFrame() != null) {
    270                                         DataSet ds = Main.main.getMapFrame().mapView.dataSet;
     276                                        DataSet ds = Main.main.getMapFrame().mapView.getActiveDataSet();
    271277                                        ZoneData zd = autoDetect(ds);
    272278                                        if (zd.zone == 0)
     
    291297        @Override
    292298        public void commitConfigurationPanel() {
    293                 ellipsoid = (Ellipsoid)ellipsoidCombo.getSelectedItem();
    294                 zone = (Integer)zoneSpinner.getValue();
    295                 hemisphere = (Hemisphere)hemisphereCombo.getSelectedItem();
    296                 fireStateChanged();
     299                if (ellipsoidCombo != null && zoneSpinner != null && hemisphereCombo != null) {
     300                        ellipsoid = (Ellipsoid)ellipsoidCombo.getSelectedItem();
     301                        zone = (Integer)zoneSpinner.getValue();
     302                        hemisphere = (Hemisphere)hemisphereCombo.getSelectedItem();
     303                        fireStateChanged();
     304                }
    297305        }
    298306}
Note: See TracChangeset for help on using the changeset viewer.