001    /*
002     * Copyright 2002-2004 the original author or authors.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.springframework.richclient.image;
017    
018    import org.springframework.util.Assert;
019    import org.springframework.util.StringUtils;
020    
021    /**
022     * Enum for various supported icon sizes.
023     * 
024     * @author Keith Donald
025     */
026    public class IconSize {
027        private String name;
028    
029        private int pixels;
030    
031        /**
032         * The standard 16 pixel "small" icon.
033         */
034        public static final IconSize SMALL = new IconSize("small", 16);
035    
036        /**
037         * The standard 24 pixel "large" icon.
038         */
039        public static final IconSize LARGE = new IconSize("large", 24);
040    
041        private IconSize(String name, int value) {
042            Assert.isTrue(StringUtils.hasText(name));
043            this.name = name;
044            this.pixels = value;
045        }
046    
047        /**
048         * Returns the icon size name.
049         * 
050         * @return The logical name of the icon size.
051         */
052        public String getName() {
053            return name;
054        }
055    
056        /**
057         * Returns the size value in pixels.
058         * 
059         * @return The value in pixels.
060         */
061        public int getValue() {
062            return pixels;
063        }
064    
065        public String toString() {
066            return "[IconSize name = '" + getName() + "', value = " + getValue() + "]";
067        }
068    }