EMMA Coverage Report (generated Wed Feb 13 07:49:24 ICT 2008)
[all classes][net.sourceforge.hiveboard.drawing]

COVERAGE SUMMARY FOR SOURCE FILE [ColorPropertyTool.java]

nameclass, %method, %block, %line, %
ColorPropertyTool.java100% (2/2)100% (8/8)100% (128/128)100% (32/32)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ColorPropertyTool100% (1/1)100% (6/6)100% (92/92)100% (23/23)
ColorPropertyTool (AlphaColorChooser): void 100% (1/1)100% (26/26)100% (7/7)
accept (): void 100% (1/1)100% (36/36)100% (9/9)
access$000 (ColorPropertyTool): Color 100% (1/1)100% (3/3)100% (1/1)
access$100 (ColorPropertyTool): ColorIcon 100% (1/1)100% (3/3)100% (1/1)
initProperty (): void 100% (1/1)100% (8/8)100% (2/2)
initResources (ResourceMap): void 100% (1/1)100% (16/16)100% (4/4)
     
class ColorPropertyTool$1100% (1/1)100% (2/2)100% (36/36)100% (9/9)
ColorPropertyTool$1 (ColorPropertyTool): void 100% (1/1)100% (6/6)100% (1/1)
propertyChange (PropertyChangeEvent): void 100% (1/1)100% (30/30)100% (8/8)

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.hiveboard.drawing;
16 
17import java.awt.Color;
18import java.beans.PropertyChangeEvent;
19import java.beans.PropertyChangeListener;
20 
21import org.jdesktop.application.Resource;
22import org.jdesktop.application.ResourceMap;
23 
24import net.sourceforge.hivegui.component.AlphaColorChooser;
25import net.sourceforge.hivegui.component.ColorIcon;
26import net.sourceforge.hivegui.component.FixedSizeColorIcon;
27 
28public class ColorPropertyTool extends AbstractPushButtonTool
29{
30        static final public String                TOOL_PROPERTY_COLOR = "Color";
31 
32        static final private int                COLOR_ICON_SIZE                = 16;
33        static final private int                COLOR_ICON_INSET        = 2;
34        
35        public ColorPropertyTool(AlphaColorChooser chooser)
36        {
37                _chooser = chooser;
38                _icon = new FixedSizeColorIcon(        COLOR_ICON_SIZE - 2 * COLOR_ICON_INSET, 
39                                                                                COLOR_ICON_SIZE - 2 * COLOR_ICON_INSET, 
40                                                                                COLOR_ICON_INSET, 
41                                                                                COLOR_ICON_INSET);
42                _icon.setColor(_color);
43        }
44        
45        @Override protected void initProperty()
46        {
47                _properties.put(TOOL_PROPERTY_COLOR, _color);
48        }
49 
50        @Override protected void initResources(ResourceMap map)
51        {
52                super.initResources(map);
53                _button.setIcon(_icon);
54                _button.addPropertyChangeListener(new PropertyChangeListener()
55                {
56                        public void propertyChange(PropertyChangeEvent e)
57                        {
58                                if ("enabled".equals(e.getPropertyName()))
59                                {
60                                        boolean enabled = ((Boolean) e.getNewValue()).booleanValue();
61                                        if (enabled)
62                                        {
63                                                _icon.setColor(_color);
64                                        }
65                                        else
66                                        {
67                                                _icon.setColor(Color.GRAY);
68                                        }
69                                        _button.repaint();
70                                }
71                        }
72                });
73        }
74 
75        @Override public void accept()
76        {
77                // Open Color chooser
78                _chooser.setTitle(_chooserTitle);
79                _chooser.setColor(_color);
80                _application.showDialog(_chooser);
81                _button.setSelected(false);
82                _color = _chooser.getColor();
83                _icon.setColor(_color);
84                _button.repaint();
85                initProperty();
86        }
87 
88        private final AlphaColorChooser        _chooser;
89        @Resource(key = "chooserTitle")
90        private String                                        _chooserTitle = "";
91        private Color                                        _color = Color.BLACK;
92        private final ColorIcon                        _icon;
93}

[all classes][net.sourceforge.hiveboard.drawing]
EMMA 2.0.5312 (C) Vladimir Roubtsov