001 /* 002 * Copyright 2002-2007 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 005 * use this file except in compliance with the License. You may obtain a copy of 006 * 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, WITHOUT 012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 013 * License for the specific language governing permissions and limitations under 014 * the License. 015 */ 016 package org.springframework.richclient.test; 017 018 import java.awt.Color; 019 import java.awt.Component; 020 import java.awt.Graphics; 021 import java.awt.Graphics2D; 022 023 import javax.swing.Icon; 024 025 /** 026 * Icon suitable for testing purposes. 027 * 028 * @author Peter De Bruycker 029 */ 030 public class TestIcon implements Icon{ 031 032 private Color color; 033 034 public TestIcon(Color color) { 035 this.color = color; 036 } 037 038 public int getIconHeight() { 039 return 16; 040 } 041 042 public int getIconWidth() { 043 return 16; 044 } 045 046 public void paintIcon(Component c, Graphics g, int x, int y) { 047 Graphics2D graphics = (Graphics2D) g.create(); 048 049 graphics.setColor(color); 050 graphics.fillRect(x, y, 16, 16); 051 052 graphics.dispose(); 053 } 054 055 }