0N/A/*
2362N/A * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * (C) Copyright Taligent, Inc. 1996 - 1997, All Rights Reserved
0N/A * (C) Copyright IBM Corp. 1996 - 1998, All Rights Reserved
0N/A *
0N/A * The original version of this source code and documentation is
0N/A * copyrighted and owned by Taligent, Inc., a wholly-owned subsidiary
0N/A * of IBM. These materials are provided under terms of a License
0N/A * Agreement between Taligent and Sun. This technology is protected
0N/A * by multiple US and International patents.
0N/A *
0N/A * This notice and attribution to Taligent may not be removed.
0N/A * Taligent is a registered trademark of Taligent, Inc.
0N/A */
0N/A
0N/Apackage java.awt.font;
0N/A
0N/A/**
0N/A * The <code>GlyphJustificationInfo</code> class represents information
0N/A * about the justification properties of a glyph. A glyph is the visual
0N/A * representation of one or more characters. Many different glyphs can
0N/A * be used to represent a single character or combination of characters.
0N/A * The four justification properties represented by
0N/A * <code>GlyphJustificationInfo</code> are weight, priority, absorb and
0N/A * limit.
0N/A * <p>
0N/A * Weight is the overall 'weight' of the glyph in the line. Generally it is
0N/A * proportional to the size of the font. Glyphs with larger weight are
0N/A * allocated a correspondingly larger amount of the change in space.
0N/A * <p>
0N/A * Priority determines the justification phase in which this glyph is used.
0N/A * All glyphs of the same priority are examined before glyphs of the next
0N/A * priority. If all the change in space can be allocated to these glyphs
0N/A * without exceeding their limits, then glyphs of the next priority are not
0N/A * examined. There are four priorities, kashida, whitespace, interchar,
0N/A * and none. KASHIDA is the first priority examined. NONE is the last
0N/A * priority examined.
0N/A * <p>
0N/A * Absorb determines whether a glyph absorbs all change in space. Within a
0N/A * given priority, some glyphs may absorb all the change in space. If any of
0N/A * these glyphs are present, no glyphs of later priority are examined.
0N/A * <p>
0N/A * Limit determines the maximum or minimum amount by which the glyph can
0N/A * change. Left and right sides of the glyph can have different limits.
0N/A * <p>
0N/A * Each <code>GlyphJustificationInfo</code> represents two sets of
0N/A * metrics, which are <i>growing</i> and <i>shrinking</i>. Growing
0N/A * metrics are used when the glyphs on a line are to be
0N/A * spread apart to fit a larger width. Shrinking metrics are used when
0N/A * the glyphs are to be moved together to fit a smaller width.
0N/A */
0N/A
0N/Apublic final class GlyphJustificationInfo {
0N/A
0N/A /**
0N/A * Constructs information about the justification properties of a
0N/A * glyph.
0N/A * @param weight the weight of this glyph when allocating space. Must be non-negative.
0N/A * @param growAbsorb if <code>true</code> this glyph absorbs
0N/A * all extra space at this priority and lower priority levels when it
0N/A * grows
0N/A * @param growPriority the priority level of this glyph when it
0N/A * grows
0N/A * @param growLeftLimit the maximum amount by which the left side of this
0N/A * glyph can grow. Must be non-negative.
0N/A * @param growRightLimit the maximum amount by which the right side of this
0N/A * glyph can grow. Must be non-negative.
0N/A * @param shrinkAbsorb if <code>true</code>, this glyph absorbs all
0N/A * remaining shrinkage at this and lower priority levels when it
0N/A * shrinks
0N/A * @param shrinkPriority the priority level of this glyph when
0N/A * it shrinks
0N/A * @param shrinkLeftLimit the maximum amount by which the left side of this
0N/A * glyph can shrink. Must be non-negative.
0N/A * @param shrinkRightLimit the maximum amount by which the right side
0N/A * of this glyph can shrink. Must be non-negative.
0N/A */
0N/A public GlyphJustificationInfo(float weight,
0N/A boolean growAbsorb,
0N/A int growPriority,
0N/A float growLeftLimit,
0N/A float growRightLimit,
0N/A boolean shrinkAbsorb,
0N/A int shrinkPriority,
0N/A float shrinkLeftLimit,
0N/A float shrinkRightLimit)
0N/A {
0N/A if (weight < 0) {
0N/A throw new IllegalArgumentException("weight is negative");
0N/A }
0N/A
0N/A if (!priorityIsValid(growPriority)) {
0N/A throw new IllegalArgumentException("Invalid grow priority");
0N/A }
0N/A if (growLeftLimit < 0) {
0N/A throw new IllegalArgumentException("growLeftLimit is negative");
0N/A }
0N/A if (growRightLimit < 0) {
0N/A throw new IllegalArgumentException("growRightLimit is negative");
0N/A }
0N/A
0N/A if (!priorityIsValid(shrinkPriority)) {
0N/A throw new IllegalArgumentException("Invalid shrink priority");
0N/A }
0N/A if (shrinkLeftLimit < 0) {
0N/A throw new IllegalArgumentException("shrinkLeftLimit is negative");
0N/A }
0N/A if (shrinkRightLimit < 0) {
0N/A throw new IllegalArgumentException("shrinkRightLimit is negative");
0N/A }
0N/A
0N/A this.weight = weight;
0N/A this.growAbsorb = growAbsorb;
0N/A this.growPriority = growPriority;
0N/A this.growLeftLimit = growLeftLimit;
0N/A this.growRightLimit = growRightLimit;
0N/A this.shrinkAbsorb = shrinkAbsorb;
0N/A this.shrinkPriority = shrinkPriority;
0N/A this.shrinkLeftLimit = shrinkLeftLimit;
0N/A this.shrinkRightLimit = shrinkRightLimit;
0N/A }
0N/A
0N/A private static boolean priorityIsValid(int priority) {
0N/A
0N/A return priority >= PRIORITY_KASHIDA && priority <= PRIORITY_NONE;
0N/A }
0N/A
0N/A /** The highest justification priority. */
0N/A public static final int PRIORITY_KASHIDA = 0;
0N/A
0N/A /** The second highest justification priority. */
0N/A public static final int PRIORITY_WHITESPACE = 1;
0N/A
0N/A /** The second lowest justification priority. */
0N/A public static final int PRIORITY_INTERCHAR = 2;
0N/A
0N/A /** The lowest justification priority. */
0N/A public static final int PRIORITY_NONE = 3;
0N/A
0N/A /**
0N/A * The weight of this glyph.
0N/A */
0N/A public final float weight;
0N/A
0N/A /**
0N/A * The priority level of this glyph as it is growing.
0N/A */
0N/A public final int growPriority;
0N/A
0N/A /**
0N/A * If <code>true</code>, this glyph absorbs all extra
0N/A * space at this and lower priority levels when it grows.
0N/A */
0N/A public final boolean growAbsorb;
0N/A
0N/A /**
0N/A * The maximum amount by which the left side of this glyph can grow.
0N/A */
0N/A public final float growLeftLimit;
0N/A
0N/A /**
0N/A * The maximum amount by which the right side of this glyph can grow.
0N/A */
0N/A public final float growRightLimit;
0N/A
0N/A /**
0N/A * The priority level of this glyph as it is shrinking.
0N/A */
0N/A public final int shrinkPriority;
0N/A
0N/A /**
0N/A * If <code>true</code>,this glyph absorbs all remaining shrinkage at
0N/A * this and lower priority levels as it shrinks.
0N/A */
0N/A public final boolean shrinkAbsorb;
0N/A
0N/A /**
0N/A * The maximum amount by which the left side of this glyph can shrink
0N/A * (a positive number).
0N/A */
0N/A public final float shrinkLeftLimit;
0N/A
0N/A /**
0N/A * The maximum amount by which the right side of this glyph can shrink
0N/A * (a positive number).
0N/A */
0N/A public final float shrinkRightLimit;
0N/A}