/*
* 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 class which implements an arbitrary border
* with the addition of a String title in a
* specified position and justification.
* <p>
* If the border, font, or color property values are not
* specified in the constuctor or by invoking the appropriate
* set methods, the property values will be defined by the current
* look and feel, using the following property names in the
* Defaults Table:
* <ul>
* <li>"TitledBorder.border"
* <li>"TitledBorder.font"
* <li>"TitledBorder.titleColor"
* </ul>
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author David Kloba
* @author Amy Fowler
*/
{
protected int titlePosition;
protected int titleJustification;
/**
* Use the default vertical orientation for the title text.
*/
/** Position the title above the border's top line. */
/** Position the title in the middle of the border's top line. */
/** Position the title below the border's top line. */
/** Position the title above the border's bottom line. */
/** Position the title in the middle of the border's bottom line. */
/** Position the title below the border's bottom line. */
/**
* Use the default justification for the title text.
*/
/** Position title text at the left side of the border line. */
/** Position title text in the center of the border line. */
/** Position title text at the right side of the border line. */
/** Position title text at the left side of the border line
* for left to right orientation, at the right side of the
* border line for right to left orientation.
*/
/** Position title text at the right side of the border line
* for left to right orientation, at the left side of the
* border line for right to left orientation.
*/
// Space between the border and the component's edge
// Space between the border and text
// Horizontal inset of text that is left or right justified
/**
* Creates a TitledBorder instance.
*
* @param title the title the border should display
*/
}
/**
* Creates a TitledBorder instance with the specified border
* and an empty title.
*
* @param border the border
*/
}
/**
* Creates a TitledBorder instance with the specified border
* and title.
*
* @param border the border
* @param title the title the border should display
*/
}
/**
* Creates a TitledBorder instance with the specified border,
* title, title-justification, and title-position.
*
* @param border the border
* @param title the title the border should display
* @param titleJustification the justification for the title
* @param titlePosition the position for the title
*/
int titleJustification,
int titlePosition) {
}
/**
* Creates a TitledBorder instance with the specified border,
* title, title-justification, title-position, and title-font.
*
* @param border the border
* @param title the title the border should display
* @param titleJustification the justification for the title
* @param titlePosition the position for the title
* @param titleFont the font for rendering the title
*/
int titleJustification,
int titlePosition,
}
/**
* Creates a TitledBorder instance with the specified border,
* title, title-justification, title-position, title-font, and
* title-color.
*
* @param border the border
* @param title the title the border should display
* @param titleJustification the justification for the title
* @param titlePosition the position for the title
* @param titleFont the font of the title
* @param titleColor the color of the title
*/
@ConstructorProperties({"border", "title", "titleJustification", "titlePosition", "titleFont", "titleColor"})
int titleJustification,
int titlePosition,
Color titleColor) {
this.titleColor = titleColor;
}
/**
* Paints the border for the specified component with the
* specified position and size.
* @param c the component for which this border is being painted
* @param g the paint graphics
* @param x the x position of the painted border
* @param y the y position of the painted border
* @param width the width of the painted border
* @param height the height of the painted border
*/
int labelY = y;
int position = getPosition();
switch (position) {
case ABOVE_TOP:
break;
case TOP:
}
else {
}
break;
case BELOW_TOP:
break;
case ABOVE_BOTTOM:
break;
case BOTTOM:
}
else {
}
break;
case BELOW_BOTTOM:
break;
}
int labelX = x;
}
switch (getJustification(c)) {
case LEFT:
break;
case RIGHT:
break;
case CENTER:
break;
}
}
else {
if (g2 instanceof Graphics2D) {
path.append(new Rectangle(labelX + labelW + TEXT_SPACING, labelY, borderX - labelX + borderW - labelW - TEXT_SPACING, labelH), false);
path.append(new Rectangle(borderX, labelY + labelH, borderW, borderY - labelY + borderH - labelH), false);
}
}
}
}
}
}
/**
* Reinitialize the insets parameter with this Border's current Insets.
* @param c the component for which this border insets value applies
* @param insets the object to be reinitialized
*/
switch (getPosition()) {
case ABOVE_TOP:
break;
case TOP: {
}
break;
}
case BELOW_TOP:
break;
case ABOVE_BOTTOM:
break;
case BOTTOM: {
}
break;
}
case BELOW_BOTTOM:
break;
}
}
return insets;
}
/**
* Returns whether or not the border is opaque.
*/
public boolean isBorderOpaque() {
return false;
}
/**
* Returns the title of the titled border.
*
* @return the title of the titled border
*/
return title;
}
/**
* Returns the border of the titled border.
*
* @return the border of the titled border
*/
? border
}
/**
* Returns the title-position of the titled border.
*
* @return the title-position of the titled border
*/
public int getTitlePosition() {
return titlePosition;
}
/**
* Returns the title-justification of the titled border.
*
* @return the title-justification of the titled border
*/
public int getTitleJustification() {
return titleJustification;
}
/**
* Returns the title-font of the titled border.
*
* @return the title-font of the titled border
*/
return titleFont;
}
/**
* Returns the title-color of the titled border.
*
* @return the title-color of the titled border
*/
return titleColor;
}
// REMIND(aim): remove all or some of these set methods?
/**
* Sets the title of the titled border.
* @param title the title for the border
*/
}
/**
* Sets the border of the titled border.
* @param border the border
*/
}
/**
* Sets the title-position of the titled border.
* @param titlePosition the position for the border
*/
switch (titlePosition) {
case ABOVE_TOP:
case TOP:
case BELOW_TOP:
case ABOVE_BOTTOM:
case BOTTOM:
case BELOW_BOTTOM:
case DEFAULT_POSITION:
this.titlePosition = titlePosition;
break;
default:
throw new IllegalArgumentException(titlePosition +
" is not a valid title position.");
}
}
/**
* Sets the title-justification of the titled border.
* @param titleJustification the justification for the border
*/
switch (titleJustification) {
case DEFAULT_JUSTIFICATION:
case LEFT:
case CENTER:
case RIGHT:
case LEADING:
case TRAILING:
this.titleJustification = titleJustification;
break;
default:
throw new IllegalArgumentException(titleJustification +
" is not a valid title justification.");
}
}
/**
* Sets the title-font of the titled border.
* @param titleFont the font for the border title
*/
}
/**
* Sets the title-color of the titled border.
* @param titleColor the color for the border title
*/
this.titleColor = titleColor;
}
/**
* Returns the minimum dimensions this border requires
* in order to fully display the border and title.
* @param c the component where this border will be drawn
* @return the {@code Dimension} object
*/
int position = getPosition();
}
}
}
return minSize;
}
/**
* Returns the baseline.
*
* @throws NullPointerException {@inheritDoc}
* @throws IllegalArgumentException {@inheritDoc}
* @see javax.swing.JComponent#getBaseline(int, int)
* @since 1.6
*/
if (c == null) {
throw new NullPointerException("Must supply non-null component");
}
if (width < 0) {
throw new IllegalArgumentException("Width must be >= 0");
}
if (height < 0) {
throw new IllegalArgumentException("Height must be >= 0");
}
switch (getPosition()) {
case ABOVE_TOP:
return baseline;
case TOP:
? baseline
case BELOW_TOP:
case ABOVE_BOTTOM:
case BOTTOM:
case BELOW_BOTTOM:
}
}
return -1;
}
/**
* Returns an enum indicating how the baseline of the border
* changes as the size changes.
*
* @throws NullPointerException {@inheritDoc}
* @see javax.swing.JComponent#getBaseline(int, int)
* @since 1.6
*/
Component c) {
super.getBaselineResizeBehavior(c);
switch (getPosition()) {
case TitledBorder.ABOVE_TOP:
case TitledBorder.TOP:
case TitledBorder.BELOW_TOP:
case TitledBorder.ABOVE_BOTTOM:
case TitledBorder.BOTTOM:
case TitledBorder.BELOW_BOTTOM:
}
}
private int getPosition() {
int position = getTitlePosition();
if (position != DEFAULT_POSITION) {
return position;
}
if ((0 < i) && (i <= 6)) {
return i;
}
}
if (s.equalsIgnoreCase("ABOVE_TOP")) {
return ABOVE_TOP;
}
if (s.equalsIgnoreCase("TOP")) {
return TOP;
}
if (s.equalsIgnoreCase("BELOW_TOP")) {
return BELOW_TOP;
}
if (s.equalsIgnoreCase("ABOVE_BOTTOM")) {
return ABOVE_BOTTOM;
}
if (s.equalsIgnoreCase("BOTTOM")) {
return BOTTOM;
}
if (s.equalsIgnoreCase("BELOW_BOTTOM")) {
return BELOW_BOTTOM;
}
}
return TOP;
}
int justification = getTitleJustification();
}
if (justification == TRAILING) {
}
return justification;
}
return font;
}
return font;
}
if (c != null) {
return font;
}
}
}
return color;
}
return color;
}
return (c != null)
? c.getForeground()
: null;
}
return this.label;
}
}
else if (border instanceof AbstractBorder) {
}
else {
}
return insets;
}
}