Graphic Rendering System 1.0
A Java-based graphic rendering system implementing various design patterns
Loading...
Searching...
No Matches
ShapeSubject.java
Go to the documentation of this file.
1package com.example.graphics.observer;
2
3import com.example.graphics.model.Shape;
4import java.util.ArrayList;
5import java.util.List;
6
11public class ShapeSubject {
12 private final List<ShapeObserver> observers;
13
17 public ShapeSubject() {
18 observers = new ArrayList<>();
19 }
20
26 if (!observers.contains(observer)) {
28 }
29 }
30
36 observers.remove(observer);
37 }
38
43 public void notifyShapeAdded(Shape shape) {
45 observer.onShapeAdded(shape);
46 }
47 }
48
53 public void notifyShapeRemoved(Shape shape) {
55 observer.onShapeRemoved(shape);
56 }
57 }
58
63 public void notifyShapeModified(Shape shape) {
65 observer.onShapeModified(shape);
66 }
67 }
68}
final List< ShapeObserver > observers
void addObserver(ShapeObserver observer)
void removeObserver(ShapeObserver observer)