1package com.example.graphics;
3import com.example.graphics.command.AddShapeCommand;
4import com.example.graphics.command.CommandManager;
5import com.example.graphics.command.MoveShapeCommand;
6import com.example.graphics.command.RemoveShapeCommand;
7import com.example.graphics.model.Shape;
8import com.example.graphics.model.Triangle;
9import com.example.graphics.observer.ShapeObserver;
10import com.example.graphics.observer.ShapeSubject;
11import com.example.graphics.render.Renderer;
12import com.example.graphics.visitor.ShapeVisitor;
14import java.io.Serializable;
15import java.util.ArrayList;
22public class Drawing implements Serializable {
35 this.shapes =
new ArrayList<>();
126 return new ArrayList<>(
shapes);
136 if (shape instanceof com.example.graphics.model.Circle) {
137 renderer.renderCircle((com.example.graphics.model.Circle) shape);
138 }
else if (shape instanceof com.example.graphics.model.Rectangle) {
139 renderer.renderRectangle((com.example.graphics.model.Rectangle) shape);
140 }
else if (shape instanceof com.example.graphics.model.Line) {
141 renderer.renderLine((com.example.graphics.model.Line) shape);
142 }
else if (shape instanceof com.example.graphics.model.Triangle) {
143 renderer.renderTriangle((com.example.graphics.model.Triangle) shape);
void setRenderer(Renderer renderer)
void removeObserver(ShapeObserver observer)
void moveShape(Shape shape, int x, int y)
List< Shape > getShapes()
final List< Shape > shapes
transient Renderer renderer
final CommandManager commandManager
void addShape(Shape shape)
void acceptVisitor(ShapeVisitor visitor)
final ShapeSubject shapeSubject
static final long serialVersionUID
void addObserver(ShapeObserver observer)
Drawing(Renderer renderer)
void removeShape(Shape shape)