Changeset 34489 in osm for applications/editors/josm/plugins/alignways/src/org
- Timestamp:
- 2018-08-18T02:46:32+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/alignways/src/org
- Files:
-
- 5 added
- 2 edited
- 18 copied
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysAction.java
r34488 r34489 1 /** 2 * 3 */ 4 package com.tilusnet.josm.plugins.alignways; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways; 5 3 6 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 16 14 import org.openstreetmap.josm.data.osm.Node; 17 15 import org.openstreetmap.josm.gui.MainApplication; 16 import org.openstreetmap.josm.plugins.alignways.AlignWaysDialog.AligningModeOption; 18 17 import org.openstreetmap.josm.tools.Shortcut; 19 18 20 import com.tilusnet.josm.plugins.alignways.AlignWaysDialog.AligningModeOption;21 22 19 /** 23 * @author tilusnet <tilusnet@gmail.com>24 * 20 * Makes a pair of selected way segments parallel by rotating one of them around a chosen pivot. 21 * @author tilusnet <tilusnet@gmail.com> 25 22 */ 26 23 public class AlignWaysAction extends JosmAction { … … 35 32 + "around a chosen pivot."), 36 33 Shortcut.registerShortcut("tools:alignways", tr("Tool: {0}", tr("Align Ways")), 37 KeyEvent.VK_SPACE, Shortcut.SHIFT) 38 ,true);34 KeyEvent.VK_SPACE, Shortcut.SHIFT), 35 true); 39 36 setEnabled(false); 40 37 } -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysAlgnSegment.java
r34441 r34489 1 package com.tilusnet.josm.plugins.alignways; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways; 2 3 3 4 import java.awt.BasicStroke; … … 27 28 28 29 /** 29 * @author tilusnet <tilusnet@gmail.com>30 * @author tilusnet <tilusnet@gmail.com> 30 31 * 31 32 * The segment to be aligned to the reference segment. Actions it can do: … … 47 48 private final Color pivotColor = Color.YELLOW; 48 49 private final Color crossColor = pivotColor; 49 private final Map<Node, ArrayList<WaySegment>> adjWaySegs = new HashMap<>();50 private final Map<Node, ArrayList<WaySegment>> adjWaySegs = new HashMap<>(); 50 51 51 52 public AlignWaysAlgnSegment(MapView mapview, Point p) … … 88 89 /** 89 90 * Updates the segment's pivot list and sets the rotation pivot to centre. 91 * @param pivotRef pivot reference 90 92 */ 91 93 private void setPivots(PivotLocations pivotRef) { … … 114 116 * @param pp 115 117 * The pivot location 118 * @return east/north coordinates of pivot location 116 119 */ 117 120 private EastNorth getPivotCoord(PivotLocations pp) { … … 203 206 pnew.setLocation(x, y); 204 207 WaySegment ws = MainApplication.getMap().mapView.getNearestWaySegment(pnew, OsmPrimitive::isUsable); 205 if (ws != null && 208 if (ws != null && !ws.equals(this.segment) && 206 209 (ws.getFirstNode().equals(node) || ws.getSecondNode().equals(node))) { 207 210 // We won't want to add a: -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysCmdKeepAngles.java
r34488 r34489 1 /** 2 * 3 */ 4 package com.tilusnet.josm.plugins.alignways; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways; 5 3 6 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 16 14 import org.openstreetmap.josm.data.osm.WaySegment; 17 15 import org.openstreetmap.josm.gui.MainApplication; 18 19 import com.tilusnet.josm.plugins.alignways.geometry.AlignWaysGeomLine; 20 import com.tilusnet.josm.plugins.alignways.geometry.AlignWaysGeomLine.IntersectionStatus; 21 import com.tilusnet.josm.plugins.alignways.geometry.AlignWaysGeomPoint; 16 import org.openstreetmap.josm.plugins.alignways.geometry.AlignWaysGeomLine; 17 import org.openstreetmap.josm.plugins.alignways.geometry.AlignWaysGeomLine.IntersectionStatus; 18 import org.openstreetmap.josm.plugins.alignways.geometry.AlignWaysGeomPoint; 22 19 23 20 /** 24 * @author tilusnet <tilusnet@gmail.com>21 * @author tilusnet <tilusnet@gmail.com> 25 22 * 26 23 */ … … 34 31 // without preserving the angles, i.e. preserving the length. 35 32 36 Map<Node, EastNorth> calcNodesKeepLength = calculatedNodes;33 Map<Node, EastNorth> calcNodesKeepLength = calculatedNodes; 37 34 38 35 // Now we'll proceed with the hypothetical recalculation of the endpoint coordinates … … 86 83 87 84 // Update the calculated node for angle preserving alignment 88 AlignWaysGeomPoint isectPnt = alignedLineKeepLength.getIntersection(new AlignWaysGeomLine(enAdjOther1.getX(), enAdjOther1.getY(), 89 endpoint.getEastNorth().getX(), endpoint.getEastNorth().getY())); 85 AlignWaysGeomPoint isectPnt = alignedLineKeepLength.getIntersection( 86 new AlignWaysGeomLine(enAdjOther1.getX(), enAdjOther1.getY(), 87 endpoint.getEastNorth().getX(), endpoint.getEastNorth().getY())); 90 88 EastNorth enIsectPt = null; 91 89 // If the intersection is null, the adjacent and the alignee are parallel already: -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysCmdKeepLength.java
r34488 r34489 1 /** 2 * 3 */ 4 package com.tilusnet.josm.plugins.alignways; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways; 5 3 6 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 30 28 * needed to align the ways. 31 29 * 32 * @author tilusnet <tilusnet@gmail.com>30 * @author tilusnet <tilusnet@gmail.com> 33 31 */ 34 32 public class AlignWaysCmdKeepLength extends Command { … … 42 40 ALGN_INV_XPOINT_FALLSOUT // for AlignWaysCmdKeepAngles 43 41 } 42 44 43 final AlignWaysAlgnSegment algnSeg; 45 44 … … 53 52 * Useful for validation. 54 53 */ 55 final Map<Node, EastNorth> calculatedNodes = new HashMap<>();54 final Map<Node, EastNorth> calculatedNodes = new HashMap<>(); 56 55 57 56 /** … … 79 78 * Creates an AlignWaysRotateCommand. 80 79 * TODO Limitation (for now): constructor assumes areSegsAlignable() returns true. 80 * @param ds the data set. Must not be null. 81 81 */ 82 82 public AlignWaysCmdKeepLength(DataSet ds) { … … 164 164 /** 165 165 * Make sure angle is in interval ( -Pi/2, Pi/2 ]. 166 * @param a angle 167 * @return normalized angle 166 168 */ 167 169 private double normalise_angle(double a) { … … 229 231 * They are not if they are connected *and* the pivot is not the connection 230 232 * node. 233 * @return alignable status 231 234 */ 232 235 AlignableStatus areSegsAlignable() { -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysDialog.java
r34441 r34489 1 /** 2 * 3 */ 4 package com.tilusnet.josm.plugins.alignways; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways; 5 3 6 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 25 23 26 24 /** 27 * @author tilusnet <tilusnet@gmail.com>25 * @author tilusnet <tilusnet@gmail.com> 28 26 * 29 27 */ … … 37 35 ALGN_OPT_KEEP_ANGLE 38 36 } 37 39 38 AligningModeOption awOpt; 40 39 JPanel activateInfoPanel, modesPanel, dlgPane; 41 42 40 43 41 public AlignWaysDialog(AlignWaysMode awMode) { … … 103 101 infoText.setBorder(BorderFactory.createCompoundBorder( 104 102 BorderFactory.createEtchedBorder(), 105 BorderFactory.createEmptyBorder(10, 10, 10, 10) 103 BorderFactory.createEmptyBorder(10, 10, 10, 10)) 106 104 ); 107 105 modesPanel.add(infoText); -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysMode.java
r34488 r34489 1 /** 2 * 3 */ 4 package com.tilusnet.josm.plugins.alignways; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways; 5 3 6 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 37 35 38 36 /** 39 * @author tilusnet <tilusnet@gmail.com>37 * @author tilusnet <tilusnet@gmail.com> 40 38 * Handles the state machine and user interaction (mouse clicks). 41 39 * … … 93 91 } 94 92 95 96 93 @Override 97 94 public void exitMode() { -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysPlugin.java
r34441 r34489 1 package com.tilusnet.josm.plugins.alignways; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways; 2 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 12 13 13 14 /** 14 * @author tilusnet <tilusnet@gmail.com>15 * @author tilusnet <tilusnet@gmail.com> 15 16 * 16 17 */ -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysRefSegment.java
r34441 r34489 1 /** 2 * 3 */ 4 package com.tilusnet.josm.plugins.alignways; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways; 5 3 6 4 import java.awt.Color; … … 10 8 11 9 /** 12 * @author tilusnet <tilusnet@gmail.com>The basic segment treated as reference.13 * 10 * @author tilusnet <tilusnet@gmail.com> The basic segment treated as reference. 11 * 14 12 */ 15 13 public class AlignWaysRefSegment extends AlignWaysSegment { -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysSegment.java
r34441 r34489 1 /** 2 * 3 */ 4 package com.tilusnet.josm.plugins.alignways; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways; 5 3 6 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 26 24 27 25 /** 28 * @author tilusnet <tilusnet@gmail.com>26 * @author tilusnet <tilusnet@gmail.com> 29 27 * 30 28 */ … … 54 52 } 55 53 } 56 57 54 58 55 void setSegmentEndpoints(WaySegment segment) { -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysSegmentMgr.java
r34488 r34489 1 package com.tilusnet.josm.plugins.alignways; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways; 2 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 18 19 * manager. Can request alignee, reference segment updates and pivot updates on 19 20 * these. 20 * 21 * @author tilusnet <tilusnet@gmail.com>22 * 21 * 22 * @author tilusnet <tilusnet@gmail.com> 23 * 23 24 */ 24 public class AlignWaysSegmentMgr {25 public final class AlignWaysSegmentMgr { 25 26 26 private volatile staticAlignWaysSegmentMgr singleton;27 private static volatile AlignWaysSegmentMgr singleton; 27 28 private AlignWaysRefSegment refSeg = null; 28 29 private AlignWaysAlgnSegment algnSeg = null; … … 35 36 /** 36 37 * Get or creates the segment manager instance belonging to a given MapView. 38 * @param mapView Map view 39 * @return segment manager instance for this map view 37 40 */ 38 41 public static AlignWaysSegmentMgr getInstance(MapView mapView) { … … 74 77 if (algnSeg != null && tmpAlgnSeg.equals(algnSeg)) { 75 78 return false; 76 } 77 else if (refSeg != null && tmpAlgnSeg.equals(refSeg)) { 79 } else if (refSeg != null && tmpAlgnSeg.equals(refSeg)) { 78 80 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 79 81 tr("Segment to be aligned cannot be the same with the reference segment.\n" + … … 108 110 if (refSeg != null && refSeg.equals(tmpRefSeg)) { 109 111 return false; 110 } 111 else if (algnSeg != null && tmpRefSeg.equals(algnSeg)) { 112 } else if (algnSeg != null && tmpRefSeg.equals(algnSeg)) { 112 113 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 113 114 tr("Reference segment cannot be the same with the segment to be aligned.\n" + … … 165 166 * Handles the event that OSM primitives were removed and checks whether 166 167 * this invalidates the currently selected alignee or reference segment. 168 * @param primitives List of primitives that were removed. 167 169 * @return Whether any of the selected segments were invalidated. 168 * @param primitives List of primitives that were removed.169 170 */ 170 171 public boolean primitivesRemoved(List<? extends OsmPrimitive> primitives) { -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysSelAlgnState.java
r34441 r34489 1 /** 2 * 3 */ 4 package com.tilusnet.josm.plugins.alignways; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways; 5 3 6 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 9 7 10 8 /** 11 * @author tilusnet <tilusnet@gmail.com>12 * 9 * @author tilusnet <tilusnet@gmail.com> 10 * 13 11 */ 14 12 public class AlignWaysSelAlgnState extends AlignWaysState { -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysSelBothState.java
r34441 r34489 1 /** 2 * 3 */ 4 package com.tilusnet.josm.plugins.alignways; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways; 5 3 6 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 9 7 10 8 /** 11 * @author tilusnet <tilusnet@gmail.com>12 * 9 * @author tilusnet <tilusnet@gmail.com> 10 * 13 11 */ 14 12 public class AlignWaysSelBothState extends AlignWaysState { -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysSelNoneState.java
r34441 r34489 1 /** 2 * 3 */ 4 package com.tilusnet.josm.plugins.alignways; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways; 5 3 6 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 9 7 10 8 /** 11 * @author tilusnet <tilusnet@gmail.com>12 * 9 * @author tilusnet <tilusnet@gmail.com> 10 * 13 11 */ 14 12 public class AlignWaysSelNoneState extends AlignWaysState { -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysSelRefState.java
r34441 r34489 1 /** 2 * 3 */ 4 package com.tilusnet.josm.plugins.alignways; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways; 5 3 6 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 9 7 10 8 /** 11 * @author tilusnet <tilusnet@gmail.com>12 * 9 * @author tilusnet <tilusnet@gmail.com> 10 * 13 11 */ 14 12 public class AlignWaysSelRefState extends AlignWaysState { -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysState.java
r34441 r34489 1 /** 2 * 3 */ 4 package com.tilusnet.josm.plugins.alignways; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways; 5 3 6 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 9 7 10 8 /** 11 * @author tilusnet <tilusnet@gmail.com>9 * @author tilusnet <tilusnet@gmail.com> 12 10 * 13 11 */ -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysTipsPanel.java
r34441 r34489 1 /** 2 * 3 */ 4 package com.tilusnet.josm.plugins.alignways; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways; 5 3 6 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 21 19 22 20 /** 23 * @author tilusnet <tilusnet@gmail.com>21 * @author tilusnet <tilusnet@gmail.com> 24 22 * 25 23 */ -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysWhatsNewPanel.java
r34441 r34489 1 /** 2 * 3 */ 4 package com.tilusnet.josm.plugins.alignways; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways; 5 3 6 4 import static org.openstreetmap.josm.tools.I18n.tr; 7 5 8 6 import java.awt.Desktop; 7 import java.awt.Dimension; 8 import java.awt.event.ActionEvent; 9 9 import java.io.IOException; 10 10 import java.net.URI; … … 13 13 import java.util.logging.Logger; 14 14 15 import javax.swing.GroupLayout; 16 import javax.swing.ImageIcon; 17 import javax.swing.JButton; 18 import javax.swing.JLabel; 15 19 import javax.swing.JOptionPane; 16 20 import javax.swing.JPanel; 21 import javax.swing.JSeparator; 17 22 18 23 /** 19 * @author tilusnet <tilusnet@gmail.com>24 * @author tilusnet <tilusnet@gmail.com> 20 25 * 21 26 */ 22 27 public class AlignWaysWhatsNewPanel extends JPanel { 23 24 28 25 29 private static final long serialVersionUID = 3691600157957492583L; … … 29 33 } 30 34 31 /*** WARNING: The following code section is generated by/for Matisse. Do not modify! ***/32 33 /** This method is called from within the constructor to34 * initialize the form.35 * WARNING: Do NOT modify this code. The content of this method is36 * always regenerated by the Form Editor.37 */38 // <editor-fold defaultstate="collapsed" desc="Generated Code">39 35 private void initComponents() { 40 36 41 lblWhatsNew = new javax.swing.JLabel();42 icnLogo = new javax.swing.JLabel();43 jSeparator1 = new javax.swing.JSeparator();44 newItem1 = new javax.swing.JLabel();45 btnHelpItem1 = new javax.swing.JButton();46 newItem2 = new javax.swing.JLabel();37 lblWhatsNew = new JLabel(); 38 icnLogo = new JLabel(); 39 jSeparator1 = new JSeparator(); 40 newItem1 = new JLabel(); 41 btnHelpItem1 = new JButton(); 42 newItem2 = new JLabel(); 47 43 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;\">" 44 lblWhatsNew.setText("<html><div style=\"font-family: sans-serif; font-weight: bold; font-style: italic;\">"+ 45 "<span style=\"font-size: large;\"><span style=\"font-size: x-large;\">" 49 46 + tr("What''s new...") 50 47 + "</span></div></html>"); 51 48 52 icnLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/wndialog/alignways64.png"))); // NOI18N49 icnLogo.setIcon(new ImageIcon(getClass().getResource("/images/wndialog/alignways64.png"))); // NOI18N 53 50 54 51 newItem1.setText("<html><div style=\"font-family: sans-serif;\"><ul style=\"margin-left: 20px;\"><li>" … … 56 53 + "</li></ul></div></html>"); 57 54 58 btnHelpItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/wndialog/extlink10.png"))); // NOI18N55 btnHelpItem1.setIcon(new ImageIcon(getClass().getResource("/images/wndialog/extlink10.png"))); // NOI18N 59 56 btnHelpItem1.setText("More Info"); 60 57 btnHelpItem1.setToolTipText("Preserving angle aligning"); … … 65 62 btnHelpItem1.setIconTextGap(6); 66 63 btnHelpItem1.setOpaque(false); 67 btnHelpItem1.setPreferredSize(new java.awt.Dimension(69, 25)); 68 btnHelpItem1.addActionListener(new java.awt.event.ActionListener() { 69 @Override 70 public void actionPerformed(java.awt.event.ActionEvent evt) { 71 btnHelpItem1ActionPerformed(evt); 72 } 73 }); 64 btnHelpItem1.setPreferredSize(new Dimension(69, 25)); 65 btnHelpItem1.addActionListener(evt -> btnHelpItem1ActionPerformed(evt)); 74 66 75 67 newItem2.setText("<html><div style=\"font-family: sans-serif;\"><ul style=\"margin-left: 20px;\"><li>" … … 77 69 + "</li></ul></div></html>"); 78 70 79 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);71 GroupLayout layout = new GroupLayout(this); 80 72 this.setLayout(layout); 81 73 layout.setHorizontalGroup( 82 layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING)74 layout.createParallelGroup(GroupLayout.Alignment.LEADING) 83 75 .addGroup(layout.createSequentialGroup() 84 76 .addContainerGap() 85 .addGroup(layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING)86 .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 349, Short.MAX_VALUE)87 .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()88 .addComponent(lblWhatsNew, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE)77 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) 78 .addComponent(jSeparator1, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 349, Short.MAX_VALUE) 79 .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 80 .addComponent(lblWhatsNew, GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE) 89 81 .addGap(18, 18, 18) 90 82 .addComponent(icnLogo)) 91 83 .addGroup(layout.createSequentialGroup() 92 .addGroup(layout.createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING, false)93 .addComponent(newItem2, javax.swing.GroupLayout.Alignment.LEADING)94 .addComponent(newItem1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE))84 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false) 85 .addComponent(newItem2, GroupLayout.Alignment.LEADING) 86 .addComponent(newItem1, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE)) 95 87 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 96 .addComponent(btnHelpItem1, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)))88 .addComponent(btnHelpItem1, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE))) 97 89 .addContainerGap()) 98 90 ); 99 91 layout.setVerticalGroup( 100 layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING)92 layout.createParallelGroup(GroupLayout.Alignment.LEADING) 101 93 .addGroup(layout.createSequentialGroup() 102 94 .addContainerGap() 103 .addGroup(layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING)95 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) 104 96 .addComponent(icnLogo) 105 .addComponent(lblWhatsNew, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE))97 .addComponent(lblWhatsNew, GroupLayout.PREFERRED_SIZE, 69, GroupLayout.PREFERRED_SIZE)) 106 98 .addGap(20, 20, 20) 107 .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)99 .addComponent(jSeparator1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) 108 100 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 109 .addGroup(layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE)110 .addComponent(newItem1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)111 .addComponent(btnHelpItem1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))101 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) 102 .addComponent(newItem1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) 103 .addComponent(btnHelpItem1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 112 104 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 113 .addComponent(newItem2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)105 .addComponent(newItem2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) 114 106 .addContainerGap(23, Short.MAX_VALUE)) 115 107 ); 116 } // </editor-fold>108 } 117 109 118 private void btnHelpItem1ActionPerformed( java.awt.event.ActionEvent evt) {110 private void btnHelpItem1ActionPerformed(ActionEvent evt) { 119 111 openURI(); 120 112 } 121 113 122 // Variables declaration - do not modify 123 private javax.swing.JButton btnHelpItem1; 124 private javax.swing.JLabel icnLogo; 125 private javax.swing.JSeparator jSeparator1; 126 private javax.swing.JLabel lblWhatsNew; 127 private javax.swing.JLabel newItem1; 128 private javax.swing.JLabel newItem2; 129 // End of variables declaration 114 private JButton btnHelpItem1; 115 private JLabel icnLogo; 116 private JSeparator jSeparator1; 117 private JLabel lblWhatsNew; 118 private JLabel newItem1; 119 private JLabel newItem2; 130 120 131 132 private void openURI() { 121 private void openURI() { 133 122 if (Desktop.isDesktopSupported()) { 134 123 try { … … 136 125 Desktop.getDesktop().browse(uri); 137 126 } catch (URISyntaxException ex) { 138 127 Logger.getLogger(AlignWaysWhatsNewPanel.class.getName()).log(Level.SEVERE, null, ex); 139 128 } catch (IOException e) { 140 129 JOptionPane.showMessageDialog(this, e, tr("Errr..."), JOptionPane.WARNING_MESSAGE); … … 144 133 } 145 134 } 146 147 /*** End of Matisse generated code section ***/148 149 135 } -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/geometry/AlignWaysGeomLine.java
r32920 r34489 1 package com.tilusnet.josm.plugins.alignways.geometry; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways.geometry; 2 3 3 4 import java.util.Objects; 4 5 5 6 /** 6 * @author tilusnet <tilusnet@gmail.com>7 * @author tilusnet <tilusnet@gmail.com> 7 8 * 8 9 */ … … 19 20 20 21 IntersectionStatus isectStat = IntersectionStatus.UNDEFINED; 21 22 23 22 24 23 /** -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/geometry/AlignWaysGeomPoint.java
r30737 r34489 1 package com.tilusnet.josm.plugins.alignways.geometry; 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.alignways.geometry; 2 3 3 4 import java.util.ArrayList; … … 40 41 if (awPts.size() <= 1) 41 42 return false; 42 43 43 44 if (awPts.size() == 2) 44 45 return true; … … 60 61 * Determines which (EastNorth) point falls between the other two. 61 62 * Ideally to be used with collinear points. 62 * 63 * @return 1, 2 or 3 for pt1, pt2 and pt3, respectively. 64 * 0 if middle value cannot be determined (i.e. some values are equal). 63 * @param pt1 point 1 64 * @param pt2 point 2 65 * @param pt3 point 3 66 * 67 * @return 1, 2 or 3 for pt1, pt2 and pt3, respectively. 68 * 0 if middle value cannot be determined (i.e. some values are equal). 65 69 */ 66 70 public static int getMiddleOf3( 67 AlignWaysGeomPoint pt1, 68 AlignWaysGeomPoint pt2, 71 AlignWaysGeomPoint pt1, 72 AlignWaysGeomPoint pt2, 69 73 AlignWaysGeomPoint pt3) { 70 74 71 75 int midPtXIdx = getMiddleOf3(pt1.x, pt2.x, pt3.x); 72 76 int midPtYIdx = getMiddleOf3(pt1.y, pt2.y, pt3.y); 73 77 74 78 if ((midPtXIdx == 0) && (midPtYIdx == 0)) 75 // All 3 points overlap: 79 // All 3 points overlap: 76 80 // Design decision: return the middle point (could be any other or none) 77 81 return 2; 78 79 if (midPtXIdx == 0) return midPtYIdx; 82 83 if (midPtXIdx == 0) return midPtYIdx; 80 84 if (midPtYIdx == 0) return midPtXIdx; 81 85 82 86 // Both x and y middle points could be determined; 83 87 // their indexes must coincide … … 88 92 // Fail 89 93 return 0; 90 94 91 95 } 92 96 93 97 /** 94 98 * Determine which value, d1, d2 or d3 falls in the middle of the other two. 95 * @return 1, 2 or 3 for d1, d2 and d3, respectively. 96 * 0 if middle value cannot be determined (i.e. some values are equal). 99 * @param d1 first value 100 * @param d2 second value 101 * @param d3 third value 102 * @return 1, 2 or 3 for d1, d2 and d3, respectively. 103 * 0 if middle value cannot be determined (i.e. some values are equal). 97 104 */ 98 105 private static int getMiddleOf3(double d1, double d2, double d3) { 99 106 100 107 Double[] dValues = {d1, d2, d3}; 101 108 ArrayList<Double> alValues = new ArrayList<>(Arrays.asList(dValues)); 102 109 Collections.sort(alValues); 103 110 104 111 if ((Math.abs(alValues.get(1) - alValues.get(0)) < 0.01) || 105 112 (Math.abs(alValues.get(1) - alValues.get(2)) < 0.01)) … … 111 118 if (Math.abs(alValues.get(1) - d3) < 0.01) return 3; 112 119 } 113 120 114 121 // Should never happen 115 122 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.