Source Code Cross Referenced for Region.java in  » 6.0-JDK-Core » swing » javax » swing » plaf » synth » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » swing » javax.swing.plaf.synth 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 2002-2004 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025        package javax.swing.plaf.synth;
026
027        import javax.swing.*;
028        import java.util.*;
029
030        /**
031         * A distinct rendering area of a Swing component.  A component may
032         * support one or more regions.  Specific component regions are defined
033         * by the typesafe enumeration in this class.
034         * <p>
035         * Regions are typically used as a way to identify the <code>Component</code>s
036         * and areas a particular style is to apply to. Synth's file format allows you 
037         * to bind styles based on the name of a <code>Region</code>.  
038         * The name is derived from the field name of the constant:
039         * <ol>
040         *  <li>Map all characters to lowercase.
041         *  <li>Map the first character to uppercase.
042         *  <li>Map the first character after underscores to uppercase.
043         *  <li>Remove all underscores.
044         * </ol>
045         * For example, to identify the <code>SPLIT_PANE</code>
046         * <code>Region</code> you would use <code>SplitPane</code>.
047         * The following shows a custom <code>SynthStyleFactory</code> 
048         * that returns a specific style for split panes:
049         * <pre>
050         *    public SynthStyle getStyle(JComponent c, Region id) {
051         *        if (id == Region.SPLIT_PANE) {
052         *            return splitPaneStyle;
053         *        }
054         *        ...
055         *    }
056         * </pre>
057         * The following <a href="doc-files/synthFileFormat.html">xml</a>
058         * accomplishes the same thing:
059         * <pre>
060         * &lt;style id="splitPaneStyle">
061         *   ...
062         * &lt;/style>
063         * &lt;bind style="splitPaneStyle" type="region" key="SplitPane"/>
064         * </pre>
065         *
066         * @version 1.37, 05/05/07
067         * @since 1.5
068         * @author Scott Violet
069         */
070        public class Region {
071            private static final Map uiToRegionMap = new HashMap();
072            private static final Map lowerCaseNameMap = new HashMap();
073
074            /**
075             * ArrowButton's are special types of buttons that also render a
076             * directional indicator, typically an arrow. ArrowButtons are used by 
077             * composite components, for example ScrollBar's contain ArrowButtons.
078             * To bind a style to this <code>Region</code> use the name 
079             * <code>ArrowButton</code>.
080             */
081            public static final Region ARROW_BUTTON = new Region("ArrowButton",
082                    "ArrowButtonUI");
083
084            /**
085             * Button region. To bind a style to this <code>Region</code> use the name 
086             * <code>Button</code>.
087             */
088            public static final Region BUTTON = new Region("Button", "ButtonUI");
089
090            /**
091             * CheckBox region. To bind a style to this <code>Region</code> use the name 
092             * <code>CheckBox</code>. 
093             */
094            public static final Region CHECK_BOX = new Region("CheckBox",
095                    "CheckBoxUI");
096
097            /**
098             * CheckBoxMenuItem region. To bind a style to this <code>Region</code> use 
099             * the name <code>CheckBoxMenuItem</code>.
100             */
101            public static final Region CHECK_BOX_MENU_ITEM = new Region(
102                    "CheckBoxMenuItem", "CheckBoxMenuItemUI");
103
104            /**
105             * ColorChooser region. To bind a style to this <code>Region</code> use 
106             * the name <code>ColorChooser</code>.
107             */
108            public static final Region COLOR_CHOOSER = new Region(
109                    "ColorChooser", "ColorChooserUI");
110
111            /**
112             * ComboBox region. To bind a style to this <code>Region</code> use 
113             * the name <code>ComboBox</code>.
114             */
115            public static final Region COMBO_BOX = new Region("ComboBox",
116                    "ComboBoxUI");
117
118            /**
119             * DesktopPane region. To bind a style to this <code>Region</code> use 
120             * the name <code>DesktopPane</code>.
121             */
122            public static final Region DESKTOP_PANE = new Region("DesktopPane",
123                    "DesktopPaneUI");
124            /**
125             * DesktopIcon region. To bind a style to this <code>Region</code> use 
126             * the name <code>DesktopIcon</code>.
127             */
128            public static final Region DESKTOP_ICON = new Region("DesktopIcon",
129                    "DesktopIconUI");
130
131            /**
132             * EditorPane region. To bind a style to this <code>Region</code> use 
133             * the name <code>EditorPane</code>.
134             */
135            public static final Region EDITOR_PANE = new Region("EditorPane",
136                    "EditorPaneUI");
137
138            /**
139             * FileChooser region. To bind a style to this <code>Region</code> use 
140             * the name <code>FileChooser</code>.
141             */
142            public static final Region FILE_CHOOSER = new Region("FileChooser",
143                    "FileChooserUI");
144
145            /**
146             * FormattedTextField region. To bind a style to this <code>Region</code> use 
147             * the name <code>FormattedTextField</code>.
148             */
149            public static final Region FORMATTED_TEXT_FIELD = new Region(
150                    "FormattedTextField", "FormattedTextFieldUI");
151
152            /**
153             * InternalFrame region. To bind a style to this <code>Region</code> use 
154             * the name <code>InternalFrame</code>.
155             */
156            public static final Region INTERNAL_FRAME = new Region(
157                    "InternalFrame", "InternalFrameUI");
158            /**
159             * TitlePane of an InternalFrame. The TitlePane typically 
160             * shows a menu, title, widgets to manipulate the internal frame. 
161             * To bind a style to this <code>Region</code> use the name 
162             * <code>InternalFrameTitlePane</code>.
163             */
164            public static final Region INTERNAL_FRAME_TITLE_PANE = new Region(
165                    "InternalFrameTitlePane", "InternalFrameTitlePaneUI");
166
167            /**
168             * Label region. To bind a style to this <code>Region</code> use the name 
169             * <code>Label</code>.
170             */
171            public static final Region LABEL = new Region("Label", "LabelUI");
172
173            /**
174             * List region. To bind a style to this <code>Region</code> use the name 
175             * <code>List</code>. 
176             */
177            public static final Region LIST = new Region("List", "ListUI");
178
179            /**
180             * Menu region. To bind a style to this <code>Region</code> use the name 
181             * <code>Menu</code>.
182             */
183            public static final Region MENU = new Region("Menu", "MenuUI");
184
185            /**
186             * MenuBar region. To bind a style to this <code>Region</code> use the name 
187             * <code>MenuBar</code>.
188             */
189            public static final Region MENU_BAR = new Region("MenuBar",
190                    "MenuBarUI");
191
192            /**
193             * MenuItem region. To bind a style to this <code>Region</code> use the name 
194             * <code>MenuItem</code>.
195             */
196            public static final Region MENU_ITEM = new Region("MenuItem",
197                    "MenuItemUI");
198
199            /**
200             * Accelerator region of a MenuItem. To bind a style to this 
201             * <code>Region</code> use the name <code>MenuItemAccelerator</code>.
202             */
203            public static final Region MENU_ITEM_ACCELERATOR = new Region(
204                    "MenuItemAccelerator");
205
206            /**
207             * OptionPane region. To bind a style to this <code>Region</code> use 
208             * the name <code>OptionPane</code>.
209             */
210            public static final Region OPTION_PANE = new Region("OptionPane",
211                    "OptionPaneUI");
212
213            /**
214             * Panel region. To bind a style to this <code>Region</code> use the name 
215             * <code>Panel</code>.
216             */
217            public static final Region PANEL = new Region("Panel", "PanelUI");
218
219            /**
220             * PasswordField region. To bind a style to this <code>Region</code> use 
221             * the name <code>PasswordField</code>.
222             */
223            public static final Region PASSWORD_FIELD = new Region(
224                    "PasswordField", "PasswordFieldUI");
225
226            /**
227             * PopupMenu region. To bind a style to this <code>Region</code> use 
228             * the name <code>PopupMenu</code>.
229             */
230            public static final Region POPUP_MENU = new Region("PopupMenu",
231                    "PopupMenuUI");
232
233            /**
234             * PopupMenuSeparator region. To bind a style to this <code>Region</code>
235             * use the name <code>PopupMenuSeparator</code>.
236             */
237            public static final Region POPUP_MENU_SEPARATOR = new Region(
238                    "PopupMenuSeparator", "PopupMenuSeparatorUI");
239
240            /**
241             * ProgressBar region. To bind a style to this <code>Region</code>
242             * use the name <code>ProgressBar</code>.
243             */
244            public static final Region PROGRESS_BAR = new Region("ProgressBar",
245                    "ProgressBarUI");
246
247            /**
248             * RadioButton region. To bind a style to this <code>Region</code>
249             * use the name <code>RadioButton</code>.
250             */
251            public static final Region RADIO_BUTTON = new Region("RadioButton",
252                    "RadioButtonUI");
253
254            /**
255             * RegionButtonMenuItem region. To bind a style to this <code>Region</code>
256             * use the name <code>RadioButtonMenuItem</code>.
257             */
258            public static final Region RADIO_BUTTON_MENU_ITEM = new Region(
259                    "RadioButtonMenuItem", "RadioButtonMenuItemUI");
260
261            /**
262             * RootPane region. To bind a style to this <code>Region</code> use 
263             * the name <code>RootPane</code>.
264             */
265            public static final Region ROOT_PANE = new Region("RootPane",
266                    "RootPaneUI");
267
268            /**
269             * ScrollBar region. To bind a style to this <code>Region</code> use 
270             * the name <code>ScrollBar</code>.
271             */
272            public static final Region SCROLL_BAR = new Region("ScrollBar",
273                    "ScrollBarUI");
274            /**
275             * Track of the ScrollBar. To bind a style to this <code>Region</code> use 
276             * the name <code>ScrollBarTrack</code>.
277             */
278            public static final Region SCROLL_BAR_TRACK = new Region(
279                    "ScrollBarTrack");
280            /**
281             * Thumb of the ScrollBar. The thumb is the region of the ScrollBar 
282             * that gives a graphical depiction of what percentage of the View is 
283             * currently visible. To bind a style to this <code>Region</code> use 
284             * the name <code>ScrollBarThumb</code>.
285             */
286            public static final Region SCROLL_BAR_THUMB = new Region(
287                    "ScrollBarThumb");
288
289            /**
290             * ScrollPane region. To bind a style to this <code>Region</code> use 
291             * the name <code>ScrollPane</code>.
292             */
293            public static final Region SCROLL_PANE = new Region("ScrollPane",
294                    "ScrollPaneUI");
295
296            /**
297             * Separator region. To bind a style to this <code>Region</code> use 
298             * the name <code>Separator</code>. 
299             */
300            public static final Region SEPARATOR = new Region("Separator",
301                    "SeparatorUI");
302
303            /**
304             * Slider region. To bind a style to this <code>Region</code> use 
305             * the name <code>Slider</code>.
306             */
307            public static final Region SLIDER = new Region("Slider", "SliderUI");
308            /**
309             * Track of the Slider. To bind a style to this <code>Region</code> use 
310             * the name <code>SliderTrack</code>.
311             */
312            public static final Region SLIDER_TRACK = new Region("SliderTrack");
313            /**
314             * Thumb of the Slider. The thumb of the Slider identifies the current 
315             * value. To bind a style to this <code>Region</code> use the name 
316             * <code>SliderThumb</code>.
317             */
318            public static final Region SLIDER_THUMB = new Region("SliderThumb");
319
320            /**
321             * Spinner region. To bind a style to this <code>Region</code> use the name
322             * <code>Spinner</code>.
323             */
324            public static final Region SPINNER = new Region("Spinner",
325                    "SpinnerUI");
326
327            /**
328             * SplitPane region. To bind a style to this <code>Region</code> use the name
329             * <code>SplitPane</code>.
330             */
331            public static final Region SPLIT_PANE = new Region("SplitPane",
332                    "SplitPaneUI");
333
334            /**
335             * Divider of the SplitPane. To bind a style to this <code>Region</code> 
336             * use the name <code>SplitPaneDivider</code>.
337             */
338            public static final Region SPLIT_PANE_DIVIDER = new Region(
339                    "SplitPaneDivider");
340
341            /**
342             * TabbedPane region. To bind a style to this <code>Region</code> use 
343             * the name <code>TabbedPane</code>.
344             */
345            public static final Region TABBED_PANE = new Region("TabbedPane",
346                    "TabbedPaneUI");
347            /**
348             * Region of a TabbedPane for one tab. To bind a style to this 
349             * <code>Region</code> use the name <code>TabbedPaneTab</code>.
350             */
351            public static final Region TABBED_PANE_TAB = new Region(
352                    "TabbedPaneTab");
353            /**
354             * Region of a TabbedPane containing the tabs. To bind a style to this 
355             * <code>Region</code> use the name <code>TabbedPaneTabArea</code>.
356             */
357            public static final Region TABBED_PANE_TAB_AREA = new Region(
358                    "TabbedPaneTabArea");
359            /**
360             * Region of a TabbedPane containing the content. To bind a style to this 
361             * <code>Region</code> use the name <code>TabbedPaneContent</code>.
362             */
363            public static final Region TABBED_PANE_CONTENT = new Region(
364                    "TabbedPaneContent");
365
366            /**
367             * Table region. To bind a style to this <code>Region</code> use 
368             * the name <code>Table</code>.
369             */
370            public static final Region TABLE = new Region("Table", "TableUI");
371
372            /**
373             * TableHeader region. To bind a style to this <code>Region</code> use 
374             * the name <code>TableHeader</code>.
375             */
376            public static final Region TABLE_HEADER = new Region("TableHeader",
377                    "TableHeaderUI");
378            /**
379             * TextArea region. To bind a style to this <code>Region</code> use 
380             * the name <code>TextArea</code>.
381             */
382            public static final Region TEXT_AREA = new Region("TextArea",
383                    "TextAreaUI");
384
385            /**
386             * TextField region. To bind a style to this <code>Region</code> use 
387             * the name <code>TextField</code>.
388             */
389            public static final Region TEXT_FIELD = new Region("TextField",
390                    "TextFieldUI");
391
392            /**
393             * TextPane region. To bind a style to this <code>Region</code> use 
394             * the name <code>TextPane</code>.
395             */
396            public static final Region TEXT_PANE = new Region("TextPane",
397                    "TextPaneUI");
398
399            /**
400             * ToggleButton region. To bind a style to this <code>Region</code> use 
401             * the name <code>ToggleButton</code>.
402             */
403            public static final Region TOGGLE_BUTTON = new Region(
404                    "ToggleButton", "ToggleButtonUI");
405
406            /**
407             * ToolBar region. To bind a style to this <code>Region</code> use 
408             * the name <code>ToolBar</code>.
409             */
410            public static final Region TOOL_BAR = new Region("ToolBar",
411                    "ToolBarUI");
412            /**
413             * Region of the ToolBar containing the content. To bind a style to this 
414             * <code>Region</code> use the name <code>ToolBarContent</code>.
415             */
416            public static final Region TOOL_BAR_CONTENT = new Region(
417                    "ToolBarContent");
418            /**
419             * Region for the Window containing the ToolBar. To bind a style to this 
420             * <code>Region</code> use the name <code>ToolBarDragWindow</code>.
421             */
422            public static final Region TOOL_BAR_DRAG_WINDOW = new Region(
423                    "ToolBarDragWindow", null, false);
424
425            /**
426             * ToolTip region. To bind a style to this <code>Region</code> use 
427             * the name <code>ToolTip</code>.
428             */
429            public static final Region TOOL_TIP = new Region("ToolTip",
430                    "ToolTipUI");
431
432            /**
433             * ToolBar separator region. To bind a style to this <code>Region</code> use 
434             * the name <code>ToolBarSeparator</code>.
435             */
436            public static final Region TOOL_BAR_SEPARATOR = new Region(
437                    "ToolBarSeparator", "ToolBarSeparatorUI");
438
439            /**
440             * Tree region. To bind a style to this <code>Region</code> use the name 
441             * <code>Tree</code>.
442             */
443            public static final Region TREE = new Region("Tree", "TreeUI");
444            /**
445             * Region of the Tree for one cell. To bind a style to this 
446             * <code>Region</code> use the name <code>TreeCell</code>.
447             */
448            public static final Region TREE_CELL = new Region("TreeCell");
449
450            /**
451             * Viewport region. To bind a style to this <code>Region</code> use 
452             * the name <code>Viewport</code>.
453             */
454            public static final Region VIEWPORT = new Region("Viewport",
455                    "ViewportUI");
456
457            private String name;
458            private boolean subregion;
459
460            static Region getRegion(JComponent c) {
461                return (Region) uiToRegionMap.get(c.getUIClassID());
462            }
463
464            static void registerUIs(UIDefaults table) {
465                Iterator uis = uiToRegionMap.keySet().iterator();
466
467                while (uis.hasNext()) {
468                    Object key = uis.next();
469
470                    table.put(key, "javax.swing.plaf.synth.SynthLookAndFeel");
471                }
472            }
473
474            Region(String name) {
475                this (name, null, true);
476            }
477
478            Region(String name, String ui) {
479                this (name, ui, false);
480            }
481
482            /**
483             * Creates a Region with the specified name. This should only be
484             * used if you are creating your own <code>JComponent</code> subclass
485             * with a custom <code>ComponentUI</code> class.
486             *
487             * @param name Name of the region
488             * @param ui String that will be returned from
489             *           <code>component.getUIClassID</code>. This will be null
490             *           if this is a subregion.
491             * @param subregion Whether or not this is a subregion.
492             */
493            protected Region(String name, String ui, boolean subregion) {
494                if (name == null) {
495                    throw new NullPointerException(
496                            "You must specify a non-null name");
497                }
498                this .name = name;
499                if (ui != null) {
500                    uiToRegionMap.put(ui, this );
501                }
502                this .subregion = subregion;
503            }
504
505            /**
506             * Returns true if the Region is a subregion of a Component, otherwise
507             * false. For example, <code>Region.BUTTON</code> corresponds do a
508             * <code>Component</code> so that <code>Region.BUTTON.isSubregion()</code>
509             * returns false.
510             *
511             * @return true if the Region is a subregion of a Component.
512             */
513            public boolean isSubregion() {
514                return subregion;
515            }
516
517            /**
518             * Returns the name of the region.
519             *
520             * @return name of the Region.
521             */
522            public String getName() {
523                return name;
524            }
525
526            /**
527             * Returns the name, in lowercase.
528             */
529            String getLowerCaseName() {
530                synchronized (lowerCaseNameMap) {
531                    String lowerCaseName = (String) lowerCaseNameMap.get(this );
532                    if (lowerCaseName == null) {
533                        lowerCaseName = getName().toLowerCase();
534                        lowerCaseNameMap.put(this , lowerCaseName);
535                    }
536                    return lowerCaseName;
537                }
538            }
539
540            /**
541             * Returns the name of the Region.
542             *
543             * @return name of the Region.
544             */
545            public String toString() {
546                return name;
547            }
548        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.