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: import java.util.ArrayList;
20: import java.util.List;
21:
22: /**
23: * A simple implementation of the color map interface.
24: *
25: * @author iant
26: * @author aaime
27: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/styling/ColorMapImpl.java $
28: */
29: public class ColorMapImpl extends AbstractGTComponent implements
30: ColorMap {
31: private List list = new ArrayList();
32: private int type = ColorMap.TYPE_RAMP;
33:
34: public void addColorMapEntry(ColorMapEntry entry) {
35: list.add(entry);
36: }
37:
38: public ColorMapEntry[] getColorMapEntries() {
39: return (ColorMapEntry[]) list.toArray(new ColorMapEntry[0]);
40: }
41:
42: public ColorMapEntry getColorMapEntry(int index) {
43: return (ColorMapEntry) list.get(index);
44: }
45:
46: /**
47: * @see org.geotools.styling.ColorMap#getType()
48: */
49: public int getType() {
50: return type;
51: }
52:
53: /**
54: * @see org.geotools.styling.ColorMap#setType(int)
55: */
56: public void setType(int type) {
57: if ((type < TYPE_RAMP) || (type > TYPE_VALUES)) {
58: throw new IllegalArgumentException();
59: }
60:
61: this .type = type;
62: fireChanged();
63: }
64:
65: public void accept(StyleVisitor visitor) {
66: visitor.visit(this);
67: }
68: }
|