01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: /* $Id: $ */
19:
20: package org.apache.fop.render.bitmap;
21:
22: import java.awt.image.BufferedImage;
23:
24: import org.apache.avalon.framework.configuration.Configuration;
25: import org.apache.fop.apps.FOPException;
26: import org.apache.fop.apps.FOUserAgent;
27: import org.apache.fop.render.PrintRendererConfigurator;
28: import org.apache.fop.render.Renderer;
29:
30: /**
31: * TIFF Renderer configurator
32: */
33: public class TIFFRendererConfigurator extends PrintRendererConfigurator {
34:
35: /**
36: * Default constructor
37: * @param userAgent user agent
38: */
39: public TIFFRendererConfigurator(FOUserAgent userAgent) {
40: super (userAgent);
41: }
42:
43: /**
44: * Configure the TIFF renderer. Get the configuration to be used for
45: * compression
46: * @param renderer tiff renderer
47: * @throws FOPException fop exception
48: * @see org.apache.fop.render.PrintRendererConfigurator#configure(Renderer)
49: */
50: public void configure(Renderer renderer) throws FOPException {
51: Configuration cfg = super .getRendererConfig(renderer);
52: if (cfg != null) {
53: TIFFRenderer tiffRenderer = (TIFFRenderer) renderer;
54: //set compression
55: String name = cfg.getChild("compression").getValue(
56: TIFFRenderer.COMPRESSION_PACKBITS);
57: //Some compression formats need a special image format:
58: if (name
59: .equalsIgnoreCase(TIFFRenderer.COMPRESSION_CCITT_T6)) {
60: tiffRenderer
61: .setBufferedImageType(BufferedImage.TYPE_BYTE_BINARY);
62: } else if (name
63: .equalsIgnoreCase(TIFFRenderer.COMPRESSION_CCITT_T4)) {
64: tiffRenderer
65: .setBufferedImageType(BufferedImage.TYPE_BYTE_BINARY);
66: } else {
67: tiffRenderer
68: .setBufferedImageType(BufferedImage.TYPE_INT_ARGB);
69: }
70: if (!"NONE".equalsIgnoreCase(name)) {
71: tiffRenderer.getWriterParams().setCompressionMethod(
72: name);
73: }
74: if (log.isInfoEnabled()) {
75: log.info("TIFF compression set to " + name);
76: }
77: }
78: }
79: }
|