GraphicsApp API
Eine überarbeitete und angepasste Variante der originalen GraphicsApp-Umgebung
Config.java
gehe zur Dokumentation dieser Datei
1package de.ur.mi.oop.app;
2
3import de.ur.mi.oop.colors.Color;
4import de.ur.mi.oop.colors.Colors;
5
6/**
7 * Basiskonfiguration der GraphicsApp-Anwendung
8 */
9
10public class Config {
11
12 private static final int DEFAULT_WIDTH = 1280;
13 private static final int DEFAULT_HEIGHT = 720;
14 private static final int DEFAULT_FRAME_RATE = 60;
15 private static final Color DEFAULT_BACKGROUND_COLOR = Colors.WHITE;
16 private static final Color DEFAULT_COLOR = Colors.RED;
17 private static final boolean DEFAULT_FRAME_RATE_VISIBILITY = false;
18 private static final String DEFAULT_TITLE = "GraphicsApp";
19 private static final boolean DEFAULT_CURSOR_VISIBILITY = true;
20
21 private static final float DEFAULT_STROKE_WIDTH = 2f;
22
23 private int width = DEFAULT_WIDTH;
24 private int height = DEFAULT_HEIGHT;
25 private int frameRate = DEFAULT_FRAME_RATE;
26 private boolean showFrameRate = DEFAULT_FRAME_RATE_VISIBILITY;
27 private Color backgroundColor = DEFAULT_BACKGROUND_COLOR;
28 private float strokeWidth = DEFAULT_STROKE_WIDTH;
29 private String title = DEFAULT_TITLE;
30 private boolean cursorVisibility = DEFAULT_CURSOR_VISIBILITY;
31
32 private ConfigChangeListener listener;
33
34
35 public void setListener(ConfigChangeListener listener) {
36 this.listener = listener;
37 }
38
39 public int getWidth() {
40 return width;
41 }
42
43 public void setWidth(int width) {
44 this.width = width;
45 listener.onSizeChanged(this.width, this.height);
46 }
47
48 public float getStrokeWidth() {
49 return strokeWidth;
50 }
51
52 public void setStrokeWidth(float strokeWidth) {
53 this.strokeWidth = strokeWidth;
54 }
55
56 public int getHeight() {
57 return height;
58 }
59
60 public void setHeight(int height) {
61 this.height = height;
62 listener.onSizeChanged(this.width, this.height);
63 }
64
65 public int getFrameRate() {
66 return frameRate;
67 }
68
69 public void setFrameRate(int frameRate) {
70 this.frameRate = frameRate;
71 listener.onFrameRateChanged(this.frameRate);
72 }
73
75 return DEFAULT_COLOR;
76 }
77
79 return backgroundColor;
80 }
81
82 public void setBackgroundColor(Color backgroundColor) {
83 this.backgroundColor = backgroundColor;
84 }
85
86 public String getTitle() {
87 return title;
88 }
89
90 public void setTitle(String title) {
91 this.title = title;
92 }
93
94 public boolean getCursorVisibility() {
95 return cursorVisibility;
96 }
97
98 public void setCursorVisibility(boolean isVisible) {
99 this.cursorVisibility = isVisible;
100 listener.onCursorVisibilityChanged(this.cursorVisibility);
101 }
102
103 public boolean shouldShowFrameRate() {
104 return this.showFrameRate;
105 }
106
107 public void setFrameRateVisibility(boolean frameRateIsVisible) {
108 this.showFrameRate = frameRateIsVisible;
109 }
110
111}
void setFrameRate(int frameRate)
Definition: Config.java:69
boolean getCursorVisibility()
Definition: Config.java:94
void setFrameRateVisibility(boolean frameRateIsVisible)
Definition: Config.java:107
void setBackgroundColor(Color backgroundColor)
Definition: Config.java:82
void setTitle(String title)
Definition: Config.java:90
Color getBackgroundColor()
Definition: Config.java:78
void setHeight(int height)
Definition: Config.java:60
void setStrokeWidth(float strokeWidth)
Definition: Config.java:52
void setListener(ConfigChangeListener listener)
Definition: Config.java:35
boolean shouldShowFrameRate()
Definition: Config.java:103
void setWidth(int width)
Definition: Config.java:43
void setCursorVisibility(boolean isVisible)
Definition: Config.java:98
static final Color RED
Definition: Colors.java:12
static final Color WHITE
Definition: Colors.java:20
void onCursorVisibilityChanged(boolean cursorVisibility)
void onSizeChanged(int newWidth, int newHeight)
void onFrameRateChanged(int newFramerate)