-
Notifications
You must be signed in to change notification settings - Fork 13
/
KYard.java
57 lines (46 loc) · 1.26 KB
/
KYard.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package org.fleen.geom_Kisrhombille;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/*
* A 2d area
* outside edge is defined by a polygon
* inside edge/s (holes) are defined by 1..n polygons
*
* It's a list of polygons
* the first polygon is the outer edge
* the rest of the polygons (if any) are the holes
*/
public class KYard extends ArrayList<KPolygon>{
private static final long serialVersionUID=-6074974764136594169L;
/*
* ################################
* CONSTRUCTORS
* ################################
*/
public KYard(KPolygon... polygons){
super(Arrays.asList(polygons));}
public KYard(List<KPolygon> polygons){
super(polygons);}
public KYard(int s){
super(s);}
/*
* ################################
* EDGE POLYGONS
* ################################
*/
/*
* returns the outer edge of this yard
* returns null if there is no outer edge
*/
public KPolygon getOuterEdge(){
if(isEmpty())return null;
return get(0);}
/*
* returns the inner edges of this yard
* returns empty list if there are no inner edges
*/
public List<KPolygon> getInnerEdges(){
if(size()<2)return new ArrayList<KPolygon>(0);
return subList(1,size());}
}