001: /*
002: * FontSizeHints.java
003: *
004: * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
019: *
020: */
021:
022: package org.underworldlabs.swing.plaf.smoothgradient;
023:
024: /* ----------------------------------------------------------
025: * CVS NOTE: Changes to the CVS repository prior to the
026: * release of version 3.0.0beta1 has meant a
027: * resetting of CVS revision numbers.
028: * ----------------------------------------------------------
029: */
030:
031: /**
032: * Describes font size hints used by the JGoodies Windows look&feel; future
033: * implementations of the Plastic l&f will use the same hints. In 1.3
034: * environments the sizes are used as absolute font sizes, in 1.4 environments
035: * size deltas are used between SYSTEM and the specified sizes.<p>
036: *
037: * NOTE: This is work in progress and will probably change in the
038: * next release, to better reflect the font choice in the J2SE 1.4.1.
039: * Currently, the size delta is used only for the Tahoma font!<p>
040: *
041: * In 1.3 environments, the font guess is Tahoma on modern Windows,
042: * "dialog" otherwise. In 1.4 environments, the system fonts will be used.
043: *
044: * @author Karsten Lentzsch
045: * @author Takis Diakoumis
046: * @version $Revision: 1.4 $
047: * @date $Date: 2006/05/14 06:56:07 $
048: *
049: * @see Options#setGlobalFontSizeHints
050: * @see FontUtils
051: */
052: public final class FontSizeHints {
053:
054: public static final FontSizeHints LARGE = new FontSizeHints(12, 12,
055: 14, 14);
056: public static final FontSizeHints SYSTEM = new FontSizeHints(11,
057: 11, 14, 14);
058: public static final FontSizeHints MIXED2 = new FontSizeHints(11,
059: 11, 14, 13);
060: public static final FontSizeHints MIXED = new FontSizeHints(11, 11,
061: 14, 12);
062: public static final FontSizeHints SMALL = new FontSizeHints(11, 11,
063: 12, 12);
064: public static final FontSizeHints FIXED = new FontSizeHints(12, 12,
065: 12, 12);
066:
067: public static final FontSizeHints DEFAULT = SYSTEM;
068:
069: private final int loResMenuFontSize;
070: private final int loResControlFontSize;
071: private final int hiResMenuFontSize;
072: private final int hiResControlFontSize;
073:
074: /**
075: * Constructs <code>FontSizeHints</code> for the specified menu and
076: * control fonts, both for low and high resolution environments.
077: */
078: public FontSizeHints(int loResMenuFontSize,
079: int loResControlFontSize, int hiResMenuFontSize,
080: int hiResControlFontSize) {
081: this .loResMenuFontSize = loResMenuFontSize;
082: this .loResControlFontSize = loResControlFontSize;
083: this .hiResMenuFontSize = hiResMenuFontSize;
084: this .hiResControlFontSize = hiResControlFontSize;
085: }
086:
087: /**
088: * Answers the low resolution menu font size.
089: */
090: public int loResMenuFontSize() {
091: return loResMenuFontSize;
092: }
093:
094: /**
095: * Answers the low resolution control font size.
096: */
097: public int loResControlFontSize() {
098: return loResControlFontSize;
099: }
100:
101: /**
102: * Answers the high resolution menu font size.
103: */
104: public int hiResMenuFontSize() {
105: return hiResMenuFontSize;
106: }
107:
108: /**
109: * Answers the high resolution control font size.
110: */
111: public int hiResControlFontSize() {
112: return hiResControlFontSize;
113: }
114:
115: /**
116: * Answers the menu font size.
117: */
118: public int menuFontSize() {
119: return hiResMenuFontSize();
120: }
121:
122: /**
123: * Answers the control font size.
124: */
125: public int controlFontSize() {
126: return hiResControlFontSize();
127: }
128:
129: /**
130: * Answers the delta between system menu font size and our menu font size hint.
131: */
132: public float menuFontSizeDelta() {
133: return menuFontSize() - SYSTEM.menuFontSize();
134: }
135:
136: /**
137: * Answers the delta between system control font size and our control font size hint.
138: */
139: public float controlFontSizeDelta() {
140: return controlFontSize() - SYSTEM.controlFontSize();
141: }
142:
143: /**
144: * Answers the <code>FontSizeHints</code> for the specified name.
145: */
146: public static FontSizeHints valueOf(String name) {
147: if (name.equalsIgnoreCase("LARGE"))
148: return LARGE;
149: else if (name.equalsIgnoreCase("SYSTEM"))
150: return SYSTEM;
151: else if (name.equalsIgnoreCase("MIXED"))
152: return MIXED;
153: else if (name.equalsIgnoreCase("SMALL"))
154: return SMALL;
155: else if (name.equalsIgnoreCase("FIXED"))
156: return FIXED;
157: else
158: throw new IllegalArgumentException(
159: "Unknown font size hints name: " + name);
160: }
161: }
|