001: /*
002: * Copyright 2003 by Michael Niedermair and 2007 Bruno Lowagie
003: *
004: * The contents of this file are subject to the Mozilla Public License Version 1.1
005: * (the "License"); you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
007: *
008: * Software distributed under the License is distributed on an "AS IS" basis,
009: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
010: * for the specific language governing rights and limitations under the License.
011: *
012: * The Original Code is 'iText, a free JAVA-PDF library'.
013: *
014: * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
015: * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
016: * All Rights Reserved.
017: * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
018: * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
019: *
020: * Contributor(s): all the names of the contributors are added in the source code
021: * where applicable.
022: *
023: * Alternatively, the contents of this file may be used under the terms of the
024: * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
025: * provisions of LGPL are applicable instead of those above. If you wish to
026: * allow use of your version of this file only under the terms of the LGPL
027: * License and not to allow others to use your version of this file under
028: * the MPL, indicate your decision by deleting the provisions above and
029: * replace them with the notice and other provisions required by the LGPL.
030: * If you do not delete the provisions above, a recipient may use your version
031: * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
032: *
033: * This library is free software; you can redistribute it and/or modify it
034: * under the terms of the MPL as stated above or under the terms of the GNU
035: * Library General Public License as published by the Free Software Foundation;
036: * either version 2 of the License, or any later version.
037: *
038: * This library is distributed in the hope that it will be useful, but WITHOUT
039: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
040: * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
041: * details.
042: *
043: * If you didn't download this code from the following link, you should check if
044: * you aren't using an obsolete version:
045: * http://www.lowagie.com/iText/
046: */
047: package com.lowagie.text;
048:
049: import com.lowagie.text.factories.GreekNumberFactory;
050:
051: /**
052: *
053: * A special-version of <CODE>LIST</CODE> whitch use greek-letters.
054: *
055: * @see com.lowagie.text.List
056: */
057:
058: public class GreekList extends List {
059:
060: // constructors
061:
062: /**
063: * Initialization
064: */
065: public GreekList() {
066: super (true);
067: setGreekFont();
068: }
069:
070: /**
071: * Initialization
072: *
073: * @param symbolIndent indent
074: */
075: public GreekList(int symbolIndent) {
076: super (true, symbolIndent);
077: setGreekFont();
078: }
079:
080: /**
081: * Initialization
082: * @param greeklower greek-char in lowercase
083: * @param symbolIndent indent
084: */
085: public GreekList(boolean greeklower, int symbolIndent) {
086: super (true, symbolIndent);
087: lowercase = greeklower;
088: setGreekFont();
089: }
090:
091: // helper method
092:
093: /**
094: * change the font to SYMBOL
095: */
096: protected void setGreekFont() {
097: float fontsize = symbol.getFont().getSize();
098: symbol.setFont(FontFactory.getFont(FontFactory.SYMBOL,
099: fontsize, Font.NORMAL));
100: }
101:
102: // overridden method
103:
104: /**
105: * Adds an <CODE>Object</CODE> to the <CODE>List</CODE>.
106: *
107: * @param o the object to add.
108: * @return true if adding the object succeeded
109: */
110: public boolean add(Object o) {
111: if (o instanceof ListItem) {
112: ListItem item = (ListItem) o;
113: Chunk chunk = new Chunk(GreekNumberFactory.getString(first
114: + list.size(), lowercase), symbol.getFont());
115: chunk.append(". ");
116: item.setListSymbol(chunk);
117: item.setIndentationLeft(symbolIndent, autoindent);
118: item.setIndentationRight(0);
119: list.add(item);
120: } else if (o instanceof List) {
121: List nested = (List) o;
122: nested.setIndentationLeft(nested.getIndentationLeft()
123: + symbolIndent);
124: first--;
125: return list.add(nested);
126: } else if (o instanceof String) {
127: return this .add(new ListItem((String) o));
128: }
129: return false;
130: }
131:
132: // deprecated methods
133:
134: /**
135: * Translates a number to a letter(combination).
136: * 1-26 correspond with a-z, 27 is aa, 28 is ab, and so on,
137: * aaa comes right after zz.
138: * @param index a number greater than 0
139: * @return a String corresponding with the index.
140: * @deprecated use GreekNumberFactory.getString(int, boolean)
141: */
142: public static int[] getGreekValue(int index, boolean lowercase) {
143: byte[] result = GreekNumberFactory.getString(index, lowercase)
144: .getBytes();
145: int n = result.length;
146: int[] r = new int[n];
147: System.arraycopy(result, 0, r, 0, n);
148: return r;
149: }
150:
151: /**
152: * set the greek-letters to lowercase otherwise to uppercase
153: *
154: * @param greeklower
155: * @deprecated use setLowercase(boolean)
156: */
157: public void setGreekLower(boolean greeklower) {
158: setLowercase(greeklower);
159: }
160:
161: /**
162: * Checks if the list is greek-letter with lowercase
163: *
164: * @return <CODE>true</CODE> if the greek-letter is lowercase, <CODE>false</CODE> otherwise.
165: * @deprecated use isLowercase()
166: */
167: public boolean isGreekLower() {
168: return isLowercase();
169: }
170: }
|