1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17/** 18 * @author Ilya S. Okomin 19 * @version $Revision$ 20 */ 21 22package java.awt.font; 23 24import org.apache.harmony.awt.internal.nls.Messages; 25 26/** 27 * The GlyphJustificationInfo class provides information about the glyph's 28 * justification properties. There are four justification properties: weight, 29 * priority, absorb, and limit. 30 * <p> 31 * There are two sets of metrics: growing and shrinking. Growing metrics are 32 * used when the glyphs are to be spread apart to fit a larger width. Shrinking 33 * metrics are used when the glyphs are to be moved together to fit a smaller 34 * width. 35 * </p> 36 * 37 * @since Android 1.0 38 */ 39public final class GlyphJustificationInfo { 40 41 /** 42 * The Constant PRIORITY_KASHIDA indicates the highest justification 43 * priority. 44 */ 45 public static final int PRIORITY_KASHIDA = 0; 46 47 /** 48 * The Constant PRIORITY_WHITESPACE indicates the second highest 49 * justification priority. 50 */ 51 public static final int PRIORITY_WHITESPACE = 1; 52 53 /** 54 * The Constant PRIORITY_INTERCHAR indicates the second lowest justification 55 * priority. 56 */ 57 public static final int PRIORITY_INTERCHAR = 2; 58 59 /** 60 * The Constant PRIORITY_NONE indicates the lowest justification priority. 61 */ 62 public static final int PRIORITY_NONE = 3; 63 64 /** 65 * The grow absorb flag indicates if this glyph absorbs all extra space at 66 * this and lower priority levels when it grows. 67 */ 68 public final boolean growAbsorb; 69 70 /** 71 * The grow left limit value represents the maximum value by which the left 72 * side of this glyph grows. 73 */ 74 public final float growLeftLimit; 75 76 /** 77 * The grow right limit value repesents the maximum value by which the right 78 * side of this glyph grows. 79 */ 80 public final float growRightLimit; 81 82 /** 83 * The grow priority value represents the priority level of this glyph as it 84 * is growing. 85 */ 86 public final int growPriority; 87 88 /** 89 * The shrink absorb fleg indicates this glyph absorbs all remaining 90 * shrinkage at this and lower priority levels as it shrinks. 91 */ 92 public final boolean shrinkAbsorb; 93 94 /** 95 * The shrink left limit value represents the maximum value by which the 96 * left side of this glyph shrinks. 97 */ 98 public final float shrinkLeftLimit; 99 100 /** 101 * The shrink right limit value represents the maximum value by which the 102 * right side of this glyph shrinks. 103 */ 104 public final float shrinkRightLimit; 105 106 /** 107 * The shrink priority represents the glyth's priority level as it is 108 * shrinking. 109 */ 110 public final int shrinkPriority; 111 112 /** 113 * The weight of the glyph. 114 */ 115 public final float weight; 116 117 /** 118 * Instantiates a new GlyphJustificationInfo object which contains glyph's 119 * justification properties. 120 * 121 * @param weight 122 * the weight of glyph. 123 * @param growAbsorb 124 * indicates if this glyph contais all space at this priority and 125 * lower priority levels when it grows. 126 * @param growPriority 127 * indicates the priority level of this glyph when it grows. 128 * @param growLeftLimit 129 * indicates the maximum value of which the left side of this 130 * glyph can grow. 131 * @param growRightLimit 132 * the maximum value of which the right side of this glyph can 133 * grow. 134 * @param shrinkAbsorb 135 * indicates if this glyph contains all remaining shrinkage at 136 * this and lower priority levels when it shrinks. 137 * @param shrinkPriority 138 * indicates the glyph's priority level when it shrinks. 139 * @param shrinkLeftLimit 140 * indicates the maximum value of which the left side of this 141 * glyph can shrink. 142 * @param shrinkRightLimit 143 * indicates the maximum amount by which the right side of this 144 * glyph can shrink. 145 */ 146 public GlyphJustificationInfo(float weight, boolean growAbsorb, int growPriority, 147 float growLeftLimit, float growRightLimit, boolean shrinkAbsorb, int shrinkPriority, 148 float shrinkLeftLimit, float shrinkRightLimit) { 149 150 if (weight < 0) { 151 // awt.19C=weight must be a positive number 152 throw new IllegalArgumentException(Messages.getString("awt.19C")); //$NON-NLS-1$ 153 } 154 this.weight = weight; 155 156 if (growLeftLimit < 0) { 157 // awt.19D=growLeftLimit must be a positive number 158 throw new IllegalArgumentException(Messages.getString("awt.19D")); //$NON-NLS-1$ 159 } 160 this.growLeftLimit = growLeftLimit; 161 162 if (growRightLimit < 0) { 163 // awt.19E=growRightLimit must be a positive number 164 throw new IllegalArgumentException(Messages.getString("awt.19E")); //$NON-NLS-1$ 165 } 166 this.growRightLimit = growRightLimit; 167 168 if ((shrinkPriority < 0) || (shrinkPriority > PRIORITY_NONE)) { 169 // awt.19F=incorrect value for shrinkPriority, more than 170 // PRIORITY_NONE or less than PRIORITY_KASHIDA value 171 throw new IllegalArgumentException(Messages.getString("awt.19F")); //$NON-NLS-1$ 172 } 173 this.shrinkPriority = shrinkPriority; 174 175 if ((growPriority < 0) || (growPriority > PRIORITY_NONE)) { 176 // awt.200=incorrect value for growPriority, more than PRIORITY_NONE 177 // or less than PRIORITY_KASHIDA value 178 throw new IllegalArgumentException(Messages.getString("awt.200")); //$NON-NLS-1$ 179 } 180 this.growPriority = growPriority; 181 182 if (shrinkLeftLimit < 0) { 183 // awt.201=shrinkLeftLimit must be a positive number 184 throw new IllegalArgumentException(Messages.getString("awt.201")); //$NON-NLS-1$ 185 } 186 this.shrinkLeftLimit = shrinkLeftLimit; 187 188 if (shrinkRightLimit < 0) { 189 // awt.202=shrinkRightLimit must be a positive number 190 throw new IllegalArgumentException(Messages.getString("awt.202")); //$NON-NLS-1$ 191 } 192 this.shrinkRightLimit = shrinkRightLimit; 193 194 this.shrinkAbsorb = shrinkAbsorb; 195 this.growAbsorb = growAbsorb; 196 } 197} 198