Gridarta Editor
PendingInfo.java
Go to the documentation of this file.
1 package net.sf.gridarta.action.exportmap;
2 
4 import org.jetbrains.annotations.NotNull;
5 
9 public class PendingInfo {
10 
16  @NotNull
17  private final Direction direction;
18 
22  private final int x;
23 
27  private final int y;
28 
38  public PendingInfo(@NotNull final Direction direction, final int x, final int y) {
39  switch (direction) {
40  case NORTH:
41  case EAST:
42  case SOUTH:
43  case UP:
44  case WEST:
45  break;
46 
47  case NORTH_EAST:
48  case SOUTH_EAST:
49  case SOUTH_WEST:
50  case NORTH_WEST:
51  case DOWN:
52  default:
53  throw new IllegalArgumentException("unexpected direction: " + direction);
54  }
55 
56  this.direction = direction;
57  this.x = x;
58  this.y = y;
59  }
60 
66  public int getX(final int width) {
67  switch (direction) {
68  case NORTH:
69  case EAST:
70  case SOUTH:
71  case UP:
72  return x;
73 
74  case WEST:
75  return x - width;
76 
77  case NORTH_EAST:
78  case SOUTH_EAST:
79  case SOUTH_WEST:
80  case NORTH_WEST:
81  case DOWN:
82  default:
83  throw new AssertionError("unexpected direction: " + direction);
84  }
85  }
86 
92  public int getY(final int height) {
93  switch (direction) {
94  case NORTH:
95  return y - height;
96 
97  case EAST:
98  case SOUTH:
99  case WEST:
100  case UP:
101  return y;
102 
103  case NORTH_EAST:
104  case SOUTH_EAST:
105  case SOUTH_WEST:
106  case NORTH_WEST:
107  case DOWN:
108  default:
109  throw new AssertionError("unexpected direction: " + direction);
110  }
111  }
112 
113 }
net.sf.gridarta.model.direction.Direction
Definition: Direction.java:28
net.sf.gridarta.action.exportmap.PendingInfo.x
final int x
Definition: PendingInfo.java:22
net.sf.gridarta.action.exportmap.PendingInfo.getX
int getX(final int width)
Definition: PendingInfo.java:66
net.sf.gridarta
net.sf
net.sf.gridarta.action.exportmap.PendingInfo
Definition: PendingInfo.java:9
net.sf.gridarta.action.exportmap.PendingInfo.y
final int y
Definition: PendingInfo.java:27
net
net.sf.gridarta.model
net.sf.gridarta.action.exportmap.PendingInfo.getY
int getY(final int height)
Definition: PendingInfo.java:92
net.sf.gridarta.action.exportmap.PendingInfo.direction
final Direction direction
Definition: PendingInfo.java:17
net.sf.gridarta.action.exportmap.PendingInfo.PendingInfo
PendingInfo(@NotNull final Direction direction, final int x, final int y)
Definition: PendingInfo.java:38
net.sf.gridarta.model.direction
Definition: Direction.java:20