001: /*
002: * Copyright (C) 2004 NNL Technology AB
003: * Visit www.infonode.net for information about InfoNode(R)
004: * products and how to contact NNL Technology AB.
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 (at your option) 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,
019: * MA 02111-1307, USA.
020: */
021:
022: // $Id: Alignment.java,v 1.5 2004/09/28 15:07:29 jesper Exp $
023: package net.infonode.util;
024:
025: import java.io.IOException;
026: import java.io.ObjectInputStream;
027:
028: /**
029: * An enum class for alignments, left, center, right, top, bottom.
030: *
031: * @author $Author: jesper $
032: * @version $Revision: 1.5 $
033: */
034: public final class Alignment extends Enum {
035: private static final long serialVersionUID = 4945539895437047593L;
036:
037: /**
038: * Left alignment.
039: */
040: public static final Alignment LEFT = new Alignment(0, "Left");
041:
042: /**
043: * Center alignment.
044: */
045: public static final Alignment CENTER = new Alignment(1, "Center");
046:
047: /**
048: * Right alignment.
049: */
050: public static final Alignment RIGHT = new Alignment(2, "Right");
051:
052: /**
053: * Top alignment.
054: */
055: public static final Alignment TOP = new Alignment(3, "Top");
056:
057: /**
058: * Bottom alignment.
059: */
060: public static final Alignment BOTTOM = new Alignment(4, "Bottom");
061:
062: /**
063: * Array containing all alignments..
064: */
065: public static final Alignment[] ALIGNMENTS = { LEFT, CENTER, RIGHT,
066: TOP, BOTTOM };
067:
068: /**
069: * Array containing all horizontal alignments..
070: */
071: public static final Alignment[] HORIZONTAL_ALIGNMENTS = { LEFT,
072: CENTER, RIGHT };
073:
074: /**
075: * Array containing all vertical alignments..
076: */
077: public static final Alignment[] VERTICAL_ALIGNMENTS = { TOP,
078: CENTER, BOTTOM };
079:
080: private Alignment(int value, String name) {
081: super (value, name);
082: }
083:
084: /**
085: * Gets the alignments.
086: *
087: * @return the alignments
088: * @since 1.1.0
089: */
090: public static Alignment[] getAlignments() {
091: return (Alignment[]) ALIGNMENTS.clone();
092: }
093:
094: /**
095: * Gets the horizontal alignments.
096: *
097: * @return the horizontal alignments
098: * @since 1.1.0
099: */
100: public static Alignment[] getHorizontalAlignments() {
101: return (Alignment[]) HORIZONTAL_ALIGNMENTS.clone();
102: }
103:
104: /**
105: * Gets the vertical alignments.
106: *
107: * @return the vertical alignments
108: * @since 1.1.0
109: */
110: public static Alignment[] getVerticalAlignments() {
111: return (Alignment[]) VERTICAL_ALIGNMENTS.clone();
112: }
113:
114: /**
115: * Decodes an alignment from a stream.
116: *
117: * @param in the stream containing the alignment
118: * @return the alignment
119: * @throws IOException if there is a stream error
120: */
121: public static Alignment decode(ObjectInputStream in)
122: throws IOException {
123: return (Alignment) decode(Alignment.class, in);
124: }
125: }
|