Changeset 32789 in osm for applications/editors


Ignore:
Timestamp:
2016-08-09T01:53:49+02:00 (8 years ago)
Author:
donvip
Message:

checkstyle

Location:
applications/editors/josm/plugins/infomode
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/infomode/.project

    r32286 r32789  
    1616                        </arguments>
    1717                </buildCommand>
     18                <buildCommand>
     19                        <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
     20                        <arguments>
     21                        </arguments>
     22                </buildCommand>
    1823        </buildSpec>
    1924        <natures>
    2025                <nature>org.eclipse.jdt.core.javanature</nature>
     26                <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
    2127        </natures>
    2228</projectDescription>
  • applications/editors/josm/plugins/infomode/src/org/openstreetmap/josm/plugins/infomode/InfoMode.java

    r32491 r32789  
    1 /*
    2  * This file is part of InfoMode plugin for JOSM.
    3  * http://wiki.openstreetmap.org/wiki/JOSM/Plugins/InfoMode
    4  *
    5  * Licence: GPL v2 or later
    6  * Author:  Alexei Kasatkin, 2011
    7  * Thanks to authors of BuildingTools, ImproveWayAccuracy
    8  * for good sample code
    9  */
     1// License: GPL. For details, see LICENSE file.
    102package org.openstreetmap.josm.plugins.infomode;
    113
     
    6052    InfoMode(MapFrame mapFrame) {
    6153        super(tr("InfoMode"), "infomode.png", tr("GPX info mode"),
    62                 Shortcut.registerShortcut("mapmode:infomode", tr("Mode: {0}", tr("GPX info mode")), KeyEvent.VK_BACK_SLASH, Shortcut.DIRECT), mapFrame, Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    63         infoPanel=new InfoPanel();
    64 
     54                Shortcut.registerShortcut("mapmode:infomode", tr("Mode: {0}", tr("GPX info mode")), KeyEvent.VK_BACK_SLASH, Shortcut.DIRECT),
     55                mapFrame, Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
     56        infoPanel = new InfoPanel();
    6557    }
    6658
     
    9082                    AWTEvent.KEY_EVENT_MASK);
    9183        } catch (SecurityException ex) {
     84            Main.error(ex);
    9285        }
    9386    }
     
    10093
    10194        Main.map.mapView.removeTemporaryLayer(this);
    102         if (oldPopup!=null) oldPopup.hide();
     95        if (oldPopup != null) oldPopup.hide();
    10396
    10497        try {
    10598            Toolkit.getDefaultToolkit().removeAWTEventListener(this);
    10699        } catch (SecurityException ex) {
     100            Main.error(ex);
    107101        }
    108102
     
    115109    }
    116110
    117 
    118 
    119111    //////////    Event listener methods
    120112
     
    122114    public void paint(Graphics2D g, MapView mv, Bounds bbox) {
    123115        if (pos == null) return;
    124         Layer curL= mv.getLayerManager().getActiveLayer();
     116        Layer curL = mv.getLayerManager().getActiveLayer();
    125117        if (curL instanceof GpxLayer) showLayerInfo(g, curL, mv); else {
    126118            for (Layer l : mv.getLayerManager().getLayers()) {
     
    155147        if (!isEnabled()) return;
    156148        if (e.getButton() != MouseEvent.BUTTON1) return;
    157         if (oldPopup!=null) {
     149        if (oldPopup != null) {
    158150            oldPopup.hide();
    159             oldPopup=null;        wpOld=null;
     151            oldPopup = null;
     152            wpOld = null;
    160153        }
    161154        repaint();
     
    164157    @Override
    165158    public void mouseDragged(MouseEvent e) {
    166         if (oldPopup!=null) {
     159        if (oldPopup != null) {
    167160            oldPopup.hide();
    168             oldPopup=null;        wpOld=null;
     161            oldPopup = null;
     162            wpOld = null;
    169163        }
    170164    }
     
    209203// </editor-fold>
    210204
    211 
    212 
    213205    private void repaint() {
    214         if (Main.map!=null) Main.map.mapView.repaint();
     206        if (Main.map != null) Main.map.mapView.repaint();
    215207    }
    216208    /*private void setStatusLine(String tr) {
     
    222214        Layer l = getLayerManager().getActiveLayer();
    223215
    224         if (l instanceof GpxLayer && pos!=null) {
    225             GpxLayer gpxL = (GpxLayer )l;
     216        if (l instanceof GpxLayer && pos != null) {
     217            GpxLayer gpxL = (GpxLayer) l;
    226218            Set<GpxTrack> toRemove = new HashSet<>();
    227219            for (GpxTrack track : gpxL.data.tracks) {
    228                 boolean f=true;
     220                boolean f = true;
    229221                sg: for (GpxTrackSegment seg : track.getSegments()) {
    230222                    for (WayPoint S : seg.getWayPoints()) {
    231                         if (S.time!=0) {f=false; break sg;}
     223                        if (S.time != 0) {
     224                            f = false;
     225                            break sg;
     226                        }
    232227                    }
    233228                }
     
    239234
    240235    private boolean showLayerInfo(Graphics2D g, Layer l, MapView mv) {
    241             GpxLayer gpxL = (GpxLayer )l;
    242 
    243             double minDist=1e9,d;
    244             WayPoint wp=null,oldWp=null,prevWp=null;
    245             GpxTrack trk=null;
     236            GpxLayer gpxL = (GpxLayer) l;
     237
     238            double minDist = 1e9, d;
     239            WayPoint wp = null, oldWp = null, prevWp = null;
     240            GpxTrack trk = null;
    246241            double maxD = mv.getDist100Pixel()/3;
    247242            for (GpxTrack track : gpxL.data.tracks) {
    248243                for (GpxTrackSegment seg : track.getSegments()) {
    249                     oldWp=null;// next segment will have new previous point
     244                    oldWp = null; // next segment will have new previous point
    250245                    for (WayPoint S : seg.getWayPoints()) {
    251246                        d = S.getEastNorth().distance(pos);
    252247
    253                         if (d<minDist && d<maxD) {
     248                        if (d < minDist && d < maxD) {
    254249                            minDist = d;
    255                             prevWp=oldWp;
    256                             wp=S;
    257                             trk=track;
     250                            prevWp = oldWp;
     251                            wp = S;
     252                            trk = track;
    258253                            }
    259                         oldWp=S;
     254                        oldWp = S;
    260255                    }
    261256                }
    262257            }
    263             if (wp!=null) {
     258            if (wp != null) {
    264259                Point p = mv.getPoint(wp.getCoor());
    265260
     
    267262                g.fillOval(p.x-10, p.y-10, 20, 20); // mark selected point
    268263                if (shift) { // highlight track
    269                     g.setColor(new Color(255,30,0,128));
     264                    g.setColor(new Color(255, 30, 0, 128));
    270265                    Stroke oldStroke = g.getStroke();
    271                     g.setStroke( new BasicStroke(10) );
     266                    g.setStroke(new BasicStroke(10));
    272267                    for (GpxTrackSegment seg : trk.getSegments()) {
    273                     Point oldP=null,curP=null;// next segment will have new previous point
     268                    Point oldP = null, curP = null; // next segment will have new previous point
    274269                        for (WayPoint S : seg.getWayPoints()) {
    275270                            curP = mv.getPoint(S.getEastNorth());
    276                             if (oldP!=null) g.drawLine(oldP.x, oldP.y, curP.x, curP.y);
     271                            if (oldP != null) g.drawLine(oldP.x, oldP.y, curP.x, curP.y);
    277272                            oldP = curP;
    278273                        }
     
    280275                    g.setStroke(oldStroke);
    281276                }
    282                 Point s=mv.getLocationOnScreen();
     277                Point s = mv.getLocationOnScreen();
    283278                int pcx = s.x+p.x-40;
    284279                int pcy = s.y+p.y+30;
    285                 if (shift) {pcx+=40; pcy-=30;}
    286 
    287                 if (wp!=wpOld) {
    288                     if (oldPopup!=null) oldPopup.hide();
    289                     double vel=-1;
    290                     if (prevWp!=null && wp.time!=prevWp.time) {
    291                         vel=wp.getCoor().greatCircleDistance(prevWp.getCoor())/
     280                if (shift) {
     281                    pcx += 40;
     282                    pcy -= 30;
     283                }
     284                if (wp != wpOld) {
     285                    if (oldPopup != null) oldPopup.hide();
     286                    double vel = -1;
     287                    if (prevWp != null && wp.time != prevWp.time) {
     288                        vel = wp.getCoor().greatCircleDistance(prevWp.getCoor())/
    292289                                (wp.time-prevWp.time)*3.6;
    293290                    }
    294                     infoPanel.setData(wp,trk,vel,gpxL.data.tracks);
    295                     Popup pp=PopupFactory.getSharedInstance().getPopup(mv, infoPanel,
    296                             pcx, pcy);
     291                    infoPanel.setData(wp, trk, vel, gpxL.data.tracks);
     292                    Popup pp = PopupFactory.getSharedInstance().getPopup(mv, infoPanel, pcx, pcy);
    297293                    pp.show();
    298                     wpOld=wp;
    299                     oldPopup=pp;
     294                    wpOld = wp;
     295                    oldPopup = pp;
    300296                }
    301297                return true;
  • applications/editors/josm/plugins/infomode/src/org/openstreetmap/josm/plugins/infomode/InfoModePlugin.java

    r26503 r32789  
    1 /*
    2  * This file is part of InfoMode plugin for JOSM.
    3  * http://wiki.openstreetmap.org/wiki/JOSM/Plugins/InfoMode
    4  *
    5  * Licence: GPL v2 or later
    6  * Author:  Alexei Kasatkin, 2011
    7  * Ideas by siberiano, Ilis, chnav, Polarbear-j,
    8  */
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.plugins.infomode;
    93
    10 package org.openstreetmap.josm.plugins.infomode;
    114import org.openstreetmap.josm.Main;
    125import org.openstreetmap.josm.gui.IconToggleButton;
     
    147import org.openstreetmap.josm.plugins.Plugin;
    158import org.openstreetmap.josm.plugins.PluginInformation;
     9
    1610public class InfoModePlugin extends Plugin {
    1711
     
    2418        if (oldFrame == null && newFrame != null) {
    2519            Main.map.addMapMode(new IconToggleButton(new InfoMode(Main.map)));
    26         }       
     20        }
    2721    }
    2822}
  • applications/editors/josm/plugins/infomode/src/org/openstreetmap/josm/plugins/infomode/InfoPanel.java

    r30737 r32789  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.infomode;
    23
     
    3233    private DateFormat df;
    3334
    34     private JLabel label1=new JLabel();
    35     private JLabel label2=new JLabel();
    36     private JLabel label3=new JLabel();
    37     private JLabel label4=new JLabel();
    38     private JLabel label5=new JLabel();
    39     private JLabel label6=new JLabel();
     35    private JLabel label1 = new JLabel();
     36    private JLabel label2 = new JLabel();
     37    private JLabel label3 = new JLabel();
     38    private JLabel label4 = new JLabel();
     39    private JLabel label5 = new JLabel();
     40    private JLabel label6 = new JLabel();
    4041    private JButton but1 = new JButton(tr("Delete this"));
    4142    private JButton but2 = new JButton(tr("Delete this&older"));
    4243
    43     public InfoPanel() {
     44    InfoPanel() {
    4445        super(new GridBagLayout());
    45         df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT,DateFormat.DEFAULT, Locale.getDefault());
    46         setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    47         add(label1, GBC.eol().insets(10,0,0,0));
    48         add(label2, GBC.eol().insets(10,0,0,0));
    49         add(label3, GBC.eol().insets(10,0,0,0));
    50         add(label4, GBC.eol().insets(10,0,0,0));
    51         add(label5, GBC.eol().insets(10,0,0,0));
    52         add(label6, GBC.eol().insets(10,0,0,0));
    53         add(but1, GBC.std().insets(10,5,0,0));
    54         add(but2, GBC.eop().insets(10,5,0,0));
     46        df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.getDefault());
     47        setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
     48        add(label1, GBC.eol().insets(10, 0, 0, 0));
     49        add(label2, GBC.eol().insets(10, 0, 0, 0));
     50        add(label3, GBC.eol().insets(10, 0, 0, 0));
     51        add(label4, GBC.eol().insets(10, 0, 0, 0));
     52        add(label5, GBC.eol().insets(10, 0, 0, 0));
     53        add(label6, GBC.eol().insets(10, 0, 0, 0));
     54        add(but1, GBC.std().insets(10, 5, 0, 0));
     55        add(but2, GBC.eop().insets(10, 5, 0, 0));
    5556        // lightweight hyperlink
    5657        label6.addMouseListener(new MouseListener() {
     
    5859            public void mouseClicked(MouseEvent e) {
    5960                String s = label6.getText();
    60                 OpenBrowser.displayUrl( s.substring(9, s.length()-11) );
     61                OpenBrowser.displayUrl(s.substring(9, s.length()-11));
    6162            }
     63
    6264            @Override
    63                         public void mousePressed(MouseEvent e) { }
     65            public void mousePressed(MouseEvent e) { }
     66
    6467            @Override
    65                         public void mouseReleased(MouseEvent e) { }
     68            public void mouseReleased(MouseEvent e) { }
     69
    6670            @Override
    67                         public void mouseEntered(MouseEvent e) { }
     71            public void mouseEntered(MouseEvent e) { }
     72
    6873            @Override
    69                         public void mouseExited(MouseEvent e) { }
     74            public void mouseExited(MouseEvent e) { }
    7075        });
    7176        but1.addActionListener(new ActionListener() {
    7277            @Override
    7378            public void actionPerformed(ActionEvent e) {
    74                 if (tracks!=null) tracks.remove(trk);
     79                if (tracks != null) tracks.remove(trk);
    7580                Main.map.mapView.repaint();
    7681            }
     
    7984            @Override
    8085            public void actionPerformed(ActionEvent e) {
    81             if (tracks==null) return;
     86            if (tracks == null) return;
    8287            Set<GpxTrack> toRemove = new HashSet<>();
    8388
    84             double tm=-1;
     89            double tm = -1;
    8590            for (GpxTrackSegment seg : trk.getSegments()) {
    8691                    for (WayPoint S : seg.getWayPoints()) {
    87                         if (S.time>tm) {tm=S.time;}
     92                        if (S.time > tm) {
     93                            tm = S.time;
     94                        }
    8895                    }
    8996                }
    9097
    9198            for (GpxTrack track : tracks) {
    92                 boolean f=true;
     99                boolean f = true;
    93100                sg: for (GpxTrackSegment seg : track.getSegments()) {
    94101                    for (WayPoint S : seg.getWayPoints()) {
    95                         if (S.time>tm) {f=false; break sg;}
     102                        if (S.time > tm) {
     103                            f = false;
     104                            break sg;
     105                        }
    96106                    }
    97107                }
     
    107117
    108118    void setData(WayPoint wp, GpxTrack trk, double vel, Collection<GpxTrack> tracks) {
    109         this.tracks=tracks;
    110         this.trk=trk;
    111         if (wp.time==0.0) { label1.setText(tr("No timestamp"));
     119        this.tracks = tracks;
     120        this.trk = trk;
     121        if (wp.time == 0.0) {
     122            label1.setText(tr("No timestamp"));
    112123            but2.setVisible(false);
    113124        } else {
     
    115126            but2.setVisible(true);
    116127        }
    117         if (vel>0) label2.setText(String.format("%.1f "+tr("km/h"), vel));
    118               else label2.setText(null);
     128        if (vel > 0) label2.setText(String.format("%.1f "+tr("km/h"), vel));
     129        else label2.setText(null);
    119130        String s = (String) trk.getAttributes().get("name");
    120         if (s!=null) label3.setText(tr("Track name: ")+s);
    121                 else label3.setText(null);
     131        if (s != null)
     132            label3.setText(tr("Track name: ")+s);
     133        else label3.setText(null);
    122134        s = (String) trk.getAttributes().get("desc");
    123135        label4.setText(s);
    124136        s = (String) wp.attr.get("ele");
    125         String s1="";
    126         try {s1 = String.format("H=%3.1f   ", Double.parseDouble(s));} catch (Exception e) { }
    127         s1=s1+"L="+(int)trk.length();
     137        String s1 = "";
     138        try {
     139            s1 = String.format("H=%3.1f   ", Double.parseDouble(s));
     140        } catch (Exception e) {
     141            Main.warn(e);
     142        }
     143        s1 = s1+"L="+(int) trk.length();
    128144        label5.setText(s1);
    129145        if (trk.getAttributes().containsKey("url")) {
Note: See TracChangeset for help on using the changeset viewer.