Put the filterX and filterY methods in a Filter class which is the base class of all filters.