1 package org.woehlke.computer.kurzweil.commons.model; 2 3 import lombok.Getter; 4 5 @Getter 6 public enum LatticePointNeighbourhoodPosition { 7 8 CENTER(0,0), 9 NORTH(0,-1), 10 EAST(1,0), 11 SOUTH(0,1), 12 WEST(-1,0), 13 NORTH_EAST(1,-1), 14 SOUTH_EAST(1,1), 15 SOUTH_WEST(-1,1), 16 NORTH_WEST(-1,-1); 17 18 private final int x; 19 private final int y; 20 21 LatticePointNeighbourhoodPosition(int x, int y){ 22 this.x = x; 23 this.y = y; 24 } 25 26 public static LatticePointNeighbourhoodPosition[] getNeighbourhoodFor( 27 LatticeNeighbourhoodType neighbourhoodType 28 ){ 29 LatticePointNeighbourhoodPosition[] result; 30 switch (neighbourhoodType) { 31 case VON_NEUMANN_NEIGHBORHOOD: 32 result = new LatticePointNeighbourhoodPosition[4]; 33 result[0]=NORTH; 34 result[1]=EAST; 35 result[2]=SOUTH; 36 result[3]=WEST; 37 break; 38 case MOORE_NEIGHBORHOOD: 39 result = new LatticePointNeighbourhoodPosition[8]; 40 result[0]=NORTH_WEST; 41 result[1]=NORTH; 42 result[2]=NORTH_EAST; 43 result[3]=EAST; 44 result[4]=SOUTH_EAST; 45 result[5]=SOUTH; 46 result[6]=SOUTH_WEST; 47 result[7]=WEST; 48 break; 49 case WOEHLKE_NEIGHBORHOOD: 50 result = new LatticePointNeighbourhoodPosition[6]; 51 result[0]=NORTH_WEST; 52 result[1]=NORTH; 53 result[2]=NORTH_EAST; 54 result[3]=EAST; 55 result[4]=SOUTH_WEST; 56 result[5]=WEST; 57 break; 58 default: 59 result = new LatticePointNeighbourhoodPosition[1]; 60 result[0]=CENTER; 61 break; 62 } 63 return result; 64 } 65 66 }