Changeset 64 in josm for src/org/openstreetmap/josm/gui


Ignore:
Timestamp:
2006-03-16T19:35:44+01:00 (20 years ago)
Author:
imi
Message:
  • renamed track to way
  • refactored Key to be a simple String
  • fixed PropertyDialog which displayed <different> for doubled values
Location:
src/org/openstreetmap/josm/gui
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/gui/ImageProvider.java

    r41 r64  
    4343                        subdir += "/";
    4444                URL path = Main.class.getResource("/images/"+subdir+name+".png");
     45                if (path == null)
     46                        throw new NullPointerException("/images/"+subdir+name+".png not found");
    4547                ImageIcon icon = cache.get(path);
    4648                if (icon == null) {
  • src/org/openstreetmap/josm/gui/MapStatus.java

    r56 r64  
    2828import org.openstreetmap.josm.Main;
    2929import org.openstreetmap.josm.data.GeoPoint;
    30 import org.openstreetmap.josm.data.osm.Key;
    3130import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3231import org.openstreetmap.josm.data.osm.visitor.SelectionComponentVisitor;
     
    141140                                                                text.append("<br>id="+osm.id);
    142141                                                        if (osm.keys != null)
    143                                                                 for (Entry<Key, String> e : osm.keys.entrySet())
    144                                                                         text.append("<br>"+e.getKey().name+"="+e.getValue());
     142                                                                for (Entry<String, String> e : osm.keys.entrySet())
     143                                                                        text.append("<br>"+e.getKey()+"="+e.getValue());
    145144                                                        final JLabel l = new JLabel("<html>"+text.toString()+"</html>", visitor.icon, JLabel.HORIZONTAL);
    146145                                                        l.setFont(l.getFont().deriveFont(Font.PLAIN));
  • src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r42 r64  
    1212import org.openstreetmap.josm.data.osm.Node;
    1313import org.openstreetmap.josm.data.osm.OsmPrimitive;
    14 import org.openstreetmap.josm.data.osm.Track;
     14import org.openstreetmap.josm.data.osm.Way;
    1515import org.openstreetmap.josm.data.projection.Projection;
    1616
     
    118118         * If no such line segment is found, and a non-pending line segment is
    119119         * within 10 pixel to p, this segment is returned, except when
    120          * <code>wholeTrack</code> is <code>true</code>, in which case the
    121          * corresponding Track is returned.
     120         * <code>wholeWay</code> is <code>true</code>, in which case the
     121         * corresponding Way is returned.
    122122         *
    123123         * If no line segment is found and the point is within an area, return that
     
    127127         *
    128128         * @param p                              The point on screen.
    129          * @param lsInsteadTrack Whether the line segment (true) or only the whole
    130          *                                               track should be returned.
     129         * @param lsInsteadWay Whether the line segment (true) or only the whole
     130         *                                               way should be returned.
    131131         * @return      The primitive, that is nearest to the point p.
    132132         */
    133         public OsmPrimitive getNearest(Point p, boolean lsInsteadTrack) {
     133        public OsmPrimitive getNearest(Point p, boolean lsInsteadWay) {
    134134                double minDistanceSq = Double.MAX_VALUE;
    135135                OsmPrimitive minPrimitive = null;
     
    149149                        return minPrimitive;
    150150               
    151                 // for whole tracks, try the tracks first
     151                // for whole waies, try the waies first
    152152                minDistanceSq = Double.MAX_VALUE;
    153                 if (!lsInsteadTrack) {
    154                         for (Track t : Main.main.ds.tracks) {
     153                if (!lsInsteadWay) {
     154                        for (Way t : Main.main.ds.waies) {
    155155                                if (t.isDeleted())
    156156                                        continue;
     
    201201         * If its a node, return all line segments and
    202202         * streets the node is part of, as well as all nodes
    203          * (with their line segments and tracks) with the same
     203         * (with their line segments and waies) with the same
    204204         * location.
    205205         *
    206          * If its a line segment, return all tracks this segment
     206         * If its a line segment, return all waies this segment
    207207         * belongs to as well as all line segments that are between
    208          * the same nodes (in both direction) with all their tracks.
     208         * the same nodes (in both direction) with all their waies.
    209209         *
    210210         * @return A collection of all items or <code>null</code>
     
    235235                }
    236236                if (osm instanceof Node || osm instanceof LineSegment) {
    237                         for (Track t : Main.main.ds.tracks) {
     237                        for (Way t : Main.main.ds.waies) {
    238238                                if (t.isDeleted())
    239239                                        continue;
  • src/org/openstreetmap/josm/gui/PreferenceDialog.java

    r43 r64  
    177177                                "An example: \"ignore ignore lat lon\" will use ' ' as delimiter, skip the first two values and read then lat/lon.<br>" +
    178178                                "Other example: \"lat,lon\" will just read lat/lon values comma seperated.</html>");
    179                 drawRawGpsLines.setToolTipText("If your gps device draw to few lines, select this to draw lines along your track.");
     179                drawRawGpsLines.setToolTipText("If your gps device draw to few lines, select this to draw lines along your way.");
    180180                drawRawGpsLines.setSelected(Main.pref.isDrawRawGpsLines());
    181181                forceRawGpsLines.setToolTipText("Force drawing of lines if the imported data contain no line information.");
  • src/org/openstreetmap/josm/gui/SelectionManager.java

    r42 r64  
    1919import org.openstreetmap.josm.data.osm.Node;
    2020import org.openstreetmap.josm.data.osm.OsmPrimitive;
    21 import org.openstreetmap.josm.data.osm.Track;
     21import org.openstreetmap.josm.data.osm.Way;
    2222
    2323/**
     
    257257         * @param alt Whether the alt key was pressed, which means select all objects
    258258         *              that are touched, instead those which are completly covered. Also
    259          *              select whole tracks instead of line segments.
     259         *              select whole waies instead of line segments.
    260260         */
    261261        public Collection<OsmPrimitive> getObjectsInRectangle(Rectangle r, boolean alt) {
     
    282282                                        selection.add(ls);
    283283
    284                         // tracks
    285                         for (Track t : Main.main.ds.tracks) {
    286                                 boolean wholeTrackSelected = !t.segments.isEmpty();
     284                        // waies
     285                        for (Way t : Main.main.ds.waies) {
     286                                boolean wholeWaySelected = !t.segments.isEmpty();
    287287                                for (LineSegment ls : t.segments)
    288288                                        if (rectangleContainLineSegment(r, alt, ls))
    289289                                                selection.add(ls);
    290290                                        else
    291                                                 wholeTrackSelected = false;
    292                                 if (wholeTrackSelected)
     291                                                wholeWaySelected = false;
     292                                if (wholeWaySelected)
    293293                                        selection.add(t);
    294294                        }
  • src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java

    r62 r64  
    1414import java.awt.event.WindowFocusListener;
    1515import java.util.Collection;
    16 import java.util.HashMap;
    1716import java.util.Iterator;
    1817import java.util.TreeMap;
     
    3736import org.openstreetmap.josm.command.ChangeKeyValueCommand;
    3837import org.openstreetmap.josm.data.SelectionChangedListener;
    39 import org.openstreetmap.josm.data.osm.Key;
    4038import org.openstreetmap.josm.data.osm.OsmPrimitive;
    4139import org.openstreetmap.josm.gui.ImageProvider;
     
    125123                if (value.equals(""))
    126124                        value = null; // delete the key
    127                 mv.editLayer().add(new ChangeKeyValueCommand(sel, Key.get(key), value));
     125                mv.editLayer().add(new ChangeKeyValueCommand(sel, key, value));
    128126
    129127                if (value == null)
     
    143141                p.add(new JLabel("<html>This will change "+sel.size()+" object"+(sel.size()==1?"":"s")+".<br><br>"+
    144142                "Please select a key"), BorderLayout.NORTH);
    145                 Vector<String> allKeys = new Vector<String>(Key.allKeys.keySet());
     143                Vector<String> allKeys = new Vector<String>();
     144                for (OsmPrimitive osm : Main.main.ds.allNonDeletedPrimitives())
     145                        if (osm.keys != null)
     146                                allKeys.addAll(osm.keys.keySet());
    146147                for (Iterator<String> it = allKeys.iterator(); it.hasNext();) {
    147148                        String s = it.next();
     
    170171                if (value.equals(""))
    171172                        return;
    172                 mv.editLayer().add(new ChangeKeyValueCommand(sel, Key.get(key), value));
     173                mv.editLayer().add(new ChangeKeyValueCommand(sel, key, value));
    173174                selectionChanged(sel); // update table
    174175        }
     
    181182                String key = data.getValueAt(row, 0).toString();
    182183                Collection<OsmPrimitive> sel = Main.main.ds.getSelected();
    183                 mv.editLayer().add(new ChangeKeyValueCommand(sel, Key.get(key), null));
     184                mv.editLayer().add(new ChangeKeyValueCommand(sel, key, null));
    184185                selectionChanged(sel); // update table
    185186        }
     
    293294                data.setRowCount(0);
    294295                TreeMap<String, Collection<String>> props = new TreeMap<String, Collection<String>>();
    295                 HashMap<String, Integer> valueCounts = new HashMap<String, Integer>();
    296296                for (OsmPrimitive osm : newSelection) {
    297297                        if (osm.keys != null) {
    298                                 for (Entry<Key, String> e : osm.keys.entrySet()) {
    299                                         Collection<String> value = props.get(e.getKey().name);
     298                                for (Entry<String, String> e : osm.keys.entrySet()) {
     299                                        Collection<String> value = props.get(e.getKey());
    300300                                        if (value == null) {
    301301                                                value = new TreeSet<String>();
    302                                                 props.put(e.getKey().name, value);
     302                                                props.put(e.getKey(), value);
    303303                                        }
    304304                                        value.add(e.getValue());
    305                                        
    306                                         Integer count = valueCounts.get(e.getValue());
    307                                         if (count == null)
    308                                                 count = 0;
    309                                         valueCounts.put(e.getValue(), count+1);
    310305                                }
    311306                        }
    312307                }
    313                 int selCount = newSelection.size();
    314308                for (Entry<String, Collection<String>> e : props.entrySet()) {
    315309                        JComboBox value = new JComboBox(e.getValue().toArray());
    316310                        value.setEditable(true);
    317                         if (e.getValue().size() > 1 || valueCounts.get(e.getValue().iterator().next()) != selCount)
    318                                 value.getEditor().setItem("<different>");
     311                        value.getEditor().setItem(e.getValue().size() > 1 ? "<different>" : e.getValue().iterator().next());
    319312                        data.addRow(new Object[]{e.getKey(), value});
    320313                }
  • src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r62 r64  
    2323import org.openstreetmap.josm.Main;
    2424import org.openstreetmap.josm.data.SelectionChangedListener;
    25 import org.openstreetmap.josm.data.osm.Key;
    2625import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2726import org.openstreetmap.josm.gui.ImageProvider;
     
    9594                                for (OsmPrimitive osm : Main.main.ds.allNonDeletedPrimitives()) {
    9695                                        if (osm.keys != null) {
    97                                                 for (Entry<Key, String> ent : osm.keys.entrySet()) {
     96                                                for (Entry<String, String> ent : osm.keys.entrySet()) {
    9897                                                        if (match(lastSearch, ent.getKey(), ent.getValue())) {
    9998                                                                osm.setSelected(true);
     
    106105                                Main.main.getMapFrame().repaint();
    107106                        }
    108                         private boolean match(String search, Key key, String value) {
     107                        private boolean match(String search, String key, String value) {
    109108                                int colon = search.indexOf(':');
    110109                                if (colon == -1)
    111                                         return key.name.indexOf(search) != -1 || value.indexOf(search) != -1;
    112                                 return key.name.equals(search.substring(0, colon)) && value.indexOf(search.substring(colon+1)) != -1;
     110                                        return key.indexOf(search) != -1 || value.indexOf(search) != -1;
     111                                return key.equals(search.substring(0, colon)) && value.indexOf(search.substring(colon+1)) != -1;
    113112                        }
    114113                });
  • src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r57 r64  
    2020import org.openstreetmap.josm.data.osm.Node;
    2121import org.openstreetmap.josm.data.osm.OsmPrimitive;
    22 import org.openstreetmap.josm.data.osm.Track;
     22import org.openstreetmap.josm.data.osm.Way;
    2323import org.openstreetmap.josm.data.osm.visitor.BoundingVisitor;
    2424import org.openstreetmap.josm.data.osm.visitor.MergeVisitor;
     
    113113                        if (!osm.isDeleted())
    114114                                osm.visit(visitor);
    115                 for (OsmPrimitive osm : data.tracks)
     115                for (OsmPrimitive osm : data.waies)
    116116                        if (!osm.isDeleted())
    117117                                osm.visit(visitor);
     
    128128                return undeletedSize(data.nodes)+" nodes, "+
    129129                        undeletedSize(data.lineSegments)+" segments, "+
    130                         undeletedSize(data.tracks)+" streets.";
     130                        undeletedSize(data.waies)+" streets.";
    131131        }
    132132
     
    238238                        for (Iterator<LineSegment> it = data.lineSegments.iterator(); it.hasNext();)
    239239                                cleanIterator(it, processedSet);
    240                         for (Iterator<Track> it = data.tracks.iterator(); it.hasNext();)
     240                        for (Iterator<Way> it = data.waies.iterator(); it.hasNext();)
    241241                                cleanIterator(it, processedSet);
    242242                }
  • src/org/openstreetmap/josm/gui/layer/RawGpsDataLayer.java

    r38 r64  
    2828
    2929        /**
    30          * A list of tracks which containing a list of points.
     30         * A list of waies which containing a list of points.
    3131         */
    3232        private final Collection<Collection<GeoPoint>> data;
     
    7878        @Override
    7979        public String getToolTipText() {
    80                 return data.size()+" tracks.";
     80                return data.size()+" waies.";
    8181        }
    8282
Note: See TracChangeset for help on using the changeset viewer.