/[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 1495 by iliev, Mon Sep 17 23:55:27 2007 UTC revision 1496 by iliev, Mon Nov 19 22:22:22 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 175  public class Res { Line 181  public class Res {
181          protected final static ImageIcon gfxBtnCrRO          protected final static ImageIcon gfxBtnCrRO
182                  = new ImageIcon(Res.class.getResource("res/gfx/btn_cr_ro.png"));                  = new ImageIcon(Res.class.getResource("res/gfx/btn_cr_ro.png"));
183                    
184            protected final static ImageIcon gfxStatusBar
185                    = new ImageIcon(Res.class.getResource("res/gfx/statusbar.png"));
186            
187                    
188          protected final static ImageIcon iconAppIcon          protected final static ImageIcon iconAppIcon
189                  = new ImageIcon(Res.class.getResource("res/icons/app_icon.png"));                  = new ImageIcon(Res.class.getResource("res/icons/app_icon.png"));
# Line 273  public class Res { Line 282  public class Res {
282                  = new ImageIcon(Res.class.getResource("res/icons/LinuxSampler-logo.png"));                  = new ImageIcon(Res.class.getResource("res/icons/LinuxSampler-logo.png"));
283                    
284          protected static Font fontScreen = null;          protected static Font fontScreen = null;
285            protected static Font fontScreenMono = null;
286                                    
287                    
288          static {          static {
289                  try {                  try {
290                          fontScreen = Font.createFont (                          fontScreen = Font.createFont (
291                                  Font.TRUETYPE_FONT,                                  Font.TRUETYPE_FONT,
292                                  Res.class.getResourceAsStream("res/fonts/LiberationSans-Bold.ttf")                                  Res.class.getResourceAsStream("res/fonts/DejaVuLGCCondensedSansBold.ttf")
293                          );                          );
294                          fontScreen = fontScreen.deriveFont(10.0f);                          fontScreen = fontScreen.deriveFont(10.0f);
295                            
296                            fontScreenMono = Font.createFont (
297                                    Font.TRUETYPE_FONT,
298                                    Res.class.getResourceAsStream("res/fonts/DejaVuLGCMonoSansBold.ttf")
299                            );
300                            fontScreenMono = fontScreenMono.deriveFont(10.0f);
301                  } catch(Exception e) {                  } catch(Exception e) {
302                          CC.getLogger().warning(HF.getErrorMessage(e));                          CC.getLogger().warning(HF.getErrorMessage(e));
303                  }                  }
304          }          }
305            
306            protected static void
307            loadTheme(String themeName) {
308                    try {
309                            Properties p = new Properties();
310                            p.load(Res.class.getResourceAsStream("res/themes/themes.properties"));
311                            
312                            String path = p.getProperty(themeName);
313                            if(path == null) {
314                                    String s = "Failed to load theme " + themeName;
315                                    s += "! Falling back to the default theme...";
316                                    CC.getLogger().warning(s);
317                                    path = p.getProperty("Graphite");
318                                    if(path == null) {
319                                            CC.getLogger().warning("Failed to load the default theme!");
320                                            CC.cleanExit();
321                                            return;
322                                    }
323                            }
324                            
325                            path = "res/" + path;
326                            if(path.charAt(path.length() - 1) != '/') path += "/";
327                            path += "theme.properties";
328                            p.load(Res.class.getResourceAsStream(path));
329                            
330                            String s = "res/" + p.getProperty("FantasiaLogo.gfx");
331                            gfxFantasiaLogo = new ImageIcon(Res.class.getResource(s));
332                            
333                            s = "res/" + p.getProperty("StandardBar.gfx");
334                            gfxToolBar = new ImageIcon(Res.class.getResource(s));
335                            
336                            insetsToolBar = parseInsets(p.getProperty("StandardBar.insets"));
337                    } catch(Exception e) {
338                            CC.getLogger().log(Level.INFO, "Failed to load theme " + themeName, e);
339                            CC.cleanExit();
340                    }
341            }
342            
343            private static Insets
344            parseInsets(String s) {
345                    Insets i = new Insets(0, 0, 0, 0);
346                    try {
347                            Integer[] list = Parser.parseIntList(s);
348                            if(list.length != 4) throw new Exception();
349                            i.set(list[0], list[1], list[2], list[3]);
350                    } catch(Exception x) {
351                            CC.getLogger().warning("Failed to parse insets: " + s);
352                    }
353                    
354                    return i;
355            }
356  }  }

Legend:
Removed from v.1495  
changed lines
  Added in v.1496

  ViewVC Help
Powered by ViewVC