Changeset 1444 in josm


Ignore:
Timestamp:
2009-02-25T14:21:24+01:00 (15 years ago)
Author:
stoecker
Message:

close #2233 and some minor fixes. patch by xeen

Location:
trunk/src/org/openstreetmap/josm
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r1443 r1444  
    99import java.awt.Color;
    1010import java.awt.Cursor;
     11import java.awt.EventQueue;
    1112import java.awt.Graphics;
    1213import java.awt.Graphics2D;
     
    5960 */
    6061public class DrawAction extends MapMode implements MapViewPaintable, SelectionChangedListener, AWTEventListener {
    61 
     62    final private Cursor cursorCrosshair;
     63    final private Cursor cursorJoinNode;
     64    final private Cursor cursorJoinWay;
     65    enum Cursors { crosshair, node, way }
     66    private Cursors currCursor = Cursors.crosshair;
     67   
    6268    private static Node lastUsedNode = null;
    6369    private double PHI=Math.toRadians(90);
     
    8894        Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
    8995            Shortcut.registerShortcut("mapmode:drawfocus", tr("Mode: Draw Focus"), KeyEvent.VK_N, Shortcut.GROUP_EDIT).getKeyStroke(), tr("Draw"));
     96       
     97        cursorCrosshair = getCursor();
     98        cursorJoinNode = ImageProvider.getCursor("crosshair", "joinnode");
     99        cursorJoinWay = ImageProvider.getCursor("crosshair", "joinway");
    90100    }
    91101
     
    99109
    100110    /**
    101      * Sets a special cursor to indicate that the next click will automatically join into
    102      * an existing node or way (if feature is enabled)
    103      *
    104      * @param way If true, the cursor will indicate it is joined into a way; node otherwise
    105      */
    106     private void setJoinCursor(boolean way) {
    107         if(!drawTargetCursor) {
    108             resetCursor();
    109             return;
    110         }
     111     * Displays the given cursor instead of the normal one
     112     * @param Cursors One of the available cursors
     113     */
     114    private void setCursor(final Cursors c) {
     115        if(currCursor.equals(c) || (!drawTargetCursor && currCursor.equals(Cursors.crosshair)))
     116            return;
    111117        try {
    112             Main.map.mapView.setCursor(
    113                     ImageProvider.getCursor("crosshair", (way ? "joinway" : "joinnode"))
    114             );
    115             return;
    116         } catch (Exception e) {
    117             e.printStackTrace();
    118         }
    119         resetCursor();
    120     }
    121 
    122     /**
    123      * Resets the cursor to the default cursor for drawing mode (i.e. crosshair)
    124      */
    125     private void resetCursor() {
    126         Main.map.mapView.setCursor(getCursor());
     118            // We invoke this to prevent strange things from happening
     119            EventQueue.invokeLater(new Runnable() {
     120                public void run() {
     121                    switch(c) {
     122                        case way:
     123                            Main.map.mapView.setCursor(cursorJoinWay);
     124                            break;
     125                        case node:
     126                            Main.map.mapView.setCursor(cursorJoinNode);
     127                            break;
     128                        default:
     129                            Main.map.mapView.setCursor(cursorCrosshair);
     130                            break;   
     131                    }
     132                }
     133            });
     134            currCursor = c;
     135        } catch(Exception e) {}
     136    }
     137   
     138    private void redrawIfRequired() {
     139        if ((!drawHelperLine || wayIsFinished) && !drawTargetHighlight) return;
     140        Main.map.mapView.repaint();
    127141    }
    128142
     
    135149        // if ctrl key is held ("no join"), don't highlight anything
    136150        if (ctrl) {
    137             resetCursor();
     151            setCursor(Cursors.crosshair);
    138152            return;
    139153        }
     
    144158
    145159        if (mouseOnExistingNode != null) {
    146             setJoinCursor(false);
     160            setCursor(Cursors.node);
    147161            // We also need this list for the statusbar help text
    148162            oldHighlights.add(mouseOnExistingNode);
     
    154168        // Insert the node into all the nearby way segments
    155169        if(mouseOnExistingWays.size() == 0) {
    156             resetCursor();
    157             return;
    158         }
    159 
    160         setJoinCursor(true);
     170            setCursor(Cursors.crosshair);
     171            return;
     172        }
     173
     174        setCursor(Cursors.way);
    161175
    162176        // We also need this list for the statusbar help text
     
    219233            return;
    220234        updateKeyModifiers((InputEvent) event);
     235        computeHelperLine();
    221236        addHighlighting();
    222         computeHelperLine();
     237        redrawIfRequired();
    223238    }
    224239    /**
     
    229244            return;
    230245        computeHelperLine();
     246        addHighlighting();
     247        redrawIfRequired();
    231248    }
    232249
     
    247264
    248265        // Redraw to remove the helper line stub
     266        computeHelperLine();
    249267        removeHighlighting();
    250         computeHelperLine();
    251         Main.map.mapView.repaint();
     268        redrawIfRequired();
    252269    }
    253270
     
    477494        computeHelperLine();
    478495        removeHighlighting();
    479         Main.map.mapView.repaint();
     496        redrawIfRequired();
    480497    }
    481498
     
    550567        mousePos = e.getPoint();
    551568
     569        computeHelperLine();
    552570        addHighlighting();
    553         computeHelperLine();
     571        redrawIfRequired();
    554572    }
    555573
     
    663681        Main.map.statusLine.setDist(distance);
    664682        updateStatusLine();
    665 
    666         if ((!drawHelperLine || wayIsFinished) && !drawTargetHighlight) return;
    667         Main.map.mapView.repaint();
    668683    }
    669684
  • trunk/src/org/openstreetmap/josm/gui/preferences/ColorPreference.java

    r1424 r1444  
    6565        Map<String, String> colorKeyList = new TreeMap<String, String>();
    6666        Map<String, String> colorKeyList_mappaint = new TreeMap<String, String>();
     67        Map<String, String> colorKeyList_layer = new TreeMap<String, String>();
    6768        for(String key : colorMap.keySet()) {
    68             if(key.startsWith("mappaint."))
     69            if(key.startsWith("layer "))
     70                colorKeyList_layer.put(getName(key), key);
     71            else if(key.startsWith("mappaint."))
    6972                colorKeyList_mappaint.put(getName(key), key);
    7073            else
     
    7881        }
    7982        for (Entry<String, String> k : colorKeyList_mappaint.entrySet()) {
     83            Vector<Object> row = new Vector<Object>(2);
     84            row.add(k.getValue());
     85            row.add(ColorHelper.html2color(colorMap.get(k.getValue())));
     86            tableModel.addRow(row);
     87        }
     88        for (Entry<String, String> k : colorKeyList_layer.entrySet()) {
    8089            Vector<Object> row = new Vector<Object>(2);
    8190            row.add(k.getValue());
     
    113122        }
    114123        catch (Exception e) {}
     124        try
     125        {
     126            Matcher m = Pattern.compile("layer (.+)").matcher(o);
     127            m.matches();
     128            return tr("Layer: {0}", tr(m.group(1)));
     129        }
     130        catch (Exception e) {}
    115131        return tr(o);
    116132    }
  • trunk/src/org/openstreetmap/josm/io/OsmReader.java

    r1425 r1444  
    7575      */
    7676     private String parseNotes = new String();
     77     private int parseNotesCount = 0;
    7778     public String getParseNotes() {
    7879         return parseNotes;
     
    373374                    Node n = findNode(id);
    374375                    if (n == null) {
    375                          parseNotes += tr("Skipping a way because it includes a node that doesn''t exist: {0}\n", id);
     376                         /* don't report ALL of them, just a few */
     377                         if (parseNotesCount++ < 6) {
     378                             parseNotes += tr("Skipping a way because it includes a node that doesn''t exist: {0}\n", id);
     379                         } else if (parseNotesCount == 6) {
     380                             parseNotes += "...\n";
     381                         }
    376382                         failed = true;
    377383                         break;
  • trunk/src/org/openstreetmap/josm/io/OsmServerObjectReader.java

    r1415 r1444  
    1010import org.openstreetmap.josm.data.osm.DataSet;
    1111import org.xml.sax.SAXException;
     12
     13import javax.swing.JOptionPane;
    1214
    1315public class OsmServerObjectReader extends OsmServerReader {
     
    4749                return null;
    4850            Main.pleaseWaitDlg.currentAction.setText(tr("Downloading OSM data..."));
    49             final DataSet data = OsmReader.parseDataSet(in, null, Main.pleaseWaitDlg);
     51            final OsmReader osm = OsmReader.parseDataSetOsm(in, null, Main.pleaseWaitDlg);
     52            final DataSet data = osm.getDs();
     53
    5054//          String origin = Main.pref.get("osm-server.url")+"/"+Main.pref.get("osm-server.version", "0.5");
    5155//          Bounds bounds = new Bounds(new LatLon(lat1, lon1), new LatLon(lat2, lon2));
    5256//          DataSource src = new DataSource(bounds, origin);
    5357//          data.dataSources.add(src);
     58            if (osm.getParseNotes().length() != 0) {
     59                JOptionPane.showMessageDialog(Main.parent, osm.getParseNotes());
     60            }
    5461            in.close();
    5562            activeConnection = null;
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r1415 r1444  
    107107                    p.put(info.stage, new LinkedList<PluginInformation>());
    108108                p.get(info.stage).add(info);
    109             } else {
     109            } else if(early) {
    110110                JOptionPane.showMessageDialog(Main.parent, tr("Plugin not found: {0}.", pluginName));
    111111            }
Note: See TracChangeset for help on using the changeset viewer.