001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package javax.swing.plaf.synth;
019:
020: import java.util.HashMap;
021:
022: /**
023: * Region used to markup the type of JComponent to be painted
024: */
025: @SuppressWarnings("nls")
026: public class Region {
027:
028: /**
029: * All regions depository
030: */
031: static final HashMap<String, Region> regionsMap = new HashMap<String, Region>();
032:
033: public static final Region ARROW_BUTTON = new Region("ArrowButton",
034: "ArrowButtonUI", true);
035:
036: public static final Region BUTTON = new Region("Button",
037: "ButtonUI", false);
038:
039: public static final Region CHECK_BOX = new Region("CheckBox",
040: "CheckBoxUI", false);
041:
042: public static final Region CHECK_BOX_MENU_ITEM = new Region(
043: "CheckBoxMenuItem", "CheckBoxMenuItemUI", false);
044:
045: public static final Region COLOR_CHOOSER = new Region(
046: "ColorChooser", "ColorChooserUI", false);
047:
048: public static final Region COMBO_BOX = new Region("ComboBox",
049: "ComboBoxUI", false);
050:
051: public static final Region DESKTOP_ICON = new Region("DesktopIcon",
052: "DesktopIconUI", false);
053:
054: public static final Region DESKTOP_PANE = new Region("DesktopPane",
055: "DesktopPaneUI", false);
056:
057: public static final Region EDITOR_PANE = new Region("EditorPane",
058: "EditorPaneUI", false);
059:
060: public static final Region FILE_CHOOSER = new Region("FileChooser",
061: "FileChooserUI", false);
062:
063: public static final Region FORMATTED_TEXT_FIELD = new Region(
064: "FormattedTextField", "FormattedTextFieldUI", false);
065:
066: public static final Region INTERNAL_FRAME = new Region(
067: "InternalFrame", null, false);
068:
069: public static final Region INTERNAL_FRAME_TITLE_PANE = new Region(
070: "InternalFrameTitlePane", "InternalFrameUI", false);
071:
072: public static final Region LABEL = new Region("Label", "LabelUI",
073: false);
074:
075: public static final Region LIST = new Region("List", "ListUI",
076: false);
077:
078: public static final Region MENU = new Region("Menu", "MenuUI",
079: false);
080:
081: public static final Region MENU_BAR = new Region("MenuBar",
082: "MenuBarUI", false);
083:
084: public static final Region MENU_ITEM = new Region("MenuItem",
085: "MenuItemUI", false);
086:
087: public static final Region MENU_ITEM_ACCELERATOR = new Region(
088: "MenuItemAccelerator", "MenuItemAcceleratorUI", false);
089:
090: public static final Region OPTION_PANE = new Region("OptionPane",
091: "OptionPaneUI", false);
092:
093: public static final Region PANEL = new Region("Panel", "PanelUI",
094: false);
095:
096: public static final Region PASSWORD_FIELD = new Region(
097: "PasswordField", "PasswordFieldUI", false);
098:
099: public static final Region POPUP_MENU = new Region("PopupMenu",
100: "PopupMenuUI", false);
101:
102: public static final Region POPUP_MENU_SEPARATOR = new Region(
103: "PopupMenuSeparator", "PopupMenuSeparatorUI", false);
104:
105: public static final Region PROGRESS_BAR = new Region("ProgressBar",
106: "ProgressBarUI", false);
107:
108: public static final Region RADIO_BUTTON = new Region("RadioButton",
109: "RadioButtonUI", false);
110:
111: public static final Region RADIO_BUTTON_MENU_ITEM = new Region(
112: "RadioButtonMenuItem", "RadioButtonMenuItemUI", false);
113:
114: public static final Region ROOT_PANE = new Region("RootPane",
115: "RootPaneUI", false);
116:
117: public static final Region SCROLL_BAR = new Region("ScrollBar",
118: "ScrollBarUI", false);
119:
120: public static final Region SCROLL_BAR_THUMB = new Region(
121: "ScrollBarThumb", null, true);
122:
123: public static final Region SCROLL_BAR_TRACK = new Region(
124: "ScrollBarTrack", null, true);
125:
126: public static final Region SCROLL_PANE = new Region("ScrollPane",
127: "ScrollPaneUI", false);
128:
129: public static final Region SEPARATOR = new Region("Separator",
130: "SeparatorUI", false);
131:
132: public static final Region SLIDER = new Region("Slider",
133: "SliderUI", false);
134:
135: public static final Region SLIDER_THUMB = new Region("SliderThumb",
136: null, true);
137:
138: public static final Region SLIDER_TRACK = new Region("SliderTrack",
139: null, true);
140:
141: public static final Region SPINNER = new Region("Spinner",
142: "SpinnerUI", false);
143:
144: public static final Region SPLIT_PANE = new Region("SplitPane",
145: "SplitPaneUI", false);
146:
147: public static final Region SPLIT_PANE_DIVIDER = new Region(
148: "SplitPaneDivider", null, true);
149:
150: public static final Region TABBED_PANE = new Region("TabbedPane",
151: "TabbedPaneUI", false);
152:
153: public static final Region TABBED_PANE_CONTENT = new Region(
154: "TabbedPaneContent", null, true);
155:
156: public static final Region TABBED_PANE_TAB = new Region(
157: "TabbedPaneTab", null, true);
158:
159: public static final Region TABBED_PANE_TAB_AREA = new Region(
160: "TabbedPaneTabArea", null, true);
161:
162: public static final Region TABLE = new Region("Table", "TableUI",
163: false);
164:
165: public static final Region TABLE_HEADER = new Region("TableHeader",
166: "TableHeaderUI", false);
167:
168: public static final Region TEXT_AREA = new Region("TextArea",
169: "TextAreaUI", false);
170:
171: public static final Region TEXT_FIELD = new Region("TextField",
172: "TextFieldUI", false);
173:
174: public static final Region TEXT_PANE = new Region("TextPane",
175: "TextPaneUI", false);
176:
177: public static final Region TOGGLE_BUTTON = new Region(
178: "ToggleButton", "ToggleButtonUI", false);
179:
180: public static final Region TOOL_BAR = new Region("ToolBar",
181: "ToolBarUI", false);
182:
183: public static final Region TOOL_BAR_CONTENT = new Region(
184: "ToolBarContent", null, true);
185:
186: public static final Region TOOL_BAR_DRAG_WINDOW = new Region(
187: "ToolBarDragWindow", "ToolBarDragWindowUI", false);
188:
189: public static final Region TOOL_BAR_SEPARATOR = new Region(
190: "ToolBarSeparator", "ToolBarSeparatorUI", false);
191:
192: public static final Region TOOL_TIP = new Region("ToolTip",
193: "ToolTipUI", false);
194:
195: public static final Region TREE = new Region("Tree", "TreeUI",
196: false);
197:
198: public static final Region TREE_CELL = new Region("TreeCell", null,
199: true);
200:
201: public static final Region VIEWPORT = new Region("Viewport",
202: "ViewportUI", false);
203:
204: private String name;
205:
206: private String ui;
207:
208: private boolean isSub;
209:
210: protected Region(String name, String ui, boolean subregion) {
211: this .name = name;
212: this .isSub = subregion;
213: this .ui = ui;
214: regionsMap.put(name, this );
215: }
216:
217: /**
218: * @return the region corresponds given UI String
219: */
220: static Region getRegionFromUIID(String ui) {
221:
222: // Possible improvement:
223: // This method creates additional object(substring) but possibly faster
224: // way is the creating two HashMaps that contains the same values but
225: // the different keys: UI and name
226: return regionsMap.get(ui.substring(0, (ui.length() - 2)));
227: }
228:
229: public String getName() {
230:
231: return this .name;
232: }
233:
234: public boolean isSubregion() {
235:
236: return this .isSub;
237: }
238:
239: @Override
240: public String toString() {
241:
242: return this .ui;
243: }
244:
245: /**
246: * @return the region corresponds given name String
247: */
248: static Region getRegionFromName(String reference) {
249: return regionsMap.get(reference);
250: }
251: }
|