01: /*
02: * @(#) $Header: /cvs/jai-operators/src/main/ca/forklabs/media/jai/CollectionImageUtil.java,v 1.1 2007/07/04 23:56:54 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 javax.media.jai.CollectionImage;
25:
26: /**
27: * Class {@code CollectionImageUtil} provides helpful methods that deals with
28: * {@link CollectionImage}.
29: *
30: * @author <a href="mailto:forklabs at dev.java.net?subject=ca.forklabs.media.jai.CollectionImageUtil">Daniel Léonard</a>
31: * @version $Revision: 1.1 $
32: */
33: public class CollectionImageUtil {
34:
35: //---------------------------
36: // Constructors
37: //---------------------------
38:
39: /**
40: * Only allow subclasses.
41: */
42: protected CollectionImageUtil() {
43: // nothing
44: }
45:
46: //---------------------------
47: // Class variables
48: //---------------------------
49:
50: /**
51: * Transforms any collection into a {@link CollectionImage}. The content of
52: * the collection should be all {@link RenderedImage}s or all
53: * {@link RenderableImage}s.
54: * @param collection the collection.
55: * @return the {@code CollectionImage}.
56: */
57: public static CollectionImage asCollectionImage(
58: Collection<?> collection) {
59: CollectionImage collection_image;
60: if (collection instanceof CollectionImage) {
61: collection_image = (CollectionImage) collection;
62: } else {
63: collection_image = new SimpleCollectionImage(collection);
64: }
65: return collection_image;
66: }
67:
68: }
69:
70: /*
71: * $Log: CollectionImageUtil.java,v $
72: * Revision 1.1 2007/07/04 23:56:54 forklabs
73: * Class CollectionImageUtil.
74: *
75: */
|