1package de.ur.mi.oop.graphics;
3import de.ur.mi.oop.app.GraphicsApp;
4import de.ur.mi.oop.colors.Color;
5import de.ur.mi.oop.colors.Colors;
7import java.util.ArrayList;
8import java.util.Iterator;
21 private ArrayList<GraphicsObject> objects;
37 this.objects =
new ArrayList<>();
98 private void updateBackground() {
107 private void drawBackground() {
108 if (backgroundRectangle !=
null) {
109 GraphicsApp.getApp().addToDrawBuffer(backgroundRectangle);
124 this.objects.add(
object);
146 return this.objects.get(index);
158 for (
int i = this.objects.size() - 1; i >= 0; --i) {
183 this.objects.clear();
184 this.backgroundRectangle =
null;
194 this.objects.remove(
object);
202 public void remove(
int index) {
203 this.objects.remove(index);
214 return this.objects.iterator();
236 return this.objects.size();
244 float maxRightBorder = -Float.MAX_VALUE;
246 if (objects.isEmpty()) {
251 float rightBorder =
object.getRightBorder();
252 if (rightBorder > maxRightBorder) {
253 maxRightBorder = rightBorder;
257 return maxRightBorder - this.
getXPos();
261 float maxBottomBorder = -Float.MAX_VALUE;
263 if (objects.isEmpty()) {
268 float bottomBorder =
object.getBottomBorder();
269 if (bottomBorder > maxBottomBorder) {
270 maxBottomBorder = bottomBorder;
274 return maxBottomBorder - this.
getYPos();
325 public void move(
float dx,
float dy) {
343 double minX = Float.MAX_VALUE;
344 double maxX = Float.MIN_VALUE;
345 double minY = Float.MAX_VALUE;
346 double maxY = Float.MIN_VALUE;
349 double objMinX =
object.getLeftBorder();
350 double objMaxX =
object.getRightBorder();
351 double objMinY =
object.getTopBorder();
352 double objMaxY =
object.getBottomBorder();
354 if (objMinX < minX) {
358 if (objMaxX > maxX) {
362 if (objMinY < minY) {
366 if (objMaxY > maxY) {
370 return x >= minX && x <= maxX && y >= minY && y <= maxY;
static GraphicsApp getApp()
void addToDrawBuffer(GraphicsObject object)
static final Color TRANSPARENT
void setPosition(Point point)
boolean contains(float x, float y)
boolean hitTest(float x, float y)
GraphicsObject getObjectAt(Point point)
GraphicsObject getObjectAt(float x, float y)
Compound(Point position, Color backgroundColor)
void setPosition(float x, float y)
Compound(float x, float y)
Iterator< GraphicsObject > iterator()
void move(float dx, float dy)
Compound(float x, float y, Color backgroundColor)
void addRelative(GraphicsObject object)
void add(GraphicsObject object)
void setWidth(float width)
void setHeight(float height)
void setColor(Color color)