/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A distinct rendering area of a Swing component. A component may
* support one or more regions. Specific component regions are defined
* by the typesafe enumeration in this class.
* <p>
* Regions are typically used as a way to identify the <code>Component</code>s
* and areas a particular style is to apply to. Synth's file format allows you
* to bind styles based on the name of a <code>Region</code>.
* The name is derived from the field name of the constant:
* <ol>
* <li>Map all characters to lowercase.
* <li>Map the first character to uppercase.
* <li>Map the first character after underscores to uppercase.
* <li>Remove all underscores.
* </ol>
* For example, to identify the <code>SPLIT_PANE</code>
* <code>Region</code> you would use <code>SplitPane</code>.
* The following shows a custom <code>SynthStyleFactory</code>
* that returns a specific style for split panes:
* <pre>
* public SynthStyle getStyle(JComponent c, Region id) {
* if (id == Region.SPLIT_PANE) {
* return splitPaneStyle;
* }
* ...
* }
* </pre>
* The following <a href="doc-files/synthFileFormat.html">xml</a>
* accomplishes the same thing:
* <pre>
* <style id="splitPaneStyle">
* ...
* </style>
* <bind style="splitPaneStyle" type="region" key="SplitPane"/>
* </pre>
*
* @since 1.5
* @author Scott Violet
*/
public class Region {
/**
* ArrowButton's are special types of buttons that also render a
* directional indicator, typically an arrow. ArrowButtons are used by
* composite components, for example ScrollBar's contain ArrowButtons.
* To bind a style to this <code>Region</code> use the name
* <code>ArrowButton</code>.
*/
/**
* Button region. To bind a style to this <code>Region</code> use the name
* <code>Button</code>.
*/
/**
* CheckBox region. To bind a style to this <code>Region</code> use the name
* <code>CheckBox</code>.
*/
/**
* CheckBoxMenuItem region. To bind a style to this <code>Region</code> use
* the name <code>CheckBoxMenuItem</code>.
*/
/**
* ColorChooser region. To bind a style to this <code>Region</code> use
* the name <code>ColorChooser</code>.
*/
/**
* ComboBox region. To bind a style to this <code>Region</code> use
* the name <code>ComboBox</code>.
*/
/**
* DesktopPane region. To bind a style to this <code>Region</code> use
* the name <code>DesktopPane</code>.
*/
/**
* DesktopIcon region. To bind a style to this <code>Region</code> use
* the name <code>DesktopIcon</code>.
*/
/**
* EditorPane region. To bind a style to this <code>Region</code> use
* the name <code>EditorPane</code>.
*/
/**
* FileChooser region. To bind a style to this <code>Region</code> use
* the name <code>FileChooser</code>.
*/
/**
* FormattedTextField region. To bind a style to this <code>Region</code> use
* the name <code>FormattedTextField</code>.
*/
/**
* InternalFrame region. To bind a style to this <code>Region</code> use
* the name <code>InternalFrame</code>.
*/
/**
* TitlePane of an InternalFrame. The TitlePane typically
* shows a menu, title, widgets to manipulate the internal frame.
* To bind a style to this <code>Region</code> use the name
* <code>InternalFrameTitlePane</code>.
*/
/**
* Label region. To bind a style to this <code>Region</code> use the name
* <code>Label</code>.
*/
/**
* List region. To bind a style to this <code>Region</code> use the name
* <code>List</code>.
*/
/**
* Menu region. To bind a style to this <code>Region</code> use the name
* <code>Menu</code>.
*/
/**
* MenuBar region. To bind a style to this <code>Region</code> use the name
* <code>MenuBar</code>.
*/
/**
* MenuItem region. To bind a style to this <code>Region</code> use the name
* <code>MenuItem</code>.
*/
/**
* Accelerator region of a MenuItem. To bind a style to this
* <code>Region</code> use the name <code>MenuItemAccelerator</code>.
*/
/**
* OptionPane region. To bind a style to this <code>Region</code> use
* the name <code>OptionPane</code>.
*/
/**
* Panel region. To bind a style to this <code>Region</code> use the name
* <code>Panel</code>.
*/
/**
* PasswordField region. To bind a style to this <code>Region</code> use
* the name <code>PasswordField</code>.
*/
/**
* PopupMenu region. To bind a style to this <code>Region</code> use
* the name <code>PopupMenu</code>.
*/
/**
* PopupMenuSeparator region. To bind a style to this <code>Region</code>
* use the name <code>PopupMenuSeparator</code>.
*/
/**
* ProgressBar region. To bind a style to this <code>Region</code>
* use the name <code>ProgressBar</code>.
*/
/**
* RadioButton region. To bind a style to this <code>Region</code>
* use the name <code>RadioButton</code>.
*/
/**
* RegionButtonMenuItem region. To bind a style to this <code>Region</code>
* use the name <code>RadioButtonMenuItem</code>.
*/
/**
* RootPane region. To bind a style to this <code>Region</code> use
* the name <code>RootPane</code>.
*/
/**
* ScrollBar region. To bind a style to this <code>Region</code> use
* the name <code>ScrollBar</code>.
*/
/**
* Track of the ScrollBar. To bind a style to this <code>Region</code> use
* the name <code>ScrollBarTrack</code>.
*/
/**
* Thumb of the ScrollBar. The thumb is the region of the ScrollBar
* that gives a graphical depiction of what percentage of the View is
* currently visible. To bind a style to this <code>Region</code> use
* the name <code>ScrollBarThumb</code>.
*/
/**
* ScrollPane region. To bind a style to this <code>Region</code> use
* the name <code>ScrollPane</code>.
*/
/**
* Separator region. To bind a style to this <code>Region</code> use
* the name <code>Separator</code>.
*/
/**
* Slider region. To bind a style to this <code>Region</code> use
* the name <code>Slider</code>.
*/
/**
* Track of the Slider. To bind a style to this <code>Region</code> use
* the name <code>SliderTrack</code>.
*/
/**
* Thumb of the Slider. The thumb of the Slider identifies the current
* value. To bind a style to this <code>Region</code> use the name
* <code>SliderThumb</code>.
*/
/**
* Spinner region. To bind a style to this <code>Region</code> use the name
* <code>Spinner</code>.
*/
/**
* SplitPane region. To bind a style to this <code>Region</code> use the name
* <code>SplitPane</code>.
*/
/**
* Divider of the SplitPane. To bind a style to this <code>Region</code>
* use the name <code>SplitPaneDivider</code>.
*/
/**
* TabbedPane region. To bind a style to this <code>Region</code> use
* the name <code>TabbedPane</code>.
*/
/**
* Region of a TabbedPane for one tab. To bind a style to this
* <code>Region</code> use the name <code>TabbedPaneTab</code>.
*/
/**
* Region of a TabbedPane containing the tabs. To bind a style to this
* <code>Region</code> use the name <code>TabbedPaneTabArea</code>.
*/
/**
* Region of a TabbedPane containing the content. To bind a style to this
* <code>Region</code> use the name <code>TabbedPaneContent</code>.
*/
/**
* Table region. To bind a style to this <code>Region</code> use
* the name <code>Table</code>.
*/
/**
* TableHeader region. To bind a style to this <code>Region</code> use
* the name <code>TableHeader</code>.
*/
/**
* TextArea region. To bind a style to this <code>Region</code> use
* the name <code>TextArea</code>.
*/
/**
* TextField region. To bind a style to this <code>Region</code> use
* the name <code>TextField</code>.
*/
/**
* TextPane region. To bind a style to this <code>Region</code> use
* the name <code>TextPane</code>.
*/
/**
* ToggleButton region. To bind a style to this <code>Region</code> use
* the name <code>ToggleButton</code>.
*/
/**
* ToolBar region. To bind a style to this <code>Region</code> use
* the name <code>ToolBar</code>.
*/
/**
* Region of the ToolBar containing the content. To bind a style to this
* <code>Region</code> use the name <code>ToolBarContent</code>.
*/
/**
* Region for the Window containing the ToolBar. To bind a style to this
* <code>Region</code> use the name <code>ToolBarDragWindow</code>.
*/
/**
* ToolTip region. To bind a style to this <code>Region</code> use
* the name <code>ToolTip</code>.
*/
/**
* ToolBar separator region. To bind a style to this <code>Region</code> use
* the name <code>ToolBarSeparator</code>.
*/
/**
* Tree region. To bind a style to this <code>Region</code> use the name
* <code>Tree</code>.
*/
/**
* Region of the Tree for one cell. To bind a style to this
* <code>Region</code> use the name <code>TreeCell</code>.
*/
/**
* Viewport region. To bind a style to this <code>Region</code> use
* the name <code>Viewport</code>.
*/
}
return map;
}
}
return map;
}
}
}
}
private final boolean subregion;
throw new NullPointerException("You must specify a non-null name");
}
}
/**
* Creates a Region with the specified name. This should only be
* used if you are creating your own <code>JComponent</code> subclass
* with a custom <code>ComponentUI</code> class.
*
* @param name Name of the region
* @param ui String that will be returned from
* <code>component.getUIClassID</code>. This will be null
* if this is a subregion.
* @param subregion Whether or not this is a subregion.
*/
}
}
/**
* Returns true if the Region is a subregion of a Component, otherwise
* false. For example, <code>Region.BUTTON</code> corresponds do a
* <code>Component</code> so that <code>Region.BUTTON.isSubregion()</code>
* returns false.
*
* @return true if the Region is a subregion of a Component.
*/
public boolean isSubregion() {
return subregion;
}
/**
* Returns the name of the region.
*
* @return name of the Region.
*/
return name;
}
/**
* Returns the name, in lowercase.
*
* @return lower case representation of the name of the Region
*/
if (lowerCaseName == null) {
}
return lowerCaseName;
}
/**
* Returns the name of the Region.
*
* @return name of the Region.
*/
return name;
}
}