Changeset 32920 in osm for applications/editors/josm
- Timestamp:
- 2016-09-03T22:06:48+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/alignways
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysAlgnSegment.java
r30737 r32920 26 26 /** 27 27 * @author tilusnet <tilusnet@gmail.com> 28 * 28 * 29 29 * The segment to be aligned to the reference segment. Actions it can do: 30 30 * - remember its selected pivot point … … 32 32 * - rotate itself 33 33 * - paint itself and its selected pivot point 34 * 34 * 35 35 */ 36 36 public class AlignWaysAlgnSegment extends AlignWaysSegment { … … 109 109 * Returns the EastNorth of the specified pivot point pp. It always returns 110 110 * up-to-date data from dataset. Assumes segment is not null. 111 * 111 * 112 112 * @param pp 113 113 * The pivot location … … 177 177 * Given a Node (usually an endpoint), it will return a collection of way segments that are adjacently 178 178 * connected to it. The current alignee waysegment is not added to the collection. 179 * 179 * 180 180 * @param node The Node (endpoint) to analyse. 181 181 * @return The collection of the adjacent waysegments. … … 194 194 Point pnew = new Point(); 195 195 pnew.setLocation(x, y); 196 WaySegment ws = Main.map.mapView.getNearestWaySegment(pnew, OsmPrimitive .isUsablePredicate);196 WaySegment ws = Main.map.mapView.getNearestWaySegment(pnew, OsmPrimitive::isUsable); 197 197 if (ws != null && !ws.equals(this.segment) && 198 198 (ws.getFirstNode().equals(node) || ws.getSecondNode().equals(node))) { … … 211 211 * The node is normally a valid endpoint of the segment. 212 212 * If it isn't, null may be returned. 213 * 213 * 214 214 * @param node The (endpoint) node. 215 215 * @return Collection of the adjacent way segments. -
applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysMode.java
r32466 r32920 1 1 /** 2 * 2 * 3 3 */ 4 4 package com.tilusnet.josm.plugins.alignways; … … 29 29 * @author tilusnet <tilusnet@gmail.com> 30 30 * Handles the state machine and user interaction (mouse clicks). 31 * 31 * 32 32 */ 33 33 public class AlignWaysMode extends MapMode /* implements MapViewPaintable */{ … … 209 209 210 210 Main.pref.put("alignways.showtips", !atp.isChkBoxSelected()); 211 212 } 213 211 } 214 212 215 213 private void showWhatsNew() { … … 226 224 wnDialog.dispose(); 227 225 228 Main.pref.put("alignways.majorver", new Integer(AlignWaysPlugin.AlignWaysMajorVersion).toString()); 229 226 Main.pref.put("alignways.majorver", Integer.toString(AlignWaysPlugin.AlignWaysMajorVersion)); 230 227 } 231 228 -
applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysSegment.java
r32160 r32920 1 1 /** 2 * 2 * 3 3 */ 4 4 package com.tilusnet.josm.plugins.alignways; … … 23 23 /** 24 24 * @author tilusnet <tilusnet@gmail.com> 25 * 25 * 26 26 */ 27 27 public class AlignWaysSegment implements MapViewPaintable { … … 60 60 segmentEndPoints.add(node1); 61 61 segmentEndPoints.add(node2); 62 63 62 } 64 63 } 65 64 66 65 protected WaySegment getNearestWaySegment(Point p) { 67 68 return mapview.getNearestWaySegment(p, OsmPrimitive.isUsablePredicate); 69 66 return mapview.getNearestWaySegment(p, OsmPrimitive::isUsable); 70 67 } 71 68 -
applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysWhatsNewPanel.java
r30345 r32920 1 1 /** 2 * 2 * 3 3 */ 4 4 package com.tilusnet.josm.plugins.alignways; … … 46 46 newItem2 = new javax.swing.JLabel(); 47 47 48 lblWhatsNew.setText("<html><div style=\"font-family: sans-serif; font-weight: bold; font-style: italic;\"><span style=\"font-size: large;\"><span style=\"font-size: x-large;\">" 49 + tr("What''s new...") 48 lblWhatsNew.setText("<html><div style=\"font-family: sans-serif; font-weight: bold; font-style: italic;\"><span style=\"font-size: large;\"><span style=\"font-size: x-large;\">" 49 + tr("What''s new...") 50 50 + "</span></div></html>"); 51 51 … … 53 53 54 54 newItem1.setText("<html><div style=\"font-family: sans-serif;\"><ul style=\"margin-left: 20px;\"><li>" 55 + tr("Added <b>angle preserving</b> aligning mode") 55 + tr("Added <b>angle preserving</b> aligning mode") 56 56 + "</li></ul></div></html>"); 57 57 … … 67 67 btnHelpItem1.setPreferredSize(new java.awt.Dimension(69, 25)); 68 68 btnHelpItem1.addActionListener(new java.awt.event.ActionListener() { 69 @Override 69 70 public void actionPerformed(java.awt.event.ActionEvent evt) { 70 71 btnHelpItem1ActionPerformed(evt); … … 136 137 } catch (URISyntaxException ex) { 137 138 Logger.getLogger(AlignWaysWhatsNewPanel.class.getName()).log(Level.SEVERE, null, ex); 138 } catch (IOException e) { 139 } catch (IOException e) { 139 140 JOptionPane.showMessageDialog(this, e, tr("Errr..."), JOptionPane.WARNING_MESSAGE); 140 141 } 141 } else { 142 } else { 142 143 JOptionPane.showMessageDialog(this, tr("Browser not supported."), tr("Errr..."), JOptionPane.WARNING_MESSAGE); 143 144 } 144 145 } 145 146 146 147 /*** End of Matisse generated code section ***/ 147 148 -
applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/geometry/AlignWaysGeomLine.java
r30345 r32920 1 1 package com.tilusnet.josm.plugins.alignways.geometry; 2 2 3 import java.util.Objects; 3 4 4 5 /** … … 131 132 /** 132 133 * Get the Y coordinate on the line of a point with the given X coordinate. 133 * 134 * @param XThe x-coordinate of the given point.134 * 135 * @param x The x-coordinate of the given point. 135 136 * @return The calculated y-coordinate or Double.NaN if the line is vertical. 136 137 */ 137 public Double getYonLine(double X) {138 139 Double Y = new Double((-coef_a*X- coef_c)/coef_b);140 141 if ( Y.isInfinite() || Y.isNaN())138 public Double getYonLine(double x) { 139 140 Double y = Double.valueOf((-coef_a*x - coef_c)/coef_b); 141 142 if (y.isInfinite() || y.isNaN()) 142 143 // Vertical line 143 144 return Double.NaN; 144 145 else 145 return Y; 146 147 } 148 146 return y; 147 } 149 148 150 149 /** 151 150 * Get the X coordinate on the line of a point with the given Y coordinate. 152 * 153 * @param YThe y-coordinate of the given point.151 * 152 * @param y The y-coordinate of the given point. 154 153 * @return The calculated x-coordinate or Double.NaN if the line is horizontal. 155 154 */ 156 public Double getXonLine(double Y) {157 158 Double X = new Double((-coef_b*Y- coef_c)/coef_a);159 160 if ( X.isInfinite() || X.isNaN())155 public Double getXonLine(double y) { 156 157 Double x = Double.valueOf((-coef_b*y - coef_c)/coef_a); 158 159 if (x.isInfinite() || x.isNaN()) 161 160 // Horizontal line 162 161 return Double.NaN; 163 162 else 164 return X; 165 163 return x; 166 164 } 167 165 … … 184 182 } 185 183 184 @Override 185 public int hashCode() { 186 return Objects.hash(coef_a, coef_b, coef_c); 187 } 188 186 189 public boolean isPointOnLine(AlignWaysGeomPoint awPt) { 187 190 // Method: … … 189 192 // 2. check getIntersectionStatus of the two lines 190 193 // 3. if status is LINES_OVERLAP, the point os one the line, otherwise not 191 194 192 195 // Need an arbitrary point on this line; let it be (x, y) 193 196 Double x = 0.0; 194 197 Double y = getYonLine(x); 195 198 if (y.isNaN()) y = 0.0; 196 199 197 200 AlignWaysGeomLine line2 = new AlignWaysGeomLine(awPt, new AlignWaysGeomPoint(x, y)); 198 201 getIntersection(line2); … … 201 204 else 202 205 return false; 203 206 204 207 } 205 208
Note:
See TracChangeset
for help on using the changeset viewer.