GraphicsApp API
Eine überarbeitete und angepasste Variante der originalen GraphicsApp-Umgebung
Point.java
gehe zur Dokumentation dieser Datei
1package de.ur.mi.oop.graphics;
2
3/**
4 * Die Punktklasse repräsentiert einen Punkt auf der Zeichenfläche.
5 */
6public class Point {
7 private float x;
8 private float y;
9
10 /**
11 * Erzeugt einen neuen Point bei (0, 0).
12 */
13 public Point() {
14 this.x = 0.0f;
15 this.y = 0.0f;
16 }
17
18 /**
19 * Erzeugt einen neuen Point bei (x, y).
20 *
21 * @param x die x-Koordinate des Punktes
22 * @param y die y-Koordinate des Punktes
23 */
24 public Point(float x, float y) {
25 this.x = x;
26 this.y = y;
27 }
28
29 public float getXPos() {
30 return this.x;
31 }
32
33 public float getYPos() {
34 return this.y;
35 }
36
37 public Point getPosition() {
38 return new Point(this.x, this.y);
39 }
40
41 /**
42 * Setzt die Position des Punktes auf die angegebene Position.
43 *
44 * @param x Die x-Position des Punktes
45 * @param y y
46 * Die y-Position des Punktes
47 */
48 public void setLocation(float x, float y) {
49 this.x = x;
50 this.y = y;
51 }
52
53 /**
54 * Bewegt den Punkt auf dem Bildschirm mit den Verschiebungen dx und dy.
55 *
56 * @param dx Die horizontale Änderung der Position
57 * @param dy Die vertikale Änderung der Position
58 */
59 public void move(float dx, float dy) {
60 this.x += dx;
61 this.y += dy;
62 }
63
64 /**
65 * Setzt die Position des Punktes auf die Position eines neuen Punktobjekts.
66 *
67 * @param point Der Punkt, der die neuen Positionsinformationen enthält.
68 */
69 public void setLocation(Point point) {
70 this.x = point.x;
71 this.y = point.y;
72 }
73}
Point(float x, float y)
Definition: Point.java:24
void setLocation(float x, float y)
Definition: Point.java:48
void setLocation(Point point)
Definition: Point.java:69
void move(float dx, float dy)
Definition: Point.java:59