1 package be
.nikiroo
.fanfix
.data
;
3 import be
.nikiroo
.utils
.Image
;
6 * A paragraph in a chapter of the story.
10 public class Paragraph
implements Cloneable
{
12 * A paragraph type, that will dictate how the paragraph will be handled.
16 public enum ParagraphType
{
17 /** Normal paragraph (text) */
21 /** A Break paragraph, i.e.: HR (Horizontal Line) or '* * *' or whatever */
23 /** Quotation (dialogue) */
25 /** An image (no text) */
29 * This paragraph type is of a text kind (quote or not).
32 * allow empty text as text, too (blanks, breaks...)
33 * @return TRUE if it is
35 public boolean isText(boolean allowEmpty
) {
36 return (this == NORMAL
|| this == QUOTE
)
37 || (allowEmpty
&& (this == BLANK
|| this == BREAK
));
41 private ParagraphType type
;
42 private String content
;
43 private Image contentImage
;
47 * Empty constructor, not to use.
49 @SuppressWarnings("unused")
51 // for serialisation purposes
55 * Create a new {@link Paragraph} with the given image.
60 public Paragraph(Image contentImage
) {
61 this(ParagraphType
.IMAGE
, null, 1);
62 this.contentImage
= contentImage
;
66 * Create a new {@link Paragraph} with the given values.
69 * the {@link ParagraphType}
71 * the content of this paragraph
73 * the number of words (or images)
75 public Paragraph(ParagraphType type
, String content
, long words
) {
77 this.content
= content
;
82 * The {@link ParagraphType}.
86 public ParagraphType
getType() {
91 * The {@link ParagraphType}.
96 public void setType(ParagraphType type
) {
101 * The content of this {@link Paragraph} if it is not an image.
103 * @return the content
105 public String
getContent() {
110 * The content of this {@link Paragraph}.
115 public void setContent(String content
) {
116 this.content
= content
;
120 * The content of this {@link Paragraph} if it is an image.
122 * @return the content
124 public Image
getContentImage() {
129 * The number of words (or images) in this {@link Paragraph}.
131 * @return the number of words
133 public long getWords() {
138 * The number of words (or images) in this {@link Paragraph}.
141 * the number of words to set
143 public void setWords(long words
) {
148 * Display a DEBUG {@link String} representation of this object.
151 public String
toString() {
152 return String
.format("%s: [%s]", "" + type
, content
== null ?
"N/A"
157 public Paragraph
clone() {
158 Paragraph para
= null;
160 para
= (Paragraph
) super.clone();
161 } catch (CloneNotSupportedException e
) {
162 // Did the clones rebel?
163 System
.err
.println(e
);