01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library 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 GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.styling;
17:
18: import org.geotools.event.AbstractGTComponent;
19:
20: /**
21: * DOCUMENT ME!
22: *
23: * @author iant
24: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/styling/ChannelSelectionImpl.java $
25: */
26: public class ChannelSelectionImpl extends AbstractGTComponent implements
27: ChannelSelection {
28: private SelectedChannelType gray;
29: private SelectedChannelType red;
30: private SelectedChannelType blue;
31: private SelectedChannelType green;
32:
33: public SelectedChannelType getGrayChannel() {
34: return gray;
35: }
36:
37: public SelectedChannelType[] getRGBChannels() {
38: return new SelectedChannelType[] { red, green, blue };
39: }
40:
41: public SelectedChannelType[] getSelectedChannels() {
42: SelectedChannelType[] ret;
43:
44: if (gray == null) {
45: ret = new SelectedChannelType[] { red, green, blue };
46: } else {
47: ret = new SelectedChannelType[] { gray };
48: }
49:
50: return ret;
51: }
52:
53: public void setGrayChannel(SelectedChannelType gray) {
54: this .gray = gray;
55: fireChanged();
56: }
57:
58: public void setRGBChannels(SelectedChannelType[] channels) {
59: if (channels.length != 3) {
60: throw new IllegalArgumentException(
61: "Three channels are required in setRGBChannels, got "
62: + channels.length);
63: }
64:
65: red = channels[0];
66: green = channels[1];
67: blue = channels[2];
68: fireChanged();
69: }
70:
71: public void setRGBChannels(SelectedChannelType red,
72: SelectedChannelType green, SelectedChannelType blue) {
73: this .red = red;
74: this .green = green;
75: this .blue = blue;
76: fireChanged();
77: }
78:
79: public void setSelectedChannels(SelectedChannelType[] channels) {
80: if (channels.length == 1) {
81: gray = channels[0];
82: } else if (channels.length == 3) {
83: red = channels[0];
84: green = channels[1];
85: blue = channels[2];
86: } else {
87: throw new IllegalArgumentException(
88: "Wrong number of elements in setSelectedChannels, expected 1 or 3, got "
89: + channels.length);
90: }
91:
92: fireChanged();
93: }
94: }
|