11package gui ;
22import java .awt .Color ;
33
4+ import org .w3c .dom .Document ;
5+ import org .w3c .dom .Element ;
6+
47public class ColorSettingProfile
58 {
6- public String name ;
7- public Color text ;
8- public Color border ;
9- public Color background ;
9+ private String name ;
10+ private Color text ;
11+ private Color border ;
12+ private Color background ;
1013
1114 public ColorSettingProfile (String name , Color text , Color border , Color background )
1215 {
@@ -15,4 +18,50 @@ public ColorSettingProfile(String name, Color text, Color border, Color backgrou
1518 this .border = border ;
1619 this .background = background ;
1720 }
21+
22+ public ColorSettingProfile (Element profile , String current_profile_name )
23+ {
24+ this .name = profile .getElementsByTagName ("name" ).item (0 ).getTextContent ();
25+ this .text = new Color (Integer .parseInt (profile .getElementsByTagName ("text" ).item (0 ).getTextContent () ) );
26+ this .border = new Color (Integer .parseInt (profile .getElementsByTagName ("border" ).item (0 ).getTextContent () ) );
27+ this .background = new Color (Integer .parseInt (profile .getElementsByTagName ("background" ).item (0 ).getTextContent () ) );
28+
29+ if (name .equals (current_profile_name ) )
30+ ColorSettings .currentColorSetting = this ;
31+ }
32+
33+ public void update (Color text , Color border , Color background )
34+ {
35+ this .text = text ;
36+ this .border = border ;
37+ this .background = background ;
38+ }
39+
40+ public String getName () { return name ; }
41+ public Color getTextColor () { return text ; }
42+ public Color getBorderColor () { return border ; }
43+ public Color getBackgroundColor () { return background ; }
44+
45+ public Element getXMLElement (Document doc )
46+ {
47+ Element result = doc .createElement ("color-profile" );
48+
49+ Element titleElement = doc .createElement ("name" );
50+ titleElement .setTextContent (name );
51+ result .appendChild (titleElement );
52+
53+ Element textElement = doc .createElement ("text" );
54+ textElement .setTextContent ("" + text .getRGB () );
55+ result .appendChild (textElement );
56+
57+ Element borderElement = doc .createElement ("border" );
58+ borderElement .setTextContent ("" + border .getRGB () );
59+ result .appendChild (borderElement );
60+
61+ Element backgroundElement = doc .createElement ("background" );
62+ backgroundElement .setTextContent ("" + background .getRGB () );
63+ result .appendChild (backgroundElement );
64+
65+ return result ;
66+ }
1867 }
0 commit comments