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

COVERAGE SUMMARY FOR SOURCE FILE [TextAreaInfo.java]

nameclass, %method, %block, %line, %
TextAreaInfo.java100% (1/1)100% (4/4)93%  (63/68)89%  (17/19)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TextAreaInfo100% (1/1)100% (4/4)93%  (63/68)89%  (17/19)
TextAreaInfo (JTextArea): void 100% (1/1)91%  (53/58)88%  (14/16)
<static initializer> 100% (1/1)100% (4/4)100% (1/1)
getLineHeight (): int 100% (1/1)100% (3/3)100% (1/1)
getLines (): String [] 100% (1/1)100% (3/3)100% (1/1)

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.Font;
18import java.awt.FontMetrics;
19 
20import javax.swing.JTextArea;
21import javax.swing.text.BadLocationException;
22 
23import org.apache.commons.logging.Log;
24import org.apache.commons.logging.LogFactory;
25 
26final public class TextAreaInfo
27{
28        static private final Log        _logger = LogFactory.getLog(TextAreaInfo.class);
29 
30        public TextAreaInfo(JTextArea area)
31        {
32                try
33                {
34                        int count = area.getLineCount();
35                        _lines = new String[count];
36                        for (int i = 0; i < count; i++)
37                        {
38                                int start = area.getLineStartOffset(i);
39                                int end = area.getLineEndOffset(i);
40                                _lines[i] = area.getText(start, end - start);
41                        }
42                        Font font = area.getFont();
43                        FontMetrics metrics = area.getFontMetrics(font);
44                        _lineHeight = metrics.getHeight();
45                }
46                catch (BadLocationException exc)
47                {
48                        _logger.error("calculateText", exc);
49                }
50        }
51        
52        public String[]        getLines()
53        {
54                return _lines;
55        }
56        
57        public int                getLineHeight()
58        {
59                return _lineHeight;
60        }
61        
62        private String[]        _lines = null;
63        private int                        _lineHeight = 0;
64}

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