Ignore:
Timestamp:
2017-08-12T11:24:39+02:00 (4 years ago)
Author:
bastiK
Message:

fixed #15139 - raster-image filter settings are Not Stored when saving session (color Saturation, Brightness, Sharpness)

Location:
trunk/src/org/openstreetmap/josm/gui/layer/imagery
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/ColorfulImageProcessor.java

    r11914 r12594  
    33
    44import java.awt.image.BufferedImage;
     5import java.util.Collections;
     6import java.util.Map;
    57
    68import org.openstreetmap.josm.gui.layer.ImageProcessor;
     9import org.openstreetmap.josm.io.session.SessionAwareReadApply;
     10import org.openstreetmap.josm.tools.Utils;
    711
    812/**
     
    1216 * @since 10547
    1317 */
    14 public class ColorfulImageProcessor implements ImageProcessor {
     18public class ColorfulImageProcessor implements ImageProcessor, SessionAwareReadApply {
    1519    private ColorfulFilter op;
    16     private double colorfulness = 1;
     20    private double colorfulness = 1.0;
    1721
    1822    /**
     
    5256
    5357    @Override
     58    public void applyFromPropertiesMap(Map<String, String> properties) {
     59        String cStr = properties.get("colorfulness");
     60        if (cStr != null) {
     61            try {
     62                setColorfulness(Double.parseDouble(cStr));
     63            } catch (NumberFormatException e) {
     64                // nothing
     65            }
     66        }
     67    }
     68
     69    @Override
     70    public Map<String, String> toPropertiesMap() {
     71        if (Utils.equalsEpsilon(colorfulness, 1.0))
     72            return Collections.emptyMap();
     73        else
     74            return Collections.singletonMap("colorfulness", Double.toString(colorfulness));
     75    }
     76
     77    @Override
    5478    public String toString() {
    5579        return "ColorfulImageProcessor [colorfulness=" + colorfulness + ']';
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/GammaImageProcessor.java

    r10547 r12594  
    66import java.awt.image.LookupOp;
    77import java.awt.image.ShortLookupTable;
     8import java.util.Collections;
     9import java.util.Map;
    810
    911import org.openstreetmap.josm.Main;
    1012import org.openstreetmap.josm.gui.layer.ImageProcessor;
     13import org.openstreetmap.josm.io.session.SessionAwareReadApply;
     14import org.openstreetmap.josm.tools.Utils;
    1115
    1216/**
     
    1418 * @since 10547
    1519 */
    16 public class GammaImageProcessor implements ImageProcessor {
    17     private double gamma = 1;
     20public class GammaImageProcessor implements ImageProcessor, SessionAwareReadApply {
     21    private double gamma = 1.0;
    1822    final short[] gammaChange = new short[256];
    1923    private final LookupOp op3 = new LookupOp(
     
    4347    @Override
    4448    public BufferedImage process(BufferedImage image) {
    45         if (gamma == 1) {
     49        if (gamma == 1.0) {
    4650            return image;
    4751        }
     
    6367
    6468    @Override
     69    public void applyFromPropertiesMap(Map<String, String> properties) {
     70        String cStr = properties.get("gamma");
     71        if (cStr != null) {
     72            try {
     73                setGamma(Double.parseDouble(cStr));
     74            } catch (NumberFormatException e) {
     75                // nothing
     76            }
     77        }
     78    }
     79
     80    @Override
     81    public Map<String, String> toPropertiesMap() {
     82        if (Utils.equalsEpsilon(gamma, 1.0))
     83            return Collections.emptyMap();
     84        else
     85            return Collections.singletonMap("gamma", Double.toString(gamma));
     86    }
     87
     88    @Override
    6589    public String toString() {
    6690        return "GammaImageProcessor [gamma=" + gamma + ']';
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/SharpenImageProcessor.java

    r12537 r12594  
    55import java.awt.image.ConvolveOp;
    66import java.awt.image.Kernel;
     7import java.util.Collections;
     8import java.util.Map;
    79
    810import org.openstreetmap.josm.gui.layer.ImageProcessor;
     11import org.openstreetmap.josm.io.session.SessionAwareReadApply;
     12import org.openstreetmap.josm.tools.Utils;
    913
    1014/**
     
    1822 * @since 10547
    1923 */
    20 public class SharpenImageProcessor implements ImageProcessor {
    21     private float sharpenLevel = 1;
     24public class SharpenImageProcessor implements ImageProcessor, SessionAwareReadApply {
     25    private float sharpenLevel = 1.0f;
    2226    private ConvolveOp op;
    2327
     
    8993
    9094    @Override
     95    public void applyFromPropertiesMap(Map<String, String> properties) {
     96        String vStr = properties.get("sharpenlevel");
     97        if (vStr != null) {
     98            try {
     99                setSharpenLevel(Float.parseFloat(vStr));
     100            } catch (NumberFormatException e) {
     101                // nothing
     102            }
     103        }
     104    }
     105
     106    @Override
     107    public Map<String, String> toPropertiesMap() {
     108        if (Utils.equalsEpsilon(sharpenLevel, 1.0))
     109            return Collections.emptyMap();
     110        else
     111            return Collections.singletonMap("sharpenlevel", Float.toString(sharpenLevel));
     112    }
     113
     114    @Override
    91115    public String toString() {
    92116        return "SharpenImageProcessor [sharpenLevel=" + sharpenLevel + ']';
Note: See TracChangeset for help on using the changeset viewer.