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

COVERAGE SUMMARY FOR SOURCE FILE [FullScreenPrefsPanel.java]

nameclass, %method, %block, %line, %
FullScreenPrefsPanel.java100% (2/2)100% (12/12)100% (517/517)100% (97/97)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FullScreenPrefsPanel100% (1/1)100% (10/10)100% (502/502)100% (94/94)
FullScreenPrefsPanel (PreferencesManager, AlphaColorChooser): void 100% (1/1)100% (131/131)100% (25/25)
accept (): void 100% (1/1)100% (72/72)100% (15/15)
access$000 (FullScreenPrefsPanel): JCheckBox 100% (1/1)100% (3/3)100% (1/1)
access$100 (FullScreenPrefsPanel): JSpinner 100% (1/1)100% (3/3)100% (1/1)
initComponents (): void 100% (1/1)100% (58/58)100% (12/12)
layoutComponents (): void 100% (1/1)100% (88/88)100% (9/9)
reset (): void 100% (1/1)100% (72/72)100% (11/11)
setBackgroundChooserTitle (String): void 100% (1/1)100% (5/5)100% (2/2)
setComponentNames (): void 100% (1/1)100% (65/65)100% (17/17)
setForegroundChooserTitle (String): void 100% (1/1)100% (5/5)100% (2/2)
     
class FullScreenPrefsPanel$1100% (1/1)100% (2/2)100% (15/15)100% (3/3)
FullScreenPrefsPanel$1 (FullScreenPrefsPanel): void 100% (1/1)100% (6/6)100% (1/1)
actionPerformed (ActionEvent): void 100% (1/1)100% (9/9)100% (2/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.hiveboard.dialog;
16 
17import java.awt.Dimension;
18import java.awt.event.ActionEvent;
19import java.awt.event.ActionListener;
20 
21import javax.swing.JCheckBox;
22import javax.swing.JComponent;
23import javax.swing.JLabel;
24import javax.swing.JSpinner;
25import javax.swing.SpinnerNumberModel;
26 
27import net.sourceforge.hiveboard.util.FontChooserHelper;
28import net.sourceforge.hiveboard.view.FullScreenPrefs;
29import net.sourceforge.hivegui.component.AlphaColorChooser;
30import net.sourceforge.hivegui.component.ColorButton;
31import net.sourceforge.hivegui.dialog.AbstractTabPanel;
32import net.sourceforge.hiveutils.service.PreferencesManager;
33 
34import zappini.designgridlayout.DesignGridLayout;
35import zappini.designgridlayout.Row;
36 
37public class FullScreenPrefsPanel extends AbstractTabPanel
38{
39        static private final String        NAME                        = "preferences-full-screen";
40        static private final String        FONT_TOOL_NAME        = NAME + "-font";
41        
42        public FullScreenPrefsPanel(PreferencesManager        manager, 
43                                                                AlphaColorChooser        chooser)
44        {
45                super(NAME);
46                
47                _manager = manager;
48                _fullScreenPrefs = (FullScreenPrefs) _manager.read(
49                                                                                                FullScreenPrefs.FULLSCREEN_PREFS_NAME);
50 
51                _fontBar = _fontHelper.getChooserPane();
52                _btnForeground = new ColorButton(chooser);
53                _btnBackground = new ColorButton(chooser);
54 
55                initComponents();
56                setComponentNames();
57                layoutComponents();
58                reset();
59        }
60        
61        private void        initComponents()
62        {
63                _chkAutoScroll.addActionListener(new ActionListener()
64                {
65                        public void        actionPerformed(ActionEvent e)
66                        {
67                                _txfScrollTime.setEnabled(_chkAutoScroll.isSelected());
68                        }
69                });
70 
71                _lblDisplayTime.setLabelFor(_txfDisplayTime);
72                _lblPosition.setLabelFor(_txfPosition);
73                _lblFont.setLabelFor(_fontBar);
74 
75                Dimension size = new Dimension(        _btnForeground.getPreferredSize().width, 
76                                                                                _fontBar.getPreferredSize().height);
77                if (size.width == 0)
78                {
79                        size.width = size.height;
80                }
81                _btnForeground.setPreferredSize(size);
82                _btnForeground.setMaximumSize(size);
83                _btnBackground.setPreferredSize(size);
84                _btnBackground.setMaximumSize(size);
85        }
86        
87        private void        setComponentNames()
88        {
89                // Set component names
90                _lblDisplayTime.setName(NAME + "-display-time-label");
91                _txfDisplayTime.setName(NAME + "-display-time");
92                _lblDisplayTimeUnit.setName(NAME + "-display-time-unit");
93 
94                _lblPosition.setName(NAME + "-position-label");
95                _txfPosition.setName(NAME + "-position");
96                _lblPositionUnit.setName(NAME + "-position-unit");
97 
98                _lblFont.setName(FONT_TOOL_NAME + "-label");
99                _fontBar.setName(FONT_TOOL_NAME);
100 
101                _lblForeground.setName(NAME + "-foreground-color-label");
102                _btnForeground.setName(NAME + "-foreground-color");
103                
104                _lblBackground.setName(NAME + "-background-color-label");
105                _btnBackground.setName(NAME + "-background-color");
106                
107                _lblAutoScroll.setName(NAME + "-auto-scroll-label");
108                _chkAutoScroll.setName(NAME + "-auto-scroll");
109                _txfScrollTime.setName(NAME + "-scroll-time");
110                _lblScrollTimeUnit.setName(NAME + "-auto-scroll-unit");
111        }
112 
113        // CSOFF: MagicNumberCheck
114        private void        layoutComponents()
115        {
116                DesignGridLayout layout = new DesignGridLayout(this); 
117                setLayout(layout);
118 
119                layout.row().label(_lblDisplayTime)
120                                                .add(_txfDisplayTime)
121                                                .add(_lblDisplayTimeUnit)
122                                                .add(Row.EMPTY, 2);
123                layout.row().label(_lblPosition)
124                                                .add(_txfPosition)
125                                                .add(_lblPositionUnit)
126                                                .add(Row.EMPTY, 2);
127                layout.row().label(_lblFont).add(_fontBar);
128                layout.row().label(_lblForeground)
129                                                .add(_btnForeground)
130                                                .add(Row.EMPTY, 3);
131                layout.row().label(_lblBackground)
132                                                .add(_btnBackground)
133                                                .add(Row.EMPTY, 3);
134                layout.row().label(_lblAutoScroll)
135                                                .add(_chkAutoScroll, 2)
136                                                .add(_txfScrollTime)
137                                                .add(_lblScrollTimeUnit);
138        }
139        // CSON: MagicNumberCheck
140 
141        @Override public void reset()
142        {
143                // Copy all prefs content to the matching fields in the panel
144                _txfDisplayTime.setValue(new Integer(_fullScreenPrefs.getDisplayTime() / ONE_SEC));
145                _txfPosition.setValue(new Double(MAX_POSITION * _fullScreenPrefs.getMatteY()));
146                _fontHelper.setFont(_fullScreenPrefs.getFont());
147                _btnForeground.setApplication(_application);
148                _btnBackground.setApplication(_application);
149                _btnForeground.setColor(_fullScreenPrefs.getForeground());
150                _btnBackground.setColor(_fullScreenPrefs.getBackground());
151                _chkAutoScroll.setSelected(_fullScreenPrefs.isAutoScroll());
152                if (_fullScreenPrefs.isAutoScroll())
153                {
154                        _txfScrollTime.setValue(new Integer(_fullScreenPrefs.getScrollTime() / ONE_SEC));
155                }
156        }
157        
158        public void accept()
159        {
160                // Copy all fields in the panel to the matching prefs content
161                int time = ((Number) _txfDisplayTime.getValue()).intValue() * ONE_SEC;
162                _fullScreenPrefs.setDisplayTime(time);
163                double position = ((Number) _txfPosition.getValue()).doubleValue() / MAX_POSITION;
164                _fullScreenPrefs.setMatteY(position);
165                _fullScreenPrefs.setFont(_fontHelper.getFont());
166                _fullScreenPrefs.setForeground(_btnForeground.getColor());
167                _fullScreenPrefs.setBackground(_btnBackground.getColor());
168                if (_chkAutoScroll.isSelected())
169                {
170                        _fullScreenPrefs.setAutoScroll(true);
171                        time = ((Number) _txfScrollTime.getValue()).intValue() * ONE_SEC;
172                        _fullScreenPrefs.setScrollTime(time);
173                }
174                else
175                {
176                        _fullScreenPrefs.setAutoScroll(false);
177                }
178                
179                // Write the prefs
180                _manager.write(FullScreenPrefs.FULLSCREEN_PREFS_NAME);
181        }
182        
183        public void        setForegroundChooserTitle(String title)
184        {
185                _btnForeground.setTitle(title);
186        }
187        
188        public void        setBackgroundChooserTitle(String title)
189        {
190                _btnBackground.setTitle(title);
191        }
192        
193        static final private int                        ONE_SEC                                = 1000;
194        static final private int                        MAX_DISPLAY_TIME        = 3600;
195        static final private int                        MAX_SCROLL_TIME                = 3600;
196        static final private int                        SCROLL_STEP                        = 5;
197        static final private double                        MAX_POSITION                = 100.0;
198        static final private double                        DEFAULT_POSITION        = 100.0;
199        
200        final private PreferencesManager        _manager;
201        final private FullScreenPrefs                _fullScreenPrefs;
202 
203        final private JLabel                                _lblDisplayTime = new JLabel();
204        final private JSpinner                                _txfDisplayTime = new JSpinner(
205                        new SpinnerNumberModel(0, 0, MAX_DISPLAY_TIME, SCROLL_STEP));
206        final private JLabel                                _lblDisplayTimeUnit = new JLabel();
207 
208        final private JLabel                                _lblPosition = new JLabel();
209        final private JSpinner                                _txfPosition = new JSpinner(
210                        new SpinnerNumberModel(DEFAULT_POSITION, 0.0, MAX_POSITION, 1.0));
211        final private JLabel                                _lblPositionUnit = new JLabel();
212 
213        final private JLabel                                _lblFont = new JLabel();
214        final private FontChooserHelper                _fontHelper = new FontChooserHelper(FONT_TOOL_NAME);
215        final private JComponent                        _fontBar;
216 
217        final private JLabel                                _lblForeground = new JLabel();
218        final private ColorButton                        _btnForeground;
219 
220        final private JLabel                                _lblBackground = new JLabel();
221        final private ColorButton                        _btnBackground;
222 
223        final private JLabel                                _lblAutoScroll = new JLabel();
224        final private JCheckBox                         _chkAutoScroll = new JCheckBox();
225        final private JSpinner                                _txfScrollTime = new JSpinner(
226                        new SpinnerNumberModel(0, 0, MAX_SCROLL_TIME, SCROLL_STEP));
227        final private JLabel                                _lblScrollTimeUnit = new JLabel();
228}

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