X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=reader%2Fui%2FGuiReaderViewerTextOutput.java;h=fc914ddb458eefbe3f2bf273d38a8d07d71dad14;hb=HEAD;hp=47d9664d384fd28ad9057590e1e08aec62467837;hpb=0fc81e6465aa9c1f1dfc19b532082220d609768a;p=fanfix.git
diff --git a/reader/ui/GuiReaderViewerTextOutput.java b/reader/ui/GuiReaderViewerTextOutput.java
deleted file mode 100644
index 47d9664..0000000
--- a/reader/ui/GuiReaderViewerTextOutput.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package be.nikiroo.fanfix.reader.ui;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import be.nikiroo.fanfix.Instance;
-import be.nikiroo.fanfix.data.Chapter;
-import be.nikiroo.fanfix.data.Paragraph;
-import be.nikiroo.fanfix.data.Paragraph.ParagraphType;
-import be.nikiroo.fanfix.data.Story;
-import be.nikiroo.fanfix.output.BasicOutput;
-
-/**
- * This class can export a chapter into HTML3 code ready for Java Swing support.
- *
- * @author niki
- */
-public class GuiReaderViewerTextOutput {
- private StringBuilder builder;
- private BasicOutput output;
- private Story fakeStory;
-
- /**
- * Create a new {@link GuiReaderViewerTextOutput} that will convert a
- * {@link Chapter} into HTML3 suited for Java Swing.
- */
- public GuiReaderViewerTextOutput() {
- builder = new StringBuilder();
- fakeStory = new Story();
-
- output = new BasicOutput() {
- private boolean paraInQuote;
-
- @Override
- protected void writeChapterHeader(Chapter chap) throws IOException {
- builder.append("");
-
- builder.append("
");
- builder.append("Chapter ");
- builder.append(chap.getNumber());
- builder.append(": ");
- builder.append(chap.getName());
- builder.append("
");
-
- builder.append("");
- }
-
- @Override
- protected void writeChapterFooter(Chapter chap) throws IOException {
- if (paraInQuote) {
- builder.append("
");
- }
- paraInQuote = false;
-
- builder.append("");
- builder.append("");
- }
-
- @Override
- protected void writeParagraph(Paragraph para) throws IOException {
- if ((para.getType() == ParagraphType.QUOTE) == !paraInQuote) {
- paraInQuote = !paraInQuote;
- if (paraInQuote) {
- builder.append("
");
- builder.append("");
- } else {
- builder.append("
");
- builder.append("
");
- }
- }
-
- switch (para.getType()) {
- case NORMAL:
- builder.append(" ");
- builder.append(decorateText(para.getContent()));
- builder.append("
");
- break;
- case BLANK:
- builder.append("
");
- break;
- case BREAK:
- builder.append("
");
- builder.append("* * *");
- builder.append("
");
- break;
- case QUOTE:
- builder.append("");
- builder.append(" ");
- builder.append("— ");
- builder.append(decorateText(para.getContent()));
- builder.append("
");
-
- break;
- case IMAGE:
- }
- }
-
- @Override
- protected String enbold(String word) {
- return "" + word + "";
- }
-
- @Override
- protected String italize(String word) {
- return "" + word + "";
- }
- };
- }
-
- /**
- * Convert the chapter into HTML3 code.
- *
- * @param chap
- * the {@link Chapter} to convert.
- *
- * @return HTML3 code tested with Java Swing
- */
- public String convert(Chapter chap) {
- builder.setLength(0);
- try {
- fakeStory.setChapters(Arrays.asList(chap));
- output.process(fakeStory, null, null);
- } catch (IOException e) {
- Instance.getTraceHandler().error(e);
- }
- return builder.toString();
- }
-}