Changeset 11502 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2017-01-25T22:37:16+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawSnapHelper.java
r11495 r11502 55 55 private static final String DRAW_ANGLESNAP_ANGLES = "draw.anglesnap.angles"; 56 56 57 private static final class RepeatedAction extends AbstractAction { 58 RepeatedAction(DrawSnapHelper snapHelper) { 59 super(tr("Toggle snapping by {0}", snapHelper.drawAction.getShortcut().getKeyText())); 60 } 61 62 @Override 63 public void actionPerformed(ActionEvent e) { 64 boolean sel = ((JCheckBoxMenuItem) e.getSource()).getState(); 65 DrawAction.USE_REPEATED_SHORTCUT.put(sel); 66 } 67 } 68 69 private static final class HelperAction extends AbstractAction { 70 private final transient DrawSnapHelper snapHelper; 71 72 HelperAction(DrawSnapHelper snapHelper) { 73 super(tr("Show helper geometry")); 74 this.snapHelper = snapHelper; 75 } 76 77 @Override 78 public void actionPerformed(ActionEvent e) { 79 boolean sel = ((JCheckBoxMenuItem) e.getSource()).getState(); 80 DrawAction.DRAW_CONSTRUCTION_GEOMETRY.put(sel); 81 DrawAction.SHOW_PROJECTED_POINT.put(sel); 82 DrawAction.SHOW_ANGLE.put(sel); 83 snapHelper.enableSnapping(); 84 } 85 } 86 87 private static final class ProjectionAction extends AbstractAction { 88 private final transient DrawSnapHelper snapHelper; 89 90 ProjectionAction(DrawSnapHelper snapHelper) { 91 super(tr("Snap to node projections")); 92 this.snapHelper = snapHelper; 93 } 94 95 @Override 96 public void actionPerformed(ActionEvent e) { 97 boolean sel = ((JCheckBoxMenuItem) e.getSource()).getState(); 98 DrawAction.SNAP_TO_PROJECTIONS.put(sel); 99 snapHelper.enableSnapping(); 100 } 101 } 102 103 private static final class DisableAction extends AbstractAction { 104 private final transient DrawSnapHelper snapHelper; 105 106 DisableAction(DrawSnapHelper snapHelper) { 107 super(tr("Disable")); 108 this.snapHelper = snapHelper; 109 } 110 111 @Override 112 public void actionPerformed(ActionEvent e) { 113 snapHelper.saveAngles("180"); 114 snapHelper.init(); 115 snapHelper.enableSnapping(); 116 } 117 } 118 119 private static final class Snap90DegreesAction extends AbstractAction { 120 private final transient DrawSnapHelper snapHelper; 121 122 Snap90DegreesAction(DrawSnapHelper snapHelper) { 123 super(tr("0,90,...")); 124 this.snapHelper = snapHelper; 125 } 126 127 @Override 128 public void actionPerformed(ActionEvent e) { 129 snapHelper.saveAngles("0", "90", "180"); 130 snapHelper.init(); 131 snapHelper.enableSnapping(); 132 } 133 } 134 135 private static final class Snap45DegreesAction extends AbstractAction { 136 private final transient DrawSnapHelper snapHelper; 137 138 Snap45DegreesAction(DrawSnapHelper snapHelper) { 139 super(tr("0,45,90,...")); 140 this.snapHelper = snapHelper; 141 } 142 143 @Override 144 public void actionPerformed(ActionEvent e) { 145 snapHelper.saveAngles("0", "45", "90", "135", "180"); 146 snapHelper.init(); 147 snapHelper.enableSnapping(); 148 } 149 } 150 151 private static final class Snap30DegreesAction extends AbstractAction { 152 private final transient DrawSnapHelper snapHelper; 153 154 Snap30DegreesAction(DrawSnapHelper snapHelper) { 155 super(tr("0,30,45,60,90,...")); 156 this.snapHelper = snapHelper; 157 } 158 159 @Override 160 public void actionPerformed(ActionEvent e) { 161 snapHelper.saveAngles("0", "30", "45", "60", "90", "120", "135", "150", "180"); 162 snapHelper.init(); 163 snapHelper.enableSnapping(); 164 } 165 } 166 57 167 private static final class AnglePopupMenu extends JPopupMenu { 58 168 … … 62 172 63 173 private AnglePopupMenu(final DrawSnapHelper snapHelper) { 64 repeatedCb = new JCheckBoxMenuItem( 65 new AbstractAction(tr("Toggle snapping by {0}", snapHelper.drawAction.getShortcut().getKeyText())) { 66 @Override 67 public void actionPerformed(ActionEvent e) { 68 boolean sel = ((JCheckBoxMenuItem) e.getSource()).getState(); 69 DrawAction.USE_REPEATED_SHORTCUT.put(sel); 70 } 71 }); 72 73 helperCb = new JCheckBoxMenuItem( 74 new AbstractAction(tr("Show helper geometry")) { 75 @Override 76 public void actionPerformed(ActionEvent e) { 77 boolean sel = ((JCheckBoxMenuItem) e.getSource()).getState(); 78 DrawAction.DRAW_CONSTRUCTION_GEOMETRY.put(sel); 79 DrawAction.SHOW_PROJECTED_POINT.put(sel); 80 DrawAction.SHOW_ANGLE.put(sel); 81 snapHelper.enableSnapping(); 82 } 83 }); 84 85 projectionCb = new JCheckBoxMenuItem( 86 new AbstractAction(tr("Snap to node projections")) { 87 @Override 88 public void actionPerformed(ActionEvent e) { 89 boolean sel = ((JCheckBoxMenuItem) e.getSource()).getState(); 90 DrawAction.SNAP_TO_PROJECTIONS.put(sel); 91 snapHelper.enableSnapping(); 92 } 93 }); 174 repeatedCb = new JCheckBoxMenuItem(new RepeatedAction(snapHelper)); 175 helperCb = new JCheckBoxMenuItem(new HelperAction(snapHelper)); 176 projectionCb = new JCheckBoxMenuItem(new ProjectionAction(snapHelper)); 94 177 95 178 helperCb.setState(DrawAction.DRAW_CONSTRUCTION_GEOMETRY.get()); … … 99 182 add(helperCb); 100 183 add(projectionCb); 101 add(new AbstractAction(tr("Disable")) { 102 @Override 103 public void actionPerformed(ActionEvent e) { 104 snapHelper.saveAngles("180"); 105 snapHelper.init(); 106 snapHelper.enableSnapping(); 107 } 108 }); 109 add(new AbstractAction(tr("0,90,...")) { 110 @Override 111 public void actionPerformed(ActionEvent e) { 112 snapHelper.saveAngles("0", "90", "180"); 113 snapHelper.init(); 114 snapHelper.enableSnapping(); 115 } 116 }); 117 add(new AbstractAction(tr("0,45,90,...")) { 118 @Override 119 public void actionPerformed(ActionEvent e) { 120 snapHelper.saveAngles("0", "45", "90", "135", "180"); 121 snapHelper.init(); 122 snapHelper.enableSnapping(); 123 } 124 }); 125 add(new AbstractAction(tr("0,30,45,60,90,...")) { 126 @Override 127 public void actionPerformed(ActionEvent e) { 128 snapHelper.saveAngles("0", "30", "45", "60", "90", "120", "135", "150", "180"); 129 snapHelper.init(); 130 snapHelper.enableSnapping(); 131 } 132 }); 184 add(new DisableAction(snapHelper)); 185 add(new Snap90DegreesAction(snapHelper)); 186 add(new Snap45DegreesAction(snapHelper)); 187 add(new Snap30DegreesAction(snapHelper)); 133 188 } 134 189 }
Note:
See TracChangeset
for help on using the changeset viewer.