Ignore:
Timestamp:
2008-08-28T00:06:55+02:00 (16 years ago)
Author:
khris78
Message:

Agpifoj plugin : changed the buttons size in AgpifojDialog

Location:
applications/editors/josm/plugins/agpifoj/src/org/openstreetmap/josm/plugins/agpifoj
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/agpifoj/src/org/openstreetmap/josm/plugins/agpifoj/AgpifojDialog.java

    r10122 r10258  
    88
    99import java.awt.BorderLayout;
     10import java.awt.Dimension;
    1011import java.awt.FlowLayout;
    1112import java.awt.event.ActionEvent;
     
    2324
    2425public class AgpifojDialog extends ToggleDialog implements ActionListener {
     26
     27    private static final String COMMAND_ZOOM = "zoom";
     28    private static final String COMMAND_CENTERVIEW = "centre";
     29    private static final String COMMAND_NEXT = "next";
     30    private static final String COMMAND_REMOVE = "remove";
     31    private static final String COMMAND_PREVIOUS = "previous";
    2532
    2633    private ImageDisplay imgDisplay = new ImageDisplay();
     
    5663        JButton button;
    5764       
     65        Dimension buttonDim = new Dimension(26,26);
    5866        button = new JButton();
    5967        button.setIcon(ImageProvider.get("dialogs", "previous"));
    60         button.setActionCommand("previous");
     68        button.setActionCommand(COMMAND_PREVIOUS);
    6169        button.setToolTipText(tr("Previous"));
    6270        button.addActionListener(this);
     71        button.setPreferredSize(buttonDim);
    6372        buttons.add(button);
    6473       
    6574        button = new JButton();
    6675        button.setIcon(ImageProvider.get("dialogs", "delete"));
    67         button.setActionCommand("remove");
     76        button.setActionCommand(COMMAND_REMOVE);
    6877        button.setToolTipText(tr("Remove photo from layer"));
    6978        button.addActionListener(this);
     79        button.setPreferredSize(buttonDim);
    7080        buttons.add(button);
    7181       
    7282        button = new JButton();
    7383        button.setIcon(ImageProvider.get("dialogs", "next"));
    74         button.setActionCommand("next");
     84        button.setActionCommand(COMMAND_NEXT);
    7585        button.setToolTipText(tr("Next"));
    7686        button.addActionListener(this);
     87        button.setPreferredSize(buttonDim);
    7788        buttons.add(button);
    7889       
    7990        JToggleButton tb = new JToggleButton();
    8091        tb.setIcon(ImageProvider.get("dialogs", "centreview"));
    81         tb.setActionCommand("centre");
     92        tb.setActionCommand(COMMAND_CENTERVIEW);
    8293        tb.setToolTipText(tr("Center view"));
    8394        tb.addActionListener(this);
     95        tb.setPreferredSize(buttonDim);
    8496        buttons.add(tb);
    8597       
    8698        button = new JButton();
    8799        button.setIcon(ImageProvider.get("dialogs", "zoom-best-fit"));
    88         button.setActionCommand("zoom");
     100        button.setActionCommand(COMMAND_ZOOM);
    89101        button.setToolTipText(tr("Zoom best fit and 1:1"));
    90102        button.addActionListener(this);
     103        button.setPreferredSize(buttonDim);
    91104        buttons.add(button);
    92105       
     
    98111
    99112    public void actionPerformed(ActionEvent e) {
    100         if ("next".equals(e.getActionCommand())) {
     113        if (COMMAND_NEXT.equals(e.getActionCommand())) {
    101114            if (currentLayer != null) {
    102115                currentLayer.showNextPhoto();
    103116            }
    104         } else if ("previous".equals(e.getActionCommand())) {
     117        } else if (COMMAND_PREVIOUS.equals(e.getActionCommand())) {
    105118            if (currentLayer != null) {
    106119                currentLayer.showPreviousPhoto();
    107120            }
    108121           
    109         } else if ("centre".equals(e.getActionCommand())) {
     122        } else if (COMMAND_CENTERVIEW.equals(e.getActionCommand())) {
    110123            centerView = ((JToggleButton) e.getSource()).isSelected();
    111124            if (centerView && currentEntry != null && currentEntry.pos != null) {
     
    113126            }
    114127           
    115         } else if ("zoom".equals(e.getActionCommand())) {
     128        } else if (COMMAND_ZOOM.equals(e.getActionCommand())) {
    116129            imgDisplay.zoomBestFitOrOne();
    117130           
    118         } else if ("remove".equals(e.getActionCommand())) {
     131        } else if (COMMAND_REMOVE.equals(e.getActionCommand())) {
    119132            if (currentLayer != null) {
    120133               currentLayer.removeCurrentPhoto();
     
    125138
    126139    public static void showImage(AgpifojLayer layer, ImageEntry entry) {
    127         if (INSTANCE == null) {
    128             Main.main.map.addToggleDialog(new AgpifojDialog());
    129         }
    130        
    131         if (INSTANCE != null) {
    132             INSTANCE.displayImage(layer, entry);
    133         }
    134        
     140        getInstance().displayImage(layer, entry);
    135141    }
    136142
     
    145151            }
    146152       
    147             if (centerView && entry != null && entry.pos != null) {
     153            if (centerView && Main.map != null && entry != null && entry.pos != null) {
    148154                Main.map.mapView.zoomTo(entry.pos, Main.map.mapView.getScale());
    149155            }
  • applications/editors/josm/plugins/agpifoj/src/org/openstreetmap/josm/plugins/agpifoj/ImageDisplay.java

    r10122 r10258  
    480480                int x = 3;
    481481                int y = 3;
     482                String line;
    482483                while (pos > 0) {
    483                     String line = osdText.substring(lastPos, pos);
     484                    line = osdText.substring(lastPos, pos);
    484485                    Rectangle2D lineSize = metrics.getStringBounds(line, g);
    485486                    g.setColor(bkground);
     
    491492                    pos = osdText.indexOf("\n", lastPos);
    492493                }
    493                 if (lastPos > 0) {
    494                     String line = osdText.substring(lastPos);
    495                     Rectangle2D lineSize = g.getFontMetrics(g.getFont()).getStringBounds(line, g);
    496                     g.setColor(bkground);
    497                     g.fillRect(x, y, (int) lineSize.getWidth(), (int) lineSize.getHeight());
    498                     g.setColor(Color.black);
    499                     g.drawString(line, x, y + ascent);
    500                 }
     494
     495                line = osdText.substring(lastPos);
     496                Rectangle2D lineSize = g.getFontMetrics(g.getFont()).getStringBounds(line, g);
     497                g.setColor(bkground);
     498                g.fillRect(x, y, (int) lineSize.getWidth(), (int) lineSize.getHeight());
     499                g.setColor(Color.black);
     500                g.drawString(line, x, y + ascent);
    501501            }
    502502        }
Note: See TracChangeset for help on using the changeset viewer.