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

COVERAGE SUMMARY FOR SOURCE FILE [FullScreenShell.java]

nameclass, %method, %block, %line, %
FullScreenShell.java100% (3/3)100% (11/11)100% (226/226)100% (48/48)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FullScreenShell100% (1/1)100% (7/7)100% (145/145)100% (34/34)
FullScreenShell (Log, Channel, ToolHandler, MenuFactory, Action, Channel, Cha... 100% (1/1)100% (105/105)100% (26/26)
access$000 (FullScreenShell): DrawingArea 100% (1/1)100% (3/3)100% (1/1)
access$100 (FullScreenShell): JScrollPane 100% (1/1)100% (3/3)100% (1/1)
access$200 (FullScreenShell): FullScreenPanel 100% (1/1)100% (3/3)100% (1/1)
access$300 (FullScreenShell): JToolBar 100% (1/1)100% (3/3)100% (1/1)
findShortcut (Action): KeyStroke 100% (1/1)100% (5/5)100% (1/1)
push (DrawingAreaHolder): void 100% (1/1)100% (23/23)100% (6/6)
     
class FullScreenShell$1100% (1/1)100% (2/2)100% (51/51)100% (8/8)
FullScreenShell$1 (FullScreenShell, JComponent): void 100% (1/1)100% (9/9)100% (1/1)
push (Object): void 100% (1/1)100% (42/42)100% (7/7)
     
class FullScreenShell$2100% (1/1)100% (2/2)100% (30/30)100% (6/6)
FullScreenShell$2 (FullScreenShell, JComponent): void 100% (1/1)100% (9/9)100% (1/1)
push (Object): void 100% (1/1)100% (21/21)100% (5/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.hiveboard.main;
16 
17import java.awt.BorderLayout;
18 
19import javax.swing.Action;
20import javax.swing.JComponent;
21import javax.swing.JFrame;
22import javax.swing.JScrollPane;
23import javax.swing.JToolBar;
24import javax.swing.JViewport;
25import javax.swing.KeyStroke;
26 
27import org.apache.commons.logging.Log;
28 
29import net.sourceforge.hiveboard.Board;
30import net.sourceforge.hiveboard.drawing.ToolHandler;
31import net.sourceforge.hiveboard.event.EventsPriorities;
32import net.sourceforge.hiveboard.view.DrawingArea;
33import net.sourceforge.hiveboard.view.DrawingAreaHolder;
34import net.sourceforge.hiveboard.view.FullScreenPanel;
35import net.sourceforge.hiveevents.Channel;
36import net.sourceforge.hiveevents.PersistentConsumer;
37import net.sourceforge.hivegui.component.IconTools;
38import net.sourceforge.hivegui.menu.MenuFactory;
39import net.sourceforge.hivegui.util.ScreenTools;
40 
41/**
42 * Special Frame used to cover the full screen. It always exists but is visible
43 * only in full-screen mode.
44 * <p>
45 * It can also display comments/notifications.
46 * 
47 * @author jean-Francois Poilpret
48 */
49public class FullScreenShell extends JFrame implements PersistentConsumer<DrawingAreaHolder>
50{
51        public FullScreenShell(        Log                                                        logger,
52                                                        Channel<DrawingAreaHolder>        boardChannel,
53                                                        ToolHandler                                        toolHandler,
54                                                        MenuFactory                                        menuFactory,
55                                                        Action                                                switchMode,
56                                                        Channel<Object>                                fullScreenMode,
57                                                        Channel<Object>                                windowMode,
58                                                        FullScreenPanel                                screenPane)
59        {
60                super();
61                setName("fullscreen-shell");
62 
63                _logger = logger;
64                _area = null;
65                _toolbar = toolHandler.getToolBar();
66                int priority = EventsPriorities.SELECTED_IMAGE_FULLSCREEN_UPDATE;
67                boardChannel.registerPushConsumer(priority, this);
68 
69                final JComponent content = (JComponent) getContentPane();
70 
71                // Set command for switching screen mode
72                KeyStroke shortcut = findShortcut(switchMode);
73                if (shortcut != null)
74                {
75                        content.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(shortcut, "switch-mode");
76                        content.getActionMap().put("switch-mode", switchMode);
77                }
78 
79                content.setLayout(new BorderLayout());
80                setIconImage(IconTools.loadIcon("image/hiveboard.gif").getImage());
81                setUndecorated(true);
82 
83                // Improve scrolling performance
84                _scroller.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE);
85 
86                _content = screenPane;
87                _content.setAreaScroller(_scroller);
88 
89            content.add(_content, BorderLayout.CENTER);
90 
91                setBounds(ScreenTools.getMainScreenBounds());
92 
93                // Register consumer for screen mode switching channels
94                priority = EventsPriorities.FULLSCREENSHELL_FULL_SWITCH;
95                fullScreenMode.registerPushConsumer(priority, new PersistentConsumer<Object>()
96                {
97                        public void        push(Object event)
98                        {
99                                _scroller.setViewportView(_area);
100                                Board board = _area.getBoardImageModel().getBoard();
101                                _content.setBoard(board);
102                                setTitle("HiveBoard - " + board.getName());
103                                content.add(_toolbar, BorderLayout.NORTH);
104                                setVisible(true);
105                        }
106                });
107                priority = EventsPriorities.FULLSCREENSHELL_WINDOW_SWITCH;
108                windowMode.registerPushConsumer(priority, new PersistentConsumer<Object>()
109                {
110                        public void        push(Object event)
111                        {
112                                setVisible(false);
113                                _scroller.setViewportView(null);
114                                _content.setBoard(null);
115                                content.remove(_toolbar);
116                        }
117                });
118        }
119 
120        private KeyStroke        findShortcut(Action command)
121        {
122                return (KeyStroke) command.getValue(Action.ACCELERATOR_KEY);
123        }
124        
125        public void                push(DrawingAreaHolder holder)
126        {
127                // Update current area
128                if (holder == null)
129                {
130                        _area = null;
131                }
132                else
133                {
134                        _area = holder.getDrawingArea();
135                }
136                _logger.debug("push() _area=" + _area);
137        }
138        
139        private DrawingArea                                _area;
140        final private Log                                _logger;
141        final private FullScreenPanel        _content;
142        final private JScrollPane                _scroller = new JScrollPane();
143        final private JToolBar                        _toolbar;
144}

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