View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  package org.xnap.gui.theme;
21  
22  import javax.swing.plaf.FontUIResource;
23  
24  import java.awt.Component;
25  
26  /***
27   * This class provides a default implementation for a theme. A theme can 
28   * customize the fonts and colors of an application.
29   */
30  public abstract class AbstractTheme implements Theme {
31  
32      //--- Constant(s) ---
33  
34      //--- Data field(s) ---
35  	
36      private String name;
37      
38      //--- Constructor(s) ---
39  
40      public AbstractTheme(String name)
41      {
42  		this.name = name;
43      }
44  
45      //--- Method(s) ---
46  
47      /***
48       * Returns false.
49       */
50      public boolean isConfigurable()
51      {
52  		return false;
53      }
54  
55  	/***
56  	 * Returns false.
57  	 */
58      public boolean isIconTheme()
59      {
60  		return false;
61      }
62  
63      /***
64       * Returns the class name of this theme.
65       */
66      public String getClassName()
67      {
68  		return getClass().getName();
69      }	
70  
71      /***
72       * Show a configuration dialog.
73       *
74       * @return true, if theme should be reloaded; false, otherwise
75       * @see #isConfigurable()
76       */
77      public boolean showConfigurationDialog(Component parent)
78      {
79  		return false;
80      }
81  
82      /***
83       * Returns the name of this theme.
84       */
85      public String getName()
86      {
87  		return name;
88      }
89  
90      /***
91       * Creates and returns font properties. Sets all fonts to
92       * <code>font</code>.
93  	 */
94      public static Object[] createProperties(FontUIResource font)
95      {
96  		Object[] array = new Object[] {
97  			"Table.font", font, 
98  			"TextPane.font", font, 
99  			"TextArea.font", font, 
100 			"TextField.font", font, 
101 			"PasswordField.font", font, 
102 			"EditorPane.font", font, 
103 			"ProgressBar.font", font, 
104 	    
105 			"MenuBar.font", font, 
106 			"Menu.font", font, 
107 			"MenuItem.font", font, 
108 			"PopupMenu.font", font, 
109 			"CheckBoxMenuItem.font", font, 
110 			"RadioButtonMenuItem.font", font, 
111 	    
112 			"CheckBox.font", font, 
113 			"ComboBox.font", font, 
114 			"Button.font", font, 
115 			"Tree.font", font, 
116 			"ScrollPane.font", font, 
117 			"TabbedPane.font", font, 
118 			"TitledBorder.font", font, 
119 			"OptionPane.font", font, 
120 			"ToolBar.font", font, 
121 			"RadioButton.font", font, 
122 			"ToggleButton.font", font, 
123 			"ToolTip.font", font, 
124 			"TableHeader.font", font, 
125 			"Panel.font", font, 
126 			"List.font", font, 
127 			"ColorChooser.font", font, 
128 			"Label.font", font, 
129 			"Viewport.font", font, 
130 		};
131 
132 		return array;
133     }
134 
135     /***
136      * Returns the name of this theme.
137      */
138     public String toString()
139     {
140 		return getName();
141     }
142 
143 }