📄 aqualayoutstyle.java
字号:
/*
* Copyright (C) 2005-2006 Sun Microsystems, Inc. All rights reserved. Use is
* subject to license terms.
*/
package org.jdesktop.layout;
import javax.swing.border.EmptyBorder;
import org.jdesktop.layout.*;
import java.awt.*;
import java.lang.reflect.*;
import javax.swing.*;
import java.util.*;
/**
* An implementation of <code>LayoutStyle</code> for Mac OS X Tiger.
* <p>
* The information used for this layout style comes from:
* http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/
*
* @author Werner Randelshofer
* @version $Revision: 1.1 $
*/
class AquaLayoutStyle extends LayoutStyle {
private static final Insets EMPTY_INSETS = new Insets(0, 0, 0, 0);
/** Mini size style. */
private final static int MINI = 0;
/** Small size style. */
private final static int SMALL = 1;
/** Regular size style. */
private final static int REGULAR = 2;
/**
* The containerGapDefinitions array defines the preferred insets (child gaps)
* of a parent container towards one of its child components.
*
* Note: As of now, we do not yet specify the preferred gap from a child
* to its parent. Therefore we may not be able to treat all special cases.
*
* This array is used to initialize the containerGaps HashMap.
*
* The array has the following structure, which is supposed to be a
* a compromise between legibility and code size.
* containerGapDefinitions[0..n] = preferred insets for some parent UI's
* containerGapDefinitions[][0..m-3] = name of parent UI,
* optionally followed by a full stop and
* a style name
* containerGapDefinitions[][m-2] = mini insets
* containerGapDefinitions[][m-1] = small insets
* containerGapDefinitions[][m] = regular insets
*/
private final static Object[][] containerGapDefinitions = {
// Format:
// { list of parent UI's,
// mini insets, small insets, regular insets }
{ "TabbedPaneUI",
new Insets(6,10,10,10), new Insets(6,10,10,12),
new Insets(12,20,20,20)
},
// http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGLayout/chapter_19_section_3.html#//apple_ref/doc/uid/TP30000360/DontLinkElementID_27
// http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGLayout/chapter_19_section_3.html#//apple_ref/doc/uid/TP30000360/DontLinkElementID_26
// note for small and mini size: leave 8 to 10 pixels on top
// note for regular size: leave only 12 pixel at top if tabbed pane UI
{ "RootPaneUI",
new Insets(8,10,10,10), new Insets(8,10,10,12),
new Insets(14,20,20,20)
},
// These child gaps are used for all other components
{ "default",
new Insets(8,10,10,10), new Insets(8,10,10,12),
new Insets(14,20,20,20)
},
};
/**
* The relatedGapDefinitions table defines the preferred gaps
* of one party of two related components.
*
* The effective preferred gap is the maximum of the preferred gaps of
* both parties.
*
* This array is used to initialize the relatedGaps HashMap.
*
* The array has the following structure, which is supposed to be a
* a compromise between legibility and code size.
* containerGapDefinitions[0..n] = preferred gaps for a party of a two related UI's
* containerGapDefinitions[][0..m-3] = name of UI
* optionally followed by a full stop and
* a style name
* containerGapDefinitions[][m-2] = mini insets
* containerGapDefinitions[][m-1] = small insets
* containerGapDefinitions[][m] = regular insets
*/
private final static Object[][] relatedGapDefinitions = {
// Format:
// { list of UI's,
// mini insets, small insets, regular insets }
// Push Button:
// http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_2.html#//apple_ref/doc/uid/20000957-TP30000359-TPXREF104
{ "ButtonUI", "ButtonUI.push", "ButtonUI.text",
"ToggleButtonUI.push", "ToggleButtonUI.text",
new Insets(8,8,8,8), new Insets(10,10,10,10), new Insets(12,12,12,12)
},
// Metal Button
// http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_2.html#//apple_ref/doc/uid/20000957-TP30000359-TPXREF187
{ "ButtonUI.metal", "ToggleButtonUI.metal",
new Insets(8,8,8,8), new Insets(8,8,8,8), new Insets(12,12,12,12)
},
// Bevel Button (Rounded and Square)
// http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_2.html#//apple_ref/doc/uid/20000957-TP30000359-TPXREF112
{ "ButtonUI.bevel", "ButtonUI.toggle", "ButtonUI.square",
"ToggleButtonUI", "ToggleButtonUI.bevel", "ToggleButtonUI.square",
"ToggleButtonUI.toggle",
new Insets(0,0,0,0), new Insets(0,0,0,0), new Insets(0,0,0,0)
},
// Bevel Button (Rounded and Square)
// http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_2.html#//apple_ref/doc/uid/20000957-TP30000359-TPXREF112
{ "ButtonUI.bevel.largeIcon", "ToggleButtonUI.bevel.largeIcon",
new Insets(8,8,8,8), new Insets(8,8,8,8), new Insets(8,8,8,8)
},
// Icon Button
// http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_2.html#//apple_ref/doc/uid/20000957-TP30000359-TPXREF189
{ "ButtonUI.icon",
new Insets(0,0,0,0), new Insets(0,0,0,0), new Insets(0,0,0,0)
},
{ "ButtonUI.icon.largeIcon",
new Insets(8,8,8,8), new Insets(8,8,8,8), new Insets(8,8,8,8)
},
// Round Button
// http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_2.html#//apple_ref/doc/uid/20000957-TP30000359-TPXREF191
{ "ButtonUI.round", "ToggleButtonUI.round",
new Insets(12,12,12,12), new Insets(12,12,12,12),
new Insets(12,12,12,12)
},
// Help Button
// http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_2.html#//apple_ref/doc/uid/20000957-TP30000359-TPXREF193
{ "ButtonUI.help",
new Insets(12,12,12,12), new Insets(12,12,12,12),
new Insets(12,12,12,12)
},
// Segmented Control
// http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_3.html#//apple_ref/doc/uid/20000957-TP30000359-TPXREF196
{ "ButtonUI.toggleCenter", "ToggleButtonUI.toggleCenter",
new Insets(8,0,8,0), new Insets(10,0,10,0), new Insets(12,0,12,0)
},
{ "ButtonUI.toggleEast", "ToggleButtonUI.toggleEast",
new Insets(8,0,8,8), new Insets(10,0,10,10), new Insets(12,0,12,12)
},
{ "ButtonUI.toggleWest", "ToggleButtonUI.toggleWest",
new Insets(8,8,8,0), new Insets(10,10,10,0), new Insets(12,12,12,0)
},
{ "ButtonUI.toolBarTab", "ToggleButtonUI.toolBarTab",
new Insets(0,0,0,0), new Insets(0,0,0,0), new Insets(0,0,0,0)
},
// Color Well Button
// http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_3.html#//apple_ref/doc/uid/20000957-TP30000359-TPXREF213
{ "ButtonUI.colorWell", "ToggleButtonUI.colorWell",
new Insets(0,0,0,0), new Insets(0,0,0,0), new Insets(0,0,0,0)
},
// http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_3.html#//apple_ref/doc/uid/20000957-TP30000359-TPXREF198
// FIXME - The following values are given in the AHIG.
// In reality, the values further below seem to be more appropriate.
// Which ones are right?
//{ "CheckBoxUI", new Insets(7, 5, 7, 5), new Insets(8, 6, 8, 6), new Insets(8, 8, 8, 8) },
{ "CheckBoxUI",
new Insets(6, 5, 6, 5), new Insets(7, 6, 7, 6), new Insets(7, 6, 7, 6)
},
// http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_3.html#//apple_ref/doc/uid/20000957-TP30000359-TPXREF198
{ "ComboBoxUI.editable",
new Insets(8, 5, 8, 5), new Insets(10, 6, 10, 6),
new Insets(12, 8, 12, 8)
},
{ "ComboBoxUI.uneditable",
new Insets(6, 5, 6, 5), new Insets(8, 6, 8, 6),
new Insets(10, 8, 10, 8)
},
// There is no spacing given for labels.
// This comes from playing with IB.
// We use the values here, which is the minimum of the spacing of all
// other components.
{ "LabelUI",
new Insets(8, 8, 8, 8), new Insets(8, 8, 8, 8), new Insets(8, 8, 8, 8)
},
// ? spacing not given
{ "ListUI",
new Insets(5, 5, 5, 5), new Insets(6, 6, 6, 6), new Insets(6, 6, 6, 6)
},
// ? spacing not given
{ "PanelUI",
new Insets(0, 0, 0, 0), new Insets(0, 0, 0, 0), new Insets(0, 0, 0, 0)
},
// http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_5.html#//apple_ref/doc/uid/20000957-TP30000359-TPXREF106
// ? spacing not given
{ "ProgressBarUI",
new Insets(8,8,8,8), new Insets(10,10,10,10), new Insets(12,12,12,12)
},
// http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_3.html#//apple_ref/doc/uid/20000957-TP30000359-BIAHBFAD
{ "RadioButtonUI",
new Insets(5, 5, 5, 5), new Insets(6, 6, 6, 6), new Insets(6, 6, 6, 6)
},
//http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_6.html#//apple_ref/doc/uid/20000957-TP30000359-TPXREF114
// ? spacing not given. We use the same as for text fields.
{ "ScrollPaneUI",
new Insets(6, 8, 6, 8), new Insets(6, 8, 6, 8),
new Insets(8, 10, 8, 10)
},
//http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_8.html#//apple_ref/doc/uid/20000957-TP30000359-TPXREF214
// ? spacing not given
//http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGLayout/chapter_19_section_2.html#//apple_ref/doc/uid/20000957-TP30000360-CHDEACGD
{ "SeparatorUI",
new Insets(8, 8, 8, 8), new Insets(10, 10, 10, 10),
new Insets(12, 12, 12, 12)
},
// http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_4.html#//apple_ref/doc/uid/20000957-TP30000359-TPXREF115
{ "SliderUI.horizontal",
new Insets(8,8,8,8), new Insets(10,10,10,10), new Insets(12,12,12,12)
},
{ "SliderUI.vertical",
new Insets(8,8,8,8), new Insets(10,10,10,10), new Insets(12,12,12,12)
},
//http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_4.html#//apple_ref/doc/uid/20000957-TP30000359-TPXREF204
{ "SpinnerUI",
new Insets(6, 8, 6, 8), new Insets(6, 8, 6, 8),
new Insets(8, 10, 8, 10)
},
// http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_7.html#//apple_ref/doc/uid/20000957-TP30000359-CHDDBIJE
// ? spacing not given
{ "SplitPaneUI",
new Insets(0,0,0,0), new Insets(0,0,0,0), new Insets(0,0,0,0)
},
// http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_7.html#//apple_ref/doc/uid/20000957-TP30000359-TPXREF105
// ? spacing not given
{ "TabbedPaneUI",
new Insets(0,0,0,0), new Insets(0,0,0,0), new Insets(0,0,0,0)
},
{ "TableUI",
new Insets(0,0,0,0), new Insets(0,0,0,0), new Insets(0,0,0,0)
},
// ? spacing not given
{ "TextAreaUI", "EditorPaneUI", "TextPaneUI",
new Insets(0,0,0,0), new Insets(0,0,0,0), new Insets(0,0,0,0)
},
//http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGControls/chapter_18_section_6.html#//apple_ref/doc/uid/20000957-TP30000359-TPXREF225
{ "TextFieldUI", "FormattedTextFieldUI", "PasswordFieldUI",
new Insets(6, 8, 6, 8), new Insets(6, 8, 6, 8),
new Insets(8, 10, 8, 10)
},
// ? spacing not given
{ "TreeUI",
new Insets(0,0,0,0), new Insets(0,0,0,0), new Insets(0,0,0,0)
},
};
private final static Object[][] unrelatedGapDefinitions = {
// UI, mini, small, regular
{ "ButtonUI.help",
new Insets(24,24,24,24), new Insets(24,24,24,24),
new Insets(24,24,24,24)
},
{ "default",
new Insets(10, 10, 10, 10), new Insets(12, 12, 12, 12),
new Insets(14, 14, 14, 14)
},
};
/**
* The indentGapDefinitions table defines the preferred indentation
* for components that are indented after the specified component.
*
* This array is used to initialize the indentGaps HashMap.
*
* The array has the following structure, which is supposed to be a
* a compromise between legibility and code size.
* indentGapDefinitions[0..n] = preferred gaps for a party of a two related UI's
* indentGapDefinitions[][0..m-3] = name of UI
* optionally followed by a full stop and
* a style name
* indentGapDefinitions[][m-2] = mini insets
* indentGapDefinitions[][m-1] = small insets
* indentGapDefinitions[][m] = regular insets
*/
private final static Object[][] indentGapDefinitions = {
// UI, mini, small, regular
// The Aqua L&F does not scale button images of check boxes and radio
// buttons. Therefore we use to the same horizontal indents for all sizes.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -