1 package com.sharkysoft.printf.engine; 2 3 import com.sharkysoft.util.EnumeratedType; 4 5 /*** 6 * Text justification styles. 7 * 8 * <p><b>Details:</b> <code>AlignmentMode</code> is an enumeration of alignment 9 * modes supported by {@link StringFormatter}. When the text is shorter than 10 * the field into which it is being rendered, it may be justified against the 11 * left edge of the field, the right edge of the field, or both. The text may 12 * also be centered. This class represents each of the alignment modes with 13 * both <code>int</code>s and type-<wbr>safe object values.</p> 14 * 15 * @see StringFormatter 16 * @author Sharky 17 */ 18 public final class AlignmentMode extends EnumeratedType 19 { 20 21 /*** 22 * Initializes type-safe object value. 23 * 24 * <p><b>Details:</b> This constructor initializes type-safe object 25 * values.</p> 26 * 27 * @param inValue magic int value 28 * @param isString string form 29 */ 30 private AlignmentMode(int inValue, String isString) 31 { 32 super(inValue, isString); 33 } 34 35 /*** 36 * Left-alignment. 37 * 38 * <p><b>Details:</b> <code>LEFT</code> indicates that text is 39 * left-<wbr>aligned in the field.</p> 40 * 41 * @see #gpLeft 42 */ 43 public static final int LEFT = 1; 44 45 /*** 46 * Left-alignment. 47 * 48 * <p><b>Details:</b> <code>gpLeft</code> is a type-<wbr>safe representation 49 * of <code>LEFT</code>.</p> 50 * 51 * @see #LEFT 52 */ 53 public static final AlignmentMode gpLeft = new AlignmentMode(LEFT, "LEFT"); 54 55 /*** 56 * Centered alignment. 57 * 58 * <p><b>Details:</b> <code>CENTER</code> indicates that text is centered in 59 * the field.</p> 60 * 61 * @see #gpCenter 62 */ 63 public static final int CENTER = 2; 64 65 /*** 66 * Centered alignment. 67 * 68 * <p><b>Details:</b> <code>gpCenter</code> is a type-<wbr>safe representation 69 * of <code>CENTER</code>.</p> 70 * 71 * @see #CENTER 72 */ 73 public static final AlignmentMode gpCenter = new AlignmentMode(CENTER, "CENTER"); 74 75 /*** 76 * Right-alignment. 77 * 78 * <p><b>Details:</b> <code>RIGHT</code> indicates that text is 79 * right-<wbr>aligned in the field.</p> 80 * 81 * @see #gpRight 82 */ 83 public static final int RIGHT = 3; 84 85 /*** 86 * Right-alignment. 87 * 88 * <p><b>Details:</b> <code>gpRight</code> is a type-<wbr>safe representation 89 * of <code>RIGHT</code>.</p> 90 * 91 * @see #RIGHT 92 */ 93 public static final AlignmentMode gpRight = new AlignmentMode(RIGHT, "RIGHT"); 94 95 /*** 96 * Full justification. 97 * 98 * <p><b>Details:</b> <code>FULL</code> indicates that text is fully justified 99 * in the field. Fully justified text is aligned to both the left and right 100 * sides of the field. It may be necessary to insert spaces into the text in 101 * order to make it the same width as the field.</p> 102 * 103 * @see #gpFull 104 */ 105 public static final int FULL = 4; 106 107 /*** 108 * Full justification. 109 * 110 * <p><b>Details:</b> <code>gpFull</code> is a type-<wbr>safe representation 111 * of <code>FULL</code>.</p> 112 * 113 * @see #FULL 114 */ 115 public static final AlignmentMode gpFull = new AlignmentMode(FULL, "FULL"); 116 117 /*** 118 * Converts int value to object value. 119 * 120 * <p><b>Details:</b> <code>forInt</code> returns the type-<wbr>safe object 121 * value corresponding to the given <code>int</code> value.</p> 122 * 123 * @param inValue int value 124 * @return type-safe object value 125 */ 126 public static AlignmentMode forInt(int inValue) 127 { 128 return (AlignmentMode) EnumeratedType.toEnumeratedType(inValue); 129 } 130 131 } 132