Ignore:
Timestamp:
2009-10-27T19:42:44+01:00 (15 years ago)
Author:
pieren
Message:

Modify serialization procedures to get core dependencies out of the cache file.

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

Legend:

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

    r17215 r18312  
    129129    }
    130130
    131     /*
    132      * Method required by BufferedImage serialization
     131    /**
     132     * Method required by BufferedImage serialization.
     133     * Save only primitives to keep cache independent of software changes.
    133134     */
    134135    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    135         max = new EastNorth((Double)in.readObject(), (Double)in.readObject());
    136         min = new EastNorth((Double)in.readObject(), (Double)in.readObject());
     136        max = new EastNorth(in.readDouble(), in.readDouble());
     137        min = new EastNorth(in.readDouble(), in.readDouble());
    137138        image = (BufferedImage) ImageIO.read(ImageIO.createImageInputStream(in));
    138139        updatePixelPer();
    139140    }
    140141
    141     /*
    142      * Method required by BufferedImage serialization
     142    /**
     143     * Method required by BufferedImage serialization.
     144     * Cache uses only primitives to stay independent of software changes.
    143145     */
    144146    private void writeObject(ObjectOutputStream out) throws IOException {
    145         out.writeObject(max.getX());
    146         out.writeObject(max.getY());
    147         out.writeObject(min.getX());
    148         out.writeObject(min.getY());
     147        out.writeDouble(max.getX());
     148        out.writeDouble(max.getY());
     149        out.writeDouble(min.getX());
     150        out.writeDouble(min.getY());
    149151        ImageIO.write(image, "png", ImageIO.createImageOutputStream(out));
    150152    }
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java

    r18289 r18312  
    356356
    357357    /**
    358      * Called by CacheControl when a new cache file is created on disk
     358     * Called by CacheControl when a new cache file is created on disk.
     359     * Save only primitives to keep cache independent of software changes.
    359360     * @param oos
    360361     * @throws IOException
     
    362363    public void write(ObjectOutputStream oos) throws IOException {
    363364        oos.writeInt(this.serializeFormatVersion);
    364         oos.writeObject(this.location);
    365         oos.writeObject(this.codeCommune);
     365        oos.writeObject(this.location);    // String
     366        oos.writeObject(this.codeCommune); // String
    366367        oos.writeInt(this.lambertZone);
    367368        oos.writeBoolean(this.isRaster);
    368369        if (this.isRaster) {
    369             oos.writeObject(this.rasterMin);
    370             oos.writeObject(this.rasterMax);
     370            oos.writeDouble(this.rasterMin.getX());
     371            oos.writeDouble(this.rasterMin.getY());
     372            oos.writeDouble(this.rasterMax.getX());
     373            oos.writeDouble(this.rasterMax.getY());
    371374            oos.writeDouble(this.rasterRatio);
    372375        }
    373         oos.writeObject(this.communeBBox);
    374     }
    375 
    376     /**
    377      * Called by CacheControl when a cache file is read from disk
     376        oos.writeObject(this.communeBBox.min.getX());
     377        oos.writeObject(this.communeBBox.min.getY());
     378        oos.writeObject(this.communeBBox.max.getX());
     379        oos.writeObject(this.communeBBox.max.getY());
     380    }
     381
     382    /**
     383     * Called by CacheControl when a cache file is read from disk.
     384     * Cache uses only primitives to stay independent of software changes.
    378385     * @param ois
    379386     * @throws IOException
     
    392399        this.setRaster(ois.readBoolean());
    393400        if (this.isRaster) {
    394             this.rasterMin = (EastNorth) ois.readObject();
    395             this.rasterMax = (EastNorth) ois.readObject();
     401            double X = ois.readDouble();
     402            double Y = ois.readDouble();
     403            this.rasterMin = new EastNorth(X, Y);
     404            X = ois.readDouble();
     405            Y = ois.readDouble();
     406            this.rasterMax = new EastNorth(X, Y);
    396407            this.rasterRatio = ois.readDouble();
    397408        }
    398         this.communeBBox = (EastNorthBound) ois.readObject();
     409        double minX = ois.readDouble();
     410        double minY = ois.readDouble();
     411        double maxX = ois.readDouble();
     412        double maxY = ois.readDouble();
     413        this.communeBBox =  new EastNorthBound(new EastNorth(minX, minY), new EastNorth(maxX, maxY));
    399414        if (this.lambertZone != currentLambertZone && currentLambertZone != -1) {
    400415            JOptionPane.showMessageDialog(Main.parent, tr("Lambert zone {0} in cache "+
Note: See TracChangeset for help on using the changeset viewer.