source: josm/trunk/src/org/openstreetmap/josm/gui/layer/imagery/ColorfulImageProcessor.java@ 11914

Last change on this file since 11914 was 11914, checked in by Don-vip, 7 years ago

sonar - squid:S2972 - Inner classes should not have too many lines of code

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.layer.imagery;
3
4import java.awt.image.BufferedImage;
5
6import org.openstreetmap.josm.gui.layer.ImageProcessor;
7
8/**
9 * Adds or removes the colorfulness of the image.
10 *
11 * @author Michael Zangl
12 * @since 10547
13 */
14public class ColorfulImageProcessor implements ImageProcessor {
15 private ColorfulFilter op;
16 private double colorfulness = 1;
17
18 /**
19 * Gets the colorfulness value.
20 * @return The value
21 */
22 public double getColorfulness() {
23 return colorfulness;
24 }
25
26 /**
27 * Sets the colorfulness value. Clamps it to 0+
28 * @param colorfulness The value
29 */
30 public void setColorfulness(double colorfulness) {
31 if (colorfulness < 0) {
32 this.colorfulness = 0;
33 } else {
34 this.colorfulness = colorfulness;
35 }
36
37 if (this.colorfulness < .95 || this.colorfulness > 1.05) {
38 op = new ColorfulFilter(this.colorfulness);
39 } else {
40 op = null;
41 }
42 }
43
44 @Override
45 public BufferedImage process(BufferedImage image) {
46 if (op != null) {
47 return op.filter(image, null);
48 } else {
49 return image;
50 }
51 }
52
53 @Override
54 public String toString() {
55 return "ColorfulImageProcessor [colorfulness=" + colorfulness + ']';
56 }
57}
Note: See TracBrowser for help on using the repository browser.