Changeset 33757 in osm for applications/editors


Ignore:
Timestamp:
2017-10-31T19:52:56+01:00 (7 years ago)
Author:
holgermappt
Message:

Code modified to fix linter issues.

Location:
applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustMapMode.java

    r33745 r33757  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.photoadjust;
    23
     
    4344    private MouseMotionAdapter mouseMotionAdapter;
    4445    private IconToggleButton mmButton;
    45     private PhotoAdjustWorker worker;
     46    private final PhotoAdjustWorker worker;
    4647    /** True if one existing GeoImageLayer is to be ignored. */
    4748    private boolean ignoreOneGILayer = false;
    4849
     50    /**
     51     * Initialize photo adjust map mode.
     52     *
     53     * @param worker Worker that does the actual work.
     54     */
    4955    public PhotoAdjustMapMode(PhotoAdjustWorker worker) {
    5056        super(tr("Adjust photos"), "photoadjust.png",
     
    7985        if (hasLayersToAdjust()) {
    8086            return tr("Click+drag photo, shift+click to position photo, control+click to set direction.");
    81         }
    82         else {
     87        } else {
    8388            return tr("Please load some photos.");
    8489        }
     
    183188    @Override
    184189    public void layerOrderChanged(LayerOrderChangeEvent e) {
     190        // Nothing to do at layer order change.
    185191    }
    186192
     
    234240     * @return list of visible GeoImageLayer's
    235241     */
    236     private List<GeoImageLayer> getVisibleGeoImageLayers() {
     242    private static List<GeoImageLayer> getVisibleGeoImageLayers() {
    237243        List<GeoImageLayer> all = new ArrayList<>(MainApplication.getLayerManager().getLayersOfType(GeoImageLayer.class));
    238244        Iterator<GeoImageLayer> it = all.iterator();
  • applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustPlugin.java

    r33745 r33757  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.photoadjust;
    23
     
    2324public class PhotoAdjustPlugin extends Plugin implements ActiveLayerChangeListener {
    2425 
    25     private GeoImageLayer imageLayer = null;
    26     private MouseAdapter mouseAdapter = null;
    27     private MouseMotionAdapter mouseMotionAdapter = null;
    28     public PhotoAdjustWorker worker = null;
     26    private GeoImageLayer imageLayer;
     27    private MouseAdapter mouseAdapter;
     28    private MouseMotionAdapter mouseMotionAdapter;
     29    private final PhotoAdjustWorker worker = new PhotoAdjustWorker();
    2930
    3031    /**
     
    3637        super(info);
    3738        GeoImageLayer.registerMenuAddition(new UntaggedGeoImageLayerAction());
    38         new PhotoPropertyEditor();
    39         worker = new PhotoAdjustWorker();
     39        PhotoPropertyEditor.init();
    4040        initAdapters();
    4141    }
     
    9090        Layer oldLayer = e.getPreviousActiveLayer();
    9191        Layer newLayer = MainApplication.getLayerManager().getActiveLayer();
    92         if ( oldLayer instanceof GeoImageLayer
    93              && newLayer instanceof GeoImageLayer) {
     92        if (oldLayer instanceof GeoImageLayer
     93            && newLayer instanceof GeoImageLayer) {
    9494            imageLayer = (GeoImageLayer)newLayer;
    95         }
    96         else {
     95        } else {
    9796            if (oldLayer instanceof GeoImageLayer) {
    9897                MainApplication.getMap().mapView.removeMouseListener(mouseAdapter);
  • applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustWorker.java

    r33745 r33757  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.photoadjust;
    23
     
    1718public class PhotoAdjustWorker {
    1819
    19     private ImageEntry dragPhoto = null;
    20     private GeoImageLayer dragLayer = null;
     20    private ImageEntry dragPhoto;
     21    private GeoImageLayer dragLayer;
    2122    // Offset between center of the photo and point where it is
    2223    // clicked.  This must be in pixels to maintain the same offset if
    2324    // the photo is moved very far.
    24     private Point2D dragOffset = null;
     25    private Point2D dragOffset;
    2526    private boolean centerViewIsDisabled = false;
    2627    private boolean centerViewNeedsEnable = false;
     
    7677
    7778        if (evt.getButton() == MouseEvent.BUTTON1
    78             && imageLayers != null && imageLayers.size() > 0) {
     79            && imageLayers != null && !imageLayers.isEmpty()) {
    7980            // Check if modifier key is pressed and change to
    8081            // image viewer photo if it is.
     
    8485                final GeoImageLayer viewerLayer = ImageViewerDialog.getCurrentLayer();
    8586                final ImageEntry img = ImageViewerDialog.getCurrentImage();
    86                 if ( img != null && viewerLayer != null
    87                      && viewerLayer.isVisible()
    88                      && imageLayers.contains(viewerLayer)) {
     87                if (img != null && viewerLayer != null
     88                    && viewerLayer.isVisible()
     89                    && imageLayers.contains(viewerLayer)) {
    8990                    // Change direction if control is pressed, position
    9091                    // otherwise.  Shift+control changes direction, similar to
     
    107108                            changeDirection(img, viewerLayer, evt);
    108109                        }
    109                     }
    110                     else { // shift pressed
     110                    } else { // shift pressed
    111111                        movePhoto(img, viewerLayer, evt);
    112112                    }
     
    114114                    dragLayer = viewerLayer;
    115115                }
    116             }
    117             else {
     116            } else {
    118117                // Start with the top layer.
    119118                for (GeoImageLayer layer: imageLayers) {
     
    151150     */
    152151    public void doMouseDragged(MouseEvent evt) {
    153         if ( dragLayer != null && dragLayer.isVisible()
    154              && dragPhoto != null) {
     152        if (dragLayer != null && dragLayer.isVisible()
     153            && dragPhoto != null) {
    155154            if ((evt.getModifiers() & InputEvent.CTRL_MASK) != 0) {
    156155                changeDirection(dragPhoto, dragLayer, evt);
    157             }
    158             else {
     156            } else {
    159157                disableCenterView();
    160158                movePhoto(dragPhoto, dragLayer, evt);
     
    189187                dragOffset.getX() + evt.getX(),
    190188                dragOffset.getY() + evt.getY());
    191         }
    192         else {
     189        } else {
    193190            newPos = MainApplication.getMap().mapView.getLatLon(evt.getX(), evt.getY());
    194191        }
  • applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoPropertyEditor.java

    r33750 r33757  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.photoadjust;
    23
    3 //import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     
    4242public class PhotoPropertyEditor {
    4343
    44     public PhotoPropertyEditor() {
     44    /**
     45     * Add photo property editor to edit menu.
     46     */
     47    public static void init() {
    4548        MainMenu.add(MainApplication.getMenu().editMenu, new PropertyEditorAction());
    4649    }
     
    6265    private static class PropertyEditorAction extends JosmAction {
    6366        public PropertyEditorAction() {
    64             super(tr("Edit photo GPS data"),    // String name
    65                   (String)null,                 // String iconName
     67            super(tr("Edit photo GPS data"),    // String name
     68                  (String)null,                         // String iconName
    6669                  tr("Edit GPS data of selected photo."), // String tooltip
    67                   null,                         // Shortcut shortcut
    68                   true,                         // boolean registerInToolbar
     70                  null,                                 // Shortcut shortcut
     71                  true,                                 // boolean registerInToolbar
    6972                  "photoadjust/propertyeditor", // String toolbarId
    70                   true                          // boolean installAdapters
     73                  true                          // boolean installAdapters
    7174                  );
    72             //putValue("help", ht("/Action/..."));
    7375        }
    7476
     
    114116         *         image shown, {@code false} otherwise.
    115117         */
    116         private boolean enabled() {
     118        private static boolean enabled() {
    117119            try {
    118120                //return ImageViewerDialog.getInstance().hasImage();
     
    147149        public PropertyEditorDialog(String title, final ImageEntry image,
    148150                                    final GeoImageLayer layer) {
    149             super(Main.parent, title, new String[] {tr("Ok"), tr("Cancel")});
     151            super(Main.parent, title, tr("Ok"), tr("Cancel"));
    150152            this.image = image;
    151153            this.layer = layer;
    152154            imgOrig = image.clone();
    153             setButtonIcons(new String[] {"ok", "cancel"});
     155            setButtonIcons("ok", "cancel");
    154156            final JPanel content = new JPanel(new GridBagLayout());
    155157            //content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
     
    183185            Action editCoordAction = new AbstractAction(tr("Edit")) {
    184186                @Override public void actionPerformed(ActionEvent evt) {
    185                     final LatLonDialog llDialog 
     187                    final LatLonDialog llDialog
    186188                        = new LatLonDialog(Main.parent,
    187189                                           tr("Edit Image Coordinates"), null);
     
    317319         * @return Image position as text.
    318320         */
    319         private String posToText(LatLon pos) {
     321        private static String posToText(LatLon pos) {
    320322            // See josm.gui.dialogs.LatLonDialog.setCoordinates().
    321             String posStr =
     323            return
    322324                pos == null ? "" :
    323325                CoordinateFormatManager.getDefaultFormat().latToString(pos) +
    324326                ' ' +
    325327                CoordinateFormatManager.getDefaultFormat().lonToString(pos);
    326             return posStr;
    327328        }
    328329
     
    389390         *         converted to double.
    390391         */
    391         private Double getDoubleValue(JosmTextField txtFld) {
     392        private static Double getDoubleValue(JosmTextField txtFld) {
    392393            final String text = txtFld.getText();
    393394            if (text == null || text.isEmpty()) {
     
    424425                // doesn't work to compare imgTmp.getPos() with getLatLon()
    425426                // because the dialog will round the initial position.
    426                 if ( imgOrig.getPos() == null
    427                      || !posToText(imgOrig.getPos()).equals(posToText(imgTmp.getPos()))
    428                      ) {
     427                if (imgOrig.getPos() == null
     428                    || !posToText(imgOrig.getPos()).equals(
     429                        posToText(imgTmp.getPos()))) {
    429430                    imgTmp.flagNewGpsData();
    430431                }
     
    492493                latLon = null;
    493494            }
    494             if ( latLon == null && coordsText != null
    495                  && !coordsText.isEmpty()) {
     495            if ((latLon == null && coordsText != null
     496                 && !coordsText.isEmpty())) {
    496497                setErrorFeedback(coords);
    497498                setOkEnabled(false);
     
    522523            final String text = txtFld.getText();
    523524            Double value = null;
    524             if (text == null || text.isEmpty()) {
    525                 isError = false;
    526             } else {
     525            if (text != null && !text.isEmpty()) {
    527526                try {
    528                     value = Double.parseDouble(text);
     527                    value = Double.valueOf(text);
    529528                    if (min != null && value < min) {
    530529                        isError = true;
  • applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/UntaggedGeoImageLayerAction.java

    r33745 r33757  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.photoadjust;
    23
Note: See TracChangeset for help on using the changeset viewer.