Changeset 768 in josm


Ignore:
Timestamp:
Aug 11, 2008 8:59:42 PM (5 years ago)
Author:
framm
Message:
  • mappaint modifications by Joerg Henne <j.henne@…>; now supports new config options mappaint.node.selected-size and .unselected-size, .fill-selected and .fill-unselected, mappaint.segment.default-width; change in unselect_all (supports escape), new keyboard shortcuts for zoom in/out (keys + and -)
Location:
trunk/src/org/openstreetmap/josm
Files:
8 edited

Legend:

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

    r627 r768  
    1414 
    1515        public UnselectAllAction() { 
    16                 super(tr("Unselect All"),"unselectall", tr("Unselect all objects."), KeyEvent.VK_U, 0, true); 
     16                super(tr("Unselect All"), "unselectall", tr("Unselect all objects."), 
     17                        KeyEvent.VK_U, 0, true); 
    1718 
    1819                // Add extra shortcut C-S-a 
    1920                Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 
    20                         KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK), tr("Unselect All")); 
    21     } 
     21                        KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK 
     22                                | KeyEvent.SHIFT_DOWN_MASK), tr("Unselect All")); 
     23 
     24                // Add extra shortcut ESCAPE 
     25                /* 
     26                 * FIXME: this isn't optimal. In a better world the mapmode actions 
     27                 * would be able to capture keyboard events and react accordingly. But 
     28                 * for now this is a reasonable approximation. 
     29                 */ 
     30                Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 
     31                        KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), 
     32                        tr("Unselect All")); 
     33        } 
    2234 
    2335        public void actionPerformed(ActionEvent e) { 
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java

    r674 r768  
    5454         */ 
    5555        public DeleteAction(MapFrame mapFrame) { 
    56                 super(tr("Delete"),  
     56                super(tr("DeleteMode"),  
    5757                                "delete",  
    5858                                tr("Delete nodes or ways."),  
     
    7575        @Override public void actionPerformed(ActionEvent e) { 
    7676                super.actionPerformed(e); 
    77                 boolean ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0; 
     77                doActionPerformed(e); 
     78        } 
     79 
     80        public void doActionPerformed(ActionEvent e) { 
     81            boolean ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0; 
    7882                boolean alt = (e.getModifiers() & ActionEvent.ALT_MASK) != 0; 
    7983 
     
    8993 
    9094                Main.map.repaint(); 
    91         } 
     95    } 
    9296 
    9397        /** 
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r655 r768  
    277277                return ColorHelper.html2color(colStr); 
    278278        } 
     279 
     280        public int getInteger(String key, int def) { 
     281            String v = get(key); 
     282            if(null == v) 
     283                return def; 
     284             
     285            try { 
     286                return Integer.parseInt(v); 
     287            } catch(NumberFormatException e) { 
     288                // fall out 
     289            } 
     290             
     291            return def; 
     292    } 
    279293} 
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java

    r757 r768  
    99import java.awt.Point; 
    1010import java.awt.Polygon; 
     11import java.awt.RenderingHints; 
    1112import java.awt.Stroke; 
    1213import java.awt.geom.GeneralPath; 
     
    1718 
    1819import org.openstreetmap.josm.Main; 
     20import org.openstreetmap.josm.actions.UnselectAllAction; 
    1921import org.openstreetmap.josm.data.Preferences; 
    2022import org.openstreetmap.josm.data.osm.DataSet; 
     
    7779    protected boolean showOrderNumber; 
    7880     
     81        private boolean fillSelectedNode; 
     82 
     83        private boolean fillUnselectedNode; 
     84 
     85        private int selectedNodeRadius; 
     86 
     87        private int unselectedNodeRadius; 
     88 
     89        private int selectedNodeSize; 
     90 
     91        private int unselectedNodeSize; 
     92 
     93        private int defaultSegmentWidth = 2; 
     94 
    7995    public final static Color darkerblue = new Color(0,0,96); 
    8096    public final static Color darkblue = new Color(0,0,128); 
     
    126142            } 
    127143        } else { 
    128             drawNode(n, n.selected ? selectedColor : nodeColor); 
     144                        if (n.selected) 
     145                                drawNode(n, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 
     146                        else 
     147                                drawNode(n, nodeColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode); 
    129148        } 
    130149    } 
     
    143162 
    144163        Color colour = untaggedColor; 
    145         int width = 2; 
     164                int width = defaultSegmentWidth; 
    146165        int realWidth = 0; //the real width of the element in meters  
    147166        boolean dashed = false; 
     
    326345     * @param color The color of the node. 
    327346     */ 
    328     public void drawNode(Node n, Color color) { 
    329         if(isZoomOk(null)) { 
    330             Point p = nc.getPoint(n.eastNorth); 
    331             if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return; 
    332             g.setColor(color); 
    333             g.drawRect(p.x-1, p.y-1, 2, 2); 
    334         } 
    335     } 
     347    public void drawNode(Node n, Color color, int size, int radius, boolean fill) { 
     348                if (isZoomOk(null) && size > 1) { 
     349                        Point p = nc.getPoint(n.eastNorth); 
     350                        if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) 
     351                                || (p.y > nc.getHeight())) 
     352                                return; 
     353                        g.setColor(color); 
     354                        if (fill) 
     355                                g.fillRect(p.x - radius, p.y - radius, size, size); 
     356                        else 
     357                                g.drawRect(p.x - radius, p.y - radius, size, size); 
     358                } 
     359        } 
    336360 
    337361    // NW 111106 Overridden from SimplePaintVisitor in josm-1.4-nw1 
     
    353377        fillAreas = Main.pref.getBoolean("mappaint.fillareas", true); 
    354378 
    355         /* XXX - there must be a better way to get a bounded Integer pref! */ 
    356         try { 
    357             fillAlpha = Integer.valueOf(Main.pref.get("mappaint.fillalpha", "50")); 
    358             if (fillAlpha < 0) { 
    359                 fillAlpha = 0; 
    360             } 
    361             if (fillAlpha > 255) { 
    362                 fillAlpha = 255; 
    363             } 
    364         } catch (NumberFormatException nfe) { 
    365             fillAlpha = 50; 
    366         } 
     379                selectedNodeRadius = Main.pref.getInteger("mappaint.node.selected-size", 
     380                        5) / 2; 
     381                selectedNodeSize = selectedNodeRadius * 2; 
     382                unselectedNodeRadius = Main.pref.getInteger( 
     383                        "mappaint.node.unselected-size", 3) / 2; 
     384                unselectedNodeSize = unselectedNodeRadius * 2; 
     385 
     386                defaultSegmentWidth = Main.pref.getInteger( 
     387                        "mappaint.segment.default-width", 2); 
     388 
     389                fillSelectedNode = Main.pref.getBoolean("mappaint.node.fill-selected", 
     390                        true); 
     391                fillUnselectedNode = Main.pref.getBoolean( 
     392                        "mappaint.node.fill-unselected", false); 
     393 
     394                ((Graphics2D)g) 
     395                        .setRenderingHint( 
     396                                RenderingHints.KEY_ANTIALIASING, 
     397                                Main.pref.getBoolean("mappaint.use-antialiasing", true) ? RenderingHints.VALUE_ANTIALIAS_ON 
     398                                        : RenderingHints.VALUE_ANTIALIAS_OFF); 
     399 
     400                fillAlpha = Math.min(255, Math.max(0, Integer.valueOf(Main.pref 
     401                        .getInteger("mappaint.fillalpha", 50)))); 
    367402 
    368403        Collection<Way> noAreaWays = new LinkedList<Way>(); 
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java

    r759 r768  
    88import java.awt.Point; 
    99import java.awt.Rectangle; 
     10import java.awt.RenderingHints; 
    1011import java.awt.Stroke; 
    1112import java.awt.geom.GeneralPath; 
    12  
    1313import java.util.Iterator; 
     14 
    1415import org.openstreetmap.josm.Main; 
    1516import org.openstreetmap.josm.data.Preferences; 
    1617import org.openstreetmap.josm.data.osm.DataSet; 
    17 import org.openstreetmap.josm.data.osm.Relation; 
    1818import org.openstreetmap.josm.data.osm.RelationMember; 
    1919import org.openstreetmap.josm.data.osm.Node; 
    2020import org.openstreetmap.josm.data.osm.OsmPrimitive; 
     21import org.openstreetmap.josm.data.osm.Relation; 
     22import org.openstreetmap.josm.data.osm.RelationMember; 
    2123import org.openstreetmap.josm.data.osm.Way; 
    2224import org.openstreetmap.josm.gui.NavigatableComponent; 
    23 import org.openstreetmap.josm.tools.ColorHelper; 
    2425 
    2526/** 
     
    6465        protected boolean showOrderNumber; 
    6566         
     67        private boolean fillSelectedNode; 
     68 
     69        private boolean fillUnselectedNode; 
     70 
     71        private int selectedNodeRadius; 
     72 
     73        private int unselectedNodeRadius; 
     74 
     75        private int selectedNodeSize; 
     76 
     77        private int unselectedNodeSize; 
     78 
     79        private int defaultSegmentWidth = 2; 
     80 
    6681        /** 
    6782         * Draw subsequent segments of same color as one Path 
     
    85100                showOrderNumber = Main.pref.getBoolean("draw.segment.order_number"); 
    86101                 
     102                selectedNodeRadius = Main.pref.getInteger("mappaint.node.selected-size", 
     103                        5) / 2; 
     104                selectedNodeSize = selectedNodeRadius * 2; 
     105                unselectedNodeRadius = Main.pref.getInteger( 
     106                        "mappaint.node.unselected-size", 3) / 2; 
     107                unselectedNodeSize = unselectedNodeRadius * 2; 
     108 
     109                defaultSegmentWidth = Main.pref.getInteger( 
     110                        "mappaint.segment.default-width", 2); 
     111 
     112                fillSelectedNode = Main.pref.getBoolean("mappaint.node.fill-selected", 
     113                        true); 
     114                fillUnselectedNode = Main.pref.getBoolean( 
     115                        "mappaint.node.fill-unselected", false); 
     116 
     117                ((Graphics2D)g) 
     118                        .setRenderingHint( 
     119                                RenderingHints.KEY_ANTIALIASING, 
     120                                Main.pref.getBoolean("mappaint.use-antialiasing", true) ? RenderingHints.VALUE_ANTIALIAS_ON 
     121                                        : RenderingHints.VALUE_ANTIALIAS_OFF); 
     122 
    87123                // draw tagged ways first, then untagged ways. takes 
    88124                // time to iterate through list twice, OTOH does not 
     
    121157                if (n.incomplete) return; 
    122158 
    123                 Color color = null; 
    124159                if (inactive) 
    125                         color = inactiveColor; 
     160                        drawNode(n, inactiveColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode); 
    126161                else if (n.selected) 
    127                         color = selectedColor; 
     162                        drawNode(n, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 
    128163                else 
    129                         color = nodeColor; 
    130                 drawNode(n, color); 
     164                        drawNode(n, nodeColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode); 
    131165        } 
    132166 
     
    235269         * @param color The color of the node. 
    236270         */ 
    237         public void drawNode(Node n, Color color) { 
    238                 Point p = nc.getPoint(n.eastNorth); 
    239         if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return; 
    240  
    241         g.setColor(color); 
    242  
    243         if (n.tagged) { 
    244             g.drawRect(p.x, p.y, 0, 0); 
    245             g.drawRect(p.x-2, p.y-2, 4, 4); 
    246         } else { 
    247             g.drawRect(p.x-1, p.y-1, 2, 2); 
    248         } 
     271        public void drawNode(Node n, Color color, int size, int radius, boolean fill) { 
     272                if (size > 1) { 
     273                        Point p = nc.getPoint(n.eastNorth); 
     274                        if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) 
     275                                || (p.y > nc.getHeight())) 
     276                                return; 
     277                        g.setColor(color); 
     278                        if (fill) 
     279                                g.fillRect(p.x - radius, p.y - radius, size, size); 
     280                        else 
     281                                g.drawRect(p.x - radius, p.y - radius, size, size); 
     282                } 
    249283        } 
    250284 
  • trunk/src/org/openstreetmap/josm/gui/MainMenu.java

    r627 r768  
    1515 
    1616import org.openstreetmap.josm.Main; 
    17 import org.openstreetmap.josm.actions.AlignInRectangleAction; 
    18 import org.openstreetmap.josm.actions.JosmAction; 
    1917import org.openstreetmap.josm.actions.AboutAction; 
    2018import org.openstreetmap.josm.actions.AlignInCircleAction; 
    2119import org.openstreetmap.josm.actions.AlignInLineAction; 
     20import org.openstreetmap.josm.actions.AlignInRectangleAction; 
    2221import org.openstreetmap.josm.actions.AutoScaleAction; 
    2322import org.openstreetmap.josm.actions.CombineWayAction; 
    2423import org.openstreetmap.josm.actions.CopyAction; 
     24import org.openstreetmap.josm.actions.DeleteAction; 
    2525import org.openstreetmap.josm.actions.DownloadAction; 
    2626import org.openstreetmap.josm.actions.DuplicateAction; 
     
    2929import org.openstreetmap.josm.actions.HelpAction; 
    3030import org.openstreetmap.josm.actions.JoinNodeWayAction; 
     31import org.openstreetmap.josm.actions.JosmAction; 
    3132import org.openstreetmap.josm.actions.MergeNodesAction; 
    3233import org.openstreetmap.josm.actions.NewAction; 
     
    4445import org.openstreetmap.josm.actions.UnselectAllAction; 
    4546import org.openstreetmap.josm.actions.UploadAction; 
     47import org.openstreetmap.josm.actions.ZoomInAction; 
     48import org.openstreetmap.josm.actions.ZoomOutAction; 
    4649import org.openstreetmap.josm.actions.audio.AudioBackAction; 
     50import org.openstreetmap.josm.actions.audio.AudioFasterAction; 
    4751import org.openstreetmap.josm.actions.audio.AudioFwdAction; 
    4852import org.openstreetmap.josm.actions.audio.AudioNextAction; 
    4953import org.openstreetmap.josm.actions.audio.AudioPlayPauseAction; 
    5054import org.openstreetmap.josm.actions.audio.AudioPrevAction; 
    51 import org.openstreetmap.josm.actions.audio.AudioFasterAction; 
    5255import org.openstreetmap.josm.actions.audio.AudioSlowerAction; 
    5356import org.openstreetmap.josm.actions.search.SearchAction; 
     
    7982        public final JosmAction copy = new CopyAction(); 
    8083        public final JosmAction paste = new PasteAction(); 
     84        public final JosmAction delete = new DeleteAction(); 
    8185        public final JosmAction pasteTags = new PasteTagsAction(copy);  
    8286        public final JosmAction duplicate = new DuplicateAction();  
     
    154158                current = editMenu.add(copy); 
    155159                current.setAccelerator(copy.shortCut); 
     160                current = editMenu.add(delete); 
     161                current.setAccelerator(delete.shortCut); 
    156162                current = editMenu.add(paste); 
    157163                current.setAccelerator(paste.shortCut); 
     
    180186        } 
    181187        viewMenu.addSeparator(); 
    182  
    183         // TODO move code to an "action" like the others? 
     188        JosmAction a = new ZoomOutAction(); 
     189                viewMenu.add(a).setAccelerator(a.shortCut); 
     190                a = new ZoomInAction(); 
     191                viewMenu.add(a).setAccelerator(a.shortCut); 
     192 
     193                viewMenu.addSeparator(); 
     194 
     195                // TODO move code to an "action" like the others? 
    184196        final JCheckBoxMenuItem wireframe = new JCheckBoxMenuItem(tr("Wireframe view")); 
    185197        wireframe.setSelected(Main.pref.getBoolean("draw.wireframe", true));      
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r655 r768  
    110110         */ 
    111111        public Point getPoint(EastNorth p) { 
     112                if(null == p) 
     113                        return new Point(); 
    112114                double x = (p.east()-center.east())/scale + getWidth()/2; 
    113115                double y = (center.north()-p.north())/scale + getHeight()/2; 
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r743 r768  
    187187                                        } 
    188188                                }); 
    189                                 fc.showOpenDialog(Main.parent); 
    190                                 File sel = fc.getSelectedFile(); 
    191                                 if (!fc.getCurrentDirectory().getAbsolutePath().equals(dir)) 
    192                                         Main.pref.put("markers.lastaudiodirectory", fc.getCurrentDirectory().getAbsolutePath()); 
    193                                 if (sel == null) 
    194                                         return; 
    195                                 importAudio(sel); 
    196                                 Main.map.repaint(); 
     189                                fc.setMultiSelectionEnabled(true); 
     190                                if(fc.showOpenDialog(Main.parent) == JFileChooser.APPROVE_OPTION) { 
     191                                        if (!fc.getCurrentDirectory().getAbsolutePath().equals(dir)) 
     192                                                Main.pref.put("markers.lastaudiodirectory", fc 
     193                                                                .getCurrentDirectory().getAbsolutePath()); 
     194                                         
     195                                        // FIXME: properly support multi-selection here.  
     196                                        // Calling importAudio several times just creates N maker layers, which 
     197                                        // is sub-optimal. 
     198                                        File sel[] = fc.getSelectedFiles(); 
     199                                        if(sel != null) 
     200                                                for (int i = 0; i < sel.length; i++)  
     201                                                        importAudio(sel[i]); 
     202                                         
     203                                        Main.map.repaint(); 
     204                                } 
    197205                        } 
    198206                }); 
Note: See TracChangeset for help on using the changeset viewer.