Gridarta Editor
PendingInfo.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.action.exportmap;
21 
23 import org.jetbrains.annotations.NotNull;
24 
28 public class PendingInfo {
29 
35  @NotNull
36  private final Direction direction;
37 
41  private final int x;
42 
46  private final int y;
47 
57  public PendingInfo(@NotNull final Direction direction, final int x, final int y) {
58  switch (direction) {
59  case NORTH:
60  case EAST:
61  case SOUTH:
62  case UP:
63  case WEST:
64  break;
65 
66  case NORTH_EAST:
67  case SOUTH_EAST:
68  case SOUTH_WEST:
69  case NORTH_WEST:
70  case DOWN:
71  default:
72  throw new IllegalArgumentException("unexpected direction: " + direction);
73  }
74 
75  this.direction = direction;
76  this.x = x;
77  this.y = y;
78  }
79 
85  public int getX(final int width) {
86  switch (direction) {
87  case NORTH:
88  case EAST:
89  case SOUTH:
90  case UP:
91  return x;
92 
93  case WEST:
94  return x - width;
95 
96  case NORTH_EAST:
97  case SOUTH_EAST:
98  case SOUTH_WEST:
99  case NORTH_WEST:
100  case DOWN:
101  default:
102  throw new AssertionError("unexpected direction: " + direction);
103  }
104  }
105 
111  public int getY(final int height) {
112  switch (direction) {
113  case NORTH:
114  return y - height;
115 
116  case EAST:
117  case SOUTH:
118  case WEST:
119  case UP:
120  return y;
121 
122  case NORTH_EAST:
123  case SOUTH_EAST:
124  case SOUTH_WEST:
125  case NORTH_WEST:
126  case DOWN:
127  default:
128  throw new AssertionError("unexpected direction: " + direction);
129  }
130  }
131 
132 }
net.sf.gridarta.model.direction.Direction
A direction.
Definition: Direction.java:28
net.sf.gridarta.action.exportmap.PendingInfo.x
final int x
The x coordinate of the border between the previous and the next map.
Definition: PendingInfo.java:41
net.sf.gridarta.action.exportmap.PendingInfo.getX
int getX(final int width)
Returns the x coordinate of the next map.
Definition: PendingInfo.java:85
net.sf.gridarta
Base package of all Gridarta classes.
net.sf
net.sf.gridarta.action.exportmap.PendingInfo
Preliminary layout information for a map.
Definition: PendingInfo.java:28
net.sf.gridarta.action.exportmap.PendingInfo.y
final int y
The y coordinate of the border between the previous and the next map.
Definition: PendingInfo.java:46
net
net.sf.gridarta.model
net.sf.gridarta.action.exportmap.PendingInfo.getY
int getY(final int height)
Returns the y coordinate of the next map.
Definition: PendingInfo.java:111
net.sf.gridarta.action.exportmap.PendingInfo.direction
final Direction direction
The direction from which the map was discovered.
Definition: PendingInfo.java:36
net.sf.gridarta.action.exportmap.PendingInfo.PendingInfo
PendingInfo(@NotNull final Direction direction, final int x, final int y)
Creates a new instance.
Definition: PendingInfo.java:57
net.sf.gridarta.model.direction
Definition: Direction.java:20