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 java.awt.Component; 019 import java.awt.Graphics; 020 021 import javax.swing.Icon; 022 023 /** 024 * A empty icon is a blank icon useful for ensuring alignment in menus between 025 * menuitems that have and do not have icons. 026 * 027 * @author Keith Donald 028 * @see javax.swing.Icon 029 */ 030 public final class EmptyIcon implements Icon { 031 032 /** 033 * Convenience object for small icons, whose size matches the size of small 034 * icons in Sun's graphics repository. 035 */ 036 public static final EmptyIcon SMALL = new EmptyIcon(IconSize.SMALL); 037 038 /** 039 * Convenience object for large icons, whose size matches the size of large 040 * icons in Sun's graphics repository. 041 */ 042 public static final EmptyIcon LARGE = new EmptyIcon(IconSize.LARGE); 043 044 private IconSize size; 045 046 /** 047 * EmptyIcon objects are always square, having identical height and width. 048 * 049 * @param size 050 * The size of the empty icon. Icons are always equal on all 051 * sides. 052 */ 053 public EmptyIcon(IconSize size) { 054 this.size = size; 055 } 056 057 public int getIconWidth() { 058 return this.size.getValue(); 059 } 060 061 public int getIconHeight() { 062 return this.size.getValue(); 063 } 064 065 /** 066 * This implementation is empty, and paints nothing. 067 */ 068 public void paintIcon(Component c, Graphics g, int x, int y) { 069 //empty 070 } 071 }