Ignore:
Timestamp:
2018-09-22T15:26:51+02:00 (6 years ago)
Author:
donvip
Message:

fix warnings

Location:
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionBoundaries.java

    r34458 r34668  
    22package org.openstreetmap.josm.plugins.fr.cadastre.actions;
    33
     4import static org.openstreetmap.josm.tools.I18n.marktr;
    45import static org.openstreetmap.josm.tools.I18n.tr;
    56
     
    1314import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer;
    1415
     16/**
     17 * Extract commune boundary
     18 */
    1519public class MenuActionBoundaries extends JosmAction {
    1620
    17     public static final String NAME = "Administrative boundary";
     21    private static final String NAME = marktr("Administrative boundary");
    1822
    1923    private static final long serialVersionUID = 1L;
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionCancelGrab.java

    r33638 r34668  
    1010import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer;
    1111
    12 @SuppressWarnings("serial")
     12/**
     13 * Cancel current grab (only vector images)
     14 */
    1315public class MenuActionCancelGrab extends JosmAction {
    1416
    15     public static final String NAME = marktr("Cancel current grab");
     17    private static final String NAME = marktr("Cancel current grab");
    1618
    1719    private WMSLayer wmsLayer;
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionGrab.java

    r33640 r34668  
    2020public class MenuActionGrab extends JosmAction {
    2121
    22     public static final String NAME = marktr("Cadastre grab");
     22    private static final String NAME = marktr("Cadastre grab");
    2323
    2424    /**
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionGrabPlanImage.java

    r34458 r34668  
    1818import org.openstreetmap.josm.spi.preferences.Config;
    1919
     20/**
     21 * Grab non-georeferenced image
     22 */
    2023public class MenuActionGrabPlanImage extends JosmAction implements Runnable {
    2124
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionLoadFromCache.java

    r34458 r34668  
    2222import org.openstreetmap.josm.tools.Logging;
    2323
     24/**
     25 * Load location from cache (only if cache is enabled)
     26 */
    2427public class MenuActionLoadFromCache extends JosmAction {
    2528    private static final long serialVersionUID = 1L;
    2629
    27     public static final String name = marktr("Load layer from cache");
     30    private static final String name = marktr("Load layer from cache");
    2831
    2932    /**
     
    4952                String ext = (filename.lastIndexOf('.') == -1) ? "" : filename.substring(filename.lastIndexOf('.')+1, filename.length());
    5053                if ((ext.length() == 3 && ext.substring(0, CacheControl.C_LAMBERT_CC_9Z.length()).equals(CacheControl.C_LAMBERT_CC_9Z) &&
    51                     !(CadastrePlugin.isLambert_cc9()))
     54                    !CadastrePlugin.isLambert_cc9())
    5255                    || (ext.length() == 4 && ext.substring(0, CacheControl.C_UTM20N.length()).equals(CacheControl.C_UTM20N) &&
    5356                            !(CadastrePlugin.isUtm_france_dom()))
    54                     || (ext.length() == 1) && !(CadastrePlugin.isLambert())) {
     57                    || (ext.length() == 1 && !CadastrePlugin.isLambert())) {
    5558                        JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    5659                                tr("{0} not allowed with the current projection", filename),
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionNewLocation.java

    r34458 r34668  
    2424import org.openstreetmap.josm.tools.Logging;
    2525
     26/**
     27 * Set a new location for the next request
     28 */
    2629public class MenuActionNewLocation extends JosmAction {
    2730
     
    5962    // CHECKSTYLE.ON: LineLength
    6063
     64    /**
     65     * Constructs a new {@code MenuActionNewLocation}.
     66     */
    6167    public MenuActionNewLocation() {
    6268        super(tr("Change location"), "cadastre_small", tr("Set a new location for the next request"), null, false,
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionOpenPreferences.java

    r34458 r34668  
    1212import org.openstreetmap.josm.plugins.fr.cadastre.preferences.CadastrePreferenceSetting;
    1313
     14/**
     15 * Open Cadastre Preferences
     16 */
    1417public class MenuActionOpenPreferences extends JosmAction {
    15     private static final long serialVersionUID = 1L;
    1618
    17     public static final String NAME = marktr("Preferences");
     19    private static final String NAME = marktr("Preferences");
    1820
    1921    /**
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionRefineGeoRef.java

    r33640 r34668  
    1313import org.openstreetmap.josm.tools.Logging;
    1414
     15/**
     16 * Improve georeferencing (only raster images)
     17 */
    1518public class MenuActionRefineGeoRef extends JosmAction {
    1619
    17     public static final String NAME = marktr("Refine georeferencing");
     20    private static final String NAME = marktr("Refine georeferencing");
    1821
    1922    private WMSLayer wmsLayer;
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionResetCookie.java

    r33638 r34668  
    88import org.openstreetmap.josm.actions.JosmAction;
    99
     10/**
     11 * Get a new cookie (session timeout)
     12 */
    1013public class MenuActionResetCookie extends JosmAction {
    1114
    1215    /**
    13      *
     16     * Constructs a new {@code MenuActionResetCookie}
    1417     */
    15     private static final long serialVersionUID = 1L;
    16 
    1718    public MenuActionResetCookie() {
    1819        super(tr("Reset cookie"), "cadastre_small", tr("Get a new cookie (session timeout)"), null, false);
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionSaveRasterAs.java

    r34495 r34668  
    3030import org.openstreetmap.josm.tools.Logging;
    3131
     32/**
     33 * Export image (only raster images)
     34 */
    3235public class MenuActionSaveRasterAs extends JosmAction {
    3336
    34     public static final String NAME = marktr("Save image as...");
    35 
    36     private static final long serialVersionUID = 1L;
     37    private static final String NAME = marktr("Save image as...");
    3738
    3839    private WMSLayer wmsLayer;
    3940
    40     public static class FiltrePng extends FileFilter {
     41    static class FiltrePng extends FileFilter {
    4142        @Override
    4243        public boolean accept(File file) {
     
    5354    }
    5455
    55     public static class FiltreTiff extends FileFilter {
     56    static class FiltreTiff extends FileFilter {
    5657        @Override
    5758        public boolean accept(File file) {
     
    9697                try {
    9798                    ImageIO.write(bi, "png", file);
    98                     /*
    99                     FileOutputStream flux = new FileOutputStream(file);
    100                     BufferedOutputStream fluxBuf = new BufferedOutputStream(flux);
    101                     JPEGImageEncoder codec = JPEGCodec.createJPEGEncoder(fluxBuf, JPEGCodec.getDefaultJPEGEncodeParam(bi));
    102                     codec.encode(bi);
    103                     fluxBuf.close();
    104                     */
    10599                } catch (IOException e) {
    106100                    Logging.error(e);
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoRecord.java

    r33653 r34668  
    1010 * Edigeo record.
    1111 */
    12 class EdigeoRecord {
     12final class EdigeoRecord {
    1313
    1414    enum Nature {
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/CacheControl.java

    r34458 r34668  
    6464    public boolean isCachePipeEmpty() {
    6565        imagesLock.lock();
    66         boolean ret = imagesToSave.isEmpty();
    67         imagesLock.unlock();
    68         return ret;
     66        try {
     67            return imagesToSave.isEmpty();
     68        } finally {
     69            imagesLock.unlock();
     70        }
    6971    }
    7072
     
    159161            ObjectInputStream ois = new ObjectInputStream(fis);
    160162        ) {
    161             successfulRead = wmsLayer.read(file, ois, currentLambertZone);
     163            wmsLayer.setAssociatedFile(file);
     164            successfulRead = wmsLayer.read(ois, currentLambertZone);
    162165        } catch (IOException | ClassNotFoundException ex) {
    163166            Logging.error(ex);
     
    176179    public synchronized void saveCache(GeorefImage image) {
    177180        imagesLock.lock();
    178         this.imagesToSave.add(image);
    179         this.notifyAll();
    180         imagesLock.unlock();
     181        try {
     182            this.imagesToSave.add(image);
     183            this.notifyAll();
     184        } finally {
     185            imagesLock.unlock();
     186        }
    181187    }
    182188
     
    203209                        try (ObjectOutputStream oos = new ObjectOutputStream(
    204210                                new BufferedOutputStream(new FileOutputStream(file)))) {
    205                             wmsLayer.write(file, oos);
     211                            wmsLayer.setAssociatedFile(file);
     212                            wmsLayer.write(oos);
    206213                            for (int i = 0; i < size; i++) {
    207214                                oos.writeObject(imagesToSave.get(i));
     
    213220                }
    214221                imagesLock.lock();
    215                 for (int i = 0; i < size; i++) {
    216                     imagesToSave.remove(0);
    217                 }
    218                 imagesLock.unlock();
     222                try {
     223                    for (int i = 0; i < size; i++) {
     224                        imagesToSave.remove(0);
     225                    }
     226                } finally {
     227                    imagesLock.unlock();
     228                }
    219229            }
    220230            try {
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/CadastreInterface.java

    r34458 r34668  
    536536        if (MainApplication.getMap() != null) {
    537537            for (Layer l : MainApplication.getLayerManager().getLayers()) {
    538                 if (l instanceof WMSLayer && l.getName().equals(wmsLayer.getName()) && (!l.equals(wmsLayer))) {
     538                if (l instanceof WMSLayer && l.getName().equals(wmsLayer.getName()) && !l.equals(wmsLayer)) {
    539539                    Logging.info("Try to grab into a new layer when "+wmsLayer.getName()+" is already opened.");
    540540                    // remove the duplicated layer
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/GrabThread.java

    r34223 r34668  
    4040    void addImages(ArrayList<EastNorthBound> moreImages) {
    4141        lockImagesToGrag.lock();
    42         imagesToGrab.addAll(moreImages);
    43         lockImagesToGrag.unlock();
     42        try {
     43            imagesToGrab.addAll(moreImages);
     44        } finally {
     45            lockImagesToGrag.unlock();
     46        }
    4447        synchronized (this) {
    4548            this.notify();
     
    5356    public int getImagesToGrabSize() {
    5457        lockImagesToGrag.lock();
    55         int size = imagesToGrab.size();
    56         lockImagesToGrag.unlock();
    57         return size;
     58        try {
     59            return imagesToGrab.size();
     60        } finally {
     61            lockImagesToGrag.unlock();
     62        }
    5863    }
    5964
     
    6166        ArrayList<EastNorthBound> copyList = new ArrayList<>();
    6267        lockImagesToGrag.lock();
    63         for (EastNorthBound img : imagesToGrab) {
    64             EastNorthBound imgCpy = new EastNorthBound(img.min, img.max);
    65             copyList.add(imgCpy);
    66         }
    67         lockImagesToGrag.unlock();
     68        try {
     69            for (EastNorthBound img : imagesToGrab) {
     70                EastNorthBound imgCpy = new EastNorthBound(img.min, img.max);
     71                copyList.add(imgCpy);
     72            }
     73        } finally {
     74            lockImagesToGrag.unlock();
     75        }
    6876        return copyList;
    6977    }
     
    7179    void clearImagesToGrab() {
    7280        lockImagesToGrag.lock();
    73         imagesToGrab.clear();
    74         lockImagesToGrag.unlock();
     81        try {
     82            imagesToGrab.clear();
     83        } finally {
     84            lockImagesToGrag.unlock();
     85        }
    7586    }
    7687
     
    109120                        if (CadastrePlugin.backgroundTransparent) {
    110121                            wmsLayer.imagesLock.lock();
    111                             for (GeorefImage img : wmsLayer.getImages()) {
    112                                 if (img.overlap(newImage))
    113                                     // mask overlapping zone in already grabbed image
    114                                     img.withdraw(newImage);
    115                                 else
    116                                     // mask overlapping zone in new image only when new image covers completely the
    117                                     // existing image
    118                                     newImage.withdraw(img);
     122                            try {
     123                                for (GeorefImage img : wmsLayer.getImages()) {
     124                                    if (img.overlap(newImage))
     125                                        // mask overlapping zone in already grabbed image
     126                                        img.withdraw(newImage);
     127                                    else
     128                                        // mask overlapping zone in new image only when new image covers completely the
     129                                        // existing image
     130                                        newImage.withdraw(img);
     131                                }
     132                            } finally {
     133                                wmsLayer.imagesLock.unlock();
    119134                            }
    120                             wmsLayer.imagesLock.unlock();
    121135                        }
    122136                        wmsLayer.addImage(newImage);
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/WMSLayer.java

    r34458 r34668  
    1515import java.awt.image.ImageObserver;
    1616import java.io.EOFException;
    17 import java.io.File;
    1817import java.io.IOException;
    1918import java.io.ObjectInputStream;
     
    6160    private int lambertZone = -1;
    6261
    63     public CadastreGrabber grabber = new CadastreGrabber();
     62    CadastreGrabber grabber = new CadastreGrabber();
    6463
    6564    protected static final Icon icon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(
     
    6867    private Vector<GeorefImage> images = new Vector<>();
    6968
    70     public Lock imagesLock = new ReentrantLock();
     69    Lock imagesLock = new ReentrantLock();
    7170
    7271    /**
     
    7776    protected final int serializeFormatVersion = 4;
    7877
    79     public static int currentFormat;
     78    static int currentFormat;
    8079
    8180    private ArrayList<EastNorthBound> dividedBbox = new ArrayList<>();
     
    8786    private String codeCommune = "";
    8887
    89     public EastNorthBound communeBBox = new EastNorthBound(new EastNorth(0, 0), new EastNorth(0, 0));
     88    EastNorthBound communeBBox = new EastNorthBound(new EastNorth(0, 0), new EastNorth(0, 0));
    9089
    9190    private boolean isRaster;
    9291    private boolean isAlreadyGeoreferenced;
    93     public double X0, Y0, angle, fX, fY;
     92    double X0, Y0, angle, fX, fY;
    9493
    9594    // bbox of the georeferenced raster image (the nice horizontal and vertical box)
     
    9998
    10099    // offset for vector images temporarily shifted (correcting Cadastre artifacts), in pixels
    101     public double deltaEast;
    102     public double deltaNorth;
     100    double deltaEast;
     101    double deltaNorth;
    103102
    104103    private Action saveAsPng;
     
    300299                g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
    301300            imagesLock.lock();
    302             for (GeorefImage img : images) {
    303                 img.paint(g, mv, CadastrePlugin.backgroundTransparent,
    304                         CadastrePlugin.transparency, CadastrePlugin.drawBoundaries);
    305             }
    306             imagesLock.unlock();
     301            try {
     302                for (GeorefImage img : images) {
     303                    img.paint(g, mv, CadastrePlugin.backgroundTransparent,
     304                            CadastrePlugin.transparency, CadastrePlugin.drawBoundaries);
     305                }
     306            } finally {
     307                imagesLock.unlock();
     308            }
    307309            g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, savedInterpolation);
    308310        }
     
    378380     * The original raster size is [0,0,12286,8730] where 0,0 is the upper left corner and
    379381     * 12286,8730 is the approx. raster max size.
     382     * @param min min east/north
     383     * @param max max east/north
    380384     * @return the raster coordinates for the wms server request URL (minX,minY,maxX,maxY)
    381385     */
     
    456460     * Called by CacheControl when a new cache file is created on disk.
    457461     * Save only primitives to keep cache independent of software changes.
    458      */
    459     public void write(File associatedFile, ObjectOutputStream oos) throws IOException {
     462     * @param oos output stream
     463     * @throws IOException if any I/O error occurs
     464     */
     465    public void write(ObjectOutputStream oos) throws IOException {
    460466        currentFormat = this.serializeFormatVersion;
    461         setAssociatedFile(associatedFile);
    462467        oos.writeInt(this.serializeFormatVersion);
    463468        oos.writeObject(this.location);    // String
     
    482487     * Called by CacheControl when a cache file is read from disk.
    483488     * Cache uses only primitives to stay independent of software changes.
    484      */
    485     public boolean read(File associatedFile, ObjectInputStream ois, int currentLambertZone) throws IOException, ClassNotFoundException {
    486         currentFormat = ois.readInt();;
     489     * @param ois input stream
     490     * @param currentLambertZone current Lambert zone
     491     * @return {@code true} for success
     492     * @throws IOException if any I/O error occurs
     493     * @throws ClassNotFoundException if class of a serialized object cannot be found
     494     */
     495    public boolean read(ObjectInputStream ois, int currentLambertZone) throws IOException, ClassNotFoundException {
     496        currentFormat = ois.readInt();
    487497        if (currentFormat < 2) {
    488498            JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
     
    495505        this.lambertZone = ois.readInt();
    496506        this.setRaster(ois.readBoolean());
    497         setAssociatedFile(associatedFile);
    498507        if (currentFormat >= 4)
    499508            ois.readBoolean();
     
    587596     * Works only for raster image layer (only one image in collection).
    588597     * Updates layer georeferences.
     598     * @param en1 first east/north
     599     * @param en2 second east/north
    589600     */
    590601    public void cropImage(EastNorth en1, EastNorth en2) {
     
    700711    public GeorefImage getImage(int index) {
    701712        imagesLock.lock();
    702         GeorefImage img = null;
    703713        try {
    704             img = this.images.get(index);
     714            return images.get(index);
    705715        } catch (ArrayIndexOutOfBoundsException e) {
    706716            Logging.error(e);
    707         }
    708         imagesLock.unlock();
    709         return img;
     717            return null;
     718        } finally {
     719            imagesLock.unlock();
     720        }
    710721    }
    711722
    712723    public Vector<GeorefImage> getImages() {
    713         return this.images;
     724        return images;
    714725    }
    715726
     
    720731    public void addImage(GeorefImage img) {
    721732        imagesLock.lock();
    722         this.images.add(img);
    723         imagesLock.unlock();
     733        try {
     734            images.add(img);
     735        } finally {
     736            imagesLock.unlock();
     737        }
    724738    }
    725739
    726740    public void setImages(Vector<GeorefImage> images) {
    727741        imagesLock.lock();
    728         this.images = images;
    729         imagesLock.unlock();
     742        try {
     743            this.images = images;
     744        } finally {
     745            imagesLock.unlock();
     746        }
    730747    }
    731748
    732749    public void clearImages() {
    733750        imagesLock.lock();
    734         this.images.clear();
    735         imagesLock.unlock();
     751        try {
     752            images.clear();
     753        } finally {
     754            imagesLock.unlock();
     755        }
    736756    }
    737757}
Note: See TracChangeset for help on using the changeset viewer.