KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > ext > awt > RenderingHintsKeyExt


1 /*
2
3    Copyright 2001-2002,2004 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        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 package org.apache.batik.ext.awt;
19
20 import java.awt.RenderingHints JavaDoc;
21
22 /**
23  * Contains additional RenderingHints Keys, such as
24  * KEY_AREA_OF_INTEREST
25  *
26  * @author <a HREF="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
27  * @version $Id: RenderingHintsKeyExt.java,v 1.9 2004/09/06 00:01:58 deweese Exp $
28  */

29 public final class RenderingHintsKeyExt {
30     public static final int KEY_BASE;
31
32     /**
33      * Hint as to the transcoding destination.
34      */

35     public static final RenderingHints.Key JavaDoc KEY_TRANSCODING;
36
37     public static final String JavaDoc VALUE_TRANSCODING_PRINTING =
38         new String JavaDoc("Printing");
39
40     public static final String JavaDoc VALUE_TRANSCODING_VECTOR =
41         new String JavaDoc("Vector");
42
43     /**
44      * Key for the AOI hint. This hint is used to propagate the AOI to Paint
45      * and PaintContext instances.
46      */

47     public static final RenderingHints.Key JavaDoc KEY_AREA_OF_INTEREST;
48
49     /**
50      * Hint for the destination of the rendering when it is a BufferedImage
51      * This works around the fact that Java 2D sometimes lies about the
52      * attributes of the Graphics2D device, when it is an image.
53      *
54      * It is strongly suggested that you use
55      * org.apache.batik.ext.awt.image.GraphicsUtil.createGraphics to
56      * create a Graphics2D from a BufferedImage, this will ensure that
57      * the proper things are done in the processes of creating the
58      * Graphics. */

59     public static final RenderingHints.Key JavaDoc KEY_BUFFERED_IMAGE;
60
61     /**
62      * Hint to source that we only want an alpha channel.
63      * The source should follow the SVG spec for how to
64      * convert ARGB, RGB, Grey and AGrey to just an Alpha channel.
65      */

66     public static final RenderingHints.Key JavaDoc KEY_COLORSPACE;
67
68     /**
69      * Hint for the org.apache.batik.ext.awt.image.GraphicsUtil class that
70      * tiling of a bitmap during rendering is undesired. This is primarily
71      * for the PDF and PostScript transcoders where tiling can lead to
72      * suboptimal results due to overlaps in transparency and filter effects.
73      */

74     public static final RenderingHints.Key JavaDoc KEY_AVOID_TILE_PAINTING;
75
76     public static final Object JavaDoc VALUE_AVOID_TILE_PAINTING_ON = new Object JavaDoc();
77     public static final Object JavaDoc VALUE_AVOID_TILE_PAINTING_OFF = new Object JavaDoc();
78     public static final Object JavaDoc VALUE_AVOID_TILE_PAINTING_DEFAULT = new Object JavaDoc();
79
80     static {
81         int base = 10100;
82         RenderingHints.Key JavaDoc trans=null, aoi=null, bi=null, cs=null, atp=null;
83         while (true) {
84             int val = base;
85
86             try {
87                 trans = new TranscodingHintKey (val++);
88                 aoi = new AreaOfInterestHintKey(val++);
89                 bi = new BufferedImageHintKey (val++);
90                 cs = new ColorSpaceHintKey (val++);
91                 atp = new AvoidTilingHintKey (val++);
92             } catch (Exception JavaDoc e) {
93                 System.err.println
94                     ("You have loaded the Batik jar files more than once\n" +
95                      "in the same JVM this is likely a problem with the\n" +
96                      "way you are loading the Batik jar files.");
97                 
98                 base = (int)(Math.random()*2000000);
99                 continue;
100             }
101             break;
102         }
103         KEY_BASE = base;
104         KEY_TRANSCODING = trans;
105         KEY_AREA_OF_INTEREST = aoi;
106         KEY_BUFFERED_IMAGE = bi;
107         KEY_COLORSPACE = cs;
108         KEY_AVOID_TILE_PAINTING = atp;
109     }
110
111     /**
112      * Do not authorize creation of instances of that class
113      */

114     private RenderingHintsKeyExt(){
115     }
116 }
117
Popular Tags