Graphic Rendering System 1.0
A Java-based graphic rendering system implementing various design patterns
Loading...
Searching...
No Matches
Rectangle.java
Go to the documentation of this file.
1package com.example.graphics.model;
2
3import com.example.graphics.visitor.ShapeVisitor;
4
8public class Rectangle implements Shape {
9 private int x;
10 private int y;
11 private int width;
12 private int height;
13
21 public Rectangle(int x, int y, int width, int height) {
22 this.x = x;
23 this.y = y;
24 this.width = width;
25 this.height = height;
26 }
27
28 @Override
29 public int getX() {
30 return x;
31 }
32
33 @Override
34 public int getY() {
35 return y;
36 }
37
38 @Override
39 public void setPosition(int x, int y) {
40 this.x = x;
41 this.y = y;
42 }
43
48 public int getWidth() {
49 return width;
50 }
51
56 public void setWidth(int width) {
57 this.width = width;
58 }
59
64 public int getHeight() {
65 return height;
66 }
67
72 public void setHeight(int height) {
73 this.height = height;
74 }
75
81 public void setSize(int width, int height) {
82 this.width = width;
83 this.height = height;
84 }
85
86 @Override
88 visitor.visit(this);
89 }
90
91 @Override
92 public Shape clone() {
93 return new Rectangle(this.x, this.y, this.width, this.height);
94 }
95}
void accept(ShapeVisitor visitor)
void setSize(int width, int height)
Rectangle(int x, int y, int width, int height)