Ignore:
Timestamp:
2017-08-26T02:27:13+02:00 (7 years ago)
Author:
donvip
Message:

update to JOSM 12663

Location:
applications/editors/josm/plugins/splinex
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/splinex/build.xml

    r32680 r33534  
    55    <property name="commit.message" value="Commit message"/>
    66    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    7     <property name="plugin.main.version" value="10580"/>
     7    <property name="plugin.main.version" value="12663"/>
    88
    99    <!-- Configure these properties (replace "..." accordingly).
  • applications/editors/josm/plugins/splinex/src/org/openstreetmap/josm/plugins/Splinex/DrawSplineAction.java

    r33140 r33534  
    2929import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
    3030import org.openstreetmap.josm.data.preferences.ColorProperty;
     31import org.openstreetmap.josm.gui.MainApplication;
    3132import org.openstreetmap.josm.gui.MapFrame;
    3233import org.openstreetmap.josm.gui.MapView;
     
    4142import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    4243import org.openstreetmap.josm.gui.util.KeyPressReleaseListener;
    43 import org.openstreetmap.josm.gui.util.ModifierListener;
     44import org.openstreetmap.josm.gui.util.ModifierExListener;
    4445import org.openstreetmap.josm.plugins.Splinex.Spline.PointHandle;
    4546import org.openstreetmap.josm.plugins.Splinex.Spline.SplinePoint;
    4647import org.openstreetmap.josm.tools.ImageProvider;
     48import org.openstreetmap.josm.tools.Logging;
    4749import org.openstreetmap.josm.tools.Shortcut;
    4850
    4951@SuppressWarnings("serial")
    50 public class DrawSplineAction extends MapMode implements MapViewPaintable, KeyPressReleaseListener, ModifierListener,
     52public class DrawSplineAction extends MapMode implements MapViewPaintable, KeyPressReleaseListener, ModifierExListener,
    5153        LayerChangeListener, ActiveLayerChangeListener {
    5254    private final Cursor cursorJoinNode;
     
    6466                "spline2", // icon name
    6567                tr("Draw a spline curve"), // tooltip
    66                 mapFrame, getCursor());
     68                getCursor());
    6769
    6870        backspaceShortcut = Shortcut.registerShortcut("mapmode:backspace", tr("Backspace in Add mode"),
     
    7173        cursorJoinNode = ImageProvider.getCursor("crosshair", "joinnode");
    7274        cursorJoinWay = ImageProvider.getCursor("crosshair", "joinway");
    73         Main.getLayerManager().addLayerChangeListener(this);
    74         Main.getLayerManager().addActiveLayerChangeListener(this);
     75        MainApplication.getLayerManager().addLayerChangeListener(this);
     76        MainApplication.getLayerManager().addActiveLayerChangeListener(this);
    7577        readPreferences();
    7678    }
     
    8082            return ImageProvider.getCursor("crosshair", "spline");
    8183        } catch (Exception e) {
    82             Main.error(e);
     84            Logging.error(e);
    8385        }
    8486        return Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
     
    9193        super.enterMode();
    9294
    93         Main.registerActionShortcut(backspaceAction, backspaceShortcut);
    94 
    95         Main.map.mapView.addMouseListener(this);
    96         Main.map.mapView.addMouseMotionListener(this);
    97         Main.map.mapView.addTemporaryLayer(this);
    98 
    99         Main.map.keyDetector.addModifierListener(this);
    100         Main.map.keyDetector.addKeyListener(this);
     95        MainApplication.registerActionShortcut(backspaceAction, backspaceShortcut);
     96
     97        MapFrame map = MainApplication.getMap();
     98        map.mapView.addMouseListener(this);
     99        map.mapView.addMouseMotionListener(this);
     100        map.mapView.addTemporaryLayer(this);
     101
     102        map.keyDetector.addModifierExListener(this);
     103        map.keyDetector.addKeyListener(this);
    101104    }
    102105
     
    115118    public void exitMode() {
    116119        super.exitMode();
    117         Main.map.mapView.removeMouseListener(this);
    118         Main.map.mapView.removeMouseMotionListener(this);
    119         Main.map.mapView.removeTemporaryLayer(this);
    120         Main.unregisterActionShortcut(backspaceAction, backspaceShortcut);
    121 
    122         Main.map.statusLine.activateAnglePanel(false);
    123         Main.map.keyDetector.removeModifierListener(this);
    124         Main.map.keyDetector.removeKeyListener(this);
     120        MapFrame map = MainApplication.getMap();
     121        map.mapView.removeMouseListener(this);
     122        map.mapView.removeMouseMotionListener(this);
     123        map.mapView.removeTemporaryLayer(this);
     124        MainApplication.unregisterActionShortcut(backspaceAction, backspaceShortcut);
     125
     126        map.statusLine.activateAnglePanel(false);
     127        map.keyDetector.removeModifierExListener(this);
     128        map.keyDetector.removeKeyListener(this);
    125129        removeHighlighting();
    126         Main.map.mapView.repaint();
    127     }
    128 
    129     @Override
    130     public void modifiersChanged(int modifiers) {
    131         updateKeyModifiers(modifiers);
     130        map.mapView.repaint();
     131    }
     132
     133    @Override
     134    public void modifiersExChanged(int modifiers) {
     135        updateKeyModifiersEx(modifiers);
    132136    }
    133137
     
    150154            return;
    151155        }
    152         if (!Main.map.mapView.isActiveLayerDrawable()) return;
     156        if (!MainApplication.getMap().mapView.isActiveLayerDrawable()) return;
    153157        Spline spl = getSpline();
    154158        if (spl == null) return;
     
    157161        dragSpline = false;
    158162        mouseDownTime = System.currentTimeMillis();
    159         ph = spl.getNearestPoint(Main.map.mapView, e.getPoint());
     163        ph = spl.getNearestPoint(MainApplication.getMap().mapView, e.getPoint());
    160164        if (e.getClickCount() == 2) {
    161165            if (!spl.isClosed() && spl.nodeCount() > 1 && ph != null && ph.point == SplinePoint.ENDPOINT
    162166                    && ((ph.idx == 0 && direction == 1) || (ph.idx == spl.nodeCount() - 1 && direction == -1))) {
    163                 Main.main.undoRedo.add(spl.new CloseSplineCommand());
     167                MainApplication.undoRedo.add(spl.new CloseSplineCommand());
    164168                return;
    165169            }
    166170            spl.finishSpline();
    167             Main.map.repaint();
     171            MainApplication.getMap().repaint();
    168172            return;
    169173        }
     
    181185                        + ph.sn.cnext.north()) < EPSILON);
    182186            }
    183             if (ph.point == SplinePoint.ENDPOINT && !Main.main.undoRedo.commands.isEmpty()) {
    184                 Command cmd = Main.main.undoRedo.commands.getLast();
     187            if (ph.point == SplinePoint.ENDPOINT && !MainApplication.undoRedo.commands.isEmpty()) {
     188                Command cmd = MainApplication.undoRedo.commands.getLast();
    185189                if (cmd instanceof MoveCommand) {
    186190                    mc = (MoveCommand) cmd;
     
    192196                }
    193197            }
    194             if (ph.point != SplinePoint.ENDPOINT && !Main.main.undoRedo.commands.isEmpty()) {
    195                 Command cmd = Main.main.undoRedo.commands.getLast();
     198            if (ph.point != SplinePoint.ENDPOINT && !MainApplication.undoRedo.commands.isEmpty()) {
     199                Command cmd = MainApplication.undoRedo.commands.getLast();
    196200                if (!(cmd instanceof Spline.EditSplineCommand && ((Spline.EditSplineCommand) cmd).sn == ph.sn))
    197201                    dragControl = true;
     
    199203            return;
    200204        }
    201         if (!ctrl && spl.doesHit(e.getX(), e.getY(), Main.map.mapView)) {
     205        if (!ctrl && spl.doesHit(e.getX(), e.getY(), MainApplication.getMap().mapView)) {
    202206            dragSpline = true;
    203207            return;
     
    212216        boolean existing = false;
    213217        if (!ctrl) {
    214             n = Main.map.mapView.getNearestNode(e.getPoint(), OsmPrimitive::isUsable);
     218            n = MainApplication.getMap().mapView.getNearestNode(e.getPoint(), OsmPrimitive::isUsable);
    215219            existing = true;
    216220        }
    217221        if (n == null) {
    218             n = new Node(Main.map.mapView.getLatLon(e.getX(), e.getY()));
     222            n = new Node(MainApplication.getMap().mapView.getLatLon(e.getX(), e.getY()));
    219223            existing = false;
    220224        }
    221225        int idx = direction == -1 ? 0 : spl.nodeCount();
    222         Main.main.undoRedo.add(spl.new AddSplineNodeCommand(new Spline.SNode(n), existing, idx));
     226        MainApplication.undoRedo.add(spl.new AddSplineNodeCommand(new Spline.SNode(n), existing, idx));
    223227        ph = spl.new PointHandle(idx, direction == -1 ? SplinePoint.CONTROL_PREV : SplinePoint.CONTROL_NEXT);
    224228        lockCounterpart = true;
    225         Main.map.repaint();
     229        MainApplication.getMap().repaint();
    226230    }
    227231
     
    245249        updateKeyModifiers(e);
    246250        if (mouseDownTime == null) return;
    247         if (!Main.map.mapView.isActiveLayerDrawable()) return;
     251        if (!MainApplication.getMap().mapView.isActiveLayerDrawable()) return;
    248252        if (System.currentTimeMillis() - mouseDownTime < initialMoveDelay) return;
    249253        Spline spl = getSpline();
     
    252256        if (clickPos != null && clickPos.distanceSq(e.getPoint()) < initialMoveThreshold)
    253257            return;
    254         EastNorth en = Main.map.mapView.getEastNorth(e.getX(), e.getY());
     258        EastNorth en = MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY());
    255259        if (Main.getProjection().eastNorth2latlon(en).isOutSideWorld())
    256260            return;
    257261        if (dragSpline) {
    258262            if (mc == null) {
    259                 mc = new MoveCommand(spl.getNodes(), Main.map.mapView.getEastNorth(clickPos.x, clickPos.y), en);
    260                 Main.main.undoRedo.add(mc);
     263                mc = new MoveCommand(spl.getNodes(), MainApplication.getMap().mapView.getEastNorth(clickPos.x, clickPos.y), en);
     264                MainApplication.undoRedo.add(mc);
    261265                clickPos = null;
    262266            } else
    263267                mc.applyVectorTo(en);
    264             Main.map.repaint();
     268            MainApplication.getMap().repaint();
    265269            return;
    266270        }
     
    270274            if (mc == null) {
    271275                mc = new MoveCommand(ph.sn.node, ph.sn.node.getEastNorth(), en);
    272                 Main.main.undoRedo.add(mc);
     276                MainApplication.undoRedo.add(mc);
    273277            } else
    274278                mc.applyVectorTo(en);
    275279        } else {
    276280            if (dragControl) {
    277                 Main.main.undoRedo.add(new Spline.EditSplineCommand(ph.sn));
     281                MainApplication.undoRedo.add(new Spline.EditSplineCommand(ph.sn));
    278282                dragControl = false;
    279283            }
     
    286290            }
    287291        }
    288         Main.map.repaint();
     292        MainApplication.getMap().repaint();
    289293    }
    290294
     
    295299    public void mouseMoved(MouseEvent e) {
    296300        updateKeyModifiers(e);
    297         if (!Main.map.mapView.isActiveLayerDrawable()) return;
     301        if (!MainApplication.getMap().mapView.isActiveLayerDrawable()) return;
    298302        Spline spl = getSpline();
    299303        if (spl == null) return;
     
    301305        PointHandle oldph = ph;
    302306        boolean redraw = false;
    303         ph = spl.getNearestPoint(Main.map.mapView, e.getPoint());
     307        ph = spl.getNearestPoint(MainApplication.getMap().mapView, e.getPoint());
    304308        if (ph == null)
    305             if (!ctrl && spl.doesHit(e.getX(), e.getY(), Main.map.mapView)) {
     309            if (!ctrl && spl.doesHit(e.getX(), e.getY(), MainApplication.getMap().mapView)) {
    306310                helperEndpoint = null;
    307                 Main.map.mapView.setNewCursor(Cursor.MOVE_CURSOR, this);
     311                MainApplication.getMap().mapView.setNewCursor(Cursor.MOVE_CURSOR, this);
    308312            } else {
    309313                Node n = null;
    310314                if (!ctrl)
    311                     n = Main.map.mapView.getNearestNode(e.getPoint(), OsmPrimitive::isUsable);
     315                    n = MainApplication.getMap().mapView.getNearestNode(e.getPoint(), OsmPrimitive::isUsable);
    312316                if (n == null) {
    313317                    redraw = removeHighlighting();
    314318                    helperEndpoint = e.getPoint();
    315                     Main.map.mapView.setNewCursor(cursor, this);
     319                    MainApplication.getMap().mapView.setNewCursor(cursor, this);
    316320                } else {
    317321                    redraw = setHighlight(n);
    318                     Main.map.mapView.setNewCursor(cursorJoinNode, this);
    319                     helperEndpoint = Main.map.mapView.getPoint(n);
     322                    MainApplication.getMap().mapView.setNewCursor(cursorJoinNode, this);
     323                    helperEndpoint = MainApplication.getMap().mapView.getPoint(n);
    320324                }
    321325            }
    322326        else {
    323327            helperEndpoint = null;
    324             Main.map.mapView.setNewCursor(cursorJoinWay, this);
     328            MainApplication.getMap().mapView.setNewCursor(cursorJoinWay, this);
    325329            if (ph.point == SplinePoint.ENDPOINT)
    326330                redraw = setHighlight(ph.sn.node);
     
    333337        if (redraw || oldHelperEndpoint != helperEndpoint || (oldph == null && ph != null)
    334338                || (oldph != null && !oldph.equals(ph)))
    335             Main.map.repaint();
     339            MainApplication.getMap().repaint();
    336340    }
    337341
     
    341345    @Override
    342346    public void mouseExited(MouseEvent e) {
    343         if (!Main.map.mapView.isActiveLayerDrawable())
     347        if (!MainApplication.getMap().mapView.isActiveLayerDrawable())
    344348            return;
    345349        removeHighlighting();
    346350        helperEndpoint = null;
    347         Main.map.mapView.repaint();
     351        MainApplication.getMap().mapView.repaint();
    348352    }
    349353
     
    396400        @Override
    397401        public void actionPerformed(ActionEvent e) {
    398             Main.main.undoRedo.undo();
     402            MainApplication.undoRedo.undo();
    399403        }
    400404    }
     
    417421    @Override
    418422    public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
    419         splCached = layerSplines.get(Main.getLayerManager().getActiveLayer());
     423        splCached = layerSplines.get(MainApplication.getLayerManager().getActiveLayer());
    420424    }
    421425
     
    444448            if (spl.nodeCount() == 3 && spl.isClosed() && ph.idx == 1)
    445449                return; // Don't allow to delete node when it results with two-node closed spline
    446             Main.main.undoRedo.add(spl.new DeleteSplineNodeCommand(ph.idx));
     450            MainApplication.undoRedo.add(spl.new DeleteSplineNodeCommand(ph.idx));
    447451            e.consume();
    448452        }
    449453        if (e.getKeyCode() == KeyEvent.VK_ESCAPE && direction != 0) {
    450454            direction = 0;
    451             Main.map.mapView.repaint();
     455            MainApplication.getMap().mapView.repaint();
    452456            e.consume();
    453457        }
  • applications/editors/josm/plugins/splinex/src/org/openstreetmap/josm/plugins/Splinex/Spline.java

    r32917 r33534  
    2828import org.openstreetmap.josm.command.SequenceCommand;
    2929import org.openstreetmap.josm.data.coor.EastNorth;
     30import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
    3031import org.openstreetmap.josm.data.osm.Node;
    3132import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3233import org.openstreetmap.josm.data.osm.Way;
    3334import org.openstreetmap.josm.data.preferences.IntegerProperty;
    34 import org.openstreetmap.josm.gui.DefaultNameFormatter;
     35import org.openstreetmap.josm.gui.MainApplication;
    3536import org.openstreetmap.josm.gui.MapView;
    3637import org.openstreetmap.josm.gui.NavigatableComponent;
     
    273274        if (!cmds.isEmpty())
    274275            cmds.add(new AddCommand(w));
    275         Main.main.undoRedo.add(new FinishSplineCommand(cmds));
     276        MainApplication.undoRedo.add(new FinishSplineCommand(cmds));
    276277    }
    277278
  • applications/editors/josm/plugins/splinex/src/org/openstreetmap/josm/plugins/Splinex/SplineHitTest.java

    r33172 r33534  
    33
    44import org.openstreetmap.josm.Main;
     5import org.openstreetmap.josm.tools.Logging;
    56
    67public class SplineHitTest {
     
    2930    }
    3031    public boolean checkCurve(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, int depth) {
    31         if (Main.isDebugEnabled()) {
    32             Main.debug("checkCurve {0} {1} {2} {3} {4} {5} {6} {7}", x1, y1, x2, y2, x3, y3, x4, y4);
     32        if (Logging.isDebugEnabled()) {
     33            Logging.debug("checkCurve {0} {1} {2} {3} {4} {5} {6} {7}", x1, y1, x2, y2, x3, y3, x4, y4);
    3334        }
    3435        //chkCnt++;
  • applications/editors/josm/plugins/splinex/src/org/openstreetmap/josm/plugins/Splinex/SplinexPlugin.java

    r32547 r33534  
    22package org.openstreetmap.josm.plugins.Splinex;
    33
    4 import org.openstreetmap.josm.Main;
    54import org.openstreetmap.josm.gui.IconToggleButton;
     5import org.openstreetmap.josm.gui.MainApplication;
    66import org.openstreetmap.josm.gui.MapFrame;
    77import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     
    2626    public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
    2727        if (oldFrame == null && newFrame != null) { // map frame added
    28             Main.map.addMapMode(new IconToggleButton(new DrawSplineAction(Main.map)));
     28            MapFrame map = MainApplication.getMap();
     29            map.addMapMode(new IconToggleButton(new DrawSplineAction(map)));
    2930        }
    3031    }
  • applications/editors/josm/plugins/splinex/src/org/openstreetmap/josm/plugins/Splinex/UndeleteNodeCommand.java

    r33172 r33534  
    77
    88import org.openstreetmap.josm.command.Command;
     9import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
    910import org.openstreetmap.josm.data.osm.Node;
    1011import org.openstreetmap.josm.data.osm.OsmPrimitive;
    11 import org.openstreetmap.josm.gui.DefaultNameFormatter;
    1212
    1313class UndeleteNodeCommand extends Command {
Note: See TracChangeset for help on using the changeset viewer.