Path: blob/master/src/java.desktop/macosx/classes/com/apple/laf/AquaGroupBorder.java
41154 views
/*1* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.apple.laf;2627import java.awt.*;2829import javax.swing.border.Border;3031import apple.laf.JRSUIConstants.Widget;3233import com.apple.laf.AquaUtilControlSize.*;34import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor;3536public abstract class AquaGroupBorder extends AquaBorder {37private static final RecyclableSingletonFromDefaultConstructor<? extends Border> tabbedPaneGroupBorder = new RecyclableSingletonFromDefaultConstructor<TabbedPane>(TabbedPane.class);38public static Border getTabbedPaneGroupBorder() {39return tabbedPaneGroupBorder.get();40}4142private static final RecyclableSingletonFromDefaultConstructor<? extends Border> titleBorderGroupBorder = new RecyclableSingletonFromDefaultConstructor<Titled>(Titled.class);43public static Border getBorderForTitledBorder() {44return titleBorderGroupBorder.get();45}4647private static final RecyclableSingletonFromDefaultConstructor<? extends Border> titlelessGroupBorder = new RecyclableSingletonFromDefaultConstructor<Titleless>(Titleless.class);48public static Border getTitlelessBorder() {49return titlelessGroupBorder.get();50}5152protected AquaGroupBorder(final SizeVariant sizeVariant) {53super(new SizeDescriptor(sizeVariant));54painter.state.set(Widget.FRAME_GROUP_BOX);55}5657public void paintBorder(final Component c, final Graphics g, int x, int y, int width, int height) {58// sg2d.setColor(Color.MAGENTA);59// sg2d.drawRect(x, y, width - 1, height - 1);6061final Insets internalInsets = sizeVariant.insets;62x += internalInsets.left;63y += internalInsets.top;64width -= (internalInsets.left + internalInsets.right);65height -= (internalInsets.top + internalInsets.bottom);6667painter.paint(g, c, x, y, width, height);68// sg2d.setColor(Color.ORANGE);69// sg2d.drawRect(x, y, width, height);70}7172protected static class TabbedPane extends AquaGroupBorder {73public TabbedPane() {74super(new SizeVariant().alterMargins(8, 12, 8, 12).alterInsets(5, 5, 7, 5));75}76}7778protected static class Titled extends AquaGroupBorder {79public Titled() {80super(new SizeVariant().alterMargins(16, 20, 16, 20).alterInsets(16, 5, 4, 5));81}82}8384protected static class Titleless extends AquaGroupBorder {85public Titleless() {86super(new SizeVariant().alterMargins(8, 12, 8, 12).alterInsets(3, 5, 1, 5));87}88}89}909192