Changeset 24615 in osm for applications/editors


Ignore:
Timestamp:
2010-12-06T15:34:54+01:00 (14 years ago)
Author:
upliner
Message:

Implement imagery sharpening(idea by Stephan Knauss)

Location:
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryLayer.java

    r24584 r24615  
    88import java.awt.Toolkit;
    99import java.awt.event.ActionEvent;
     10import java.awt.image.BufferedImage;
     11import java.awt.image.BufferedImageOp;
     12import java.awt.image.ConvolveOp;
     13import java.awt.image.Kernel;
    1014import java.util.List;
    1115
     
    4145    protected double dy = 0.0;
    4246
     47    protected int sharpenLevel;
     48
    4349    public ImageryLayer(ImageryInfo info) {
    4450        super(info.getName());
    4551        this.info = info;
    4652        this.mv = Main.map.mapView;
     53        this.sharpenLevel = ImageryPreferences.PROP_SHARPEN_LEVEL.get();
    4754    }
    4855
     
    175182    }
    176183
     184    public BufferedImage sharpenImage(BufferedImage img) {
     185        if (sharpenLevel <= 0) return img;
     186        int width = img.getWidth(null);
     187        int height = img.getHeight(null);
     188        BufferedImage tmp = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
     189        tmp.getGraphics().drawImage(img, 0, 0, null);
     190        Kernel kernel;
     191        if (sharpenLevel == 1) {
     192            kernel = new Kernel(2, 2, new float[] { 4, -1, -1, -1});
     193        } else {
     194            kernel = new Kernel(3, 3, new float[] { -1, -1, -1, -1, 9, -1, -1, -1, -1});
     195        }
     196        BufferedImageOp op = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);
     197        return op.filter(tmp, null);
     198    }
    177199}
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryPlugin.java

    r24584 r24615  
    5757    /** RemoteControlPlugin older than this SVN revision is not compatible */
    5858    final int REMOTECONTROL_MIN_REVISION = 22734;
    59     /** WMSPlugin needs this specific API major version of RemoteControlPlugin */
     59    /** Imagery Plugin needs this specific API major version of RemoteControlPlugin */
    6060    final int REMOTECONTROL_NEED_API_MAJOR = 1;
    6161    /** All API minor versions starting from this should be compatible */
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryPreferenceEditor.java

    r24584 r24615  
    3838    ImageryProvidersPanel imageryProviders;
    3939
     40    WMSAdapter wmsAdapter = ImageryPlugin.wmsAdapter;
     41    ImageryPlugin plugin = ImageryPlugin.instance;
     42
    4043    // Common settings
    4144    private Color colFadeColor;
     
    4346    private JSlider fadeAmount = new JSlider(0, 100);
    4447    private JCheckBox remoteCheckBox;
    45     boolean allowRemoteControl = true;
     48    private JComboBox sharpen;
     49    private boolean allowRemoteControl = true;
    4650
    4751    // WMS Settings
     
    5155    JSpinner spinNorth;
    5256    JSpinner spinSimConn;
    53     WMSAdapter wmsAdapter = ImageryPlugin.wmsAdapter;
    54     ImageryPlugin plugin = ImageryPlugin.instance;
    5557
    5658    //TMS settings controls
     
    98100        p.add(remoteCheckBox,GBC.eol().fill(GBC.HORIZONTAL));
    99101
     102        this.sharpen = new JComboBox(new String[] {
     103                tr("None"),
     104                tr("Soft"),
     105                tr("Strong")});
     106        p.add(new JLabel(tr("Sharpen (requires layer re-add): ")));
     107        p.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));
     108        p.add(this.sharpen, GBC.std().fill(GBC.HORIZONTAL));
     109        this.sharpen.setSelectedIndex(ImageryPreferences.PROP_SHARPEN_LEVEL.get());
     110
    100111        return p;
    101112    }
     
    109120                "webkit-image-gtk {0}"});
    110121        browser.setEditable(true);
    111         browser.setSelectedItem(Main.pref.get("wmsplugin.browser", "webkit-image {0}"));
     122        browser.setSelectedItem(wmsAdapter.PROP_BROWSER.get());
    112123        p.add(new JLabel(tr("Downloader:")), GBC.eol().fill(GBC.HORIZONTAL));
    113124        p.add(browser);
     
    219230        allowRemoteControl = remoteCheckBox.getModel().isSelected();
    220231
    221         Main.pref.put("wmsplugin.browser", browser.getEditor().getItem().toString());
    222 
     232        Main.pref.put("imagery.wms.browser", browser.getEditor().getItem().toString());
    223233
    224234        TMSPreferences.PROP_DEFAULT_AUTOZOOM.put(this.autozoomActive.isSelected());
     
    227237        TMSPreferences.setMinZoomLvl((Integer)this.minZoomLvl.getValue());
    228238
    229         ImageryPreferences.PROP_REMOTE_CONTROL.put(allowRemoteControl);
    230239        ImageryPreferences.PROP_FADE_AMOUNT.put(this.fadeAmount.getValue());
    231240        ImageryPreferences.setFadeColor(this.colFadeColor);
     241        ImageryPreferences.PROP_REMOTE_CONTROL.put(allowRemoteControl);
     242        ImageryPreferences.PROP_SHARPEN_LEVEL.put(sharpen.getSelectedIndex());
    232243
    233244        return false;
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryPreferences.java

    r24584 r24615  
    88
    99public class ImageryPreferences {
    10 
    1110    public static final BooleanProperty PROP_REMOTE_CONTROL = new BooleanProperty("imagery.remotecontrol", true);
    1211    public static final IntegerProperty PROP_FADE_AMOUNT = new IntegerProperty("imagery.fade_amount", 0);
     12    public static final IntegerProperty PROP_SHARPEN_LEVEL = new IntegerProperty("imagery.sharpen_level", 0);
    1313
    1414    public static Color getFadeColor() {
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/tms/TMSLayer.java

    r24584 r24615  
    5353import org.openstreetmap.josm.gui.layer.Layer;
    5454import org.openstreetmap.josm.plugins.imagery.ImageryInfo;
     55import org.openstreetmap.josm.plugins.imagery.ImageryInfo.ImageryType;
    5556import org.openstreetmap.josm.plugins.imagery.ImageryLayer;
    5657import org.openstreetmap.josm.plugins.imagery.ImageryPreferences;
    57 import org.openstreetmap.josm.plugins.imagery.ImageryInfo.ImageryType;
    5858
    5959/**
     
    8585        Main.map.repaint(100);
    8686        tileRequestsOutstanding.remove(tile);
     87        if (sharpenLevel != 0) tile.setImage(sharpenImage(tile.getImage()));
    8788        if (debug)
    8889            out("tileLoadingFinished() tile: " + tile + " success: " + success);
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/GeorefImage.java

    r24548 r24615  
    9797        }
    9898        default:
     99            this.image = layer.sharpenImage(this.image);
    99100            break;
    100101        }
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/HTMLGrabber.java

    r24501 r24615  
    1010import javax.imageio.ImageIO;
    1111
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.gui.MapView;
    1413import org.openstreetmap.josm.io.CacheFiles;
     14import org.openstreetmap.josm.plugins.imagery.ImageryPlugin;
    1515
    1616public class HTMLGrabber extends WMSGrabber {
     
    2727        ArrayList<String> cmdParams = new ArrayList<String>();
    2828        StringTokenizer st = new StringTokenizer(MessageFormat.format(
    29                 Main.pref.get("wmsplugin.browser", "webkit-image {0}"), urlstring));
     29                ImageryPlugin.wmsAdapter.PROP_BROWSER.get(), urlstring));
    3030        while( st.hasMoreTokens() )
    3131            cmdParams.add(st.nextToken());
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/WMSAdapter.java

    r24555 r24615  
    44import org.openstreetmap.josm.data.preferences.BooleanProperty;
    55import org.openstreetmap.josm.data.preferences.IntegerProperty;
     6import org.openstreetmap.josm.data.preferences.StringProperty;
    67import org.openstreetmap.josm.gui.MapView;
    78import org.openstreetmap.josm.io.CacheFiles;
     
    1415    CacheFiles cache = new CacheFiles("wmsplugin");
    1516
    16     public final IntegerProperty PROP_SIMULTANEOUS_CONNECTIONS = new IntegerProperty("wmsplugin.simultaneousConnections", 3);
    17     public final BooleanProperty PROP_OVERLAP = new BooleanProperty("wmsplugin.url.overlap", false);
    18     public final IntegerProperty PROP_OVERLAP_EAST = new IntegerProperty("wmsplugin.url.overlapEast", 14);
    19     public final IntegerProperty PROP_OVERLAP_NORTH = new IntegerProperty("wmsplugin.url.overlapNorth", 4);
     17    public final StringProperty PROP_BROWSER = new StringProperty("imagery.wms.browser", "webkit-image {0}");
     18    public final IntegerProperty PROP_SIMULTANEOUS_CONNECTIONS = new IntegerProperty("imagery.wms.simultaneousConnections", 3);
     19    public final BooleanProperty PROP_OVERLAP = new BooleanProperty("imagery.wms.overlap", false);
     20    public final IntegerProperty PROP_OVERLAP_EAST = new IntegerProperty("imagery.wms.overlapEast", 14);
     21    public final IntegerProperty PROP_OVERLAP_NORTH = new IntegerProperty("imagery.wms.overlapNorth", 4);
    2022
    2123    protected void initExporterAndImporter() {
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/WMSGrabber.java

    r24555 r24615  
    170170        if(layer.getInfo().getCookies() != null && !layer.getInfo().getCookies().equals(""))
    171171            conn.setRequestProperty("Cookie", layer.getInfo().getCookies());
    172         conn.setRequestProperty("User-Agent", Main.pref.get("wmsplugin.user_agent", Version.getInstance().getAgentString()));
    173         conn.setConnectTimeout(Main.pref.getInteger("wmsplugin.timeout.connect", 30) * 1000);
    174         conn.setReadTimeout(Main.pref.getInteger("wmsplugin.timeout.read", 30) * 1000);
     172        conn.setRequestProperty("User-Agent", Main.pref.get("imagery.wms.user_agent", Version.getInstance().getAgentString()));
     173        conn.setConnectTimeout(Main.pref.getInteger("imagery.wms.timeout.connect", 30) * 1000);
     174        conn.setReadTimeout(Main.pref.getInteger("imagery.wms.timeout.read", 30) * 1000);
    175175
    176176        String contentType = conn.getHeaderField("Content-Type");
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/WMSLayer.java

    r24584 r24615  
    5454public class WMSLayer extends ImageryLayer implements PreferenceChangedListener {
    5555
    56     public static final BooleanProperty PROP_ALPHA_CHANNEL = new BooleanProperty("wmsplugin.alpha_channel", true);
     56    public static final BooleanProperty PROP_ALPHA_CHANNEL = new BooleanProperty("imagery.wms.alpha_channel", true);
    5757    WMSAdapter plugin = ImageryPlugin.wmsAdapter;
    5858
Note: See TracChangeset for help on using the changeset viewer.