Ticket #11713: raster_filters.diff
| File raster_filters.diff, 6.5 KB (added by , 11 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/MapView.java
1158 1158 changedLayer = l; 1159 1159 repaint(); 1160 1160 } 1161 } else if (evt.getPropertyName().equals(Layer.FILTER_STATE_PROP)){ 1162 Layer l = (Layer) evt.getSource(); 1163 if (l.isVisible()) { 1164 changedLayer = l; 1165 repaint(); 1166 } 1161 1167 } else if (evt.getPropertyName().equals(OsmDataLayer.REQUIRES_SAVE_TO_DISK_PROP) 1162 1168 || evt.getPropertyName().equals(OsmDataLayer.REQUIRES_UPLOAD_TO_SERVER_PROP)) { 1163 1169 OsmDataLayer layer = (OsmDataLayer) evt.getSource(); -
src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
16 16 import java.awt.event.ActionEvent; 17 17 import java.awt.event.MouseAdapter; 18 18 import java.awt.event.MouseEvent; 19 import java.awt.image.BufferedImage; 19 20 import java.awt.image.ImageObserver; 20 21 import java.io.File; 21 22 import java.io.IOException; … … 985 986 missedTiles.add(tile); 986 987 continue; 987 988 } 989 990 // applying all filters to this layer 991 img = applyImageProcessors((BufferedImage) img); 992 988 993 Rectangle sourceRect = tileToRect(tile); 989 994 if (borderRect != null && !sourceRect.intersects(borderRect)) { 990 995 continue; -
src/org/openstreetmap/josm/gui/layer/ImageProcessor.java
1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.layer; 3 4 import java.awt.image.BufferedImage; 5 6 /** 7 * This interface was created for processing {@link ImageryLayer}s 8 * following the rules of created image processors 9 * 10 * @author Nipel-Crumple 11 * 12 * @since 8614 13 * 14 */ 15 public interface ImageProcessor { 16 17 /** 18 * This method should process given image according to image processors 19 * which is contained in the {@link Layer} 20 * 21 * @param image that should be processed 22 * 23 * @return processed image 24 */ 25 public BufferedImage process(BufferedImage image); 26 27 } -
src/org/openstreetmap/josm/gui/layer/ImageryLayer.java
21 21 import java.awt.image.Kernel; 22 22 import java.text.AttributedCharacterIterator; 23 23 import java.text.AttributedString; 24 import java.util.ArrayList; 24 25 import java.util.Hashtable; 25 26 import java.util.List; 26 27 import java.util.Map; … … 55 56 public static final IntegerProperty PROP_FADE_AMOUNT = new IntegerProperty("imagery.fade_amount", 0); 56 57 public static final IntegerProperty PROP_SHARPEN_LEVEL = new IntegerProperty("imagery.sharpen_level", 0); 57 58 59 private final List<ImageProcessor> imageProcessors = new ArrayList<>(); 60 58 61 public static Color getFadeColor() { 59 62 return PROP_FADE_COLOR.get(); 60 63 } … … 251 254 } 252 255 253 256 /** 257 * This method adds the {@link ImageProcessor} to this Layer 258 * 259 * @param processor that processes the image 260 * 261 * @return true if processor was added, false otherwise 262 * 263 * @since 8614 264 */ 265 public boolean addImageProcessor(ImageProcessor processor) { 266 return imageProcessors.add(processor); 267 } 268 269 /** 270 * This method removes given {@link ImageProcessor} from this layer 271 * 272 * @param processor which is needed to be removed 273 * 274 * @return true if processor was removed 275 * 276 * @since 8614 277 */ 278 public boolean removeImageProcessor(ImageProcessor processor) { 279 return imageProcessors.remove(processor); 280 } 281 282 /** 283 * This method gets all {@link ImageProcessor}s of the layer 284 * 285 * @return list of image processors without removed one 286 * 287 * @since 8614 288 */ 289 public List<ImageProcessor> getImageProcessors() { 290 return imageProcessors; 291 } 292 293 /** 294 * Applies all the chosen {@link ImageProcessor}s to the image 295 * 296 * @param img - image which should be changed 297 * 298 * @return the new changed image 299 * 300 * @since 8614 301 */ 302 public BufferedImage applyImageProcessors(BufferedImage img) { 303 for (ImageProcessor processor : imageProcessors) { 304 img = processor.process(img); 305 } 306 return img; 307 } 308 309 /** 254 310 * Draws a red error tile when imagery tile cannot be fetched. 255 311 * @param img The buffered image 256 312 * @param message Additional error message to display -
src/org/openstreetmap/josm/gui/layer/Layer.java
85 85 public static final String VISIBLE_PROP = Layer.class.getName() + ".visible"; 86 86 public static final String OPACITY_PROP = Layer.class.getName() + ".opacity"; 87 87 public static final String NAME_PROP = Layer.class.getName() + ".name"; 88 public static final String FILTER_STATE_PROP = Layer.class.getName() + ".filterstate"; 88 89 89 90 public static final int ICON_SIZE = 16; 90 91 … … 313 314 } 314 315 315 316 /** 317 * Sets new state to the layer after applying {@link ImageProcessor} 318 * 319 * @since 8614 320 */ 321 public void setFilterStateChanged() { 322 fireFilterStateChanged(); 323 } 324 325 /** 316 326 * Toggles the visibility state of this layer. 317 327 */ 318 328 public void toggleVisible() { … … 358 368 } 359 369 360 370 /** 371 * fires a property change for the property {@link #FILTER_STATE_PROP} 372 * 373 */ 374 protected void fireFilterStateChanged() { 375 propertyChangeSupport.firePropertyChange(FILTER_STATE_PROP, null, null); 376 } 377 378 /** 361 379 * Check changed status of layer 362 380 * 363 381 * @return True if layer was changed since last paint
