EMMA Coverage Report (generated Sat Apr 29 12:52:00 BST 2006)
[all classes][net.sourceforge.pseudoq.model]

COVERAGE SUMMARY FOR SOURCE FILE [Region.java]

nameclass, %method, %block, %line, %
Region.java100% (1/1)100% (9/9)96%  (64/67)96%  (25/26)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Region100% (1/1)100% (9/9)96%  (64/67)96%  (25/26)
toString (): String 100% (1/1)75%  (9/12)80%  (4/5)
Region (): void 100% (1/1)100% (3/3)100% (2/2)
Region (Set): void 100% (1/1)100% (7/7)100% (3/3)
Region (String): void 100% (1/1)100% (6/6)100% (3/3)
Region (String, Set): void 100% (1/1)100% (10/10)100% (4/4)
getName (): String 100% (1/1)100% (3/3)100% (1/1)
intersection (Region): Region 100% (1/1)100% (11/11)100% (3/3)
setName (String): void 100% (1/1)100% (4/4)100% (2/2)
union (Region): Region 100% (1/1)100% (11/11)100% (3/3)

1/*
2 * Copyright (c) 2005 The PseudoQ Project.
3 *
4 * This file is part of PseudoQ.
5 *
6 * PseudoQ is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
10 *
11 * PseudoQ is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with PseudoQ; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 */
20 
21package net.sourceforge.pseudoq.model;
22 
23import java.util.HashSet;
24import java.util.Set;
25 
26/**
27 * A region of cells in the grid.  Essentially it's a set of coordinates, plus
28 * some other metadata.
29 * @author <a href="http://sourceforge.net/users/stevensa">Andrew Stevens</a>
30 */
31public class Region extends HashSet<Coordinate> {
32    /**
33     * Holds value of property name.
34     */
35    private String name;
36 
37    /** Creates a new instance of Region */
38    public Region() {
39    }
40 
41    /** Creates a new instance of Region */
42    public Region(String name) {
43        this.name = name;
44    }
45 
46    /** Creates a new instance of Region */
47    public Region(Set<Coordinate> coords) {
48        this.addAll(coords);
49    }
50 
51    /** Creates a new instance of Region */
52    public Region(String name, Set<Coordinate> coords) {
53        this.name = name;
54        this.addAll(coords);
55    }
56 
57    /**
58     * Getter for property name.
59     * @return Value of property name.
60     */
61    public String getName() {
62        return this.name;
63    }
64 
65    /**
66     * Setter for property name.
67     * @param name New value of property name.
68     */
69    public void setName(String name) {
70        this.name = name;
71    }
72 
73    /**
74     * Calculates the union of this region and another.
75     * @param region The other region.
76     * @return A new region containing the union.
77     */
78    public Region union(Region region) {
79        Region union = new Region(this);
80        union.addAll(region);
81        return union;
82    }
83 
84    /**
85     * Calculates the intersection of this region and another.
86     * @param region The other region.
87     * @return A new region containing the union.
88     */
89    public Region intersection(Region region) {
90        Region intersection = new Region(this);
91        intersection.retainAll(region);
92        return intersection;
93    }
94 
95    public String toString() {
96        String retValue;
97 
98        if (this.name != null) {
99            retValue = this.name;
100        } else {
101            retValue = super.toString();
102        }
103 
104        return retValue;
105    }
106 
107}

[all classes][net.sourceforge.pseudoq.model]
EMMA 2.0.5312 (C) Vladimir Roubtsov