GraphicsApp API
Eine überarbeitete und angepasste Variante der originalen GraphicsApp-Umgebung
GraphicsAppCore.java
gehe zur Dokumentation dieser Datei
1package de.ur.mi.oop.app;
2
3import de.ur.mi.oop.graphics.GraphicsObject;
4
5import java.lang.ref.Cleaner;
6import java.util.ArrayList;
7
8/**
9 * Die GraphicsAppCore-Klasse verwaltet den Zeichenpuffer und die Konfiguration.
10 */
11public class GraphicsAppCore {
12
13 private static GraphicsAppCore app = null;
14 private AppManager manager;
15 private ArrayList<GraphicsObject> drawBuffer;
16 private Config config;
17
18 /*
19 * Full singleton pattern might not be possible:
20 *
21 * On runtime, only one GraphicsApp instance is allowed but all GraphicsApps need a public constructor to be created
22 * in GraphicsAppLauncher via reflection.
23 */
24 public GraphicsAppCore() {
25 try {
26 if (app == null) {
27 app = this;
28 drawBuffer = new ArrayList<>();
29 } else {
31 }
33 e.printStackTrace();
34 }
35 }
36
37 public static GraphicsApp getApp() {
38 return (GraphicsApp) app;
39 }
40
41 public void setAppManager(AppManager manager) {
42 this.manager = manager;
43 }
44
46 return manager;
47 }
48
49 public void setConfig(Config config) {
50 this.config = config;
51 }
52
53 public Config getConfig() {
54 return config;
55 }
56
57 public void addToDrawBuffer(GraphicsObject object) {
58 drawBuffer.add(object);
59 }
60
62 // TODO Think about passing copies of the objects!
63 return drawBuffer.toArray(new GraphicsObject[0]);
64 }
65
66 public void clearDrawBuffer() {
67 drawBuffer.clear();
68 }
69
70 public void destroy() {
71 app = null;
72 }
73}
void setAppManager(AppManager manager)
void addToDrawBuffer(GraphicsObject object)