hypesystem

GD - Coordinate.java

Nov 1st, 2011
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1. package gd;
  2.  
  3. /**
  4.  * Holds coordinates for an object (in this case shapes). It is quite a lot like
  5.  * java.awt.Dimension, but with coordinates, made for this specifically.
  6.  * @author hypesystem
  7.  * @email  [email protected]
  8.  */
  9. public class Coordinate {
  10.     private int x, y;
  11.    
  12.     /**
  13.      * creates a coordinate object from an x and a y coordinate
  14.      * @param x horizontal placement
  15.      * @param y vertical placement
  16.      */
  17.     public Coordinate(int x, int y) {
  18.         this.x = x;
  19.         this.y = y;
  20.     }
  21.    
  22.     /**
  23.      * Moves the coordinate set.
  24.      * @param dx amount to move horizontally
  25.      * @param dy amount to move vertically
  26.      */
  27.     public void move(int dx, int dy) {
  28.         x += dx;
  29.         y += dy;
  30.     }
  31.    
  32.     /**
  33.      * Sets the position of the coordinate set to something specific.
  34.      * @param x horizontal position
  35.      * @param y vertical position
  36.      */
  37.     public void set(int x, int y) {
  38.         this.x = x;
  39.         this.y = y;
  40.     }
  41.    
  42.     /**
  43.      * Gets the horizontal position (x-coordinate)
  44.      * @return horizontal position
  45.      */
  46.     public int getX() {
  47.         return x;
  48.     }
  49.    
  50.     /**
  51.      * Gets the vertical position (y-coordinate)
  52.      * @return vertical position
  53.      */
  54.     public int getY() {
  55.         return y;
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment