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

COVERAGE SUMMARY FOR SOURCE FILE [AlphaColorSelectionModel.java]

nameclass, %method, %block, %line, %
AlphaColorSelectionModel.java0%   (0/1)0%   (0/3)0%   (0/30)0%   (0/8)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AlphaColorSelectionModel0%   (0/1)0%   (0/3)0%   (0/30)0%   (0/8)
AlphaColorSelectionModel (): void 0%   (0/1)0%   (0/6)0%   (0/2)
setAlpha (int, boolean): void 0%   (0/1)0%   (0/10)0%   (0/4)
setSelectedColor (Color): void 0%   (0/1)0%   (0/14)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;
18 
19import javax.swing.colorchooser.DefaultColorSelectionModel;
20 
21/**
22 * Special ColorSelectionModel that supports the alpha channel.
23 * It is supposed to be used in conjunction with special RGBAChooserPanel
24 * (instead of swing DefaultRGBChooserPanel).
25 *
26 * @author Jean-Francois Poilpret
27 */
28public class AlphaColorSelectionModel extends DefaultColorSelectionModel
29{
30        /**
31         * Allows to explicitely set the alpha channel of the color (transparency).
32         * This is the only way to set the alpha (do not use
33         * <code>setSelectedColor</code> it will ignore the alpha channel of its
34         * <code>color</code> argument).
35         */
36        public void        setAlpha(int alpha, boolean refresh)
37        {
38                _alpha = alpha;
39                if (refresh)
40                {
41                        // The following line enforces update of the color in the parent
42                        // class and notification of all listeners.
43                        setSelectedColor(getSelectedColor());
44                }
45        }
46        
47        @Override public void setSelectedColor(Color color)
48        {
49                super.setSelectedColor(new Color(        color.getRed(),
50                                                                                        color.getGreen(),
51                                                                                        color.getBlue(),
52                                                                                        _alpha));
53        }
54 
55        static private final int        OPAQUE = 0xFF;
56        private int        _alpha = OPAQUE;
57}

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