1 /*
2 * Copyright 2002-2007 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16 package org.springframework.richclient.test;
17
18 import java.awt.Color;
19 import java.awt.Component;
20 import java.awt.Graphics;
21 import java.awt.Graphics2D;
22
23 import javax.swing.Icon;
24
25 /**
26 * Icon suitable for testing purposes.
27 *
28 * @author Peter De Bruycker
29 */
30 public class TestIcon implements Icon{
31
32 private Color color;
33
34 public TestIcon(Color color) {
35 this.color = color;
36 }
37
38 public int getIconHeight() {
39 return 16;
40 }
41
42 public int getIconWidth() {
43 return 16;
44 }
45
46 public void paintIcon(Component c, Graphics g, int x, int y) {
47 Graphics2D graphics = (Graphics2D) g.create();
48
49 graphics.setColor(color);
50 graphics.fillRect(x, y, 16, 16);
51
52 graphics.dispose();
53 }
54
55 }