1 package be
.nikiroo
.fanfix
.data
;
3 import java
.io
.Serializable
;
5 import be
.nikiroo
.utils
.Image
;
8 * A paragraph in a chapter of the story.
12 public class Paragraph
implements Cloneable
, Serializable
{
13 private static final long serialVersionUID
= 1L;
16 * A paragraph type, that will dictate how the paragraph will be handled.
20 public enum ParagraphType
{
21 /** Normal paragraph (text) */
25 /** A Break paragraph, i.e.: HR (Horizontal Line) or '* * *' or whatever */
27 /** Quotation (dialogue) */
29 /** An image (no text) */
33 * This paragraph type is of a text kind (quote or not).
36 * allow empty text as text, too (blanks, breaks...)
37 * @return TRUE if it is
39 public boolean isText(boolean allowEmpty
) {
40 return (this == NORMAL
|| this == QUOTE
)
41 || (allowEmpty
&& (this == BLANK
|| this == BREAK
));
45 private ParagraphType type
;
46 private String content
;
47 private Image contentImage
;
51 * Empty constructor, not to use.
53 @SuppressWarnings("unused")
55 // for serialisation purposes
59 * Create a new {@link Paragraph} with the given image.
64 public Paragraph(Image contentImage
) {
65 this(ParagraphType
.IMAGE
, null, 1);
66 this.contentImage
= contentImage
;
70 * Create a new {@link Paragraph} with the given values.
73 * the {@link ParagraphType}
75 * the content of this paragraph
77 * the number of words (or images)
79 public Paragraph(ParagraphType type
, String content
, long words
) {
81 this.content
= content
;
86 * The {@link ParagraphType}.
90 public ParagraphType
getType() {
95 * The {@link ParagraphType}.
100 public void setType(ParagraphType type
) {
105 * The content of this {@link Paragraph} if it is not an image.
107 * @return the content
109 public String
getContent() {
114 * The content of this {@link Paragraph}.
119 public void setContent(String content
) {
120 this.content
= content
;
124 * The content of this {@link Paragraph} if it is an image.
126 * @return the content
128 public Image
getContentImage() {
133 * The number of words (or images) in this {@link Paragraph}.
135 * @return the number of words
137 public long getWords() {
142 * The number of words (or images) in this {@link Paragraph}.
145 * the number of words to set
147 public void setWords(long words
) {
152 * Display a DEBUG {@link String} representation of this object.
155 public String
toString() {
156 return String
.format("%s: [%s]", "" + type
, content
== null ?
"N/A"
161 public Paragraph
clone() {
162 Paragraph para
= null;
164 para
= (Paragraph
) super.clone();
165 } catch (CloneNotSupportedException e
) {
166 // Did the clones rebel?
167 System
.err
.println(e
);