Ignore:
Timestamp:
2011-12-30T16:03:22+01:00 (13 years ago)
Author:
tilusnet
Message:
  • Added new, angle preserving aligning mode
  • Improvements and bugfixes
Location:
applications/editors/josm/plugins/alignways
Files:
30 added
2 edited
13 copied

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/alignways/.classpath

    r21613 r27348  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<classpath>
    3         <classpathentry kind="src" path="src" />
    4         <classpathentry combineaccessrules="false" exported="true"
    5                 kind="src" path="/JOSM" />
    6         <classpathentry kind="con"
    7                 path="org.eclipse.jdt.launching.JRE_CONTAINER" />
    8         <classpathentry kind="lib" path="lib" />
    9         <classpathentry kind="output" path="build" />
     3        <classpathentry kind="src" path="src"/>
     4        <classpathentry kind="src" path="test/unit"/>
     5        <classpathentry combineaccessrules="false" exported="true" kind="src" path="/JOSM"/>
     6        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
     7        <classpathentry kind="lib" path="lib"/>
     8        <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
     9        <classpathentry kind="output" path="build"/>
    1010</classpath>
  • applications/editors/josm/plugins/alignways/build.xml

    r27292 r27348  
    104104            <manifest>
    105105                <attribute name="Author" value="Attila Szász"/>
    106                 <attribute name="Plugin-Class" value="org.openstreetmap.josm.plugins.alignways.AlignWaysPlugin"/>
     106                <attribute name="Plugin-Class" value="com.tilusnet.josm.plugins.alignways.AlignWaysPlugin"/>
    107107                <attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
    108108                <attribute name="Plugin-Description" value="Makes a pair of selected way segments parallel by rotating one of them around a chosen pivot."/>
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysAction.java

    r26842 r27348  
    22 *
    33 */
    4 package org.openstreetmap.josm.plugins.alignways;
     4package com.tilusnet.josm.plugins.alignways;
    55
    66import static org.openstreetmap.josm.tools.I18n.tr;
     
    1010import java.util.Collection;
    1111
    12 import javax.swing.JOptionPane;
    13 
    1412import org.openstreetmap.josm.Main;
    1513import org.openstreetmap.josm.actions.JosmAction;
     
    1715import org.openstreetmap.josm.data.osm.Node;
    1816import org.openstreetmap.josm.tools.Shortcut;
     17
     18import com.tilusnet.josm.plugins.alignways.AlignWaysDialog.AligningModeOption;
    1919
    2020/**
     
    2424public class AlignWaysAction extends JosmAction {
    2525
    26     /**
    27      *
    28      */
    2926    private static final long serialVersionUID = -1540319652562985458L;
    3027
    3128    public AlignWaysAction() {
    32         super(tr("Align Way Segments"), "alignways",
    33                 tr("Makes a pair of selected way segments parallel by rotating one of them " +
    34                 "around a chosen pivot."),
    35                 Shortcut.registerShortcut("tools:alignways", tr("Tool: {0}",
    36                         tr("Align Ways")), KeyEvent.VK_A, Shortcut.GROUP_EDIT, KeyEvent.CTRL_DOWN_MASK|KeyEvent.ALT_DOWN_MASK), true);
     29        super(
     30                tr("Align Way Segments"),
     31                "alignways",
     32                tr("Makes a pair of selected way segments parallel by rotating one of them "
     33                        + "around a chosen pivot."), Shortcut.registerShortcut(
     34                                "tools:alignways", tr("Tool: {0}", tr("Align Ways")),
     35                                KeyEvent.VK_A, Shortcut.GROUP_EDIT,
     36                                KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK), true);
    3737        setEnabled(false);
    3838    }
    3939
     40    @Override
    4041    public void actionPerformed(ActionEvent e) {
    4142        if (!isEnabled())
     
    4445            return;
    4546
    46         Collection<Node> affectedNodes = AlignWaysSegmentMgr.getInstance(Main.map.mapView).getSelectedNodes();
     47        Collection<Node> affectableNodes = AlignWaysSegmentMgr.getInstance(
     48                Main.map.mapView).getSelectedNodes();
    4749
     50        // c is the last command launched, if any
    4851        Command c = !Main.main.undoRedo.commands.isEmpty() ? Main.main.undoRedo.commands
    49                 .getLast()
    50                 : null;
     52                .getLast() : null;
    5153
    52                 if (!(c instanceof AlignWaysRotateCommand &&
    53                         affectedNodes.equals(((AlignWaysRotateCommand) c).getRotatedNodes()))) {
    54                     c = new AlignWaysRotateCommand();
    55                     if (actionValid((AlignWaysRotateCommand)c, affectedNodes)) {
    56                         Main.main.undoRedo.add(c);
     54                // Potentially add my type of command only if last command wasn't my type
     55                // or, if it was, the rotated nodes were not the same as now
     56                if (!(c instanceof AlignWaysCmdKeepLength && affectableNodes
     57                        .equals(((AlignWaysCmdKeepLength) c).getPrevAffectedNodes()))) {
     58
     59                    AlignWaysCmdKeepLength cmdAW;
     60                    if (AlignWaysPlugin.awDialog.getAwOpt() == AligningModeOption.ALGN_OPT_KEEP_ANGLE) {
     61                        cmdAW = new AlignWaysCmdKeepAngles();
     62                    } else {
     63                        cmdAW = new AlignWaysCmdKeepLength();
     64                    }
     65
     66                    if (cmdAW.executable()) {
     67                        // This will also trigger AlignWaysCmdKeepLength.executeCommand()
     68                        Main.main.undoRedo.add(cmdAW);
    5769                    }
    5870                }
     
    6375    }
    6476
    65 
    66     /**
    67      * Validates the circumstances of the alignment (rotation) command to be executed.
    68      * @param c Command to be verified.
    69      * @param affectedNodes Nodes to be affected by the action.
    70      * @return true if the aligning action can be done, false otherwise.
    71      */
    72     private boolean actionValid(AlignWaysRotateCommand c, Collection<Node> affectedNodes) {
    73         // Deny action if reference and alignee segment cannot be aligned
    74         if (!c.areSegsAlignable()) {
    75             JOptionPane.showMessageDialog(Main.parent,
    76                     tr("Please select two segments that don''t share any nodes\n"
    77                             + " or put the pivot on their common node.\n"),
    78                             tr("AlignWayS: Alignment not possible"), JOptionPane.WARNING_MESSAGE);
    79             return false;
    80         }
    81 
    82         // Deny action if the nodes would end up outside world
    83         for (Node n : affectedNodes) {
    84             if (n.getCoor().isOutSideWorld()) {
    85                 // Revert move
    86                 (c).undoCommand();
    87                 JOptionPane.showMessageDialog(Main.parent,
    88                         tr("Aligning would result nodes outside the world.\n"),
    89                         tr("AlignWayS: Alignment not possible"), JOptionPane.WARNING_MESSAGE);
    90                 return false;
    91             }
    92 
    93         }
    94 
    95         // Action valid
    96         return true;
    97     }
    98 
    9977}
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysAlgnSegment.java

    r26842 r27348  
    1 package org.openstreetmap.josm.plugins.alignways;
     1package com.tilusnet.josm.plugins.alignways;
    22
    33import java.awt.BasicStroke;
     
    88import java.awt.geom.Ellipse2D;
    99import java.awt.geom.Line2D;
     10import java.util.ArrayList;
     11import java.util.Collection;
    1012import java.util.EnumMap;
     13import java.util.HashMap;
     14import java.util.HashSet;
    1115import java.util.Map;
    1216
     17import org.openstreetmap.josm.Main;
    1318import org.openstreetmap.josm.data.Bounds;
    1419import org.openstreetmap.josm.data.coor.EastNorth;
     20import org.openstreetmap.josm.data.osm.Node;
     21import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1522import org.openstreetmap.josm.data.osm.WaySegment;
    1623import org.openstreetmap.josm.gui.MapView;
     
    1825
    1926/**
    20  * @author tilusnet <tilusnet@gmail.com> The segment to be aligned to the
    21  *         reference segment. Actions it can do: - remember its selected pivot
    22  *         point - keeps its potential pivot point list up to date - rotate
    23  *         itself - paint itself and its selected pivot point
    24  *
     27 * @author tilusnet <tilusnet@gmail.com>
     28 *
     29 * The segment to be aligned to the reference segment. Actions it can do:
     30 *         - remember its selected pivot point
     31 *         - keeps its potential pivot point list up to date
     32 *         - rotate itself
     33 *         - paint itself and its selected pivot point
     34 *
    2535 */
    2636public class AlignWaysAlgnSegment extends AlignWaysSegment {
     
    3545    private final Color pivotColor = Color.YELLOW;
    3646    private final Color crossColor = pivotColor;
     47    private final Map<Node,ArrayList<WaySegment>> adjWaySegs = new HashMap<Node,ArrayList<WaySegment>>();
    3748
    3849    public AlignWaysAlgnSegment(MapView mapview, Point p)
    39     throws IllegalArgumentException {
     50            throws IllegalArgumentException {
    4051        super(mapview, p);
    4152        setSegment(getNearestWaySegment(p));
     
    5364    }
    5465
     66    /* (non-Javadoc)
     67     * @see com.tilusnet.josm.plugins.alignways.AlignWaysSegment#setSegmentEndpoints(org.openstreetmap.josm.data.osm.WaySegment)
     68     */
     69    @Override
     70    void setSegmentEndpoints(WaySegment segment) {
     71        super.setSegmentEndpoints(segment);
     72
     73        // Update the list of adjacent waysegments to the endpoints
     74        for (Node nA : getSegmentEndPoints()) {
     75            adjWaySegs.put(nA, new ArrayList<WaySegment>(determineAdjacentWaysegments(nA)));
     76        }
     77
     78    }
     79
    5580    /**
    5681     * Useful when segments moves (or e.g. rotates) on the map. Updates the end
     
    88113     * Returns the EastNorth of the specified pivot point pp. It always returns
    89114     * up-to-date data from dataset. Assumes segment is not null.
    90      *
     115     * 
    91116     * @param pp
    92117     *            The pivot location
     
    153178    }
    154179
     180    /**
     181     * Given a Node (usually an endpoint), it will return a collection of way segments that are adjacently
     182     * connected to it. The current alignee waysegment is not added to the collection.
     183     *
     184     * @param node The Node (endpoint) to analyse.
     185     * @return The collection of the adjacent waysegments.
     186     */
     187    private Collection<WaySegment> determineAdjacentWaysegments(Node node) {
     188        Collection<WaySegment> wsSet = new HashSet<WaySegment>();
     189        final double radius = 10.0;
     190        final int stepsOnCircle = 24;
     191        final double incrementOnCircle = 2 * Math.PI / stepsOnCircle;
     192
     193        Point p = Main.map.mapView.getPoint(node);
     194        for (int i = 0; i < stepsOnCircle; i++) {
     195            double ang = i * incrementOnCircle;
     196            double x = p.getX() + (Math.cos(ang) * radius);
     197            double y = p.getY() + (Math.sin(ang) * radius);
     198            Point pnew = new Point();
     199            pnew.setLocation(x, y);
     200            WaySegment ws = Main.map.mapView.getNearestWaySegment(pnew, OsmPrimitive.isUsablePredicate);
     201            if (ws != null &&  !ws.equals(this.segment) &&
     202                    (ws.getFirstNode().equals(node) || ws.getSecondNode().equals(node))) {
     203                // We won't want to add a:
     204                // - 'no match' (=null)
     205                // - segment that is not connected to the alignee endpoint
     206                wsSet.add(ws);
     207            }
     208        }
     209
     210        return wsSet;
     211    }
     212
     213    /**
     214     * Returns the collection of adjacent way segments to Node node.
     215     * The node is normally a valid endpoint of the segment.
     216     * If it isn't, null may be returned.
     217     *
     218     * @param node The (endpoint) node.
     219     * @return Collection of the adjacent way segments.
     220     */
     221    public ArrayList<WaySegment> getAdjacentWaySegments(Node node) {
     222        return adjWaySegs.get(node);
     223    }
     224
    155225    /*
    156226     * (non-Javadoc)
    157      *
     227     * 
    158228     * @see
    159      * org.openstreetmap.josm.plugins.alignways.AlignWaysRefSegment#paint(java
     229     * com.tilusnet.josm.plugins.alignways.AlignWaysRefSegment#paint(java
    160230     * .awt.Graphics2D, org.openstreetmap.josm.gui.MapView,
    161231     * org.openstreetmap.josm.data.Bounds)
     
    165235        // Note: segment should never be null here
    166236        super.paint(g, mv, bbox);
     237
     238        // Ensure consistency
     239        updatePivotsEndpoints();
    167240
    168241        // Highlight potential pivot points
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysMode.java

    r26842 r27348  
    22 *
    33 */
    4 package org.openstreetmap.josm.plugins.alignways;
     4package com.tilusnet.josm.plugins.alignways;
    55
    66import static org.openstreetmap.josm.tools.I18n.tr;
    77
    88import java.awt.Cursor;
     9import java.awt.Dimension;
     10import java.awt.Image;
    911import java.awt.Point;
    1012import java.awt.event.ActionEvent;
     
    1315import java.awt.event.MouseEvent;
    1416
     17import javax.swing.BorderFactory;
     18import javax.swing.ImageIcon;
     19import javax.swing.JButton;
    1520import javax.swing.JDialog;
    1621import javax.swing.JOptionPane;
     
    1823import org.openstreetmap.josm.Main;
    1924import org.openstreetmap.josm.actions.mapmode.MapMode;
     25import org.openstreetmap.josm.gui.IconToggleButton;
    2026import org.openstreetmap.josm.gui.MapFrame;
     27import org.openstreetmap.josm.gui.layer.Layer;
    2128import org.openstreetmap.josm.tools.Shortcut;
    2229
     
    5461    public void enterMode() {
    5562        super.enterMode();
     63
     64        AlignWaysPlugin.getAwDialog().activate(true);
     65        IconToggleButton optBtn = AlignWaysPlugin.getOptBtn();
     66        if (!optBtn.isSelected()) {
     67            // Make sure the option panel is visible when align mode starts
     68            optBtn.doClick();
     69        }
     70
    5671        boolean showTips = Boolean.parseBoolean(Main.pref.get("alignways.showtips", "true"));
    5772        if ((showTips) && (!tipShown)) {
    5873            showTips();
    5974        }
     75        int majorVer = Integer.parseInt(Main.pref.get("alignways.majorver", "-1"));
     76        if (majorVer != AlignWaysPlugin.AlignWaysMajorVersion) {
     77            showWhatsNew();
     78        }
     79
    6080        awSegs = AlignWaysSegmentMgr.getInstance(Main.map.mapView);
    6181        Main.map.mapView.addMouseListener(this);
     
    6383    }
    6484
     85
    6586    @Override
    6687    public void exitMode() {
    6788        super.exitMode();
     89
     90        AlignWaysPlugin.getAwDialog().activate(false);
     91        IconToggleButton optBtn = AlignWaysPlugin.getOptBtn();
     92        if (optBtn.isSelected()) {
     93            // The option panel is switched off
     94            optBtn.doClick();
     95        }
     96
    6897        setCurrentState(noneSelected);
    6998        Main.map.mapView.removeMouseListener(this);
     
    120149        if (currentState == noneSelected) {
    121150            awSegs.cleanupWays();
    122             // FIX: getCurrentDataSet may return null when the editable layer had
     151            // TODO getCurrentDataSet may return null when the editable layer had
    123152            // already been removed by JOSM. This happens e.g. when the user closes
    124153            // JOSM while AlignWays mode is still active.
     
    166195    private void showTips() {
    167196
    168         AlignWaysTipsPanel atd = new AlignWaysTipsPanel();
     197        AlignWaysTipsPanel atp = new AlignWaysTipsPanel();
    169198        Object[] okButton = {tr("I''m ready!")};
    170         JOptionPane tipPane = new JOptionPane(atd, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, okButton, okButton[0]);
    171         // JDialog tipDialog = tipPane.createDialog(null, tr("AlignWays Tips"));
    172         // Take Main.map as frame as it's better to inherit its icon than the default Java cup
     199        JOptionPane tipPane = new JOptionPane(atp, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION,
     200                                                                                      null, okButton, okButton[0]);
     201        tipPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 30, 10));
    173202        JDialog tipDialog = tipPane.createDialog(Main.parent, tr("AlignWays Tips"));
    174         // ((Frame)tipDialog.getOwner()).setIconImage(new ImageIcon(getClass().getResource("/images/blank.png")).getImage());
     203        tipDialog.setIconImage(new ImageIcon(getClass().getResource("/images/alignways.png")).getImage());
    175204
    176205        tipDialog.setResizable(true);
     
    180209        tipDialog.dispose();
    181210
    182         Main.pref.put("alignways.showtips", !atd.isChkBoxSelected());
    183 
     211        Main.pref.put("alignways.showtips", !atp.isChkBoxSelected());
     212
     213    }
     214
     215
     216    private void showWhatsNew() {
     217
     218        AlignWaysWhatsNewPanel awnp = new AlignWaysWhatsNewPanel();
     219        JOptionPane wnPane = new JOptionPane(awnp, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null);
     220        wnPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
     221        JDialog wnDialog = wnPane.createDialog(Main.parent, tr("AlignWays: What''s New..."));
     222        wnDialog.setIconImage(new ImageIcon(getClass().getResource("/images/alignways.png")).getImage());
     223
     224        wnDialog.setResizable(true);
     225        wnDialog.setVisible(true);
     226
     227        wnDialog.dispose();
     228
     229        Main.pref.put("alignways.majorver", new Integer(AlignWaysPlugin.AlignWaysMajorVersion).toString());
     230
     231    }
     232
     233    /* (non-Javadoc)
     234     * @see org.openstreetmap.josm.actions.mapmode.MapMode#layerIsSupported(org.openstreetmap.josm.gui.layer.Layer)
     235     */
     236    @Override
     237    public boolean layerIsSupported(Layer l) {
     238        if (l == null)
     239            return false;
     240        else
     241            return true;
    184242    }
    185243}
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysPlugin.java

    r26842 r27348  
    1 package org.openstreetmap.josm.plugins.alignways;
     1package com.tilusnet.josm.plugins.alignways;
    22
    33import static org.openstreetmap.josm.tools.I18n.tr;
     
    2424    static JMenuItem alignWaysMenuItem;
    2525    static JosmAction awAction;
     26    static AlignWaysDialog awDialog;
     27    static IconToggleButton optBtn;
    2628
    27     /**
    28      *
    29      */
     29    // The major version is e.g. used to decide when to trigger What's New windows
     30    public static final int AlignWaysMajorVersion = 2;
     31
    3032    public AlignWaysPlugin(PluginInformation info) {
    3133        super(info);
     
    3638        awAction = new AlignWaysAction();
    3739        alignWaysMenuItem = MainMenu.add(Main.main.menu.toolsMenu, awAction);
    38         Main.main.menu.toolsMenu.addSeparator();
    39 
     40        awDialog = new AlignWaysDialog(awMode);
    4041    }
    4142
    4243    @Override
    4344    public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
     45        if(newFrame != null) {
     46            optBtn = newFrame.addToggleDialog(AlignWaysPlugin.getAwDialog());
     47        }
    4448        if (Main.map != null) {
    4549            Main.map.addMapMode(btn);
     
    6165    }
    6266
     67    /**
     68     * @return the awDialog
     69     */
     70    public static AlignWaysDialog getAwDialog() {
     71        return awDialog;
     72    }
     73
     74    /**
     75     * @return the optBtn
     76     */
     77    public static IconToggleButton getOptBtn() {
     78        return optBtn;
     79    }
     80
    6381}
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysRefSegment.java

    r26842 r27348  
    22 *
    33 */
    4 package org.openstreetmap.josm.plugins.alignways;
     4package com.tilusnet.josm.plugins.alignways;
    55
    66import java.awt.Color;
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysSegment.java

    r26842 r27348  
    22 *
    33 */
    4 package org.openstreetmap.josm.plugins.alignways;
     4package com.tilusnet.josm.plugins.alignways;
    55
    66import static org.openstreetmap.josm.tools.I18n.tr;
     
    2727public class AlignWaysSegment implements MapViewPaintable {
    2828
    29     protected WaySegment segment;
    30     protected MapView mapview;
    31     protected Color segmentColor = Color.WHITE;
    32     protected Collection<Node> segmentEndPoints;
     29        protected WaySegment segment;
     30        protected MapView mapview;
     31        protected Color segmentColor = Color.WHITE;
     32        protected Collection<Node> segmentEndPoints;
    3333
    34     public AlignWaysSegment(MapView mapview, Point p)
    35     throws IllegalArgumentException {
    36         if (mapview == null)
    37             throw new IllegalArgumentException(tr(
    38                     "Parameter ''{0}'' must not be null", "mapview"));
    39         if (p == null)
    40             throw new IllegalArgumentException(tr(
    41                     "Parameter ''{0}'' must not be null", "p"));
     34        public AlignWaysSegment(MapView mapview, Point p) throws IllegalArgumentException {
     35                if (mapview == null)
     36                        throw new IllegalArgumentException(tr(
     37                                        "Parameter ''{0}'' must not be null", "mapview"));
     38                if (p == null)
     39                        throw new IllegalArgumentException(tr(
     40                                        "Parameter ''{0}'' must not be null", "p"));
    4241
    43         this.mapview = mapview;
    44     }
     42                this.mapview = mapview;
     43        }
    4544
    46     void setSegment(WaySegment segment) {
    47         this.segment = segment;
    48         if (segment != null) {
    49             setSegmentEndpoints(segment);
    50             mapview.addTemporaryLayer(this);
    51         }
    52     }
     45        void setSegment(WaySegment segment) {
     46                this.segment = segment;
     47                if (segment != null) {
     48                        setSegmentEndpoints(segment);
     49                        mapview.addTemporaryLayer(this);
     50                }
     51        }
    5352
    5453
    55     void setSegmentEndpoints(WaySegment segment) {
    56         if (segment != null) {
    57             Node node1 = segment.way.getNode(segment.lowerIndex);
    58             Node node2 = segment.way.getNode(segment.lowerIndex + 1);
     54        void setSegmentEndpoints(WaySegment segment) {
     55                if (segment != null) {
     56                        Node node1 = segment.way.getNode(segment.lowerIndex);
     57                        Node node2 = segment.way.getNode(segment.lowerIndex + 1);
    5958
    60             segmentEndPoints = new HashSet<Node>();
    61             segmentEndPoints.add(node1);
    62             segmentEndPoints.add(node2);
     59                        segmentEndPoints = new HashSet<Node>();
     60                        segmentEndPoints.add(node1);
     61                        segmentEndPoints.add(node2);
    6362
    64         }
    65     }
     63                }
     64        }
    6665
    67     protected WaySegment getNearestWaySegment(Point p) {
     66        protected WaySegment getNearestWaySegment(Point p) {
    6867
    69         return mapview.getNearestWaySegment(p, OsmPrimitive.isUsablePredicate);
     68                return mapview.getNearestWaySegment(p, OsmPrimitive.isUsablePredicate);
    7069
    71     }
     70        }
    7271
    73     public void destroy() {
    74         if (segment != null) {
    75             mapview.removeTemporaryLayer(this);
    76         }
    77     }
     72        public void destroy() {
     73                if (segment != null) {
     74                        mapview.removeTemporaryLayer(this);
     75                }
     76        }
    7877
    79     public WaySegment getSegment() {
    80         return segment;
    81     }
     78        public WaySegment getSegment() {
     79                return segment;
     80        }
    8281
    83     public Collection<Node> getSegmentEndPoints() {
    84         return segmentEndPoints;
    85     }
     82        public Collection<Node> getSegmentEndPoints() {
     83                return segmentEndPoints;
     84        }
    8685
    87     public void paint(Graphics2D g, MapView mv, Bounds bbox) {
    88         highlightSegment(segmentColor, g, mv);
    89     }
     86        @Override
     87        public void paint(Graphics2D g, MapView mv, Bounds bbox) {
     88                highlightSegment(segmentColor, g, mv);
     89        }
    9090
    91     protected void highlightSegment(Color c, Graphics2D g, MapView mv) {
     91        protected void highlightSegment(Color c, Graphics2D g, MapView mv) {
    9292
    93         g.setColor(c);
    94         g.setStroke(new BasicStroke(6, BasicStroke.CAP_ROUND,
    95                 BasicStroke.JOIN_ROUND));
    96         drawSegment(g, mv);
     93                g.setColor(c);
     94                g.setStroke(new BasicStroke(6, BasicStroke.CAP_ROUND,
     95                                BasicStroke.JOIN_ROUND));
     96                drawSegment(g, mv);
    9797
    98     }
     98        }
    9999
    100     protected void drawSegment(Graphics2D g, MapView mv) {
    101         Node n1 = segment.way.getNode(segment.lowerIndex);
    102         Node n2 = segment.way.getNode(segment.lowerIndex + 1);
     100        protected void drawSegment(Graphics2D g, MapView mv) {
     101                Node n1 = segment.way.getNode(segment.lowerIndex);
     102                Node n2 = segment.way.getNode(segment.lowerIndex + 1);
    103103
    104         Line2D newline = new Line2D.Double(mv.getPoint(n1), mv.getPoint(n2));
    105         g.draw(newline);
    106     }
     104                Line2D newline = new Line2D.Double(mv.getPoint(n1), mv.getPoint(n2));
     105                g.draw(newline);
     106        }
    107107
    108     /*
    109     * (non-Javadoc)
    110     *
    111     * @see java.lang.Object#hashCode()
    112     */
    113     @Override
    114     public int hashCode() {
    115         final int prime = 31;
    116         int result = 1;
    117         result = prime * result + ((segment == null) ? 0 : segment.hashCode());
    118         result = prime * result
    119         + ((segmentColor == null) ? 0 : segmentColor.hashCode());
    120         return result;
    121     }
     108        /*
     109        * (non-Javadoc)
     110        *
     111        * @see java.lang.Object#hashCode()
     112        */
     113        @Override
     114        public int hashCode() {
     115                final int prime = 31;
     116                int result = 1;
     117                result = prime * result + ((segment == null) ? 0 : segment.hashCode());
     118                result = prime * result
     119                                + ((segmentColor == null) ? 0 : segmentColor.hashCode());
     120                return result;
     121        }
    122122
    123     /*
    124      * (non-Javadoc)
    125      *
    126      * @see java.lang.Object#equals(java.lang.Object)
    127      */
    128     @Override
    129     public boolean equals(Object obj) {
    130         if (this == obj)
    131             return true;
    132         if (obj == null)
    133             return false;
    134         if (!(obj instanceof AlignWaysSegment))
    135             return false;
    136         AlignWaysSegment other = (AlignWaysSegment) obj;
    137         if (segment == null) {
    138             if (other.segment != null)
    139                 return false;
    140         } else if (!segment.equals(other.segment))
    141             return false;
    142         /* Segment colour is ignored in comparison
     123        /*
     124          * (non-Javadoc)
     125          *
     126          * @see java.lang.Object#equals(java.lang.Object)
     127          */
     128        @Override
     129        public boolean equals(Object obj) {
     130                if (this == obj)
     131                        return true;
     132                if (obj == null)
     133                        return false;
     134                if (!(obj instanceof AlignWaysSegment))
     135                        return false;
     136                AlignWaysSegment other = (AlignWaysSegment) obj;
     137                if (segment == null) {
     138                        if (other.segment != null)
     139                                return false;
     140                } else if (!segment.equals(other.segment))
     141                        return false;
     142                /* Segment colour is ignored in comparison
    143143        if (segmentColor == null) {
    144144            if (other.segmentColor != null)
     
    146146        } else if (!segmentColor.equals(other.segmentColor))
    147147            return false;
    148          */
    149         return true;
    150     }
     148                  */
     149                return true;
     150        }
    151151}
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysSegmentMgr.java

    r26842 r27348  
    1 package org.openstreetmap.josm.plugins.alignways;
     1package com.tilusnet.josm.plugins.alignways;
    22
    33import static org.openstreetmap.josm.tools.I18n.tr;
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysSelAlgnState.java

    r26842 r27348  
    22 *
    33 */
    4 package org.openstreetmap.josm.plugins.alignways;
     4package com.tilusnet.josm.plugins.alignways;
    55
    66import org.openstreetmap.josm.Main;
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysSelBothState.java

    r26842 r27348  
    22 *
    33 */
    4 package org.openstreetmap.josm.plugins.alignways;
     4package com.tilusnet.josm.plugins.alignways;
    55
    66import org.openstreetmap.josm.Main;
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysSelNoneState.java

    r26842 r27348  
    22 *
    33 */
    4 package org.openstreetmap.josm.plugins.alignways;
     4package com.tilusnet.josm.plugins.alignways;
    55
    66import org.openstreetmap.josm.Main;
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysSelRefState.java

    r26842 r27348  
    22 *
    33 */
    4 package org.openstreetmap.josm.plugins.alignways;
     4package com.tilusnet.josm.plugins.alignways;
    55
    66import org.openstreetmap.josm.Main;
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysState.java

    r26842 r27348  
    22 *
    33 */
    4 package org.openstreetmap.josm.plugins.alignways;
     4package com.tilusnet.josm.plugins.alignways;
    55
    66import org.openstreetmap.josm.Main;
  • applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysTipsPanel.java

    r26842 r27348  
    22 *
    33 */
    4 package org.openstreetmap.josm.plugins.alignways;
     4package com.tilusnet.josm.plugins.alignways;
    55
    66import static org.openstreetmap.josm.tools.I18n.tr;
     
    2525 *
    2626 */
    27 public class AlignWaysTipsPanel extends javax.swing.JPanel {
     27public class AlignWaysTipsPanel extends JPanel {
    2828
    2929    private static final long serialVersionUID = -8583989497599985140L;
     
    5353
    5454        WelcomeTo.setText("<html>\n<div style=\"font-family: \"sans-serif\"; font-weight: bold; font-style: italic;\">\n<span style=\"font-size: large;\">"
    55         + tr("Welcome to the</span><br>\n<span style=\"font-size: xx-large;\">AlignWay<span style=\"color: rgb(204, 85, 0);\">S</span> Plugin<br>\n</span>"
    56         + "<span style=\"font-size: medium;\"><br>\n...or it rather should be called <br>\n<span style=\"font-size: large;\">AlignWayS(egments)</span> Plugin...")
    57         + "</span>\n</div>\n</html>");
     55                + tr("Welcome to the</span><br>\n<span style=\"font-size: xx-large;\">AlignWay<span style=\"color: rgb(204, 85, 0);\">S</span> Plugin<br>\n</span>"
     56                        + "<span style=\"font-size: medium;\"><br>\n...or it rather should be called <br>\n<span style=\"font-size: large;\">AlignWayS(egments)</span> Plugin...")
     57                        + "</span>\n</div>\n</html>");
    5858
    5959        WelcomeTo.setVerticalAlignment(SwingConstants.TOP);
     
    6969                        .addPreferredGap(LayoutStyle.RELATED)
    7070                        .add(Icon, GroupLayout.PREFERRED_SIZE, 132, GroupLayout.PREFERRED_SIZE))
    71         );
     71                );
    7272        TitleLayout.setVerticalGroup(
    7373                TitleLayout.createParallelGroup(GroupLayout.LEADING)
     
    7676                        .addContainerGap())
    7777                        .add(WelcomeTo, GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
    78         );
     78                );
    7979
    8080        Intro.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
     
    120120                                .add(GroupLayout.LEADING, step01, GroupLayout.DEFAULT_SIZE, 496, Short.MAX_VALUE))
    121121                                .add(18, 18, 18))
    122         );
     122                );
    123123        stepsLayout.setVerticalGroup(
    124124                stepsLayout.createParallelGroup(GroupLayout.LEADING)
     
    134134                        .add(lastHint, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    135135                        .addContainerGap(22, Short.MAX_VALUE))
    136         );
     136                );
    137137
    138138        scrollableSteps.setViewportView(steps);
     
    150150                        .add(scrollableSteps, GroupLayout.DEFAULT_SIZE, 534, Short.MAX_VALUE)
    151151                        .add(introText, GroupLayout.DEFAULT_SIZE, 534, Short.MAX_VALUE)
    152         );
     152                );
    153153        IntroLayout.setVerticalGroup(
    154154                IntroLayout.createParallelGroup(GroupLayout.LEADING)
     
    160160                        .add(dontShow)
    161161                        .addContainerGap())
    162         );
     162                );
    163163
    164164        GroupLayout layout = new GroupLayout(this);
     
    173173                                .add(Intro, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    174174                                .addContainerGap())
    175         );
     175                );
    176176        layout.setVerticalGroup(
    177177                layout.createParallelGroup(GroupLayout.LEADING)
     
    184184                        .add(Intro, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
    185185                        .addContainerGap(45, Short.MAX_VALUE))
    186         );
     186                );
    187187    }
    188188
Note: See TracChangeset for help on using the changeset viewer.