/[svn]/jsampler/trunk/src/org/jsampler/view/fantasia/Res.java
ViewVC logotype

Diff of /jsampler/trunk/src/org/jsampler/view/fantasia/Res.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1355 by iliev, Mon Sep 17 23:55:27 2007 UTC revision 1497 by iliev, Mon Nov 19 22:26:16 2007 UTC
# Line 23  Line 23 
23  package org.jsampler.view.fantasia;  package org.jsampler.view.fantasia;
24    
25  import java.awt.Font;  import java.awt.Font;
26    import java.awt.Insets;
27    
28    import java.util.Properties;
29    import java.util.logging.Level;
30    
31  import javax.swing.ImageIcon;  import javax.swing.ImageIcon;
32    
33  import org.jsampler.CC;  import org.jsampler.CC;
34  import org.jsampler.HF;  import org.jsampler.HF;
35    
36    import org.linuxsampler.lscp.Parser;
37    
38    
39  /**  /**
40   * This class contains all pixmap resources needed by <b>Fantasia</b> view.   * This class contains all pixmap resources needed by <b>Fantasia</b> view.
# Line 38  public class Res { Line 45  public class Res {
45          /** Forbits the instantiation of this class. */          /** Forbits the instantiation of this class. */
46          private Res() { }          private Res() { }
47                    
48          protected final static ImageIcon gfxFantasiaLogo          protected static ImageIcon gfxFantasiaLogo;
                 = new ImageIcon(Res.class.getResource("res/gfx/fantasia_logo.png"));  
49                    
50          protected final static ImageIcon gfxPowerOn          protected final static ImageIcon gfxPowerOn
51                  = new ImageIcon(Res.class.getResource("res/gfx/power_on.png"));                  = new ImageIcon(Res.class.getResource("res/gfx/power_on.png"));
# Line 163  public class Res { Line 169  public class Res {
169          protected final static ImageIcon gfxChannelsBg          protected final static ImageIcon gfxChannelsBg
170                  = new ImageIcon(Res.class.getResource("res/gfx/channels_bg.png"));                  = new ImageIcon(Res.class.getResource("res/gfx/channels_bg.png"));
171                    
172          protected final static ImageIcon gfxToolbar          protected static ImageIcon gfxToolBar;
173                  = new ImageIcon(Res.class.getResource("res/gfx/toolbar.png"));          protected static Insets insetsToolBar;
174                    
175          protected final static ImageIcon gfxBorder          protected final static ImageIcon gfxBorder
176                  = new ImageIcon(Res.class.getResource("res/gfx/border.png"));                  = new ImageIcon(Res.class.getResource("res/gfx/border.png"));
# Line 273  public class Res { Line 279  public class Res {
279                  = new ImageIcon(Res.class.getResource("res/icons/LinuxSampler-logo.png"));                  = new ImageIcon(Res.class.getResource("res/icons/LinuxSampler-logo.png"));
280                    
281          protected static Font fontScreen = null;          protected static Font fontScreen = null;
282            protected static Font fontScreenMono = null;
283                                    
284                    
285          static {          static {
286                  try {                  try {
287                          fontScreen = Font.createFont (                          fontScreen = Font.createFont (
288                                  Font.TRUETYPE_FONT,                                  Font.TRUETYPE_FONT,
289                                  Res.class.getResourceAsStream("res/fonts/LiberationSans-Bold.ttf")                                  Res.class.getResourceAsStream("res/fonts/DejaVuLGCCondensedSansBold.ttf")
290                          );                          );
291                          fontScreen = fontScreen.deriveFont(10.0f);                          fontScreen = fontScreen.deriveFont(10.0f);
292                            
293                            fontScreenMono = Font.createFont (
294                                    Font.TRUETYPE_FONT,
295                                    Res.class.getResourceAsStream("res/fonts/DejaVuLGCMonoSansBold.ttf")
296                            );
297                            fontScreenMono = fontScreenMono.deriveFont(10.0f);
298                  } catch(Exception e) {                  } catch(Exception e) {
299                          CC.getLogger().warning(HF.getErrorMessage(e));                          CC.getLogger().warning(HF.getErrorMessage(e));
300                  }                  }
301          }          }
302            
303            protected static void
304            loadTheme(String themeName) {
305                    try {
306                            Properties p = new Properties();
307                            p.load(Res.class.getResourceAsStream("res/themes/themes.properties"));
308                            
309                            String path = p.getProperty(themeName);
310                            if(path == null) {
311                                    String s = "Failed to load theme " + themeName;
312                                    s += "! Falling back to the default theme...";
313                                    CC.getLogger().warning(s);
314                                    path = p.getProperty("Graphite");
315                                    if(path == null) {
316                                            CC.getLogger().warning("Failed to load the default theme!");
317                                            CC.cleanExit();
318                                            return;
319                                    }
320                            }
321                            
322                            path = "res/" + path;
323                            if(path.charAt(path.length() - 1) != '/') path += "/";
324                            path += "theme.properties";
325                            p.load(Res.class.getResourceAsStream(path));
326                            
327                            String s = "res/" + p.getProperty("FantasiaLogo.gfx");
328                            gfxFantasiaLogo = new ImageIcon(Res.class.getResource(s));
329                            
330                            s = "res/" + p.getProperty("StandardBar.gfx");
331                            gfxToolBar = new ImageIcon(Res.class.getResource(s));
332                            
333                            insetsToolBar = parseInsets(p.getProperty("StandardBar.insets"));
334                    } catch(Exception e) {
335                            CC.getLogger().log(Level.INFO, "Failed to load theme " + themeName, e);
336                            CC.cleanExit();
337                    }
338            }
339            
340            private static Insets
341            parseInsets(String s) {
342                    Insets i = new Insets(0, 0, 0, 0);
343                    try {
344                            Integer[] list = Parser.parseIntList(s);
345                            if(list.length != 4) throw new Exception();
346                            i.set(list[0], list[1], list[2], list[3]);
347                    } catch(Exception x) {
348                            CC.getLogger().warning("Failed to parse insets: " + s);
349                    }
350                    
351                    return i;
352            }
353  }  }

Legend:
Removed from v.1355  
changed lines
  Added in v.1497

  ViewVC Help
Powered by ViewVC