EMMA Coverage Report (generated Sun Apr 20 22:38:01 CEST 2008)
[all classes][net.sf.jomic.comic]

COVERAGE SUMMARY FOR SOURCE FILE [ComicSheetindexOverlapComparator.java]

nameclass, %method, %block, %line, %
ComicSheetindexOverlapComparator.java100% (1/1)100% (3/3)99%  (66/67)99%  (15.9/16)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ComicSheetindexOverlapComparator100% (1/1)100% (3/3)99%  (66/67)99%  (15.9/16)
<static initializer> 100% (1/1)91%  (10/11)91%  (0.9/1)
ComicSheetindexOverlapComparator (): void 100% (1/1)100% (3/3)100% (2/2)
compare (Object, Object): int 100% (1/1)100% (53/53)100% (13/13)

1// Jomic - a viewer for comic book archives.
2// Copyright (C) 2004-2008 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 
18import java.util.Comparator;
19 
20import net.sf.wraplog.Logger;
21 
22/**
23 *  Comparator to decide if two ComicSheets overlap. Two ComicSheets are equal if they contain at
24 *  least the same left or right image index.
25 *
26 * @author    Thomas Aglassinger
27 */
28class ComicSheetindexOverlapComparator implements Comparator
29{
30    private static Logger logger = Logger.getLogger(ComicSheetindexOverlapComparator.class);
31 
32    public ComicSheetindexOverlapComparator() {
33        super();
34    }
35 
36    public int compare(Object arg0, Object arg1) {
37        ComicSheet sheet1 = (ComicSheet) arg0;
38        ComicSheet sheet2 = (ComicSheet) arg1;
39 
40        if (logger.isDebugEnabled()) {
41            logger.debug("compare: sheet1=" + sheet1 + ", sheet2=" + sheet2);
42        }
43        int left1 = sheet1.getLeftImageIndex();
44        int left2 = sheet2.getLeftImageIndex();
45        int result = left1 - left2;
46 
47        if (Math.abs(result) == 1) {
48            int right1 = sheet1.getRightImageIndexOrNoImage();
49            int right2 = sheet2.getRightImageIndexOrNoImage();
50 
51            if ((left1 == right2) || (left2 == right1)) {
52                result = 0;
53            }
54        }
55        return result;
56    }
57}

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