Exemple #1
0
  public Pixel getTopRightNeighbour() {
    Pixel neighbour = (Pixel) neighbours.get(2);
    boolean found = false;

    if (neighbour.getX() != (x + 1) || neighbour.getY() != (y - 1)) {
      for (int i = 0; i < neighbours.size() && i != 2; i++) {
        neighbour = (Pixel) neighbours.get(i);
        if (neighbour.getX() == (x + 1) && neighbour.getY() == (y - 1)) {
          found = true;
          break;
        }
      }
      if (!found) return null;
    }

    return neighbour;
  }
Exemple #2
0
  public Pixel getLeftNeighbour() {
    Pixel neighbour;
    boolean found = false;

    if (neighbours.size() > 3) neighbour = (Pixel) neighbours.get(3);
    else neighbour = (Pixel) neighbours.lastElement();

    if (neighbour.getX() != (x - 1) || neighbour.getY() != y) {
      for (int i = 0; i < neighbours.size() && i != 3; i++) {
        neighbour = (Pixel) neighbours.get(i);
        if (neighbour.getX() == (x - 1) && neighbour.getY() == y) {
          found = true;
          break;
        }
      }
      if (!found) return null;
    }

    return neighbour;
  }
Exemple #3
0
  public Pixel getBottomRightNeighbour() {
    Pixel neighbour;
    boolean found = false;

    if (neighbours.size() > 7) neighbour = (Pixel) neighbours.get(7);
    else neighbour = (Pixel) neighbours.lastElement();

    if (neighbour.getX() != (x + 1) || neighbour.getY() != (y + 1)) {
      for (int i = 0; i < neighbours.size() && i != 7; i++) {
        neighbour = (Pixel) neighbours.get(i);
        if (neighbour.getX() == (x + 1) && neighbour.getY() == (y + 1)) {
          found = true;
          break;
        }
      }
      if (!found) return null;
    }

    return neighbour;
  }