Mercurial > hg > digilib-old
comparison servlet/src/digilib/servlet/Scaler.java @ 394:31643c12d939
digilib can now take its error-icons from the web app
| author | robcast |
|---|---|
| date | Wed, 07 Dec 2005 19:06:32 +0100 |
| parents | b37d2737b342 |
| children | ffb2036da205 |
comparison
equal
deleted
inserted
replaced
| 393:8a9fd4d64ea7 | 394:31643c12d939 |
|---|---|
| 57 public class Scaler extends HttpServlet { | 57 public class Scaler extends HttpServlet { |
| 58 | 58 |
| 59 private static final long serialVersionUID = -325080527268912852L; | 59 private static final long serialVersionUID = -325080527268912852L; |
| 60 | 60 |
| 61 /** digilib servlet version (for all components) */ | 61 /** digilib servlet version (for all components) */ |
| 62 public static final String dlVersion = "1.5.9f"; | 62 public static final String dlVersion = "1.5.9g"; |
| 63 | 63 |
| 64 /** logger for accounting requests */ | 64 /** logger for accounting requests */ |
| 65 private static Logger accountlog = Logger.getLogger("account.request"); | 65 private static Logger accountlog = Logger.getLogger("account.request"); |
| 66 | 66 |
| 67 /** gengeral logger for this class */ | 67 /** gengeral logger for this class */ |
| 145 useAuthorization = dlConfig.getAsBoolean("use-authorization"); | 145 useAuthorization = dlConfig.getAsBoolean("use-authorization"); |
| 146 authOp = (AuthOps) dlConfig.getValue("servlet.auth.op"); | 146 authOp = (AuthOps) dlConfig.getValue("servlet.auth.op"); |
| 147 | 147 |
| 148 // DocuDirCache instance | 148 // DocuDirCache instance |
| 149 dirCache = (DocuDirCache) dlConfig.getValue("servlet.dir.cache"); | 149 dirCache = (DocuDirCache) dlConfig.getValue("servlet.dir.cache"); |
| 150 denyImgFile = (File) dlConfig.getValue("denied-image"); | 150 denyImgFile = ServletOps.getFile((File) dlConfig.getValue("denied-image"), config); |
| 151 errorImgFile = (File) dlConfig.getValue("error-image"); | 151 errorImgFile = ServletOps.getFile((File) dlConfig.getValue("error-image"), config); |
| 152 notfoundImgFile = (File) dlConfig.getValue("notfound-image"); | 152 notfoundImgFile = ServletOps.getFile((File) dlConfig.getValue("notfound-image"), config); |
| 153 sendFileAllowed = dlConfig.getAsBoolean("sendfile-allowed"); | 153 sendFileAllowed = dlConfig.getAsBoolean("sendfile-allowed"); |
| 154 minSubsample = dlConfig.getAsFloat("subsample-minimum"); | 154 minSubsample = dlConfig.getAsFloat("subsample-minimum"); |
| 155 defaultQuality = dlConfig.getAsInt("default-quality"); | 155 defaultQuality = dlConfig.getAsInt("default-quality"); |
| 156 } | 156 } |
| 157 | 157 |
| 225 | 225 |
| 226 // scale the image file to fit window size i.e. respect dw,dh | 226 // scale the image file to fit window size i.e. respect dw,dh |
| 227 boolean scaleToFit = true; | 227 boolean scaleToFit = true; |
| 228 // scale the image by a fixed factor only | 228 // scale the image by a fixed factor only |
| 229 boolean absoluteScale = false; | 229 boolean absoluteScale = false; |
| 230 // only crop the image to fit | |
| 231 boolean cropToFit = false; | |
| 232 // send the file as is | |
| 233 boolean sendFile = false; | |
| 234 // use low resolution images only | 230 // use low resolution images only |
| 235 boolean loresOnly = false; | 231 boolean loresOnly = false; |
| 236 // use hires images only | 232 // use hires images only |
| 237 boolean hiresOnly = false; | 233 boolean hiresOnly = false; |
| 238 // send the image always as a specific type (e.g. JPEG or PNG) | 234 // send the image always as a specific type (e.g. JPEG or PNG) |
| 239 int forceType = ImageOps.TYPE_AUTO; | 235 int forceType = ImageOps.TYPE_AUTO; |
| 240 // interpolation to use for scaling | 236 // interpolation to use for scaling |
| 241 int scaleQual = defaultQuality; | 237 int scaleQual = defaultQuality; |
| 242 // send html error message (or image file) | 238 // send html error message (or image file) |
| 243 boolean errorMsgHtml = false; | 239 boolean errorMsgHtml = false; |
| 244 // mirror the image | |
| 245 boolean doMirror = false; | |
| 246 // angle of mirror axis | |
| 247 float mirrorAngle = 0; | |
| 248 // original (hires) image resolution | 240 // original (hires) image resolution |
| 249 float origResX = 0; | 241 float origResX = 0; |
| 250 float origResY = 0; | 242 float origResY = 0; |
| 251 | 243 |
| 252 /* request parameters */ | 244 /* request parameters */ |
| 299 * resolution cropped, "file": send whole file (if allowed) | 291 * resolution cropped, "file": send whole file (if allowed) |
| 300 */ | 292 */ |
| 301 if (dlRequest.hasOption("mo", "clip")) { | 293 if (dlRequest.hasOption("mo", "clip")) { |
| 302 scaleToFit = false; | 294 scaleToFit = false; |
| 303 absoluteScale = false; | 295 absoluteScale = false; |
| 304 cropToFit = true; | |
| 305 sendFile = false; | |
| 306 hiresOnly = true; | 296 hiresOnly = true; |
| 307 } else if (dlRequest.hasOption("mo", "fit")) { | 297 } else if (dlRequest.hasOption("mo", "fit")) { |
| 308 scaleToFit = true; | 298 scaleToFit = true; |
| 309 absoluteScale = false; | 299 absoluteScale = false; |
| 310 cropToFit = false; | |
| 311 sendFile = false; | |
| 312 hiresOnly = false; | 300 hiresOnly = false; |
| 313 } else if (dlRequest.hasOption("mo", "osize")) { | 301 } else if (dlRequest.hasOption("mo", "osize")) { |
| 314 scaleToFit = false; | 302 scaleToFit = false; |
| 315 absoluteScale = true; | 303 absoluteScale = true; |
| 316 cropToFit = false; | |
| 317 sendFile = false; | |
| 318 hiresOnly = true; | 304 hiresOnly = true; |
| 319 } | 305 } |
| 320 // operation mode: "lores": try to use scaled image, "hires": use | 306 // operation mode: "lores": try to use scaled image, "hires": use |
| 321 // unscaled image | 307 // unscaled image |
| 322 // "autores": try best fitting resolution | 308 // "autores": try best fitting resolution |
| 541 + imgSize.getHeight()); | 527 + imgSize.getHeight()); |
| 542 logger.debug("time " + (System.currentTimeMillis() - startTime) | 528 logger.debug("time " + (System.currentTimeMillis() - startTime) |
| 543 + "ms"); | 529 + "ms"); |
| 544 | 530 |
| 545 // coordinates and scaling | 531 // coordinates and scaling |
| 546 float areaXoff; | |
| 547 float areaYoff; | |
| 548 float areaWidth; | 532 float areaWidth; |
| 549 float areaHeight; | 533 float areaHeight; |
| 550 float scaleX; | 534 float scaleX; |
| 551 float scaleY; | 535 float scaleY; |
| 552 float scaleXY; | 536 float scaleXY; |
