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

COVERAGE SUMMARY FOR SOURCE FILE [DynSizeColorIcon.java]

nameclass, %method, %block, %line, %
DynSizeColorIcon.java0%   (0/1)0%   (0/8)0%   (0/61)0%   (0/17)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DynSizeColorIcon0%   (0/1)0%   (0/8)0%   (0/61)0%   (0/17)
DynSizeColorIcon (Component): void 0%   (0/1)0%   (0/5)0%   (0/2)
DynSizeColorIcon (Component, int): void 0%   (0/1)0%   (0/6)0%   (0/2)
DynSizeColorIcon (Component, int, int): void 0%   (0/1)0%   (0/12)0%   (0/5)
getColor (): Color 0%   (0/1)0%   (0/3)0%   (0/1)
getIconHeight (): int 0%   (0/1)0%   (0/9)0%   (0/1)
getIconWidth (): int 0%   (0/1)0%   (0/9)0%   (0/1)
paintIcon (Component, Graphics, int, int): void 0%   (0/1)0%   (0/13)0%   (0/3)
setColor (Color): void 0%   (0/1)0%   (0/4)0%   (0/2)

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.awt.Color;
18import java.awt.Component;
19import java.awt.Graphics;
20 
21/**
22 * Specific Icon implementation that simply displays as a rectangle of a given
23 * color (which is settable).
24 * This is particularly useful for creating a colored JToggleButton in a
25 * JToolBar.
26 *
27 * @author jean-Francois Poilpret
28 */
29public class DynSizeColorIcon implements ColorIcon
30{
31        public DynSizeColorIcon(Component parent)
32        {
33                this(parent, DEFAULT_INSET);
34        }
35 
36        public DynSizeColorIcon(Component parent, int inset)
37        {
38                this(parent, inset, inset);
39        }
40        
41        public DynSizeColorIcon(Component parent, int insetX, int insetY)
42        {
43                _parent = parent;
44                _insetX = insetX;
45                _insetY = insetY;
46        }
47 
48        public void                setColor(Color color)
49        {
50                _color = color;
51        }
52        
53        public Color        getColor()
54        {
55                return _color;
56        }
57        
58        public int        getIconWidth()
59        {
60                return _parent.getWidth() - 2 * _insetX;
61        }
62        
63        public int        getIconHeight()
64        {
65                return _parent.getHeight() - 2 * _insetY;
66        }
67 
68        public void        paintIcon(Component c, Graphics g, int x, int y)
69        {
70                g.setColor(_color);
71                g.fillRect(x, y, getIconWidth(), getIconHeight());
72        }
73 
74        private final Component        _parent;
75        private final int                _insetX;
76        private final int                _insetY;
77        private Color                        _color;
78        
79        static private final int        DEFAULT_INSET        = 4;
80}

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