1 package org.woehlke.computer.kurzweil.mandelbrot.config;
2
3 import java.io.FileInputStream;
4 import java.io.IOException;
5 import java.io.InputStream;
6 import java.util.Objects;
7 import java.util.Properties;
8
9
10
11
12
13
14
15
16
17
18 public class Config implements ConfigProperties {
19
20 private String title;
21 private String subtitle;
22 private String copyright;
23 private int width;
24 private int height;
25
26 private String buttonsLabel;
27 private String buttonsSwitch;
28 private String buttonsZoom;
29 private String buttonsZoomOut;
30
31 public Config() {
32 String appPropertiesFile = (APP_PROPERTIES_FILENAME);
33 Properties prop = new Properties();
34 try (
35 InputStream input = new FileInputStream(appPropertiesFile)) {
36 prop.load(input);
37
38
39
40
41
42 title = prop.getProperty(KEY_TITLE,TITLE);
43 subtitle = prop.getProperty(KEY_SUBTITLE,SUBTITLE);
44 copyright = prop.getProperty(KEY_COPYRIGHT,COPYRIGHT);
45 String widthString = prop.getProperty(KEY_WIDTH,WIDTH);
46 String heightString = prop.getProperty(KEY_HEIGHT,HEIGHT);
47 width = Integer.parseInt(widthString);
48 height = Integer.parseInt(heightString);
49 buttonsLabel = prop.getProperty(KEY_BUTTONS_LABEL,BUTTONS_LABEL);
50 buttonsSwitch = prop.getProperty(KEY_BUTTONS_SWITCH,BUTTONS_SWITCH);
51 buttonsZoom = prop.getProperty(KEY_BUTTONS_ZOOM,BUTTONS_ZOOM);
52 buttonsZoomOut = prop.getProperty(KEY_BUTTONS_ZOOMOUT,BUTTONS_ZOOMOUT);
53 } catch (IOException ex) {
54 System.out.println(ex.getLocalizedMessage());
55 }
56 }
57
58 public String getTitle() {
59 return title;
60 }
61
62 public String getSubtitle() {
63 return subtitle;
64 }
65
66 public String getCopyright() {
67 return copyright;
68 }
69
70 public int getWidth() {
71 return width;
72 }
73
74 public int getHeight() {
75 return height;
76 }
77
78 public String getButtonsLabel() {
79 return buttonsLabel;
80 }
81
82 public String getButtonsSwitch() {
83 return buttonsSwitch;
84 }
85
86 public String getButtonsZoom() {
87 return buttonsZoom;
88 }
89
90 public String getButtonsZoomOut() {
91 return buttonsZoomOut;
92 }
93
94 @Override
95 public boolean equals(Object o) {
96 if (this == o) return true;
97 if (!(o instanceof Config)) return false;
98 Config../../../../../../org/woehlke/computer/kurzweil/mandelbrot/config/Config.html#Config">Config config = (Config) o;
99 return getWidth() == config.getWidth() &&
100 getHeight() == config.getHeight() &&
101 Objects.equals(getTitle(), config.getTitle()) &&
102 Objects.equals(getSubtitle(), config.getSubtitle()) &&
103 Objects.equals(getCopyright(), config.getCopyright()) &&
104 Objects.equals(getButtonsLabel(), config.getButtonsLabel()) &&
105 Objects.equals(getButtonsSwitch(), config.getButtonsSwitch()) &&
106 Objects.equals(getButtonsZoom(), config.getButtonsZoom()) &&
107 Objects.equals(getButtonsZoomOut(), config.getButtonsZoomOut());
108 }
109
110 @Override
111 public int hashCode() {
112 return Objects.hash(getTitle(), getSubtitle(), getCopyright(), getWidth(), getHeight(), getButtonsLabel(), getButtonsSwitch(), getButtonsZoom(), getButtonsZoomOut());
113 }
114
115 @Override
116 public String toString() {
117 return "Config{" +
118 "title='" + title + '\'' +
119 ", subtitle='" + subtitle + '\'' +
120 ", copyright='" + copyright + '\'' +
121 ", width=" + width +
122 ", height=" + height +
123 ", buttonsLabel='" + buttonsLabel + '\'' +
124 ", buttonsSwitch='" + buttonsSwitch + '\'' +
125 ", buttonsZoom='" + buttonsZoom + '\'' +
126 ", buttonsZoomOut='" + buttonsZoomOut + '\'' +
127 '}';
128 }
129 }