1 | /* | |
2 | * $Id: ListItem.java 4052 2009-08-28 13:54:31Z blowagie $ | |
3 | * | |
4 | * Copyright 1999, 2000, 2001, 2002 by Bruno Lowagie. | |
5 | * | |
6 | * The contents of this file are subject to the Mozilla Public License Version 1.1 | |
7 | * (the "License"); you may not use this file except in compliance with the License. | |
8 | * You may obtain a copy of the License at http://www.mozilla.org/MPL/ | |
9 | * | |
10 | * Software distributed under the License is distributed on an "AS IS" basis, | |
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
12 | * for the specific language governing rights and limitations under the License. | |
13 | * | |
14 | * The Original Code is 'iText, a free JAVA-PDF library'. | |
15 | * | |
16 | * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by | |
17 | * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie. | |
18 | * All Rights Reserved. | |
19 | * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer | |
20 | * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved. | |
21 | * | |
22 | * Contributor(s): all the names of the contributors are added in the source code | |
23 | * where applicable. | |
24 | * | |
25 | * Alternatively, the contents of this file may be used under the terms of the | |
26 | * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the | |
27 | * provisions of LGPL are applicable instead of those above. If you wish to | |
28 | * allow use of your version of this file only under the terms of the LGPL | |
29 | * License and not to allow others to use your version of this file under | |
30 | * the MPL, indicate your decision by deleting the provisions above and | |
31 | * replace them with the notice and other provisions required by the LGPL. | |
32 | * If you do not delete the provisions above, a recipient may use your version | |
33 | * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE. | |
34 | * | |
35 | * This library is free software; you can redistribute it and/or modify it | |
36 | * under the terms of the MPL as stated above or under the terms of the GNU | |
37 | * Library General Public License as published by the Free Software Foundation; | |
38 | * either version 2 of the License, or any later version. | |
39 | * | |
40 | * This library is distributed in the hope that it will be useful, but WITHOUT | |
41 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
42 | * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more | |
43 | * details. | |
44 | * | |
45 | * If you didn't download this code from the following link, you should check if | |
46 | * you aren't using an obsolete version: | |
47 | * http://www.lowagie.com/iText/ | |
48 | */ | |
49 | ||
50 | package com.lowagie.text; | |
51 | ||
52 | /** | |
53 | * A <CODE>ListItem</CODE> is a <CODE>Paragraph</CODE> | |
54 | * that can be added to a <CODE>List</CODE>. | |
55 | * <P> | |
56 | * <B>Example 1:</B> | |
57 | * <BLOCKQUOTE><PRE> | |
58 | * List list = new List(true, 20); | |
59 | * list.add(<STRONG>new ListItem("First line")</STRONG>); | |
60 | * list.add(<STRONG>new ListItem("The second line is longer to see what happens once the end of the line is reached. Will it start on a new line?")</STRONG>); | |
61 | * list.add(<STRONG>new ListItem("Third line")</STRONG>); | |
62 | * </PRE></BLOCKQUOTE> | |
63 | * | |
64 | * The result of this code looks like this: | |
65 | * <OL> | |
66 | * <LI> | |
67 | * First line | |
68 | * </LI> | |
69 | * <LI> | |
70 | * The second line is longer to see what happens once the end of the line is reached. Will it start on a new line? | |
71 | * </LI> | |
72 | * <LI> | |
73 | * Third line | |
74 | * </LI> | |
75 | * </OL> | |
76 | * | |
77 | * <B>Example 2:</B> | |
78 | * <BLOCKQUOTE><PRE> | |
79 | * List overview = new List(false, 10); | |
80 | * overview.add(<STRONG>new ListItem("This is an item")</STRONG>); | |
81 | * overview.add("This is another item"); | |
82 | * </PRE></BLOCKQUOTE> | |
83 | * | |
84 | * The result of this code looks like this: | |
85 | * <UL> | |
86 | * <LI> | |
87 | * This is an item | |
88 | * </LI> | |
89 | * <LI> | |
90 | * This is another item | |
91 | * </LI> | |
92 | * </UL> | |
93 | * | |
94 | * @see Element | |
95 | * @see List | |
96 | * @see Paragraph | |
97 | */ | |
98 | ||
99 | public class ListItem extends Paragraph { | |
100 | | |
101 | // constants | |
102 | private static final long serialVersionUID = 1970670787169329006L; | |
103 | | |
104 | // member variables | |
105 | | |
106 | /** | |
107 | * this is the symbol that will precede the listitem. | |
108 | * @since 5.0 used to be private | |
109 | */ | |
110 | protected Chunk symbol; | |
111 | | |
112 | // constructors | |
113 | | |
114 | /** | |
115 | * Constructs a <CODE>ListItem</CODE>. | |
116 | */ | |
117 | public ListItem() { | |
118 | super(); | |
119 | } | |
120 | | |
121 | /** | |
122 | * Constructs a <CODE>ListItem</CODE> with a certain leading. | |
123 | * | |
124 | * @param leading the leading | |
125 | */ | |
126 | public ListItem(float leading) { | |
127 | super(leading); | |
128 | } | |
129 | | |
130 | /** | |
131 | * Constructs a <CODE>ListItem</CODE> with a certain <CODE>Chunk</CODE>. | |
132 | * | |
133 | * @param chunk a <CODE>Chunk</CODE> | |
134 | */ | |
135 | public ListItem(Chunk chunk) { | |
136 | super(chunk); | |
137 | } | |
138 | | |
139 | /** | |
140 | * Constructs a <CODE>ListItem</CODE> with a certain <CODE>String</CODE>. | |
141 | * | |
142 | * @param string a <CODE>String</CODE> | |
143 | */ | |
144 | public ListItem(String string) { | |
145 | super(string); | |
146 | } | |
147 | | |
148 | /** | |
149 | * Constructs a <CODE>ListItem</CODE> with a certain <CODE>String</CODE> | |
150 | * and a certain <CODE>Font</CODE>. | |
151 | * | |
152 | * @param string a <CODE>String</CODE> | |
153 | * @param font a <CODE>String</CODE> | |
154 | */ | |
155 | public ListItem(String string, Font font) { | |
156 | super(string, font); | |
157 | } | |
158 | | |
159 | /** | |
160 | * Constructs a <CODE>ListItem</CODE> with a certain <CODE>Chunk</CODE> | |
161 | * and a certain leading. | |
162 | * | |
163 | * @param leading the leading | |
164 | * @param chunk a <CODE>Chunk</CODE> | |
165 | */ | |
166 | public ListItem(float leading, Chunk chunk) { | |
167 | super(leading, chunk); | |
168 | } | |
169 | | |
170 | /** | |
171 | * Constructs a <CODE>ListItem</CODE> with a certain <CODE>String</CODE> | |
172 | * and a certain leading. | |
173 | * | |
174 | * @param leading the leading | |
175 | * @param string a <CODE>String</CODE> | |
176 | */ | |
177 | public ListItem(float leading, String string) { | |
178 | super(leading, string); | |
179 | } | |
180 | | |
181 | /** | |
182 | * Constructs a <CODE>ListItem</CODE> with a certain leading, <CODE>String</CODE> | |
183 | * and <CODE>Font</CODE>. | |
184 | * | |
185 | * @param leading the leading | |
186 | * @param string a <CODE>String</CODE> | |
187 | * @param font a <CODE>Font</CODE> | |
188 | */ | |
189 | public ListItem(float leading, String string, Font font) { | |
190 | super(leading, string, font); | |
191 | } | |
192 | | |
193 | /** | |
194 | * Constructs a <CODE>ListItem</CODE> with a certain <CODE>Phrase</CODE>. | |
195 | * | |
196 | * @param phrase a <CODE>Phrase</CODE> | |
197 | */ | |
198 | public ListItem(Phrase phrase) { | |
199 | super(phrase); | |
200 | } | |
201 | | |
202 | // implementation of the Element-methods | |
203 | | |
204 | /** | |
205 | * Gets the type of the text element. | |
206 | * | |
207 | * @return a type | |
208 | */ | |
209 | public int type() { | |
210 | return Element.LISTITEM; | |
211 | } | |
212 | | |
213 | // methods | |
214 | | |
215 | /** | |
216 | * Sets the listsymbol. | |
217 | * | |
218 | * @param symbol a <CODE>Chunk</CODE> | |
219 | */ | |
220 | public void setListSymbol(Chunk symbol) { | |
221 |
1
1. setListSymbol : negated conditional → NO_COVERAGE |
if (this.symbol == null) { |
222 | this.symbol = symbol; | |
223 |
1
1. setListSymbol : negated conditional → NO_COVERAGE |
if (this.symbol.getFont().isStandardFont()) { |
224 |
1
1. setListSymbol : removed call to com/lowagie/text/Chunk::setFont → NO_COVERAGE |
this.symbol.setFont(font); |
225 | } | |
226 | } | |
227 | } | |
228 | | |
229 | /** | |
230 | * Sets the indentation of this paragraph on the left side. | |
231 | * | |
232 | * @param indentation the new indentation | |
233 | */ | |
234 | public void setIndentationLeft(float indentation, boolean autoindent) { | |
235 |
1
1. setIndentationLeft : negated conditional → NO_COVERAGE |
if (autoindent) { |
236 |
1
1. setIndentationLeft : removed call to com/lowagie/text/ListItem::setIndentationLeft → NO_COVERAGE |
setIndentationLeft(getListSymbol().getWidthPoint()); |
237 | } | |
238 | else { | |
239 |
1
1. setIndentationLeft : removed call to com/lowagie/text/ListItem::setIndentationLeft → NO_COVERAGE |
setIndentationLeft(indentation); |
240 | } | |
241 | } | |
242 | | |
243 | // methods to retrieve information | |
244 | ||
245 | /** | |
246 | * Returns the listsymbol. | |
247 | * | |
248 | * @return a <CODE>Chunk</CODE> | |
249 | */ | |
250 | public Chunk getListSymbol() { | |
251 | return symbol; | |
252 | } | |
253 | ||
254 | } | |
Mutations | ||
221 |
1.1 |
|
223 |
1.1 |
|
224 |
1.1 |
|
235 |
1.1 |
|
236 |
1.1 |
|
239 |
1.1 |