Path: blob/master/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameBorderMetrics.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.Font;2829import apple.laf.JRSUIUtils;30import com.apple.laf.AquaUtils.RecyclableSingleton;3132public abstract class AquaInternalFrameBorderMetrics {33private static final boolean useLegacyBorderMetrics = JRSUIUtils.InternalFrame.shouldUseLegacyBorderMetrics();3435public Font font;36public int titleBarHeight;37public int leftSidePadding;38public int buttonHeight;39public int buttonWidth;40public int buttonPadding;41public int downShift;4243private AquaInternalFrameBorderMetrics() {44initialize();45}4647protected abstract void initialize();4849public static AquaInternalFrameBorderMetrics getMetrics(boolean isUtility) {50if (useLegacyBorderMetrics) {51return isUtility ? legacyUtilityMetrics.get() : legacyStandardMetrics.get();52} else {53return isUtility ? utilityMetrics.get() : standardMetrics.get();54}55}5657private static final RecyclableSingleton<AquaInternalFrameBorderMetrics> standardMetrics = new RecyclableSingleton<AquaInternalFrameBorderMetrics>() {58@Override59protected AquaInternalFrameBorderMetrics getInstance() {60return new AquaInternalFrameBorderMetrics() {61protected void initialize() {62font = new Font("Lucida Grande", Font.PLAIN, 13);63titleBarHeight = 22;64leftSidePadding = 7;65buttonHeight = 15;66buttonWidth = 15;67buttonPadding = 5;68downShift = 0;69}70};71}72};7374private static final RecyclableSingleton<AquaInternalFrameBorderMetrics> utilityMetrics = new RecyclableSingleton<AquaInternalFrameBorderMetrics>() {75@Override76protected AquaInternalFrameBorderMetrics getInstance() {77return new AquaInternalFrameBorderMetrics() {78protected void initialize() {79font = new Font("Lucida Grande", Font.PLAIN, 11);80titleBarHeight = 16;81leftSidePadding = 6;82buttonHeight = 12;83buttonWidth = 12;84buttonPadding = 6;85downShift = 0;86}87};88}89};9091private static final RecyclableSingleton<AquaInternalFrameBorderMetrics> legacyStandardMetrics = new RecyclableSingleton<AquaInternalFrameBorderMetrics>() {92@Override93protected AquaInternalFrameBorderMetrics getInstance() {94return new AquaInternalFrameBorderMetrics() {95protected void initialize() {96font = new Font("Lucida Grande", Font.PLAIN, 13);97titleBarHeight = 22;98leftSidePadding = 8;99buttonHeight = 15;100buttonWidth = 15;101buttonPadding = 6;102downShift = 1;103}104};105}106};107108private static final RecyclableSingleton<AquaInternalFrameBorderMetrics> legacyUtilityMetrics = new RecyclableSingleton<AquaInternalFrameBorderMetrics>() {109@Override110protected AquaInternalFrameBorderMetrics getInstance() {111return new AquaInternalFrameBorderMetrics() {112protected void initialize() {113font = new Font("Lucida Grande", Font.PLAIN, 11);114titleBarHeight = 16;115leftSidePadding = 5;116buttonHeight = 13;117buttonWidth = 13;118buttonPadding = 5;119downShift = 0;120}121};122}123};124}125126127