Mercurial > hg > digilib-old
annotate common/src/main/java/digilib/image/ImageWorker.java @ 930:333e60e5cae9
new counter for open requests.
author | robcast |
---|---|
date | Tue, 20 Dec 2011 15:51:36 +0100 |
parents | 66f1ba72d07b |
children |
rev | line source |
---|---|
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
1 /** Worker (Callable) that renders an image. |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
2 * |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
3 */ |
557 | 4 package digilib.image; |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
5 |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
6 import java.awt.Rectangle; |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
7 import java.io.IOException; |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
8 import java.util.concurrent.Callable; |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
9 |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
10 import org.apache.log4j.Logger; |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
11 |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
12 import digilib.io.FileOpException; |
557 | 13 import digilib.servlet.DigilibConfiguration; |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
14 |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
15 /** |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
16 * Worker that renders an image. |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
17 * |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
18 * @author casties |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
19 * |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
20 */ |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
21 public class ImageWorker implements Callable<DocuImage> { |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
22 |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
23 protected static Logger logger = Logger.getLogger(ImageWorker.class); |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
24 private DigilibConfiguration dlConfig; |
547 | 25 private ImageJobDescription jobinfo; |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
26 |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
27 /** flag for stopping the thread */ |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
28 private boolean stopNow = false; |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
29 |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
30 public ImageWorker(DigilibConfiguration dlConfig, |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
31 ImageJobDescription jobinfo) { |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
32 super(); |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
33 this.dlConfig = dlConfig; |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
34 this.jobinfo = jobinfo; |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
35 } |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
36 |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
37 /** |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
38 * render and return the image |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
39 */ |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
40 public DocuImage call() throws FileOpException, IOException, |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
41 ImageOpException { |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
42 |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
43 logger.debug("ImageWorker starting"); |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
44 long startTime = System.currentTimeMillis(); |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
45 if (stopNow) { |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
46 logger.debug("ImageWorker stopping (at the start)"); |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
47 return null; |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
48 } |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
49 |
906 | 50 DocuImage docuImage = jobinfo.getDocuImage(); |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
51 if (docuImage == null) { |
906 | 52 docuImage = DigilibConfiguration.getDocuImageInstance(); |
53 if (docuImage == null) { | |
54 throw new ImageOpException("Unable to load DocuImage class!"); | |
55 } | |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
56 } |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
57 |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
58 // set interpolation quality |
565 | 59 docuImage.setQuality(jobinfo.getScaleQual()); |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
60 |
547 | 61 Rectangle loadRect = jobinfo.getOuterUserImgArea().getBounds(); |
62 float scaleXY = jobinfo.getScaleXY(); | |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
63 |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
64 if (stopNow) { |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
65 logger.debug("ImageWorker stopping (after setup)"); |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
66 return null; |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
67 } |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
68 // use subimage loading if possible |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
69 if (docuImage.isSubimageSupported()) { |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
70 logger.debug("Subimage: scale " + scaleXY + " = " + (1 / scaleXY)); |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
71 float subf = 1f; |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
72 float subsamp = 1f; |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
73 if (scaleXY < 1) { |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
74 subf = 1 / scaleXY; |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
75 // for higher quality reduce subsample factor by minSubsample |
565 | 76 if (jobinfo.getScaleQual() > 0) { |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
77 subsamp = (float) Math |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
78 .max(Math.floor(subf |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
79 / dlConfig.getAsFloat("subsample-minimum")), |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
80 1d); |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
81 } else { |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
82 subsamp = (float) Math.floor(subf); |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
83 } |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
84 scaleXY = subsamp / subf; |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
85 logger.debug("Using subsampling: " + subsamp + " rest " |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
86 + scaleXY); |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
87 } |
593
7768ea8f59cf
more work on stream input -- cleaning up references to files
robcast
parents:
589
diff
changeset
|
88 docuImage.loadSubimage(jobinfo.getInput(), loadRect, (int) subsamp); |
570 | 89 logger.debug("SUBSAMP: " + subsamp + " -> " + docuImage.getSize()); |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
90 if (stopNow) { |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
91 logger.debug("ImageWorker stopping (after loading and cropping)"); |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
92 return null; |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
93 } |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
94 docuImage.scale(scaleXY, scaleXY); |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
95 } else { |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
96 // else load and crop the whole file |
593
7768ea8f59cf
more work on stream input -- cleaning up references to files
robcast
parents:
589
diff
changeset
|
97 docuImage.loadImage(jobinfo.getInput()); |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
98 if (stopNow) { |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
99 logger.debug("ImageWorker stopping (after loading)"); |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
100 return null; |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
101 } |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
102 docuImage.crop((int) loadRect.getX(), (int) loadRect.getY(), |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
103 (int) loadRect.getWidth(), (int) loadRect.getHeight()); |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
104 if (stopNow) { |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
105 logger.debug("ImageWorker stopping (after cropping)"); |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
106 return null; |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
107 } |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
108 docuImage.scale(scaleXY, scaleXY); |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
109 } |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
110 |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
111 if (stopNow) { |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
112 logger.debug("ImageWorker stopping (after scaling)"); |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
113 return null; |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
114 } |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
115 // mirror image |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
116 // operation mode: "hmir": mirror horizontally, "vmir": mirror |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
117 // vertically |
547 | 118 if (jobinfo.hasOption("hmir")) { |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
119 docuImage.mirror(0); |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
120 } |
547 | 121 if (jobinfo.hasOption("vmir")) { |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
122 docuImage.mirror(90); |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
123 } |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
124 |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
125 if (stopNow) { |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
126 logger.debug("ImageWorker stopping (after mirroring)"); |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
127 return null; |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
128 } |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
129 // rotate image |
547 | 130 if (jobinfo.getAsFloat("rot") != 0d) { |
131 docuImage.rotate(jobinfo.getAsFloat("rot")); | |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
132 /* |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
133 * if (jobinfo.get_wholeRotArea()) { // crop to the inner bounding |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
134 * box float xcrop = (float) (docuImage.getWidth() - |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
135 * jobinfo.get_innerUserImgArea().getWidth() scaleXY); float ycrop = |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
136 * (float) (docuImage.getHeight() - |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
137 * jobinfo.get_innerUserImgArea().getHeight() scaleXY); if ((xcrop > |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
138 * 0) || (ycrop > 0)) { // only crop smaller xcrop = (xcrop > 0) ? |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
139 * xcrop : 0; ycrop = (ycrop > 0) ? ycrop : 0; // crop image |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
140 * docuImage.crop((int) (xcrop / 2), (int) (ycrop / 2), (int) |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
141 * (docuImage.getWidth() - xcrop), (int) (docuImage.getHeight() - |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
142 * ycrop)); } } |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
143 */ |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
144 |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
145 } |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
146 |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
147 if (stopNow) { |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
148 logger.debug("ImageWorker stopping (after rotating)"); |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
149 return null; |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
150 } |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
151 // color modification |
547 | 152 float[] paramRGBM = jobinfo.getRGBM(); |
153 float[] paramRGBA = jobinfo.getRGBA(); | |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
154 if ((paramRGBM != null) || (paramRGBA != null)) { |
547 | 155 // make sure we actually have two arrays |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
156 if (paramRGBM == null) { |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
157 paramRGBM = new float[3]; |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
158 } |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
159 if (paramRGBA == null) { |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
160 paramRGBA = new float[3]; |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
161 } |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
162 // calculate "contrast" values (c=2^x) |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
163 float[] mult = new float[3]; |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
164 for (int i = 0; i < 3; i++) { |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
165 mult[i] = (float) Math.pow(2, (float) paramRGBM[i]); |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
166 } |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
167 docuImage.enhanceRGB(mult, paramRGBA); |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
168 } |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
169 |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
170 if (stopNow) { |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
171 logger.debug("ImageWorker stopping (after enhanceRGB)"); |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
172 return null; |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
173 } |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
174 // contrast and brightness enhancement |
547 | 175 float paramCONT = jobinfo.getAsFloat("cont"); |
176 float paramBRGT = jobinfo.getAsFloat("brgt"); | |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
177 if ((paramCONT != 0f) || (paramBRGT != 0f)) { |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
178 float mult = (float) Math.pow(2, paramCONT); |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
179 docuImage.enhance(mult, paramBRGT); |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
180 } |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
181 |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
182 if (stopNow) { |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
183 logger.debug("ImageWorker stopping (after enhance)"); |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
184 return null; |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
185 } |
829 | 186 // color operation |
187 DocuImage.ColorOp colop = jobinfo.getColOp(); | |
188 if (colop != null) { | |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
189 docuImage.colorOp(colop); |
829 | 190 } |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
191 |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
192 logger.debug("rendered in " + (System.currentTimeMillis() - startTime) |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
193 + "ms"); |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
194 |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
195 return docuImage; |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
196 } |
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
197 |
925
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
198 /** |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
199 * Set the stopNow flag. Thread stops at the next occasion. |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
200 */ |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
201 public void stopNow() { |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
202 this.stopNow = true; |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
203 } |
66f1ba72d07b
added timeout-parameter and timeout-handler to AsyncServletWorker.
robcast
parents:
906
diff
changeset
|
204 |
543
919e008ab1fb
more steps towards more standard java.util.concurrent design
robcast
parents:
diff
changeset
|
205 } |