11package gui ;
22
33import java .awt .Color ;
4- import java .awt .Component ;
5- import java .awt .Container ;
64import java .awt .Dimension ;
75import java .awt .GridBagConstraints ;
86import java .awt .GridBagLayout ;
9- import java .util .ArrayList ;
10- import java .util .List ;
117
128import javax .swing .BoxLayout ;
139import javax .swing .JButton ;
1612import javax .swing .JLabel ;
1713import javax .swing .JPanel ;
1814import javax .swing .JTextField ;
19- import javax .swing .border .MatteBorder ;
20- import javax .swing .border .TitledBorder ;
21-
22- import edit .CellEditDialog ;
23- import logic .Row ;
24- import logic .Section ;
2515
2616public class ColorSettings
2717{
@@ -36,7 +26,7 @@ public class ColorSettings
3626 static void selectColorSettings (int index )
3727 {
3828 currentColorSetting = colorSettingProfiles [index ];
39- applyLightingMode ();
29+ MainGui . updateLightingSettings ();
4030 }
4131
4232 private static void fillColorSettingsPane (JPanel options_panel , ColorSettingProfile color_setting )
@@ -103,7 +93,7 @@ private static void fillColorSettingsRow(JPanel panel, GridBagConstraints gbc, C
10393 private static void updateCustomColorSettings (JDialog options )
10494 {
10595 int [][] colors = new int [3 ][3 ];
106- getAllComponents (options ).stream ().filter (comp -> comp instanceof JTextField ).forEach (text -> {
96+ GuiHelper . getAllComponents (options ).stream ().filter (comp -> comp instanceof JTextField ).forEach (text -> {
10797 String name = text .getName ();
10898 colors [name .startsWith ("Text" ) ? 0 : name .startsWith ("Border" ) ? 1 : 2 ][name .endsWith ("r" ) ? 0 : name .endsWith ("g" ) ? 1 : 2 ] = getColorInt ( (JTextField ) text );
10999 });
@@ -129,49 +119,6 @@ private static int getColorInt(JTextField text)
129119
130120 return res ;
131121 }
132-
133- static void applyLightingMode ()
134- {
135- // backgrounds
136- MainGui .window .setBackground (ColorSettings .getBackgroundColor () );
137- MainGui .scrollPane .setBackground (ColorSettings .getBackgroundColor () );
138- MainGui .mainPanel .setBackground (ColorSettings .getBackgroundColor () );
139-
140- // text for cells
141- for (JLabel label : MainGui .labelsText ) label .setForeground (ColorSettings .getTextColor () );
142-
143- // text for add-remove-controls
144- for (JLabel label : MainGui .labelsTextsHideWhenNotInEdit ) label .setForeground (MainGui .inEditMode ? ColorSettings .getTextColor () : ColorSettings .getBackgroundColor () );
145-
146- // border color for sections
147- for (Section section : MainGui .sectionsList )
148- if (section .getBorder () != null )
149- ((TitledBorder ) section .getBorder () ).setTitleColor (ColorSettings .getTextColor () );
150-
151- // border for cells
152- for (Section section : MainGui .sectionsList )
153- for (Row row : section .getRows () )
154- for (JPanel cell : row .getCells () )
155- if (cell .getBorder () != null )
156- cell .setBorder (new MatteBorder ( ((MatteBorder ) cell .getBorder () ).getBorderInsets (), ColorSettings .getBorderColor () ) );
157-
158- // border for section label cells
159- for (JLabel label : MainGui .sectionLabels )
160- {
161- label .setBorder (new MatteBorder ( ((MatteBorder ) label .getBorder () ).getBorderInsets (), ColorSettings .getBorderColor () ) );
162- label .setForeground (ColorSettings .getTextColor () );
163- }
164-
165- // background and border for sectionManagerDialog
166- if (edit .SectionManagerDialog .sectionManagerPanel != null )
167- {
168- edit .SectionManagerDialog .sectionManagerPanel .setBackground (ColorSettings .getBackgroundColor () );
169- edit .SectionManagerDialog .sectionManagerPanel .setBorder (new MatteBorder ( ((MatteBorder ) edit .SectionManagerDialog .sectionManagerPanel .getBorder () ).getBorderInsets (), ColorSettings .getTextColor () ) );
170- }
171-
172- // unpdate CellEditDialog
173- CellEditDialog .updateColorSettings ();
174- }
175122
176123 static void changeCustomLightingSettings ()
177124 {
@@ -221,16 +168,4 @@ static void changeCustomLightingSettings()
221168 options .setVisible (true );
222169 options .repaint ();
223170 }
224-
225- private static List <Component > getAllComponents (final Container c )
226- {
227- List <Component > compList = new ArrayList <Component >();
228- for (Component comp : c .getComponents ()) {
229- compList .add (comp );
230- if (comp instanceof Container )
231- compList .addAll (getAllComponents ((Container ) comp ));
232- }
233- return compList ;
234- }
235-
236171}
0 commit comments