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 private ParagraphType type
;
30 private String content
;
31 private Image contentImage
;
35 * Empty constructor, not to use.
37 @SuppressWarnings("unused")
39 // for serialisation purposes
43 * Create a new {@link Paragraph} with the given image.
48 public Paragraph(Image contentImage
) {
49 this(ParagraphType
.IMAGE
, null, 1);
50 this.contentImage
= contentImage
;
54 * Create a new {@link Paragraph} with the given values.
57 * the {@link ParagraphType}
59 * the content of this paragraph
61 * the number of words (or images)
63 public Paragraph(ParagraphType type
, String content
, long words
) {
65 this.content
= content
;
70 * The {@link ParagraphType}.
74 public ParagraphType
getType() {
79 * The {@link ParagraphType}.
84 public void setType(ParagraphType type
) {
89 * The content of this {@link Paragraph} if it is not an image.
93 public String
getContent() {
98 * The content of this {@link Paragraph}.
103 public void setContent(String content
) {
104 this.content
= content
;
108 * The content of this {@link Paragraph} if it is an image.
110 * @return the content
112 public Image
getContentImage() {
117 * The number of words (or images) in this {@link Paragraph}.
119 * @return the number of words
121 public long getWords() {
126 * The number of words (or images) in this {@link Paragraph}.
129 * the number of words to set
131 public void setWords(long words
) {
136 * Display a DEBUG {@link String} representation of this object.
139 public String
toString() {
140 return String
.format("%s: [%s]", "" + type
, "" + content
);
144 public Paragraph
clone() {
145 Paragraph para
= null;
147 para
= (Paragraph
) super.clone();
148 } catch (CloneNotSupportedException e
) {
149 // Did the clones rebel?
150 System
.err
.println(e
);