ac.essex.ca.neighbourhoods
Class Neighbourhood

java.lang.Object
  extended by ac.essex.ca.neighbourhoods.Neighbourhood
Direct Known Subclasses:
VonNeumannNeighbourhood

public abstract class Neighbourhood
extends java.lang.Object

A neighbourhood defines the pixels around a given pixel which are to be examined. Different shaped neighbourhoods can produce different behaviours.

The neighbourhood is defined in terms of relative positions about the central pixel which is at (0,0). Once a neighbourhood is defined a set of rules can be applied to it which either switch the central pixel on or off.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version, provided that any use properly credits the author. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org


Field Summary
 java.util.Vector<ac.essex.ca.util.Position> positions
           
 
Constructor Summary
Neighbourhood()
           
 
Method Summary
 void addPosition(int x, int y)
           
abstract  void createNeighbourhood()
          Initialises the rest of the positions within the neighbourhood to produce the kind of shape we want.
 ac.essex.ca.util.Position getPosition(int index)
           
 java.util.Vector<ac.essex.ca.util.Position> getPositions()
          Returns all the positions in the neighbourhood.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

positions

public java.util.Vector<ac.essex.ca.util.Position> positions
Constructor Detail

Neighbourhood

public Neighbourhood()
Method Detail

addPosition

public void addPosition(int x,
                        int y)

getPositions

public java.util.Vector<ac.essex.ca.util.Position> getPositions()
Returns all the positions in the neighbourhood. All positions are saved as relative coordinates to a central pixel.


getPosition

public ac.essex.ca.util.Position getPosition(int index)

createNeighbourhood

public abstract void createNeighbourhood()
Initialises the rest of the positions within the neighbourhood to produce the kind of shape we want. See subclasses of this object for examples.