KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > ext > awt > image > PadMode


1 /*
2
3    Copyright 2001 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;
19
20 /**
21  * This is a typesafe enumeration of the standard Composite rules for
22  * the CompositeRable operation. (over, in, out, atop, xor, arith)
23  *
24  * @author <a HREF="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
25  * @version $Id: PadMode.java,v 1.3 2004/08/18 07:13:49 vhardy Exp $
26  */

27 public final class PadMode implements java.io.Serializable JavaDoc {
28       /** Pad edges with zeros */
29     public static final int MODE_ZERO_PAD = 1;
30
31       /** Pad edges by replicating edge pixels */
32     public static final int MODE_REPLICATE = 2;
33
34       /** Pad edges by wrapping around edge pixels */
35     public static final int MODE_WRAP = 3;
36
37       /** Pad edges with zeros */
38     public static final PadMode ZERO_PAD = new PadMode(MODE_ZERO_PAD);
39
40       /** Pad edges by replicating edge pixels */
41     public static final PadMode REPLICATE = new PadMode(MODE_REPLICATE);
42
43       /** Pad edges by replicating edge pixels */
44     public static final PadMode WRAP = new PadMode(MODE_WRAP);
45
46     /**
47      * Returns the mode of this pad mode.
48      */

49     public int getMode() {
50         return mode;
51     }
52
53       /**
54        * The pad mode for this object.
55        */

56     private int mode;
57
58     private PadMode(int mode) {
59         this.mode = mode;
60     }
61
62     /**
63      * This is called by the serialization code before it returns
64      * an unserialized object. To provide for unicity of
65      * instances, the instance that was read is replaced by its
66      * static equivalent. See the serialiazation specification for
67      * further details on this method's logic.
68      */

69     private Object JavaDoc readResolve() throws java.io.ObjectStreamException JavaDoc {
70         switch(mode){
71         case MODE_ZERO_PAD:
72             return ZERO_PAD;
73         case MODE_REPLICATE:
74             return REPLICATE;
75         case MODE_WRAP:
76             return WRAP;
77         default:
78             throw new Error JavaDoc("Unknown Pad Mode type");
79         }
80     }
81 }
82
Popular Tags