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.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright (c) 2002 Palo Alto Research Center, Incorporated.
  2. // All Rights Reserved.
  3. package figures;
  4. import java.awt.*;
  5. import java.awt.geom.*;
  6. public class Point extends ShapeFigureElement {
  7. private int _x;
  8. private int _y;
  9. public Point(int x, int y) {
  10. _x = x;
  11. _y = y;
  12. }
  13. public int getX() { return _x; }
  14. public int getY() { return _y; }
  15. public void setX(int x) { _x = x; }
  16. public void setY(int y) { _y = y; }
  17. public void move() {}
  18. public void move(int dx, int dy) {
  19. _x += dx;
  20. _y += dy;
  21. //setX(getX() + dx);
  22. //setY(getY() + dy);
  23. }
  24. public String toString() {
  25. return "Point(" + _x + ", " + _y + ")";
  26. }
  27. /** The height of displayed {@link Point}s. */
  28. private final static int HEIGHT = 10;
  29. /** The width of displayed {@link Point}s. -- same as {@link HEIGHT}. */
  30. private final static int WIDTH = Point.HEIGHT;
  31. public Shape getShape() {
  32. return new Ellipse2D.Float((float)getX()-Point.WIDTH/2,
  33. (float)getY()-Point.HEIGHT/2,
  34. (float)Point.HEIGHT,
  35. (float)Point.WIDTH);
  36. }
  37. }