Changeset 9346 in josm


Ignore:
Timestamp:
2016-01-09T11:52:36+01:00 (9 years ago)
Author:
simon04
Message:

fix #10773 - Improve map status display for projected coordinate systems

Location:
trunk
Files:
2 added
2 edited

Legend:

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

    r9317 r9346  
    3434import java.util.ConcurrentModificationException;
    3535import java.util.List;
     36import java.util.Objects;
    3637import java.util.TreeSet;
    3738import java.util.concurrent.BlockingQueue;
     
    182183    }
    183184
     185    /** The {@link CoordinateFormat} set in the previous update */
     186    private transient CoordinateFormat previousCoordinateFormat = null;
    184187    private final ImageLabel latText = new ImageLabel("lat",
    185             tr("The geographic latitude at the mouse pointer."), 11, PROP_BACKGROUND_COLOR.get());
     188            null, 11, PROP_BACKGROUND_COLOR.get());
    186189    private final ImageLabel lonText = new ImageLabel("lon",
    187             tr("The geographic longitude at the mouse pointer."), 11, PROP_BACKGROUND_COLOR.get());
     190            null, 11, PROP_BACKGROUND_COLOR.get());
    188191    private final ImageLabel headingText = new ImageLabel("heading",
    189192            tr("The (compass) heading of the line segment being drawn."),
     
    871874                    latText.setText(p.latToString(mCord));
    872875                    lonText.setText(p.lonToString(mCord));
     876                    if (Objects.equals(previousCoordinateFormat, mCord)) {
     877                        // do nothing
     878                    } else if (CoordinateFormat.EAST_NORTH.equals(mCord)) {
     879                        latText.setIcon("northing");
     880                        lonText.setIcon("easting");
     881                        latText.setToolTipText(tr("The northing at the mouse pointer."));
     882                        lonText.setToolTipText(tr("The easting at the mouse pointer."));
     883                        previousCoordinateFormat = mCord;
     884                    } else {
     885                        latText.setIcon("lat");
     886                        lonText.setIcon("lon");
     887                        latText.setToolTipText(tr("The geographic latitude at the mouse pointer."));
     888                        lonText.setToolTipText(tr("The geographic longitude at the mouse pointer."));
     889                        previousCoordinateFormat = mCord;
     890                    }
    873891                }
    874892            }
  • trunk/src/org/openstreetmap/josm/gui/widgets/ImageLabel.java

    r9078 r9346  
    66import java.awt.GridBagLayout;
    77
     8import javax.swing.Icon;
    89import javax.swing.JLabel;
    910import javax.swing.JPanel;
     
    1819 */
    1920public class ImageLabel extends JPanel {
     21    private final JLabel imgLabel;
    2022    private final JLabel tf;
    2123    private final int charCount;
     
    2325    /**
    2426     * Constructs a new {@code ImageLabel}.
    25      * @param img Image name (without .png extension) to find in {@code statusline} directory
     27     * @param img Image name (without extension) to find in {@code statusline} directory
    2628     * @param tooltip Tooltip text to display
    2729     * @param charCount Character count used to compute min/preferred size
     
    3133        setLayout(new GridBagLayout());
    3234        setBackground(background);
    33         add(new JLabel(ImageProvider.get("statusline/"+img+".png")), GBC.std().anchor(GBC.WEST).insets(0, 1, 1, 0));
     35        add(imgLabel = new JLabel(), GBC.std().anchor(GBC.WEST).insets(0, 1, 1, 0));
     36        setIcon(img);
    3437        add(tf = new JLabel(), GBC.std().fill(GBC.BOTH).anchor(GBC.WEST).insets(2, 1, 1, 0));
    3538        setToolTipText(tooltip);
     
    4548    }
    4649
     50    /**
     51     * Sets the image to display.
     52     * @param img Image name (without extension) to find in {@code statusline} directory
     53     */
     54    public void setIcon(String img) {
     55        imgLabel.setIcon(ImageProvider.get("statusline/" + img));
     56    }
     57
    4758    @Override
    4859    public Dimension getPreferredSize() {
Note: See TracChangeset for help on using the changeset viewer.