EMMA Coverage Report (generated Sat Oct 08 11:41:37 CEST 2011)
[all classes][net.sf.jomic.comic]

COVERAGE SUMMARY FOR SOURCE FILE [ComicSheet.java]

nameclass, %method, %block, %line, %
ComicSheet.java100% (1/1)90%  (9/10)49%  (90/185)68%  (17.7/26)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ComicSheet100% (1/1)90%  (9/10)49%  (90/185)68%  (17.7/26)
toString (): String 0%   (0/1)0%   (0/41)0%   (0/5)
setRightImageIndex (int): void 100% (1/1)45%  (17/38)72%  (2.9/4)
ComicSheet (int, int, int): void 100% (1/1)54%  (30/56)81%  (6.5/8)
getRightImageIndex (): int 100% (1/1)67%  (8/12)78%  (1.6/2)
<static initializer> 100% (1/1)80%  (12/15)80%  (0.8/1)
ComicSheet (int, int): void 100% (1/1)100% (6/6)100% (2/2)
getLeftImageIndex (): int 100% (1/1)100% (3/3)100% (1/1)
getPage (): int 100% (1/1)100% (3/3)100% (1/1)
getRightImageIndexOrNoImage (): int 100% (1/1)100% (3/3)100% (1/1)
hasRightImage (): boolean 100% (1/1)100% (8/8)100% (1/1)

1// Jomic - a viewer for comic book archives.
2// Copyright (C) 2004-2011 Thomas Aglassinger
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16package net.sf.jomic.comic;
17 
18/**
19 *  A sheet containig 1 or 2 images, depending on the size of the images: if an image is wider than
20 *  high, a sheet can contain only 1 image.<p>
21 *
22 *  Sheets are used to render a the ComicView in two page mode. ComicImages are referred to by their
23 *  index in the ComicViews internal ComicView[].
24 *
25 * @author    Thomas Aglassinger
26 */
27public class ComicSheet
28{
29    /**
30     *  Value to indicat that no image is assigned.
31     */
32    public static final int NO_IMAGE = -1;
33    private int leftImageIndex;
34    private int page;
35    private int rightImage;
36 
37    /**
38     *  Create a sheet holding a single image. Use <code>setRightImageIndex()</code> to add an
39     *  image.
40     *
41     * @see                       #setRightImageIndex(int)
42     * @param  newPage            page number of the left ComicImage
43     * @param  newLeftImageIndex  index of the ComicImage that describes this page
44     */
45    public ComicSheet(int newPage, int newLeftImageIndex) {
46        this(newPage, newLeftImageIndex, NO_IMAGE);
47    }
48 
49    /**
50     *  Create a sheet holding a single image. Use <code>setRightImageIndex()</code> to add an
51     *  image.
52     *
53     * @param  newPage             page number of the left ComicImage
54     * @param  newLeftImageIndex   index of the ComicImage that describes this page
55     * @param  newRightImageIndex  Description of the parameter
56     */
57    public ComicSheet(int newPage, int newLeftImageIndex, int newRightImageIndex) {
58        assert newPage >= 0;
59        assert newLeftImageIndex >= 0;
60        assert (newRightImageIndex == NO_IMAGE) || (newRightImageIndex == newLeftImageIndex + 1)
61                : "newRightImageIndex must be NO_IMAGE or " + (newLeftImageIndex + 1) + " but is " + newRightImageIndex;
62        page = newPage;
63        leftImageIndex = newLeftImageIndex;
64        rightImage = newRightImageIndex;
65    }
66 
67 
68    void setRightImageIndex(int newRightImageIndex) {
69        assert !hasRightImage();
70        assert newRightImageIndex == (leftImageIndex + 1)
71                : "left=" + leftImageIndex + ", newRight=" + newRightImageIndex;
72        rightImage = newRightImageIndex;
73    }
74 
75    public int getLeftImageIndex() {
76        return leftImageIndex;
77    }
78 
79    /**
80     *  Get the page to which the left image refers to.
81     */
82    public int getPage() {
83        return page;
84    }
85 
86    public int getRightImageIndex() {
87        assert hasRightImage();
88        return getRightImageIndexOrNoImage();
89    }
90 
91    public int getRightImageIndexOrNoImage() {
92        return rightImage;
93    }
94 
95    /**
96     *  Does the sheet have a second image?
97     */
98    public boolean hasRightImage() {
99        return rightImage != NO_IMAGE;
100    }
101 
102    public String toString() {
103        String result = "ComicSheet[page=" + getPage() + ", left=" + getLeftImageIndex();
104 
105        if (hasRightImage()) {
106            result += ", right=" + getRightImageIndex();
107        }
108        result += "]";
109        return result;
110    }
111}

[all classes][net.sf.jomic.comic]
EMMA 2.0.4217 (C) Vladimir Roubtsov