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

COVERAGE SUMMARY FOR SOURCE FILE [ColorButton.java]

nameclass, %method, %block, %line, %
ColorButton.java0%   (0/2)0%   (0/17)0%   (0/132)0%   (0/34)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ColorButton0%   (0/1)0%   (0/15)0%   (0/96)0%   (0/28)
<static initializer> 0%   (0/1)0%   (0/3)0%   (0/1)
ColorButton (): void 0%   (0/1)0%   (0/4)0%   (0/2)
ColorButton (AlphaColorChooser): void 0%   (0/1)0%   (0/5)0%   (0/2)
ColorButton (Color): void 0%   (0/1)0%   (0/7)0%   (0/2)
ColorButton (Color, AlphaColorChooser): void 0%   (0/1)0%   (0/28)0%   (0/8)
access$000 (ColorButton): Color 0%   (0/1)0%   (0/3)0%   (0/1)
access$100 (ColorButton): AlphaColorChooser 0%   (0/1)0%   (0/3)0%   (0/1)
access$200 (ColorButton): String 0%   (0/1)0%   (0/3)0%   (0/1)
access$300 (ColorButton): HiveGuiApplicationMain 0%   (0/1)0%   (0/3)0%   (0/1)
getBaseline (int, int): int 0%   (0/1)0%   (0/12)0%   (0/2)
getColor (): Color 0%   (0/1)0%   (0/3)0%   (0/1)
getTitle (): String 0%   (0/1)0%   (0/3)0%   (0/1)
setApplication (HiveGuiApplicationMain): void 0%   (0/1)0%   (0/4)0%   (0/2)
setColor (Color): void 0%   (0/1)0%   (0/11)0%   (0/4)
setTitle (String): void 0%   (0/1)0%   (0/4)0%   (0/2)
     
class ColorButton$10%   (0/1)0%   (0/2)0%   (0/36)0%   (0/6)
ColorButton$1 (ColorButton): void 0%   (0/1)0%   (0/6)0%   (0/1)
actionPerformed (ActionEvent): void 0%   (0/1)0%   (0/30)0%   (0/5)

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.event.ActionEvent;
19import java.awt.event.ActionListener;
20 
21import javax.swing.JButton;
22 
23import net.sourceforge.hivegui.application.HiveGuiApplicationMain;
24 
25/**
26 * @author jean-Francois Poilpret
27 */
28public class ColorButton extends JButton
29{
30        static private final Color        DEFAULT_COLOR = Color.WHITE;
31        
32        public ColorButton()
33        {
34                this(DEFAULT_COLOR);
35        }
36        
37        public ColorButton(Color color)
38        {
39                this(color, new AlphaColorChooser());
40        }
41 
42        public ColorButton(AlphaColorChooser chooser)
43        {
44                this(DEFAULT_COLOR, chooser);
45        }
46        
47        public ColorButton(Color color, AlphaColorChooser chooser)
48        {
49                _color = color;
50                _chooser = chooser;
51                _icon = new DynSizeColorIcon(this);
52                setIcon(_icon);
53                addActionListener(new ActionListener()
54                {
55                        public void        actionPerformed(ActionEvent e)
56                        {
57                                // Display Color Chooser
58                                _chooser.setColor(_color);
59                                _chooser.setTitle(_title);
60                                _application.showDialog(_chooser);
61                                setColor(_chooser.getColor());
62                        }
63                });
64        }
65        
66        public String getTitle()
67        {
68                return _title;
69        }
70 
71        public void setTitle(String title)
72        {
73                _title = title;
74        }
75 
76        public void                setApplication(HiveGuiApplicationMain application)
77        {
78                _application = application;
79        }
80        
81        public void                setColor(Color color)
82        {
83                _color = color;
84                _icon.setColor(_color);
85                repaint();
86        }
87        
88        public Color        getColor()
89        {
90                return _color;
91        }
92        
93        // Workaround a problem with Java 6 where labels are aligned ABOVE
94        // the button!
95        public int getBaseline(int width, int height)
96        {
97                int iconHeight = getIcon().getIconHeight();
98                return iconHeight + (height - iconHeight) / 2;
99        }
100 
101        private Color                                        _color;
102        private String                                        _title = "";
103        private final ColorIcon                        _icon;
104        private final AlphaColorChooser        _chooser;
105        private HiveGuiApplicationMain        _application;
106}

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