Changeset 10258 in osm for applications/editors/josm
- Timestamp:
- 2008-08-28T00:06:55+02:00 (16 years ago)
- 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 8 8 9 9 import java.awt.BorderLayout; 10 import java.awt.Dimension; 10 11 import java.awt.FlowLayout; 11 12 import java.awt.event.ActionEvent; … … 23 24 24 25 public 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"; 25 32 26 33 private ImageDisplay imgDisplay = new ImageDisplay(); … … 56 63 JButton button; 57 64 65 Dimension buttonDim = new Dimension(26,26); 58 66 button = new JButton(); 59 67 button.setIcon(ImageProvider.get("dialogs", "previous")); 60 button.setActionCommand( "previous");68 button.setActionCommand(COMMAND_PREVIOUS); 61 69 button.setToolTipText(tr("Previous")); 62 70 button.addActionListener(this); 71 button.setPreferredSize(buttonDim); 63 72 buttons.add(button); 64 73 65 74 button = new JButton(); 66 75 button.setIcon(ImageProvider.get("dialogs", "delete")); 67 button.setActionCommand( "remove");76 button.setActionCommand(COMMAND_REMOVE); 68 77 button.setToolTipText(tr("Remove photo from layer")); 69 78 button.addActionListener(this); 79 button.setPreferredSize(buttonDim); 70 80 buttons.add(button); 71 81 72 82 button = new JButton(); 73 83 button.setIcon(ImageProvider.get("dialogs", "next")); 74 button.setActionCommand( "next");84 button.setActionCommand(COMMAND_NEXT); 75 85 button.setToolTipText(tr("Next")); 76 86 button.addActionListener(this); 87 button.setPreferredSize(buttonDim); 77 88 buttons.add(button); 78 89 79 90 JToggleButton tb = new JToggleButton(); 80 91 tb.setIcon(ImageProvider.get("dialogs", "centreview")); 81 tb.setActionCommand( "centre");92 tb.setActionCommand(COMMAND_CENTERVIEW); 82 93 tb.setToolTipText(tr("Center view")); 83 94 tb.addActionListener(this); 95 tb.setPreferredSize(buttonDim); 84 96 buttons.add(tb); 85 97 86 98 button = new JButton(); 87 99 button.setIcon(ImageProvider.get("dialogs", "zoom-best-fit")); 88 button.setActionCommand( "zoom");100 button.setActionCommand(COMMAND_ZOOM); 89 101 button.setToolTipText(tr("Zoom best fit and 1:1")); 90 102 button.addActionListener(this); 103 button.setPreferredSize(buttonDim); 91 104 buttons.add(button); 92 105 … … 98 111 99 112 public void actionPerformed(ActionEvent e) { 100 if ( "next".equals(e.getActionCommand())) {113 if (COMMAND_NEXT.equals(e.getActionCommand())) { 101 114 if (currentLayer != null) { 102 115 currentLayer.showNextPhoto(); 103 116 } 104 } else if ( "previous".equals(e.getActionCommand())) {117 } else if (COMMAND_PREVIOUS.equals(e.getActionCommand())) { 105 118 if (currentLayer != null) { 106 119 currentLayer.showPreviousPhoto(); 107 120 } 108 121 109 } else if ( "centre".equals(e.getActionCommand())) {122 } else if (COMMAND_CENTERVIEW.equals(e.getActionCommand())) { 110 123 centerView = ((JToggleButton) e.getSource()).isSelected(); 111 124 if (centerView && currentEntry != null && currentEntry.pos != null) { … … 113 126 } 114 127 115 } else if ( "zoom".equals(e.getActionCommand())) {128 } else if (COMMAND_ZOOM.equals(e.getActionCommand())) { 116 129 imgDisplay.zoomBestFitOrOne(); 117 130 118 } else if ( "remove".equals(e.getActionCommand())) {131 } else if (COMMAND_REMOVE.equals(e.getActionCommand())) { 119 132 if (currentLayer != null) { 120 133 currentLayer.removeCurrentPhoto(); … … 125 138 126 139 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); 135 141 } 136 142 … … 145 151 } 146 152 147 if (centerView && entry != null && entry.pos != null) {153 if (centerView && Main.map != null && entry != null && entry.pos != null) { 148 154 Main.map.mapView.zoomTo(entry.pos, Main.map.mapView.getScale()); 149 155 } -
applications/editors/josm/plugins/agpifoj/src/org/openstreetmap/josm/plugins/agpifoj/ImageDisplay.java
r10122 r10258 480 480 int x = 3; 481 481 int y = 3; 482 String line; 482 483 while (pos > 0) { 483 Stringline = osdText.substring(lastPos, pos);484 line = osdText.substring(lastPos, pos); 484 485 Rectangle2D lineSize = metrics.getStringBounds(line, g); 485 486 g.setColor(bkground); … … 491 492 pos = osdText.indexOf("\n", lastPos); 492 493 } 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); 501 501 } 502 502 }
Note:
See TracChangeset
for help on using the changeset viewer.