+ /**
+ * Display the given text on the window.
+ *
+ * @param text
+ * the text to display
+ */
+ private void setText(String text) {
+ textField.setText(text);
+ textField.reflowData();
+ textField.toTop();
+ }
+
+ /**
+ * Set the current chapter area to the correct value.
+ */
+ private void setCurrentChapterText() {
+ String name;
+ if (chapter < 0) {
+ name = " " + getStory().getMeta().getTitle();
+ } else if (chapter == 0) {
+ Chapter resume = getStory().getMeta().getResume();
+ if (resume != null) {
+ name = String.format(" %s", resume.getName());
+ } else {
+ // TODO: i18n
+ name = "[No RESUME]";
+ }
+ } else {
+ int max = getStory().getChapters().size();
+ Chapter chap = getStory().getChapters().get(chapter - 1);
+ name = String.format(" %d/%d: %s", chapter, max, chap.getName());
+ }
+
+ int width = getWidth() - currentChapter.getX();
+ name = String.format("%-" + width + "s", name);
+ if (name.length() > width) {
+ name = name.substring(0, width);
+ }
+
+ currentChapter.setLabel(name);
+ }
+
+ /**
+ * Set the current title in-window.
+ *
+ * @param title
+ * the new title
+ */
+ private void setCurrentTitle(String title) {
+ String pad = "";
+ if (title.length() < getWidth()) {
+ int padSize = (getWidth() - title.length()) / 2;
+ pad = String.format("%" + padSize + "s", "");
+ }
+
+ title = pad + title + pad;
+ titleField.setWidth(title.length());
+ titleField.setLabel(title);
+ }
+