Source Code Cross Referenced for MaxFilterDescriptor.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » javax » media » jai » operator » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » Java Advanced Imaging » javax.media.jai.operator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: MaxFilterDescriptor.java,v $
003:         *
004:         * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * Use is subject to license terms.
007:         *
008:         * $Revision: 1.1 $
009:         * $Date: 2005/02/11 04:57:39 $
010:         * $State: Exp $
011:         */
012:        package javax.media.jai.operator;
013:
014:        import com.sun.media.jai.util.AreaOpPropertyGenerator;
015:        import java.awt.RenderingHints;
016:        import java.awt.image.RenderedImage;
017:        import java.awt.image.renderable.ParameterBlock;
018:        import javax.media.jai.EnumeratedParameter;
019:        import javax.media.jai.JAI;
020:        import javax.media.jai.OperationDescriptorImpl;
021:        import javax.media.jai.ParameterBlockJAI;
022:        import javax.media.jai.PropertyGenerator;
023:        import javax.media.jai.RenderedOp;
024:        import javax.media.jai.operator.MaxFilterShape;
025:        import javax.media.jai.registry.RenderedRegistryMode;
026:
027:        /**
028:         * An <code>OperationDescriptor</code> describing the "MaxFilter" operation.
029:         *
030:         * <p> The "MaxFilter" operation is a non-linear filter which is
031:         * useful for removing isolated lines or pixels while preserving the
032:         * overall appearance of an image. The filter is implemented by moving
033:         * a mask over the image. For each position of the mask, the
034:         * center pixel is replaced by the max of the pixel values covered
035:         * by the mask.
036:         *
037:         * <p> There are several shapes possible for the mask.  The
038:         * MaxFilter operation supports three shapes, as follows:
039:         *
040:         * <p> Square Mask:
041:         * <pre>
042:         *                       x x x
043:         *                       x x x
044:         *                       x x x
045:         * </pre>
046:         *
047:         * <p> Plus Mask:
048:         * <pre>
049:         *                         x
050:         *                       x x x
051:         *                         x
052:         * </pre>
053:         *
054:         * <p> X Mask:
055:         * <pre>
056:         *                       x   x
057:         *                         x
058:         *                       x   x
059:         * </pre>
060:         *
061:         * <p>Example:
062:         * <pre>
063:         * 	SeekableStream s = new FileSeekableStream(new File(imagefilename); 
064:         *	ParameterBlock pb = new ParameterBlock();
065:         *      pb.add(s);
066:         *      RenderedImage src = (RenderedImage)JAI.create("stream", pb);
067:         *
068:         *      pb = new ParameterBlock();
069:         *      pb.addSource(src);
070:         *      pb.add(MaxFilterDescriptor.MAX_MASK_PLUS);    // mask Type
071:         *      pb.add(new Integer(5));                       // mask size
072:         *      
073:         *      RenderedImage dst = (RenderedImage)JAI.create("maxfilter", pb);
074:         * </pre>
075:         * <p> A RenderingHints can also be added to the above.
076:         *
077:         * It should be noted that this operation automatically adds a
078:         * value of <code>Boolean.TRUE</code> for the
079:         * <code>JAI.KEY_REPLACE_INDEX_COLOR_MODEL</code> to the given
080:         * <code>configuration</code> so that the operation is performed
081:         * on the pixel values instead of being performed on the indices into
082:         * the color map if the source(s) have an <code>IndexColorModel</code>.
083:         * This addition will take place only if a value for the 
084:         * <code>JAI.KEY_REPLACE_INDEX_COLOR_MODEL</code> has not already been
085:         * provided by the user. Note that the <code>configuration</code> Map
086:         * is cloned before the new hint is added to it. The operation can be 
087:         * smart about the value of the <code>JAI.KEY_REPLACE_INDEX_COLOR_MODEL</code>
088:         * <code>RenderingHints</code>, i.e. while the default value for the
089:         * <code>JAI.KEY_REPLACE_INDEX_COLOR_MODEL</code> is
090:         * <code>Boolean.TRUE</code>, in some cases the operator could set the
091:         * default. 
092:         *
093:         * <p><table align=center border=1>
094:         * <caption>Resource List</caption>
095:         * <tr><th>Name</th>        <th>Value</th></tr>
096:         * <tr><td>GlobalName</td>  <td>MaxFilter</td></tr>
097:         * <tr><td>LocallName</td>  <td>MaxFilter</td></tr>
098:         * <tr><td>Vendor</td>      <td>com.sun.media.jai</td></tr>
099:         * <tr><td>Description</td> <td>Performs max filtering on an image.</td></tr>
100:         * <tr><td>DocURL</td>      <td>http://java.sun.com/products/java-media/jai/forDevelopers/jaiapi/javax.media.jai.operator.MaxFilterDescriptor.html</td></tr>
101:         * <tr><td>Version</td>     <td>1.0</td></tr>
102:         * <tr><td>arg0Desc</td>    <td>The shape of the mask to be used for Max Filtering.</td></tr>
103:         * <tr><td>arg1Desc</td>    <td>The size (width/height) of the mask to be used in Max Filtering.</td></tr>
104:         * </table></p>
105:         *
106:         * <p><table align=center border=1>
107:         * <caption>Parameter List</caption>
108:         * <tr><th>Name</th>   <th>Class Type</th>
109:         *                     <th>Default Value</th></tr>
110:         * <tr><td>maskShape</td> <td>javax.media.jai.operator.MaxFilterShape</td>
111:         *                     <td>MAX_MASK_SQUARE</td>
112:         * <tr><td>maskSize</td> <td>java.lang.Integer</td>
113:         *                     <td>3</td>
114:         * </table></p>
115:         *
116:         * @see javax.media.jai.OperationDescriptor
117:         * @see MaxFilterShape
118:         *
119:         * @since JAI 1.1
120:         */
121:        public class MaxFilterDescriptor extends OperationDescriptorImpl {
122:
123:            /**
124:             * Default 3x3 Windows
125:             */
126:
127:            /** Square shaped mask. */
128:            public static final MaxFilterShape MAX_MASK_SQUARE = new MaxFilterShape(
129:                    "MAX_MASK_SQUARE", 1);
130:
131:            /** Plus shaped mask. */
132:            public static final MaxFilterShape MAX_MASK_PLUS = new MaxFilterShape(
133:                    "MAX_MASK_PLUS", 2);
134:
135:            /** X shaped mask. */
136:            public static final MaxFilterShape MAX_MASK_X = new MaxFilterShape(
137:                    "MAX_MASK_X", 3);
138:
139:            /** Separable square mask. */
140:            public static final MaxFilterShape MAX_MASK_SQUARE_SEPARABLE = new MaxFilterShape(
141:                    "MAX_MASK_SQUARE_SEPARABLE", 4);
142:
143:            /**
144:             * The resource strings that provide the general documentation
145:             * and specify the parameter list for this operation.
146:             */
147:            private static final String[][] resources = {
148:                    { "GlobalName", "MaxFilter" },
149:                    { "LocalName", "MaxFilter" },
150:                    { "Vendor", "com.sun.media.jai" },
151:                    { "Description", JaiI18N.getString("MaxFilterDescriptor0") },
152:                    {
153:                            "DocURL",
154:                            "http://java.sun.com/products/java-media/jai/forDevelopers/jaiapi/javax.media.jai.operator.MaxFilterDescriptor.html" },
155:                    { "Version", JaiI18N.getString("DescriptorVersion2") },
156:                    { "arg0Desc", JaiI18N.getString("MaxFilterDescriptor1") },
157:                    { "arg1Desc", JaiI18N.getString("MaxFilterDescriptor2") } };
158:
159:            /** The parameter class list for this operation. */
160:            private static final Class[] paramClasses = { MaxFilterShape.class,
161:                    java.lang.Integer.class };
162:
163:            /** The parameter name list for this operation. */
164:            private static final String[] paramNames = { "maskShape",
165:                    "maskSize" };
166:
167:            /** The parameter default value list for this operation. */
168:            private static final Object[] paramDefaults = { MAX_MASK_SQUARE,
169:                    new Integer(3) };
170:
171:            /** Constructor for the MaxFilterDescriptor. */
172:            public MaxFilterDescriptor() {
173:                super (resources, 1, paramClasses, paramNames, paramDefaults);
174:            }
175:
176:            /**
177:             * Returns the minimum legal value of a specified numeric parameter
178:             * for this operation.
179:             */
180:            public Number getParamMinValue(int index) {
181:                if (index == 0) {
182:                    return null;
183:                } else if (index == 1) {
184:                    return new Integer(1);
185:                } else {
186:                    throw new ArrayIndexOutOfBoundsException();
187:                }
188:            }
189:
190:            /**
191:             * Returns the maximum legal value of a specified numeric parameter
192:             * for this operation.
193:             */
194:            public Number getParamMaxValue(int index) {
195:                if (index == 0) {
196:                    return null;
197:                } else if (index == 1) {
198:                    return new Integer(Integer.MAX_VALUE);
199:                } else {
200:                    throw new ArrayIndexOutOfBoundsException();
201:                }
202:            }
203:
204:            /**
205:             * Returns an array of <code>PropertyGenerators</code> implementing
206:             * property inheritance for the "MaxFilter" operation.
207:             *
208:             * @return  An array of property generators.
209:             */
210:            public PropertyGenerator[] getPropertyGenerators() {
211:                PropertyGenerator[] pg = new PropertyGenerator[1];
212:                pg[0] = new AreaOpPropertyGenerator();
213:                return pg;
214:            }
215:
216:            /**
217:             * Performs max filtering on an image.
218:             *
219:             * <p>Creates a <code>ParameterBlockJAI</code> from all
220:             * supplied arguments except <code>hints</code> and invokes
221:             * {@link JAI#create(String,ParameterBlock,RenderingHints)}.
222:             *
223:             * @see JAI
224:             * @see ParameterBlockJAI
225:             * @see RenderedOp
226:             *
227:             * @param source0 <code>RenderedImage</code> source 0.
228:             * @param maskShape The shape of the mask to be used for Max Filtering.
229:             * May be <code>null</code>.
230:             * @param maskSize The size (width/height) of the mask to be used in Max Filtering.
231:             * May be <code>null</code>.
232:             * @param hints The <code>RenderingHints</code> to use.
233:             * May be <code>null</code>.
234:             * @return The <code>RenderedOp</code> destination.
235:             * @throws IllegalArgumentException if <code>source0</code> is <code>null</code>.
236:             */
237:            public static RenderedOp create(RenderedImage source0,
238:                    MaxFilterShape maskShape, Integer maskSize,
239:                    RenderingHints hints) {
240:                ParameterBlockJAI pb = new ParameterBlockJAI("MaxFilter",
241:                        RenderedRegistryMode.MODE_NAME);
242:
243:                pb.setSource("source0", source0);
244:
245:                pb.setParameter("maskShape", maskShape);
246:                pb.setParameter("maskSize", maskSize);
247:
248:                return JAI.create("MaxFilter", pb, hints);
249:            }
250:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.