- Timestamp:
- 2012-03-30T20:52:30+02:00 (13 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r5106 r5137 2 2 package org.openstreetmap.josm.actions.mapmode; 3 3 4 import java.awt.*; 4 5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 5 6 import static org.openstreetmap.josm.tools.I18n.marktr; … … 7 8 import static org.openstreetmap.josm.tools.I18n.trn; 8 9 9 import java.awt.AWTEvent;10 import java.awt.BasicStroke;11 import java.awt.Color;12 import java.awt.Cursor;13 import java.awt.Graphics2D;14 import java.awt.Point;15 import java.awt.Stroke;16 import java.awt.Toolkit;17 10 import java.awt.event.AWTEventListener; 18 11 import java.awt.event.ActionEvent; … … 36 29 import java.util.TreeSet; 37 30 38 import javax.swing.AbstractAction; 39 import javax.swing.JCheckBoxMenuItem; 40 import javax.swing.JMenuItem; 41 import javax.swing.JOptionPane; 42 import javax.swing.JPopupMenu; 43 import javax.swing.Timer; 31 import javax.swing.*; 44 32 45 33 import org.openstreetmap.josm.Main; … … 238 226 snapHelper.unsetFixedMode(); 239 227 snapCheckboxMenuItem.getAction().setEnabled(false); 228 240 229 Main.map.statusLine.getAnglePanel().removeMouseListener(snapHelper.anglePopupListener); 230 Main.map.statusLine.activateAnglePanel(false); 241 231 242 232 removeHighlighting(); … … 262 252 return; 263 253 if (event instanceof KeyEvent) { 264 processKeyEvent((KeyEvent) event); 254 KeyEvent e = (KeyEvent) event; 255 if (snappingShortcut.isEvent(e) || getShortcut().isEvent(e)) { 256 Component focused = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); 257 if (SwingUtilities.getWindowAncestor(focused) instanceof JFrame) 258 processKeyEvent(e); 259 } 265 260 } // toggle angle snapping 266 261 updateKeyModifiers((InputEvent) event); … … 275 270 private Timer timer; 276 271 void processKeyEvent(KeyEvent e) { 277 if (!snappingShortcut.isEvent(e) )278 return; 279 272 if (!snappingShortcut.isEvent(e) && !getShortcut().isEvent(e)) 273 return; 274 280 275 if (e.getID() == KeyEvent.KEY_PRESSED) { 281 276 if (timer.isRunning()) { … … 764 759 mouseOnExistingWays = new HashSet<Way>(); 765 760 766 showStatusInfo(-1, -1, -1 );761 showStatusInfo(-1, -1, -1, snapHelper.isSnapOn()); 767 762 768 763 if (!ctrl && mousePos != null) { … … 809 804 } 810 805 811 private void showStatusInfo(double angle, double hdg, double distance ) {806 private void showStatusInfo(double angle, double hdg, double distance, boolean activeFlag) { 812 807 Main.map.statusLine.setAngle(angle); 808 Main.map.statusLine.activateAnglePanel(activeFlag); 813 809 Main.map.statusLine.setHeading(hdg); 814 810 Main.map.statusLine.setDist(distance); … … 1420 1416 if (angle > 360) angle=0; 1421 1417 } 1422 showStatusInfo(angle, hdg, distance );1418 showStatusInfo(angle, hdg, distance, isSnapOn()); 1423 1419 } 1424 1420 … … 1465 1461 if (selectedWays.size()==1) { 1466 1462 Way w = selectedWays.iterator().next(); 1467 for (Node n: w.getNodes()) { 1468 EastNorth en=n.getEastNorth(); 1463 Collection <EastNorth> pointsToProject = new ArrayList<EastNorth>(); 1464 if (w.getNodesCount()<1000) for (Node n: w.getNodes()) { 1465 pointsToProject.add(n.getEastNorth()); 1466 } 1467 if (customBaseHeading >=0 ) { 1468 pointsToProject.add(segmentPoint1); 1469 pointsToProject.add(segmentPoint2); 1470 } 1471 EastNorth enOpt=null; 1472 double dOpt=1e5; 1473 for (EastNorth en: pointsToProject) { // searching for besht projection 1469 1474 double l1 = (en.east()-e0)*pe+(en.north()-n0)*pn; 1470 if (Math.abs(l1-l) < delta) { 1475 double d1 = Math.abs(l1-l); 1476 if (d1 < delta && d1 < dOpt) { 1471 1477 l=l1; 1472 projectionSource =en;1473 break;1478 enOpt = en; 1479 dOpt = d1; 1474 1480 } 1481 } 1482 if (enOpt!=null) { 1483 projectionSource = enOpt; 1475 1484 } 1476 1485 } -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r5129 r5137 76 76 */ 77 77 static class ImageLabel extends JPanel { 78 static Color backColor = Color.decode("#b8cfe5"); 79 static Color backColorActive = Color.decode("#aaff5e"); 80 78 81 private JLabel tf; 79 82 private int chars; … … 81 84 super(); 82 85 setLayout(new GridBagLayout()); 83 setBackground( Color.decode("#b8cfe5"));86 setBackground(backColor); 84 87 add(new JLabel(ImageProvider.get("statusline/"+img+".png")), GBC.std().anchor(GBC.WEST).insets(0,1,1,0)); 85 88 add(tf = new JLabel(), GBC.std().fill(GBC.BOTH).anchor(GBC.WEST).insets(2,1,1,0)); … … 788 791 distText.setText(dist < 0 ? "--" : NavigatableComponent.getDistText(dist)); 789 792 } 793 public void activateAnglePanel(boolean activeFlag) { 794 angleText.setBackground(activeFlag ? ImageLabel.backColorActive : ImageLabel.backColor); 795 } 790 796 }
Note:
See TracChangeset
for help on using the changeset viewer.