01: /*
02: * @(#) $Header: /cvs/jai-operators/src/main/ca/forklabs/media/jai/OpImageUtil.java,v 1.1 2007/07/03 19:05:42 forklabs Exp $
03: *
04: * Copyright (C) 2007 Forklabs Daniel Léonard
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU General Public License
08: * as published by the Free Software Foundation; either version 2
09: * of the License, or (at your option) any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19: */
20:
21: package ca.forklabs.media.jai;
22:
23: import java.util.Collection;
24: import java.util.Vector;
25: import javax.media.jai.OpImage;
26: import ca.forklabs.baselib.util.Algorithm;
27: import ca.forklabs.baselib.util.Iterators;
28:
29: /**
30: * Class {@link OpImageUtil} provides useful routines for {@link OpImage}s.
31: *
32: * @author <a href="mailto:forklabs at dev.java.net?subject=ca.forklabs.media.jai.OpImageUtil">Daniel Léonard</a>
33: * @version $Revision: 1.1 $
34: */
35: public class OpImageUtil {
36:
37: //---------------------------
38: // Constructor
39: //---------------------------
40:
41: /**
42: * Only allow subclasses.
43: */
44: protected OpImageUtil() {
45: // nothing
46: }
47:
48: //---------------------------
49: // Class methods
50: //---------------------------
51:
52: /**
53: * Vectorizes the collection.
54: * @param <E> the type of elements in the vector.
55: * @param collection the collection.
56: * @return the collection as a vector.
57: */
58: public static <E> Vector<E> vectorize(Collection<E> collection) {
59: Vector<E> vector;
60: if (collection instanceof Vector) {
61: vector = (Vector<E>) collection;
62: } else {
63: int size = collection.size();
64: vector = new Vector<E>(size);
65: Algorithm.copy(collection.iterator(), Iterators
66: .backInserter(vector));
67: }
68: return vector;
69: }
70:
71: }
72:
73: /*
74: * $Log: OpImageUtil.java,v $
75: * Revision 1.1 2007/07/03 19:05:42 forklabs
76: * Removed the listerize method and moved the class to its new home.
77: *
78: * Revision 1.1 2007/06/13 18:56:37 forklabs
79: * Operator mediancollection.
80: *
81: */
|