Changeset 36 in josm for src


Ignore:
Timestamp:
2005-12-29T02:06:38+01:00 (18 years ago)
Author:
imi
Message:

added Mercator projection

Location:
src/org/openstreetmap/josm
Files:
1 added
5 edited

Legend:

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

    r33 r36  
    1919import org.jdom.output.XMLOutputter;
    2020import org.openstreetmap.josm.data.projection.LatitudeLongitude;
     21import org.openstreetmap.josm.data.projection.Mercator;
    2122import org.openstreetmap.josm.data.projection.Projection;
    2223import org.openstreetmap.josm.data.projection.UTM;
     
    6970         */
    7071        public static final Projection[] allProjections = new Projection[]{
     72                new Mercator(),
    7173                new UTM(),
    7274                new LatitudeLongitude()
  • src/org/openstreetmap/josm/data/osm/LineSegment.java

    r23 r36  
    11package org.openstreetmap.josm.data.osm;
    22
     3import org.openstreetmap.josm.data.GeoPoint;
    34import org.openstreetmap.josm.data.osm.visitor.Visitor;
    45
     
    3536                visitor.visit(this);
    3637        }
     38       
     39        /**
     40         * @return <code>true</code>, if the <code>ls</code> occupy
     41         * exactly the same place as <code>this</code>.
     42         */
     43        public boolean equalPlace(LineSegment ls) {
     44                if (equals(ls))
     45                        return true;
     46                GeoPoint s1 = start.coor;
     47                GeoPoint s2 = ls.start.coor;
     48                GeoPoint e1 = end.coor;
     49                GeoPoint e2 = ls.end.coor;
     50                return ((s1.equalsLatLon(s2) && e1.equalsLatLon(e2)) ||
     51                                (s1.equalsLatLon(e2) && e1.equalsLatLon(s2)));
     52        }
    3753}       
  • src/org/openstreetmap/josm/gui/MapStatus.java

    r22 r36  
    22
    33import java.awt.AWTEvent;
     4import java.awt.Font;
     5import java.awt.GridBagLayout;
    46import java.awt.Point;
    57import java.awt.Toolkit;
     
    1012import java.beans.PropertyChangeEvent;
    1113import java.beans.PropertyChangeListener;
     14import java.util.Collection;
    1215import java.util.Map.Entry;
    1316
     
    6366                 * The last object displayed in status line.
    6467                 */
    65                 OsmPrimitive osmStatus;
    66                 /**
    67                  * A visitor to retrieve name information about the osm primitive
    68                  */
    69                 private SelectionComponentVisitor visitor = new SelectionComponentVisitor();
     68                Collection<OsmPrimitive> osmStatus;
    7069                /**
    7170                 * The old modifiers, that was pressed the last time this collector ran.
     
    9695                                if ((ms.modifiers & MouseEvent.CTRL_DOWN_MASK) != 0 || ms.mousePos == null)
    9796                                        continue; // freeze display when holding down ctrl
    98                                 OsmPrimitive osm = mv.getNearest(ms.mousePos, (ms.modifiers & MouseEvent.ALT_DOWN_MASK) != 0);
    99                                 if (osm == osmStatus && ms.modifiers == oldModifiers)
     97                                Collection<OsmPrimitive> osms = mv.getAllNearest(ms.mousePos);
     98                               
     99                                if (osms == null && osmStatus == null && ms.modifiers == oldModifiers)
    100100                                        continue;
    101                                 osmStatus = osm;
     101                                if (osms != null && osms.equals(osmStatus) && ms.modifiers == oldModifiers)
     102                                        continue;
     103
     104                                osmStatus = osms;
    102105                                oldModifiers = ms.modifiers;
    103                                 if (osm != null) {
    104                                         osm.visit(visitor);
     106                               
     107                                // Set the text label in the bottom status bar
     108                                OsmPrimitive osmNearest = mv.getNearest(ms.mousePos, (ms.modifiers & MouseEvent.ALT_DOWN_MASK) != 0);
     109                                if (osmNearest != null) {
     110                                        SelectionComponentVisitor visitor = new SelectionComponentVisitor();
     111                                        osmNearest.visit(visitor);
    105112                                        nameText.setText(visitor.name);
    106113                                } else
     
    108115                               
    109116                                // Popup Information
    110                                 if ((ms.modifiers & MouseEvent.BUTTON2_DOWN_MASK) != 0 && osm != null) {
     117                                if ((ms.modifiers & MouseEvent.BUTTON2_DOWN_MASK) != 0 && osms != null) {
    111118                                        if (popup != null)
    112119                                                popup.hide();
    113120                                       
    114                                         StringBuilder text = new StringBuilder("<html>");
    115                                         text.append(visitor.name);
    116                                         if (osm.keys != null) {
    117                                                 for (Entry<Key, String> e : osm.keys.entrySet()) {
    118                                                         text.append("<br>");
    119                                                         text.append(e.getKey().name);
    120                                                         text.append("=");
    121                                                         text.append(e.getValue());
    122                                                 }
     121                                        JPanel c = new JPanel(new GridBagLayout());
     122                                        for (OsmPrimitive osm : osms) {
     123                                                SelectionComponentVisitor visitor = new SelectionComponentVisitor();
     124                                                osm.visit(visitor);
     125                                                StringBuilder text = new StringBuilder("<html>");
     126                                                if (osm.id == 0 || osm.modified || osm.modifiedProperties)
     127                                                        visitor.name = "<i><b>"+visitor.name+"*</b></i>";
     128                                                text.append(visitor.name);
     129                                                if (osm.id != 0)
     130                                                        text.append("<br>id="+osm.id);
     131                                                if (osm.keys != null)
     132                                                        for (Entry<Key, String> e : osm.keys.entrySet())
     133                                                                text.append("<br>"+e.getKey().name+"="+e.getValue());
     134                                                JLabel l = new JLabel(text.toString()+"</html>", visitor.icon, JLabel.HORIZONTAL);
     135                                                l.setFont(l.getFont().deriveFont(Font.PLAIN));
     136                                                l.setVerticalTextPosition(JLabel.TOP);
     137                                                c.add(l, GBC.eol());
    123138                                        }
    124                                         JLabel l = new JLabel(text.toString(), visitor.icon, JLabel.HORIZONTAL);
    125                                         l.setVerticalTextPosition(JLabel.TOP);
    126139                                       
    127140                                        Point p = mv.getLocationOnScreen();
    128                                         popup = PopupFactory.getSharedInstance().getPopup(mv, l, p.x+ms.mousePos.x+16, p.y+ms.mousePos.y+16);
     141                                        popup = PopupFactory.getSharedInstance().getPopup(mv, c, p.x+ms.mousePos.x+16, p.y+ms.mousePos.y+16);
    129142                                        popup.show();
    130143                                } else if (popup != null) {
  • src/org/openstreetmap/josm/gui/MapView.java

    r35 r36  
    1111import java.util.Collection;
    1212import java.util.Collections;
     13import java.util.HashSet;
    1314import java.util.LinkedList;
    1415
     
    137138                // autoselect the new layer
    138139                setActiveLayer(layer);
     140                recalculateCenterScale();
    139141        }
    140142
     
    292294        }
    293295
     296        /**
     297         * @return A list of all objects that are nearest to
     298         * the mouse. To do this, first the nearest object is
     299         * determined.
     300         *
     301         * If its a node, return all line segments and
     302         * streets the node is part of, as well as all nodes
     303         * (with their line segments and tracks) with the same
     304         * location.
     305         *
     306         * If its a line segment, return all tracks this segment
     307         * belongs to as well as all line segments that are between
     308         * the same nodes (in both direction) with all their tracks.
     309         *
     310         * @return A collection of all items or <code>null</code>
     311         *              if no item under or near the point. The returned
     312         *              list is never empty.
     313         */
     314        public Collection<OsmPrimitive> getAllNearest(Point p) {
     315                OsmPrimitive osm = getNearest(p, false);
     316                if (osm == null)
     317                        return null;
     318                Collection<OsmPrimitive> c = new HashSet<OsmPrimitive>();
     319                c.add(osm);
     320                if (osm instanceof Node) {
     321                        Node node = (Node)osm;
     322                        for (Node n : Main.main.ds.nodes)
     323                                if (n.coor.equalsLatLon(node.coor))
     324                                        c.add(n);
     325                        for (LineSegment ls : Main.main.ds.lineSegments)
     326                                // line segments never match nodes, so they are skipped by contains
     327                                if (c.contains(ls.start) || c.contains(ls.end))
     328                                        c.add(ls);
     329                }
     330                if (osm instanceof LineSegment) {
     331                        LineSegment line = (LineSegment)osm;
     332                        for (LineSegment ls : Main.main.ds.lineSegments)
     333                                if (ls.equalPlace(line))
     334                                        c.add(ls);
     335                }
     336                if (osm instanceof Node || osm instanceof LineSegment) {
     337                        for (Track t : Main.main.ds.tracks) {
     338                                for (LineSegment ls : t.segments) {
     339                                        if (c.contains(ls)) {
     340                                                c.add(t);
     341                                                break;
     342                                        }
     343                                }
     344                        }
     345                }
     346                return c;
     347        }
    294348       
    295349        /**
  • src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java

    r30 r36  
    9696
    9797                final JOptionPane optionPane = new JOptionPane(p, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
    98                 final JDialog dlg = optionPane.createDialog(PropertiesDialog.this, "Change values?");
     98                final JDialog dlg = optionPane.createDialog(Main.main, "Change values?");
    9999                dlg.addWindowFocusListener(new WindowFocusListener(){
    100100                        public void windowGainedFocus(WindowEvent e) {
     
    162162                JTextField values = new JTextField();
    163163                p2.add(values, BorderLayout.CENTER);
    164                 int answer = JOptionPane.showConfirmDialog(PropertiesDialog.this, p,
     164                int answer = JOptionPane.showConfirmDialog(Main.main, p,
    165165                                "Change values?", JOptionPane.OK_CANCEL_OPTION);
    166166                if (answer != JOptionPane.OK_OPTION)
     
    251251                                else if (e.getActionCommand().equals("Edit")) {
    252252                                        if (sel == -1)
    253                                                 JOptionPane.showMessageDialog(PropertiesDialog.this, "Please select the row to edit.");
     253                                                JOptionPane.showMessageDialog(Main.main, "Please select the row to edit.");
    254254                                        else
    255255                                                edit(sel);
    256256                                } else if (e.getActionCommand().equals("Delete")) {
    257257                                        if (sel == -1)
    258                                                 JOptionPane.showMessageDialog(PropertiesDialog.this, "Please select the row to delete.");
     258                                                JOptionPane.showMessageDialog(Main.main, "Please select the row to delete.");
    259259                                        else
    260260                                                delete(sel);
Note: See TracChangeset for help on using the changeset viewer.