1 /* ========================================================================
2 * JFiglet, a free open source java implementation of figlet and the
3 * figfont specification (see http://www.figlet.org)
4 * Copyright (C) 2004 Sebastien Brunot
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * ========================================================================
20 */
21 package org.gnu.jfiglet.core;
22
23 import java.util.ArrayList;
24 import java.util.Iterator;
25 import java.util.List;
26
27 /***
28 * @TODO : DOCUMENT ME !
29 *
30 * @version $Id: FIGure.java,v 1.4 2004/05/01 14:22:37 sbrunot Exp $
31 *
32 * @author <a href="mailto:sebastien.brunot@club-internet.fr">Sebastien Brunot</a>
33 *
34 */
35 public class FIGure
36 {
37 //////////////////////////////////////
38 // Attributes
39 //////////////////////////////////////
40
41 /***
42 * A list of String[], each one holding a line of the FIGure
43 */
44 private List figCharactersLines = new ArrayList();
45
46 //////////////////////////////////////
47 // Constructor
48 //////////////////////////////////////
49
50 /***
51 * A constructor that takes no arguments and creates an
52 * empty figure.
53 */
54 public FIGure()
55 {
56 super();
57 }
58
59 //////////////////////////////////////
60 // Public methods
61 //////////////////////////////////////
62
63 /***
64 * @TODO : DOCUMENTS ME !
65 */
66 public String[] getSubcharactersLines()
67 {
68 String[] returnedValue = null;
69 int returnedValueLenght = 0;
70 Iterator lineIterator = this.figCharactersLines.iterator();
71 // count the number of subcharacter lines the FIGure
72 // is made of
73 while (lineIterator.hasNext())
74 {
75 String[] currentLine = (String[]) lineIterator.next();
76 returnedValueLenght += currentLine.length;
77 }
78 if (returnedValueLenght > 0)
79 {
80 returnedValue = new String[returnedValueLenght];
81 int currentReturnedLineIndex = 0;
82 lineIterator = this.figCharactersLines.iterator();
83 while (lineIterator.hasNext())
84 {
85 String[] currentLine = (String[]) lineIterator.next();
86 for (int index=0; index < currentLine.length; index++)
87 {
88 returnedValue[currentReturnedLineIndex] = currentLine[index];
89 currentReturnedLineIndex++;
90 }
91 }
92 }
93
94 return returnedValue;
95 }
96
97 /***
98 * @TODO : DOCUMENTS ME !
99 * @param theFigCharactersLine
100 */
101 public void addFigCharactersLine(String[] theFigCharactersLine)
102 {
103 if (theFigCharactersLine == null)
104 {
105 throw new IllegalArgumentException("the FIGCharacters line musn't be null");
106 }
107 this.figCharactersLines.add(theFigCharactersLine);
108 }
109
110 }