Changeset 3237 in josm for trunk


Ignore:
Timestamp:
2010-05-12T21:37:49+02:00 (9 years ago)
Author:
jttt
Message:

Fix #4659 Waypoint layers captions are hiddden when layer is hidden and shown again.

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    r2901 r3237  
    588588                    return;
    589589                Layer layer = model.getLayer(index);
    590                 String current = Main.pref.get("marker.show "+layer.getName(),"show");
    591                 Main.pref.put("marker.show "+layer.getName(), current.equalsIgnoreCase("show") ? "hide" : "show");
    592590                layer.toggleVisible();
    593591            }
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ButtonMarker.java

    r1727 r3237  
    4141    }
    4242
    43     @Override public void paint(Graphics g, MapView mv, boolean mousePressed, String show) {
    44         if (! show.equalsIgnoreCase("show")) {
    45             super.paint(g, mv, mousePressed, show);
     43    @Override public void paint(Graphics g, MapView mv, boolean mousePressed, boolean showTextOrIcon) {
     44        if (!showTextOrIcon) {
     45            super.paint(g, mv, mousePressed, showTextOrIcon);
    4646            return;
    4747        }
     
    6262        r.grow((inset.top+inset.bottom)/2, (inset.left+inset.right)/2);
    6363        b.paintBorder(mv, g, r.x, r.y, r.width, r.height);
    64         if ((text != null) && (show.equalsIgnoreCase("show")) && Main.pref.getBoolean("marker.buttonlabels", true))
     64        if ((text != null) && showTextOrIcon && Main.pref.getBoolean("marker.buttonlabels", true)) {
    6565            g.drawString(text, screen.x+4, screen.y+2);
     66        }
    6667    }
    6768}
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java

    r2811 r3237  
    178178     * @param mousePressed true if the left mouse button is pressed
    179179     */
    180     public void paint(Graphics g, MapView mv, boolean mousePressed, String show) {
     180    public void paint(Graphics g, MapView mv, boolean mousePressed, boolean showTextOrIcon) {
    181181        Point screen = mv.getPoint(getEastNorth());
    182         if (symbol != null && show.equalsIgnoreCase("show")) {
     182        if (symbol != null && showTextOrIcon) {
    183183            symbol.paintIcon(mv, g, screen.x-symbol.getIconWidth()/2, screen.y-symbol.getIconHeight()/2);
    184184        } else {
     
    187187        }
    188188
    189         if ((text != null) && (show.equalsIgnoreCase("show"))) {
     189        if ((text != null) && showTextOrIcon) {
    190190            g.drawString(text, screen.x+4, screen.y+2);
    191191        }
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java

    r3220 r3237  
    155155
    156156    @Override public void paint(Graphics2D g, MapView mv, Bounds box) {
    157         String mkrTextShow = Main.pref.get("marker.show "+getName(), "show");
     157        boolean showTextOrIcon = isTextOrIconShown();
    158158        g.setColor(getColor(getName()));
    159159
     
    163163            for (Marker mkr : data) {
    164164                if (mousePos != null && mkr.containsPoint(mousePos)) {
    165                     mkr.paint(g, mv, mousePressedTmp, mkrTextShow);
     165                    mkr.paint(g, mv, mousePressedTmp, showTextOrIcon);
    166166                    mousePressedTmp = false;
    167167                }
     
    169169        } else {
    170170            for (Marker mkr : data) {
    171                 mkr.paint(g, mv, false, mkrTextShow);
     171                mkr.paint(g, mv, false, showTextOrIcon);
    172172            }
    173173        }
     
    284284        components.add(new JMenuItem(LayerListDialog.getInstance().createShowHideLayerAction(this)));
    285285        JCheckBoxMenuItem showMarkerTextItem = new JCheckBoxMenuItem(new ShowHideMarkerText(this));
    286         showMarkerTextItem.setState(isTextShown());
     286        showMarkerTextItem.setState(isTextOrIconShown());
    287287        components.add(showMarkerTextItem);
    288288        components.add(new JMenuItem(LayerListDialog.getInstance().createDeleteLayerAction(this)));
     
    452452    }
    453453
    454     private boolean isTextShown() {
     454    private boolean isTextOrIconShown() {
    455455        String current = Main.pref.get("marker.show "+getName(),"show");
    456         return current.equalsIgnoreCase("show");
     456        return "show".equalsIgnoreCase(current);
    457457    }
    458458
     
    469469
    470470        public void actionPerformed(ActionEvent e) {
    471             Main.pref.put("marker.show "+layer.getName(), layer.isTextShown() ? "hide" : "show");
     471            Main.pref.put("marker.show "+layer.getName(), layer.isTextOrIconShown() ? "hide" : "show");
    472472            Main.map.mapView.repaint();
    473473        }
Note: See TracChangeset for help on using the changeset viewer.