KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > ext > awt > image > renderable > ProfileRable


1 /*
2
3    Copyright 2001,2003 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.image.renderable;
19
20 import java.awt.image.RenderedImage JavaDoc;
21 import java.awt.image.renderable.RenderContext JavaDoc;
22
23 import org.apache.batik.ext.awt.color.ICCColorSpaceExt;
24 import org.apache.batik.ext.awt.image.GraphicsUtil;
25 import org.apache.batik.ext.awt.image.rendered.CachableRed;
26 import org.apache.batik.ext.awt.image.rendered.ProfileRed;
27
28 /**
29  * Implements the interface expected from a color matrix
30  * operation
31  *
32  * @author <a HREF="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
33  * @version $Id: ProfileRable.java,v 1.5 2004/08/18 07:13:59 vhardy Exp $
34  */

35 public class ProfileRable extends AbstractRable{
36     
37     private ICCColorSpaceExt colorSpace;
38
39     /**
40      * Instances should be built through the static
41      * factory methods
42      */

43     public ProfileRable(Filter src, ICCColorSpaceExt colorSpace){
44         super(src);
45         this.colorSpace = colorSpace;
46     }
47
48     /**
49      * Sets the source of the blur operation
50      */

51     public void setSource(Filter src){
52         init(src, null);
53     }
54
55     /**
56      * Returns the source of the blur operation
57      */

58     public Filter getSource(){
59         return (Filter)getSources().get(0);
60     }
61
62     /**
63      * Sets the ColorSpace of the Profile operation
64      */

65     public void setColorSpace(ICCColorSpaceExt colorSpace){
66         touch();
67         this.colorSpace = colorSpace;
68     }
69
70     /**
71      * Returns the ColorSpace of the Profile operation
72      */

73     public ICCColorSpaceExt getColorSpace(){
74         return colorSpace;
75     }
76
77     public RenderedImage JavaDoc createRendering(RenderContext JavaDoc rc) {
78         //
79
// Get source's rendered image
80
//
81
RenderedImage JavaDoc srcRI = getSource().createRendering(rc);
82
83         if(srcRI == null)
84             return null;
85
86         CachableRed srcCR = GraphicsUtil.wrap(srcRI);
87         return new ProfileRed(srcCR, colorSpace);
88     }
89 }
90
Popular Tags