EMMA Coverage Report (generated Tue Feb 12 22:23:49 ICT 2008)
[all classes][net.sourceforge.hivegui.component]

COVERAGE SUMMARY FOR SOURCE FILE [IconMapRendererDelegate.java]

nameclass, %method, %block, %line, %
IconMapRendererDelegate.java0%   (0/1)0%   (0/6)0%   (0/106)0%   (0/25)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class IconMapRendererDelegate0%   (0/1)0%   (0/6)0%   (0/106)0%   (0/25)
IconMapRendererDelegate (): void 0%   (0/1)0%   (0/13)0%   (0/3)
addIcon (Object): void 0%   (0/1)0%   (0/19)0%   (0/5)
addIcon (Object, Icon): void 0%   (0/1)0%   (0/7)0%   (0/2)
getCellHeight (): int 0%   (0/1)0%   (0/30)0%   (0/6)
init (): void 0%   (0/1)0%   (0/26)0%   (0/6)
setValue (JLabel, Object): void 0%   (0/1)0%   (0/11)0%   (0/3)

1//  Copyright 2004-2007 Jean-Francois Poilpret
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14 
15package net.sourceforge.hivegui.component;
16 
17import java.util.HashMap;
18import java.util.HashSet;
19import java.util.Map;
20import java.util.Set;
21 
22import javax.swing.Icon;
23import javax.swing.JLabel;
24 
25public class IconMapRendererDelegate extends AbstractRendererDelegate
26        implements RendererInformation
27{
28        @Override protected void init()
29        {
30                for (Object value: _keys)
31                {
32                        String key = getKey(value);
33                        addIcon(value, _map.getIcon(key));
34                }
35                _keys = null;
36        }
37        
38        public void        addIcon(Object value)
39        {
40                if (_map != null)
41                {
42                        addIcon(value, _map.getIcon(getKey(value)));
43                }
44                else
45                {
46                        _keys.add(value);
47                }
48        }
49        
50        public void        addIcon(Object value, Icon icon)
51        {
52                _icons.put(value, icon);
53        }
54        
55        public int        getCellHeight()
56        {
57                if (_height == 0)
58                {
59                        for (Icon icon: _icons.values())
60                        {
61                                if (icon != null && icon.getIconHeight() > _height)
62                                {
63                                        _height = icon.getIconHeight();
64                                }
65                        }
66                }
67                return _height;
68        }
69 
70        @Override public void setValue(JLabel renderer, Object value)
71        {
72                renderer.setIcon(_icons.get(value));
73                renderer.setText(null);
74        }
75 
76        private Set<Object>                                _keys = new HashSet<Object>();
77        private final Map<Object, Icon>        _icons = new HashMap<Object, Icon>();
78        private int                                                _height;
79}

[all classes][net.sourceforge.hivegui.component]
EMMA 2.0.5312 (C) Vladimir Roubtsov