Revision 41314 trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/theme/Theme.java

View differences:

Theme.java
33 33
import java.util.Map;
34 34

  
35 35
import javax.swing.ImageIcon;
36
import javax.swing.UIManager;
36 37
import org.apache.commons.io.IOUtils;
37 38
import org.apache.commons.lang.text.StrSubstitutor;
39
import org.apache.commons.lang3.StringUtils;
38 40

  
39 41
import org.gvsig.andami.Launcher;
40 42
import org.gvsig.andami.PluginServices;
......
71 73
    private static final String PRIORITY = "priority";
72 74
    private static final String VALUE = "value";
73 75
    private static final String BACKGROUND_IMAGE = "BackgroundImage";
76
    private static final String BACKGROUND_COLOR = "BackgroundColor";
74 77
    private static final String WALLPAPER_TYPE = "WallpaperType";
75 78

  
76 79
    private static final String VERSION = "version";
......
90 93
    private ArrayList<String> fontpositionsY = new ArrayList<String>();
91 94

  
92 95
    private String name = null;
93
    private String backgroundimage;
96
    private String backgroundimage = null;
97
    private Color backgroundColor = null;
94 98
    private String wallpaperType = CENTERED;
95 99
    private int priority = 0;
96 100

  
......
101 105
    private StrSubstitutor strSubstitutor = null;
102 106

  
103 107
    public Theme() {
104

  
105 108
    }
106 109

  
107 110
    public Theme(Map vars) {
111
        this();
108 112
        this.strSubstitutor = new StrSubstitutor(vars);
109 113
    }
110 114

  
......
121 125
        FileInputStream fis = null;
122 126
        try {
123 127
            String encoding = XMLUtils.getEncoding(file, "UTF-8");
124
            
128

  
125 129
            fis = new FileInputStream(file);
126 130
            KXmlParser parser = new KXmlParser();
127 131
            parser.setInput(fis, encoding);
......
171 175
                                    if ( parser.getName().compareTo(BACKGROUND_IMAGE) == 0 ) {
172 176
                                        backgroundimage = fixPath(file, parser.getAttributeValue("", PATH));
173 177
                                        tag = parser.next();
178
                                    } else if ( parser.getName().compareTo(BACKGROUND_COLOR) == 0 ) {
179
                                        backgroundColor = parseColor(parser.getAttributeValue("", "color"));
180
                                        tag = parser.next();
174 181
                                    } else if ( parser.getName().compareTo(ICON) == 0 ) {
175 182
                                        icon = fixPath(file, parser.getAttributeValue("", PATH));
176 183
                                        tag = parser.next();
......
191 198
                            String s = parser.getAttributeValue("", VALUE);
192 199
                            try {
193 200
                                this.priority = Integer.parseInt(s);
194
                            } catch(Exception ex) {
201
                            } catch (Exception ex) {
195 202
                                this.priority = 0;
196 203
                            }
197 204
                            tag = parser.next();
......
291 298
        }
292 299
    }
293 300

  
301
    public Color getBackgroundColor() {
302
        if ( this.backgroundColor == null ) {
303
            this.backgroundColor = (Color) UIManager.get("Desktop.background");
304
        }
305
        return this.backgroundColor;
306
    }
307

  
294 308
    /**
295 309
     * Return the time of the splash images.
296 310
     *
......
368 382
        for ( int i = 0; i < colors.length; i++ ) {
369 383
            try {
370 384
                String s = fontColors.get(i);
371
                String[] rgb = s.split(",");
372
                colors[i] = new Color(Integer.valueOf(rgb[0]), Integer.valueOf(rgb[1]), Integer.valueOf(rgb[2]));
385
                colors[i] = parseColor(s);
373 386
            } catch (Exception e) {
374 387
                NotificationManager.addInfo(PluginServices.getText(this, "incorrect_color"), e);
375 388
            }
......
377 390
        return colors;
378 391
    }
379 392

  
393
    private Color parseColor(String s) {
394
        if ( StringUtils.isEmpty(s) ) {
395
            return null;
396
        }
397
        String[] rgb = s.split(",");
398
        Color color = new Color(Integer.valueOf(rgb[0]), Integer.valueOf(rgb[1]), Integer.valueOf(rgb[2]));
399
        return color;
400
    }
401

  
380 402
    private String expand(String value) {
381 403
        if ( this.strSubstitutor == null ) {
382 404
            return value;
383 405
        }
384 406
        return strSubstitutor.replace(value);
385 407
    }
386
    
408

  
387 409
    public int getPriority() {
388 410
        return this.priority;
389 411
    }

Also available in: Unified diff