You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Point.java 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. Copyright (c) Xerox Corporation 1998-2002. All rights reserved.
  3. Use and copying of this software and preparation of derivative works based
  4. upon this software are permitted. Any distribution of this software or
  5. derivative works must comply with all applicable United States export control
  6. laws.
  7. This software is made available AS IS, and Xerox Corporation makes no warranty
  8. about the software, its performance or its conformity to any specification.
  9. */
  10. package bean;
  11. class Point {
  12. protected int x = 0;
  13. protected int y = 0;
  14. /**
  15. * Return the X coordinate
  16. */
  17. public int getX(){
  18. return x;
  19. }
  20. /**
  21. * Return the y coordinate
  22. */
  23. public int getY(){
  24. return y;
  25. }
  26. /**
  27. * Set the x and y coordinates
  28. */
  29. public void setRectangular(int newX, int newY){
  30. setX(newX);
  31. setY(newY);
  32. }
  33. /**
  34. * Set the X coordinate
  35. */
  36. public void setX(int newX) {
  37. x = newX;
  38. }
  39. /**
  40. * set the y coordinate
  41. */
  42. public void setY(int newY) {
  43. y = newY;
  44. }
  45. /**
  46. * Move the point by the specified x and y offset
  47. */
  48. public void offset(int deltaX, int deltaY){
  49. setRectangular(x + deltaX, y + deltaY);
  50. }
  51. /**
  52. * Make a string of this
  53. */
  54. public String toString(){
  55. return "(" + getX() + ", " + getY() + ")" ;
  56. }
  57. }