Ignore:
Timestamp:
2017-06-13T22:06:05+02:00 (8 years ago)
Author:
donvip
Message:

fix #josm14728 - fix NPE

Location:
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreGrabber.java

    r32556 r33392  
    3232                url = getURLVector(lambertMin, lambertMax);
    3333            BufferedImage img = grab(url);
     34            if (img == null)
     35                throw new OsmTransferException(url.toString());
    3436            ImageModifier imageModified;
    3537            if (wmsLayer.isRaster())
     
    3739            else
    3840                imageModified = new VectorImageModifier(img, false);
    39             return new GeorefImage(imageModified.bufferedImage, lambertMin, lambertMax, wmsLayer);
     41            return new GeorefImage(imageModified.getBufferedImage(), lambertMin, lambertMax, wmsLayer);
    4042        } catch (MalformedURLException e) {
    4143            throw (IOException) new IOException(tr("CadastreGrabber: Illegal url.")).initCause(e);
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/GeorefImage.java

    r32556 r33392  
    1717import java.io.ObjectOutputStream;
    1818import java.io.Serializable;
     19import java.util.Objects;
    1920
    2021import javax.imageio.ImageIO;
     
    4647
    4748    public GeorefImage(BufferedImage img, EastNorth min, EastNorth max, WMSLayer wmsLayer) {
    48         image = img;
    49 
    50         this.min = min;
    51         this.max = max;
     49        image = Objects.requireNonNull(img);
     50
     51        this.min = Objects.requireNonNull(min);
     52        this.max = Objects.requireNonNull(max);
    5253        this.orgRaster[0] = min;
    5354        this.orgRaster[1] = new EastNorth(min.east(), max.north());
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/ImageModifier.java

    r32556 r33392  
    88import java.awt.image.DataBuffer;
    99import java.awt.image.IndexColorModel;
     10import java.util.Objects;
    1011
    1112public abstract class ImageModifier {
     
    1718    protected int parcelColor = Color.RED.getRGB();
    1819
    19     public BufferedImage bufferedImage;
     20    protected BufferedImage bufferedImage;
    2021
    2122    public static int[] cRoofColors = new int[] {-197380, -592138};
     
    160161    }
    161162
     163    /**
     164     * Returns the buffered image.
     165     * @return the buffered image
     166     */
     167    public final BufferedImage getBufferedImage() {
     168        return bufferedImage;
     169    }
     170
     171    /**
     172     * Sets the buffered image.
     173     * @param bufferedImage the buffered image
     174     */
     175    protected final void setBufferedImage(BufferedImage bufferedImage) {
     176        this.bufferedImage = Objects.requireNonNull(bufferedImage);
     177    }
    162178}
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/RasterImageModifier.java

    r32556 r33392  
    1818
    1919    public RasterImageModifier(BufferedImage bi) {
    20         bufferedImage = bi;
     20        setBufferedImage(bi);
    2121        transparencyEnabled = Main.pref.getBoolean("cadastrewms.backgroundTransparent");
    2222        if (transparencyEnabled)
     
    8484                }
    8585            }
    86             bufferedImage = bi;
     86            setBufferedImage(bi);
    8787        }
    8888        return;
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/VectorImageModifier.java

    r32556 r33392  
    2424
    2525    public VectorImageModifier(BufferedImage bi, boolean monocolor) {
    26         bufferedImage = bi;
     26        setBufferedImage(bi);
    2727        if (Main.pref.getBoolean("cadastrewms.backgroundTransparent"))
    2828            makeTransparent();
     
    3232            invertGrey();
    3333        if (monocolor)
    34             bufferedImage = convert8(convert4(bufferedImage));
     34            setBufferedImage(convert8(convert4(bufferedImage)));
    3535    }
    3636
     
    107107            IndexColorModel icm2 = new IndexColorModel(colorModel.getPixelSize(), size, reds, greens, blues,
    108108                    backgroundPixel);
    109             bufferedImage = new BufferedImage(icm2, raster, bufferedImage.isAlphaPremultiplied(), null);
     109            setBufferedImage(new BufferedImage(icm2, raster, bufferedImage.isAlphaPremultiplied(), null));
    110110        }
    111111        return;
Note: See TracChangeset for help on using the changeset viewer.