Source Code Cross Referenced for GlyphJustificationInfo.java in  » 6.0-JDK-Core » AWT » java » awt » font » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » AWT » java.awt.font 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 1997-1999 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        /*
027         * (C) Copyright Taligent, Inc. 1996 - 1997, All Rights Reserved
028         * (C) Copyright IBM Corp. 1996 - 1998, All Rights Reserved
029         *
030         * The original version of this source code and documentation is
031         * copyrighted and owned by Taligent, Inc., a wholly-owned subsidiary
032         * of IBM. These materials are provided under terms of a License
033         * Agreement between Taligent and Sun. This technology is protected
034         * by multiple US and International patents.
035         *
036         * This notice and attribution to Taligent may not be removed.
037         * Taligent is a registered trademark of Taligent, Inc.
038         */
039
040        package java.awt.font;
041
042        /**
043         * The <code>GlyphJustificationInfo</code> class represents information
044         * about the justification properties of a glyph.  A glyph is the visual 
045         * representation of one or more characters.  Many different glyphs can
046         * be used to represent a single character or combination of characters.
047         * The four justification properties represented by
048         * <code>GlyphJustificationInfo</code> are weight, priority, absorb and
049         * limit.
050         * <p>
051         * Weight is the overall 'weight' of the glyph in the line.  Generally it is
052         * proportional to the size of the font.  Glyphs with larger weight are
053         * allocated a correspondingly larger amount of the change in space.
054         * <p>
055         * Priority determines the justification phase in which this glyph is used.
056         * All glyphs of the same priority are examined before glyphs of the next
057         * priority.  If all the change in space can be allocated to these glyphs
058         * without exceeding their limits, then glyphs of the next priority are not
059         * examined. There are four priorities, kashida, whitespace, interchar,
060         * and none.  KASHIDA is the first priority examined. NONE is the last
061         * priority examined.
062         * <p>
063         * Absorb determines whether a glyph absorbs all change in space.  Within a
064         * given priority, some glyphs may absorb all the change in space.  If any of
065         * these glyphs are present, no glyphs of later priority are examined.
066         * <p>
067         * Limit determines the maximum or minimum amount by which the glyph can
068         * change. Left and right sides of the glyph can have different limits.
069         * <p>
070         * Each <code>GlyphJustificationInfo</code> represents two sets of
071         * metrics, which are <i>growing</i> and <i>shrinking</i>.  Growing
072         * metrics are used when the glyphs on a line are to be
073         * spread apart to fit a larger width.  Shrinking metrics are used when
074         * the glyphs are to be moved together to fit a smaller width.
075         */
076
077        public final class GlyphJustificationInfo {
078
079            /**
080             * Constructs information about the justification properties of a
081             * glyph.
082             * @param weight the weight of this glyph when allocating space.  Must be non-negative.
083             * @param growAbsorb if <code>true</code> this glyph absorbs
084             * all extra space at this priority and lower priority levels when it
085             * grows
086             * @param growPriority the priority level of this glyph when it
087             * grows
088             * @param growLeftLimit the maximum amount by which the left side of this
089             * glyph can grow.  Must be non-negative.
090             * @param growRightLimit the maximum amount by which the right side of this
091             * glyph can grow.  Must be non-negative.
092             * @param shrinkAbsorb if <code>true</code>, this glyph absorbs all
093             * remaining shrinkage at this and lower priority levels when it
094             * shrinks
095             * @param shrinkPriority the priority level of this glyph when
096             * it shrinks
097             * @param shrinkLeftLimit the maximum amount by which the left side of this
098             * glyph can shrink.  Must be non-negative.
099             * @param shrinkRightLimit the maximum amount by which the right side
100             * of this glyph can shrink.  Must be non-negative.
101             */
102            public GlyphJustificationInfo(float weight, boolean growAbsorb,
103                    int growPriority, float growLeftLimit,
104                    float growRightLimit, boolean shrinkAbsorb,
105                    int shrinkPriority, float shrinkLeftLimit,
106                    float shrinkRightLimit) {
107                if (weight < 0) {
108                    throw new IllegalArgumentException("weight is negative");
109                }
110
111                if (!priorityIsValid(growPriority)) {
112                    throw new IllegalArgumentException("Invalid grow priority");
113                }
114                if (growLeftLimit < 0) {
115                    throw new IllegalArgumentException(
116                            "growLeftLimit is negative");
117                }
118                if (growRightLimit < 0) {
119                    throw new IllegalArgumentException(
120                            "growRightLimit is negative");
121                }
122
123                if (!priorityIsValid(shrinkPriority)) {
124                    throw new IllegalArgumentException(
125                            "Invalid shrink priority");
126                }
127                if (shrinkLeftLimit < 0) {
128                    throw new IllegalArgumentException(
129                            "shrinkLeftLimit is negative");
130                }
131                if (shrinkRightLimit < 0) {
132                    throw new IllegalArgumentException(
133                            "shrinkRightLimit is negative");
134                }
135
136                this .weight = weight;
137                this .growAbsorb = growAbsorb;
138                this .growPriority = growPriority;
139                this .growLeftLimit = growLeftLimit;
140                this .growRightLimit = growRightLimit;
141                this .shrinkAbsorb = shrinkAbsorb;
142                this .shrinkPriority = shrinkPriority;
143                this .shrinkLeftLimit = shrinkLeftLimit;
144                this .shrinkRightLimit = shrinkRightLimit;
145            }
146
147            private static boolean priorityIsValid(int priority) {
148
149                return priority >= PRIORITY_KASHIDA
150                        && priority <= PRIORITY_NONE;
151            }
152
153            /** The highest justification priority. */
154            public static final int PRIORITY_KASHIDA = 0;
155
156            /** The second highest justification priority. */
157            public static final int PRIORITY_WHITESPACE = 1;
158
159            /** The second lowest justification priority. */
160            public static final int PRIORITY_INTERCHAR = 2;
161
162            /** The lowest justification priority. */
163            public static final int PRIORITY_NONE = 3;
164
165            /**
166             * The weight of this glyph.
167             */
168            public final float weight;
169
170            /**
171             * The priority level of this glyph as it is growing.
172             */
173            public final int growPriority;
174
175            /**
176             * If <code>true</code>, this glyph absorbs all extra
177             * space at this and lower priority levels when it grows.
178             */
179            public final boolean growAbsorb;
180
181            /**
182             * The maximum amount by which the left side of this glyph can grow.
183             */
184            public final float growLeftLimit;
185
186            /**
187             * The maximum amount by which the right side of this glyph can grow.
188             */
189            public final float growRightLimit;
190
191            /**
192             * The priority level of this glyph as it is shrinking.
193             */
194            public final int shrinkPriority;
195
196            /**
197             * If <code>true</code>,this glyph absorbs all remaining shrinkage at
198             * this and lower priority levels as it shrinks.
199             */
200            public final boolean shrinkAbsorb;
201
202            /**
203             * The maximum amount by which the left side of this glyph can shrink
204             * (a positive number).
205             */
206            public final float shrinkLeftLimit;
207
208            /**
209             * The maximum amount by which the right side of this glyph can shrink
210             * (a positive number).
211             */
212            public final float shrinkRightLimit;
213        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.