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

COVERAGE SUMMARY FOR SOURCE FILE [AbstractImageHolder.java]

nameclass, %method, %block, %line, %
AbstractImageHolder.java100% (1/1)100% (5/5)98%  (98/100)96%  (23/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AbstractImageHolder100% (1/1)100% (5/5)98%  (98/100)96%  (23/24)
getImage (): BufferedImage 100% (1/1)96%  (50/52)86%  (6/7)
AbstractImageHolder (int, int []): void 100% (1/1)100% (9/9)100% (4/4)
getImageRaster (): byte [] 100% (1/1)100% (3/3)100% (1/1)
setImage (BufferedImage): void 100% (1/1)100% (23/23)100% (7/7)
setImage (int, int, byte []): void 100% (1/1)100% (13/13)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.util;
16 
17import java.awt.image.BufferedImage;
18import java.awt.image.ColorModel;
19import java.awt.image.DataBuffer;
20import java.awt.image.DataBufferByte;
21import java.awt.image.Raster;
22import java.awt.image.WritableRaster;
23 
24public abstract class AbstractImageHolder implements ImageHolder
25{
26        protected AbstractImageHolder(int bytesPerPixel, int[] bandOffset)
27        {
28                _bytesPerPixel = bytesPerPixel;
29                _bandOffset = bandOffset;
30        }
31        
32        abstract protected ColorModel        getColorModel();
33        
34        public BufferedImage        getImage()
35        {
36                if (_content == null)
37                {
38                        return null;
39                }
40                if (_image == null)
41                {
42                        DataBuffer buffer = new DataBufferByte(
43                                                                                _content, _width * _height * _bytesPerPixel);
44                    WritableRaster raster = Raster.createInterleavedRaster(
45                                                                            buffer, _width, _height, 
46                                                                            _width * _bytesPerPixel, 
47                                                                            _bytesPerPixel, 
48                                                                            _bandOffset, null); 
49                    _image = new BufferedImage(getColorModel(), raster, false, null);
50            }
51            return _image;
52        }
53        
54        public byte[]        getImageRaster()
55        {
56                return _content;
57        }
58        
59        public void                setImage(BufferedImage image)
60        {
61                _image = null;
62                WritableRaster raster = image.getRaster();
63                _height = raster.getHeight();
64                _width = raster.getWidth();
65                DataBufferByte buffer = (DataBufferByte) raster.getDataBuffer();
66                _content = buffer.getData();
67        }
68        
69        public void                setImage(int width, int height, byte[] content)
70        {
71                _image = null;
72                _height = height;
73                _width = width;
74                _content = content;
75        }
76        
77        final private int                                _bytesPerPixel;
78        final private int[]                                _bandOffset;
79        private int                                                _width;
80        private int                                                _height;
81        private byte[]                                        _content;
82        private transient BufferedImage        _image;
83}

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