Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.51 KB | None | 0 0
  1. public Iterator<Pixel> sample(int initX, int initY, int dx, int dy) {
  2. if (dx < 0 || dy < 0) {
  3. throw new IllegalArgumentException("Dx or Dy cannot be negative");
  4. } else if (initX < 0 || initX > width) {
  5. throw new IllegalArgumentException("initX must be within the picture");
  6. } else if (initY < 0 || initY > height) {
  7. throw new IllegalArgumentException("initY must be within the picture");
  8. }
  9.  
  10. Iterator<Pixel> iter = new SampleIterator(this, initX, initY, dx, dy);
  11. return iter;
  12. }
  13.  
  14. public Iterator<SubPicture> window(int windowWidth, int windowHeight) {
  15. if (windowWidth < 0 || windowHeight < 0) {
  16. throw new IllegalArgumentException("windowWidth or windowHeight cannot be negative");
  17. } else if (windowWidth > width || windowHeight > height) {
  18. throw new IllegalArgumentException("windowWidth and windowHeight must be smaller or equal to picture width and height");
  19. }
  20.  
  21. Iterator<SubPicture> iter = new WindowIterator(this, windowWidth, windowHeight);
  22. return iter;
  23. }
  24.  
  25. public Iterator<SubPicture> tile(int tileWidth, int tileHeight) {
  26. if (tileWidth < 0 || tileHeight < 0) {
  27. throw new IllegalArgumentException("tileWidth or tileHeight cannot be negative");
  28. } else if (tileWidth > width || tileHeight > height) {
  29. throw new IllegalArgumentException("tileWidth and tileHeight must be smaller or equal to picture width and height");
  30. }
  31.  
  32. Iterator<SubPicture> iter = new TileIterator(this, tileWidth, tileHeight);
  33. return iter;
  34. }
  35.  
  36. public Iterator<Pixel> zigzag() {
  37. Iterator<Pixel> iter = new ZigzagIterator(this);
  38. return iter;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement