~ubuntu-branches/debian/stretch/insubstantial/stretch

« back to all changes in this revision

Viewing changes to substance/src/main/java/org/pushingpixels/substance/internal/contrib/jgoodies/looks/FontSizeHints.java

  • Committer: Package Import Robot
  • Author(s): Felix Natter
  • Date: 2016-01-18 20:58:45 UTC
  • Revision ID: package-import@ubuntu.com-20160118205845-crbmrkda61qsi5qa
Tags: upstream-7.3+dfsg2
ImportĀ upstreamĀ versionĀ 7.3+dfsg2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2001-2005 JGoodies Karsten Lentzsch. All Rights Reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without 
 
5
 * modification, are permitted provided that the following conditions are met:
 
6
 * 
 
7
 *  o Redistributions of source code must retain the above copyright notice, 
 
8
 *    this list of conditions and the following disclaimer. 
 
9
 *     
 
10
 *  o Redistributions in binary form must reproduce the above copyright notice, 
 
11
 *    this list of conditions and the following disclaimer in the documentation 
 
12
 *    and/or other materials provided with the distribution. 
 
13
 *     
 
14
 *  o Neither the name of JGoodies Karsten Lentzsch nor the names of 
 
15
 *    its contributors may be used to endorse or promote products derived 
 
16
 *    from this software without specific prior written permission. 
 
17
 *     
 
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 
19
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
 
20
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
 
21
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
 
22
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
 
23
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
 
24
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
 
25
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 
26
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
 
27
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
 
28
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
29
 */
 
30
 
 
31
package org.pushingpixels.substance.internal.contrib.jgoodies.looks;
 
32
 
 
33
import org.pushingpixels.lafwidget.utils.LookUtils;
 
34
 
 
35
/**
 
36
 * Describes font size hints used by the JGoodies Windows look&feel; future
 
37
 * implementations of the Plastic l&f may use the same hints.
 
38
 * <p>
 
39
 * 
 
40
 * These hints are only applied if the dialog font is <em>Tahoma</em>, which is
 
41
 * the default font on the majority of Windows desktops. The hints apply a size
 
42
 * delta to increase or decrease the given system font size.
 
43
 * <p>
 
44
 * 
 
45
 * NOTE: This is work in progress and will probably change in the next release,
 
46
 * to better reflect the font choice in the J2SE 1.4.".
 
47
 * 
 
48
 * @author Karsten Lentzsch
 
49
 * 
 
50
 * @see Options#setGlobalFontSizeHints(FontSizeHints)
 
51
 */
 
52
public final class FontSizeHints {
 
53
 
 
54
        public static final FontSizeHints LARGE = new FontSizeHints(12, 12, 14, 14);
 
55
        public static final FontSizeHints SYSTEM = new FontSizeHints(11, 11, 14, 14);
 
56
        public static final FontSizeHints MIXED2 = new FontSizeHints(11, 11, 14, 13);
 
57
        public static final FontSizeHints MIXED = new FontSizeHints(11, 11, 14, 12);
 
58
        public static final FontSizeHints SMALL = new FontSizeHints(11, 11, 12, 12);
 
59
        public static final FontSizeHints FIXED = new FontSizeHints(12, 12, 12, 12);
 
60
 
 
61
        public static final FontSizeHints DEFAULT = SYSTEM;
 
62
 
 
63
        private final int loResMenuFontSize;
 
64
        private final int loResControlFontSize;
 
65
        private final int hiResMenuFontSize;
 
66
        private final int hiResControlFontSize;
 
67
 
 
68
        /**
 
69
         * Constructs <code>FontSizeHints</code> for the specified menu and control
 
70
         * fonts, both for low and high resolution environments.
 
71
         * 
 
72
         * @param loResMenuFontSize
 
73
         *            the size of the menu font in low resolution
 
74
         * @param loResControlFontSize
 
75
         *            the size of the control font in low resolution
 
76
         * @param hiResMenuFontSize
 
77
         *            the size of the menu font in low resolution
 
78
         * @param hiResControlFontSize
 
79
         *            the size of the control font in low resolution
 
80
         */
 
81
        public FontSizeHints(int loResMenuFontSize, int loResControlFontSize,
 
82
                        int hiResMenuFontSize, int hiResControlFontSize) {
 
83
                this.loResMenuFontSize = loResMenuFontSize;
 
84
                this.loResControlFontSize = loResControlFontSize;
 
85
                this.hiResMenuFontSize = hiResMenuFontSize;
 
86
                this.hiResControlFontSize = hiResControlFontSize;
 
87
        }
 
88
 
 
89
        /**
 
90
         * Returns the low resolution menu font size.
 
91
         * 
 
92
         * @return the size of the menu font in low resolution mode
 
93
         */
 
94
        public int loResMenuFontSize() {
 
95
                return loResMenuFontSize;
 
96
        }
 
97
 
 
98
        /**
 
99
         * Returns the low resolution control font size.
 
100
         * 
 
101
         * @return the size of the control font in low resolution mode
 
102
         */
 
103
        public int loResControlFontSize() {
 
104
                return loResControlFontSize;
 
105
        }
 
106
 
 
107
        /**
 
108
         * Returns the high resolution menu font size.
 
109
         * 
 
110
         * @return the size of the menu font in high resolution mode
 
111
         */
 
112
        public int hiResMenuFontSize() {
 
113
                return hiResMenuFontSize;
 
114
        }
 
115
 
 
116
        /**
 
117
         * Returns the high resolution control font size.
 
118
         * 
 
119
         * @return the size of the control font in high resolution mode
 
120
         */
 
121
        public int hiResControlFontSize() {
 
122
                return hiResControlFontSize;
 
123
        }
 
124
 
 
125
        /**
 
126
         * Returns the menu font size.
 
127
         * 
 
128
         * @return the size of the menu font in the current resolution
 
129
         */
 
130
        public int menuFontSize() {
 
131
                return LookUtils.IS_LOW_RESOLUTION ? loResMenuFontSize
 
132
                                : hiResMenuFontSize();
 
133
        }
 
134
 
 
135
        /**
 
136
         * Returns the control font size.
 
137
         * 
 
138
         * @return the size of the control font in the current resolution
 
139
         */
 
140
        public int controlFontSize() {
 
141
                return LookUtils.IS_LOW_RESOLUTION ? loResControlFontSize
 
142
                                : hiResControlFontSize();
 
143
        }
 
144
 
 
145
        /**
 
146
         * Returns the delta between the system menu font size and our menu font
 
147
         * size hint.
 
148
         * 
 
149
         * @return the delta between the system menu font size and our menu font
 
150
         *         size hint
 
151
         */
 
152
        public float menuFontSizeDelta() {
 
153
                return menuFontSize() - SYSTEM.menuFontSize();
 
154
        }
 
155
 
 
156
        /**
 
157
         * Returns the delta between system control font size and our control font
 
158
         * size hint.
 
159
         * 
 
160
         * @return the delta between the system control font size and our control
 
161
         *         font size hint
 
162
         */
 
163
        public float controlFontSizeDelta() {
 
164
                return controlFontSize() - SYSTEM.controlFontSize();
 
165
        }
 
166
 
 
167
        /**
 
168
         * Looksup and returns the <code>FontSizeHints</code> for the specified
 
169
         * name.
 
170
         * 
 
171
         * @param name
 
172
         *            the name of the FontSizeHints object
 
173
         * @return the associated FontSizeHints object
 
174
         */
 
175
        public static FontSizeHints valueOf(String name) {
 
176
                if (name.equalsIgnoreCase("LARGE"))
 
177
                        return LARGE;
 
178
                else if (name.equalsIgnoreCase("SYSTEM"))
 
179
                        return SYSTEM;
 
180
                else if (name.equalsIgnoreCase("MIXED"))
 
181
                        return MIXED;
 
182
                else if (name.equalsIgnoreCase("SMALL"))
 
183
                        return SMALL;
 
184
                else if (name.equalsIgnoreCase("FIXED"))
 
185
                        return FIXED;
 
186
                else
 
187
                        throw new IllegalArgumentException("Unknown font size hints name: "
 
188
                                        + name);
 
189
        }
 
190
}
 
 
b'\\ No newline at end of file'