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

COVERAGE SUMMARY FOR SOURCE FILE [DrawingArea.java]

nameclass, %method, %block, %line, %
DrawingArea.java100% (1/1)82%  (9/11)87%  (94/108)88%  (29/33)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DrawingArea100% (1/1)82%  (9/11)87%  (94/108)88%  (29/33)
getScrollableBlockIncrement (Rectangle, int, int): int 0%   (0/1)0%   (0/12)0%   (0/3)
getScrollableUnitIncrement (Rectangle, int, int): int 0%   (0/1)0%   (0/2)0%   (0/1)
DrawingArea (BoardImageModel): void 100% (1/1)100% (47/47)100% (12/12)
contentRefreshed (Rectangle): void 100% (1/1)100% (9/9)100% (5/5)
getBoardImageModel (): BoardImageModel 100% (1/1)100% (3/3)100% (1/1)
getMaximumSize (): Dimension 100% (1/1)100% (3/3)100% (1/1)
getPreferredScrollableViewportSize (): Dimension 100% (1/1)100% (3/3)100% (1/1)
getPreferredSize (): Dimension 100% (1/1)100% (3/3)100% (1/1)
getScrollableTracksViewportHeight (): boolean 100% (1/1)100% (2/2)100% (1/1)
getScrollableTracksViewportWidth (): boolean 100% (1/1)100% (2/2)100% (1/1)
paintComponent (Graphics): void 100% (1/1)100% (22/22)100% (6/6)

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.view;
16 
17import java.awt.Color;
18import java.awt.Dimension;
19import java.awt.Graphics;
20import java.awt.Graphics2D;
21import java.awt.Rectangle;
22import java.awt.image.BufferedImage;
23 
24import javax.swing.JPanel;
25import javax.swing.Scrollable;
26import javax.swing.SwingConstants;
27 
28import net.sourceforge.hiveboard.model.BoardImageModel;
29import net.sourceforge.hiveboard.model.BoardImageModelListener;
30 
31public class        DrawingArea
32        extends                JPanel
33        implements        Scrollable, BoardImageModelListener
34{
35        public DrawingArea(BoardImageModel model)
36        {
37                super(null, false);
38                setName("drawing-area");
39                setOpaque(true);
40                setBackground(Color.WHITE);
41                setAutoscrolls(true);
42                _model = model;
43                _model.addBoardImageModelListener(this);
44                _size = new Dimension(_model.getWidth(), _model.getHeight());
45                setMinimumSize(_size);
46                setPreferredSize(_size);
47                setMaximumSize(_size);
48        }
49        
50        public void                contentRefreshed(Rectangle content)
51        {
52                if (content != null)
53                {
54                        repaint(content);
55                }
56                else
57                {
58                        repaint();
59                }
60        }
61        
62        public BoardImageModel        getBoardImageModel()
63        {
64                return _model;
65        }
66        
67        @Override protected void paintComponent(Graphics g)
68        {
69                // Ensure background is painted
70                super.paintComponent(g);
71                // Then draw the image
72                BufferedImage image = _model.getImage();
73                if (image != null)
74                {
75                        g.drawImage(image, 0, 0, this);
76                        // Draw additional hilites directly on the Graphics
77                        _model.paintHilites((Graphics2D) g);
78                }
79        }
80        
81        public Dimension getPreferredScrollableViewportSize()
82        {
83                return _size;
84        }
85        
86        @Override public Dimension getPreferredSize()
87        {
88                return _size;
89        }
90        
91        @Override public Dimension getMaximumSize()
92        {
93                return _size;
94        }
95        
96        public int getScrollableUnitIncrement(        Rectangle        visibleRect,
97                                                                                        int                        orientation,
98                                                                                        int                        direction)
99        {
100                return UNIT_SCROLL_PIXELS;
101        }
102        
103        public int getScrollableBlockIncrement(        Rectangle        visibleRect,
104                                                                                        int                        orientation,
105                                                                                        int                        direction)
106        {
107                if (orientation == SwingConstants.HORIZONTAL)
108                {
109                        return visibleRect.width - UNIT_SCROLL_PIXELS;
110                }
111                else
112                {
113                        return visibleRect.height - UNIT_SCROLL_PIXELS;
114                }
115        }
116        
117        public boolean getScrollableTracksViewportWidth()
118        {
119                return false;
120        }
121        
122        public boolean getScrollableTracksViewportHeight()
123        {
124                return false;
125        }
126 
127        private BoardImageModel        _model;
128        private Dimension                _size;
129 
130        static final private int        UNIT_SCROLL_PIXELS = 8;
131}

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