0N/A/*
2362N/A * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/Apackage javax.swing.plaf.synth;
0N/A
0N/Aimport java.awt.*;
0N/Aimport javax.swing.*;
0N/Aimport javax.swing.text.JTextComponent;
0N/Aimport javax.swing.border.*;
0N/Aimport javax.swing.plaf.UIResource;
0N/A
0N/A/**
0N/A * SynthBorder is a border that delegates to a Painter. The Insets
0N/A * are determined at construction time.
0N/A *
0N/A * @author Scott Violet
0N/A */
0N/Aclass SynthBorder extends AbstractBorder implements UIResource {
0N/A private SynthUI ui;
0N/A private Insets insets;
0N/A
0N/A SynthBorder(SynthUI ui, Insets insets) {
0N/A this.ui = ui;
0N/A this.insets = insets;
0N/A }
0N/A
0N/A SynthBorder(SynthUI ui) {
0N/A this(ui, null);
0N/A }
0N/A
0N/A public void paintBorder(Component c, Graphics g, int x, int y,
0N/A int width, int height) {
0N/A JComponent jc = (JComponent)c;
0N/A SynthContext context = ui.getContext(jc);
0N/A SynthStyle style = context.getStyle();
0N/A if (style == null) {
0N/A assert false: "SynthBorder is being used outside after the UI " +
0N/A "has been uninstalled";
0N/A return;
0N/A }
0N/A ui.paintBorder(context, g, x, y, width, height);
0N/A context.dispose();
0N/A }
0N/A
0N/A /**
0N/A * Reinitializes the insets parameter with this Border's current Insets.
0N/A * @param c the component for which this border insets value applies
0N/A * @param insets the object to be reinitialized
0N/A * @return the <code>insets</code> object
0N/A */
0N/A public Insets getBorderInsets(Component c, Insets insets) {
0N/A if (this.insets != null) {
0N/A if (insets == null) {
0N/A insets = new Insets(this.insets.top, this.insets.left,
0N/A this.insets.bottom, this.insets.right);
0N/A }
0N/A else {
0N/A insets.top = this.insets.top;
0N/A insets.bottom = this.insets.bottom;
0N/A insets.left = this.insets.left;
0N/A insets.right = this.insets.right;
0N/A }
0N/A }
0N/A else if (insets == null) {
0N/A insets = new Insets(0, 0, 0, 0);
0N/A }
0N/A else {
0N/A insets.top = insets.bottom = insets.left = insets.right = 0;
0N/A }
0N/A if (c instanceof JComponent) {
0N/A Region region = Region.getRegion((JComponent)c);
0N/A Insets margin = null;
0N/A if ((region == Region.ARROW_BUTTON || region == Region.BUTTON ||
0N/A region == Region.CHECK_BOX ||
0N/A region == Region.CHECK_BOX_MENU_ITEM ||
0N/A region == Region.MENU || region == Region.MENU_ITEM ||
0N/A region == Region.RADIO_BUTTON ||
0N/A region == Region.RADIO_BUTTON_MENU_ITEM ||
0N/A region == Region.TOGGLE_BUTTON) &&
0N/A (c instanceof AbstractButton)) {
0N/A margin = ((AbstractButton)c).getMargin();
0N/A }
0N/A else if ((region == Region.EDITOR_PANE ||
0N/A region == Region.FORMATTED_TEXT_FIELD ||
0N/A region == Region.PASSWORD_FIELD ||
0N/A region == Region.TEXT_AREA ||
0N/A region == Region.TEXT_FIELD ||
0N/A region == Region.TEXT_PANE) &&
0N/A (c instanceof JTextComponent)) {
0N/A margin = ((JTextComponent)c).getMargin();
0N/A }
0N/A else if (region == Region.TOOL_BAR && (c instanceof JToolBar)) {
0N/A margin = ((JToolBar)c).getMargin();
0N/A }
0N/A else if (region == Region.MENU_BAR && (c instanceof JMenuBar)) {
0N/A margin = ((JMenuBar)c).getMargin();
0N/A }
0N/A if (margin != null) {
0N/A insets.top += margin.top;
0N/A insets.bottom += margin.bottom;
0N/A insets.left += margin.left;
0N/A insets.right += margin.right;
0N/A }
0N/A }
0N/A return insets;
0N/A }
0N/A
0N/A /**
0N/A * This default implementation returns false.
0N/A * @return false
0N/A */
0N/A public boolean isBorderOpaque() {
0N/A return false;
0N/A }
0N/A}