/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* OblivionBookCreator.java
*
* Created on Jan 1, 2010, 11:50:20 PM
*/
package oblivion;
import java.awt.Color;
import java.awt.Font;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import java.io.*;
import java.io.BufferedReader;
import java.util.Scanner;
import java.io.IOException;
import java.io.FileWriter;
import javax.swing.text.*;
import javax.swing.text.html.*;
/**
*
* @author Tyler Hallada (aka. Critterman)
* Please credit me if you use this code
*
*/
public class OblivionBookCreator extends javax.swing.JFrame {
/** Creates new form OblivionBookCreator */
public OblivionBookCreator() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
openFileFrame = new javax.swing.JFrame();
openFileChooser = new javax.swing.JFileChooser();
errorFrame = new javax.swing.JFrame();
errorBox = new javax.swing.JOptionPane();
openImageFrame = new javax.swing.JFrame();
openImageChooser = new javax.swing.JFileChooser();
openFancyFrame = new javax.swing.JFrame();
openFancyChooser = new javax.swing.JFileChooser();
questionSizeFrame = new javax.swing.JFrame();
questionSizeOptionPane = new javax.swing.JOptionPane();
saveFileFrame = new javax.swing.JFrame();
saveFileChooser = new javax.swing.JFileChooser();
readmeFrame = new javax.swing.JFrame();
readmeScrollPane = new javax.swing.JScrollPane();
readmeTextArea = new javax.swing.JTextArea();
previewFrame = new javax.swing.JFrame();
previewScrollPage01 = new javax.swing.JScrollPane();
previewPage01 = new javax.swing.JTextPane();
previewScrollPage02 = new javax.swing.JScrollPane();
previewPage02 = new javax.swing.JTextPane();
convertButton = new javax.swing.JButton();
normalScrollPane = new javax.swing.JScrollPane();
normalTextArea = new javax.swing.JTextArea();
closeButton = new javax.swing.JButton();
previewButton = new javax.swing.JButton();
menuBar = new javax.swing.JMenuBar();
fileMenu = new javax.swing.JMenu();
openMenuItem = new javax.swing.JMenuItem();
openSaveSeparator = new javax.swing.JPopupMenu.Separator();
saveMenuItem = new javax.swing.JMenuItem();
saveAsMenuItem = new javax.swing.JMenuItem();
editMenu = new javax.swing.JMenu();
undoMenuItem = new javax.swing.JMenuItem();
undoCopySeparator = new javax.swing.JPopupMenu.Separator();
copyMenuItem = new javax.swing.JMenuItem();
pasteMenuItem = new javax.swing.JMenuItem();
fontMenu = new javax.swing.JMenu();
changeFontSubMenu = new javax.swing.JMenu();
font01MenuItem = new javax.swing.JMenuItem();
font02MenuItem = new javax.swing.JMenuItem();
font03MenuItem = new javax.swing.JMenuItem();
font04MenuItem = new javax.swing.JMenuItem();
font05MenuItem = new javax.swing.JMenuItem();
changeSizeSubMenu = new javax.swing.JMenu();
size01MenuItem = new javax.swing.JMenuItem();
size02MenuItem = new javax.swing.JMenuItem();
size03MenuItem = new javax.swing.JMenuItem();
size04MenuItem = new javax.swing.JMenuItem();
size05MenuItem = new javax.swing.JMenuItem();
changeColorMenuItem = new javax.swing.JMenu();
color01MenuItem = new javax.swing.JMenuItem();
color02MenuItem = new javax.swing.JMenuItem();
color03MenuItem = new javax.swing.JMenuItem();
color04MenuItem = new javax.swing.JMenuItem();
color05MenuItem = new javax.swing.JMenuItem();
color06MenuItem = new javax.swing.JMenuItem();
color07MenuItem = new javax.swing.JMenuItem();
color08MenuItem = new javax.swing.JMenuItem();
imageMenu = new javax.swing.JMenu();
insertImageMenuItem = new javax.swing.JMenuItem();
insertFancyMenuItem = new javax.swing.JMenuItem();
formatMenu = new javax.swing.JMenu();
centerMenuItem = new javax.swing.JMenuItem();
leftMenuItem = new javax.swing.JMenuItem();
rightMenuItem = new javax.swing.JMenuItem();
jSeparator1 = new javax.swing.JPopupMenu.Separator();
lineBreakMenuItem = new javax.swing.JMenuItem();
pageBreakMenuItem = new javax.swing.JMenuItem();
helpMenu = new javax.swing.JMenu();
readmeMenuItem = new javax.swing.JMenuItem();
openFileFrame.setTitle("Open Text File"); //translate
openFileChooser.setAcceptAllFileFilterUsed(false);
openFileChooser.setCurrentDirectory(new java.io.File("C:\\Program Files\\NetBeans 6.8\\null"));
openFileChooser.setDialogTitle("Open Text File"); //translate
javax.swing.GroupLayout openFileFrameLayout = new javax.swing.GroupLayout(openFileFrame.getContentPane());
openFileFrame.getContentPane().setLayout(openFileFrameLayout);
openFileFrameLayout.setHorizontalGroup(
openFileFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
.addGroup(openFileFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(openFileFrameLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(openFileChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
);
openFileFrameLayout.setVerticalGroup(
openFileFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
.addGroup(openFileFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(openFileFrameLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(openFileChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
);
errorFrame.setTitle("Error"); //translate
javax.swing.GroupLayout errorFrameLayout = new javax.swing.GroupLayout(errorFrame.getContentPane());
errorFrame.getContentPane().setLayout(errorFrameLayout);
errorFrameLayout.setHorizontalGroup(
errorFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
.addGroup(errorFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(errorFrameLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(errorBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
);
errorFrameLayout.setVerticalGroup(
errorFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
.addGroup(errorFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(errorFrameLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(errorBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
);
openImageFrame.setTitle("Open Image"); //translate
openImageChooser.setCurrentDirectory(new java.io.File("C:\\Program Files\\Bethesda Softworks\\Oblivion\\Data"));
openImageChooser.setDialogTitle("Open Image File"); //translate
javax.swing.GroupLayout openImageFrameLayout = new javax.swing.GroupLayout(openImageFrame.getContentPane());
openImageFrame.getContentPane().setLayout(openImageFrameLayout);
openImageFrameLayout.setHorizontalGroup(
openImageFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
.addGroup(openImageFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(openImageFrameLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(openImageChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
);
openImageFrameLayout.setVerticalGroup(
openImageFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
.addGroup(openImageFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(openImageFrameLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(openImageChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
);
openFancyFrame.setTitle("Choose Fancy Font");
openFancyChooser.setCurrentDirectory(new java.io.File("C:\\Program Files\\Bethesda Softworks\\Oblivion\\Data\\textures\\menus\\Book\\fancy_font\\y_62x62.dds"));
openFancyChooser.setDialogTitle("Open Fancy Font Image");
javax.swing.GroupLayout openFancyFrameLayout = new javax.swing.GroupLayout(openFancyFrame.getContentPane());
openFancyFrame.getContentPane().setLayout(openFancyFrameLayout);
openFancyFrameLayout.setHorizontalGroup(
openFancyFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
.addGroup(openFancyFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(openFancyFrameLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(openFancyChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
);
openFancyFrameLayout.setVerticalGroup(
openFancyFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
.addGroup(openFancyFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(openFancyFrameLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(openFancyChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
);
questionSizeFrame.setTitle("Choose Image Size"); //translate
javax.swing.GroupLayout questionSizeFrameLayout = new javax.swing.GroupLayout(questionSizeFrame.getContentPane());
questionSizeFrame.getContentPane().setLayout(questionSizeFrameLayout);
questionSizeFrameLayout.setHorizontalGroup(
questionSizeFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(questionSizeFrameLayout.createSequentialGroup()
.addContainerGap()
.addComponent(questionSizeOptionPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
questionSizeFrameLayout.setVerticalGroup(
questionSizeFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(questionSizeFrameLayout.createSequentialGroup()
.addContainerGap()
.addComponent(questionSizeOptionPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
saveFileChooser.setApproveButtonToolTipText("Save file as .txt"); //translate
saveFileChooser.setCurrentDirectory(new java.io.File("C:\\Program Files\\NetBeans 6.8\\null"));
saveFileChooser.setDialogTitle("Save Text File"); //translate
saveFileChooser.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG);
saveFileChooser.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
saveFileChooser.addInputMethodListener(new java.awt.event.InputMethodListener() {
public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {
}
public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
saveFileChooserInputMethodTextChanged(evt);
}
});
javax.swing.GroupLayout saveFileFrameLayout = new javax.swing.GroupLayout(saveFileFrame.getContentPane());
saveFileFrame.getContentPane().setLayout(saveFileFrameLayout);
saveFileFrameLayout.setHorizontalGroup(
saveFileFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 582, Short.MAX_VALUE)
.addGroup(saveFileFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(saveFileFrameLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(saveFileChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
);
saveFileFrameLayout.setVerticalGroup(
saveFileFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 397, Short.MAX_VALUE)
.addGroup(saveFileFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(saveFileFrameLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(saveFileChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
);
readmeFrame.setTitle("Oblivion Book Creator Readme"); //translate
readmeFrame.setMinimumSize(new java.awt.Dimension(600, 750));
readmeTextArea.setBackground(java.awt.SystemColor.textInactiveText);
readmeTextArea.setColumns(20);
readmeTextArea.setEditable(false);
readmeTextArea.setLineWrap(true);
readmeTextArea.setRows(5);
readmeTextArea.setText("=======================================================================\t\n ***********************************************************************************\t\n + OBLIVION BOOK CREATOR + MADE BY CRITTERMAN + VERSION 1.0 + \t\n ***********************************************************************************\t\n=======================================================================\t\n\nAuthor: Critterman \nVersion: 1.0\nDate: 1/11/2010 \nCategory: Utilities \nRequirements: Java JRE 6 or higher\n\n===============\nDescription:\n===============\n\nDo you have a lengthy story and want to put it in Oblivion but are turned off because the tedious process of putting <BR> at the end of every line and the HTML-like formatting? The Oblivion Book Creator lets you instantly convert normal text into CS-friendly formatting. With a click of a button you can add in the codes to change fonts, colors, sizes, align text, create line and page breaks, insert fancy font, and insert your own images that can be seen in the book in-game. Copy the converted text right into the CS to create a book without any tedious typing or copy and pasting. Expanding your in-game library has never been easier!\n\n===============\nFeatures:\n===============\n\n* Convert - Will automatically convert any text in the Oblivion Book Creator text area into Oblivion Book Format (add <BR> to the end of each line). Once you click the convert button you can use the other Oblivion Book Format features in the menu (Change font, size, color, insert image, insert fancy font, aligning, line break, and page break).\n\nThese features can be located in the menus on the menu bar at the top of the window:\n* Open – Open any .txt or .rtf file and convert it into Oblivion Book Format. Any other file may not open correctly.\n* Save and Save as – Save your converted text as a .txt file, so you can open it again later with the Oblivion Book Creator. Just make sure you add a “.txt” at the end of the filename while saving as. Click the save button later to save on the file you created earlier with save as. (If you click save without clicking save as before-hand, a new .txt file called OblivionBook# will be added to the same folder that the OblivionBookCreator.jar is in.)\n* Undo – The wonderful undo is here, so do not fear! Make a mistake and the undo button will save your book.\n* Copy – Copy all the text in the Oblivion Book Creator text area to your clipboard so you can paste it in the CS. (or ctrl+a then ctrl+c)\n* Paste – Paste any text from your clipboard to the Oblivion Book Creator text area. (or ctrl+v)\n* Change Font – Inserts code around highlighted text to change the font to any of the five Oblivion fonts.\n* Change Size – Inserts code around highlighted text to change the font size to any of the five Oblivion font sizes.\n* Change Color – Inserts code around highlighted text to change the font color to any of eight pre-determined colors. Change the color number yourself once the code is inserted to create any other color.\n* Insert Image from File – Opens a prompt asking for the desired image size and then a file chooser will open where you can select any image and the directory will be copied into the code. Make sure you only select .dds file though, any other image file will not show up in-game. This will insert the image code to wherever your cursor is in the text when you press the button.\n* Insert Fancy Font – Lets you select any of the fancy fonts created by Bethesda. The directory and size will automatically be created with the code which is inserted to wherever your curser is in the text when you press the button.\n* Aligning Options – Automatically surround any portion of text with the code for center, left, or right alignment.\n* Line Break – If you have to add in some text after you already used the convert button, use this feature to add in the <BR> code into wherever your curser is in the text. This causes the in-game book text to stop and then go to the next line. \n* Page Break – End of a chapter? Use this to make the in-game book to end the page and start a new one. Remember, this only works for books and is ignored by scrolls.\n* Help – If you ever forget how something works consult this readme by clicking the Readme File button in the Help menu.\n* Close -- Does the same as the X in the upper right hand corner, closes the application.\n\n===============\nGuide to making books in Oblivion:\n===============\n\nYou need the following things to make a book in Oblivion:\n * The Elder Scrolls Construction Set (AKA. CS) - Latest Version (v1.2) - Download Here:
http://cs.elderscrolls.com/constwiki/in ... tion_Set\n * The Oblivion Book Creator (Technically you don't need this to make a book but it helps xD)\n * A basic knowledge of the CS. Read around in the CS Wiki (
http://cs.elderscrolls.com/constwiki/in ... /Main_Page) and do some tutorials to get familiar (Note: This guide is written as if you have never opened the CS before. This is to make sure it is absolutely readable to everyone).\n\nNow, how to make a book in 20 steps:\n1. Copy and paste your book into the Oblivion Book Creator, or alternatively write your book in the Oblivion Book Creator.\n2. Convert and add in any special features that you wish. (see the feature list above to get details on how to use these).\n3. Now copy the text in the Oblivion Book Creator (Edit Menu > Copy).\n4. Open the CS.\n5. Once open go to File Menu > Data... and check Oblivion.esm and your mod's .esp (if you have not made your plugin yet just open the Oblivion.esm and the next time you save you can make your .esp).\n6. In the Object Window, under Items, click Book. You should now see a list of all of the books and scrolls in the game.\n7. Right click > new. A new \"Book\" window should popup.\n8. Make an ID for your book. This is not the name that will appear in-game, this is only to make your book unique. Name it whatever you want, just don't start the name with numbers (I usually use the prefix CM, for Critterman, so I can find my stuff easier. You can use your own acronym if you like).\n9. Name your book. The text that you put in the name box is the name of the book that will appear in-game so choose wisely.\n10. The script part is not needed unless you want your book to do special stuff. If you are interested then check out the scripting portal in the CS Wiki:
http://cs.elderscrolls.com/constwiki/in ... ipting\n11. Choose your weight now. A book weight of 1.0000 is pretty much the standard, but it is your choice.\n12. Now for the value, this is the amount, in gold, that the book is worth.\n13. The \"Teaches\" popup menu lets your book teach the player one point in any skill. Leave blank or choose a skill to teach the player when they open the book.\n14. Now you need to add a NIF file. This is what your book will look like when you place it in the game world. Look in meshes > clutter > books to find the .nif files for books. If you are unsure of which one to pick check out some of the other books in the book list to see what models they use. NOTE: If you see no meshes or have no meshes > clutter > books directory then you need to unpack your meshes.bsa. See this site on how to do this:
http://cs.elderscrolls.com/constwiki/in ... torial\n15. You now need to add an icon image to your book. Make sure the icon somewhat corresponds to the mesh you picked. If you picked a scroll mesh then pick a scroll icon. The textures for the books can be found in textures > clutter. If you see no book textures there or do not have that folder then you will need to unpack your textures.bsa (see above step).\n16. Now check whether it is a scroll. If checked there will be one long page that can be scrolled, if not there will be pages.\n17. Can't be Taken is obvious, if checked you can read the book but can't take it.\n18. Quest Item makes the book impossible to drop from inventory.\n19. If the enchanting field is set, activating the book will prepare these spell effects and not display the Book Text field (like the spell scrolls in vanilla oblivion). Scroll box must be checked to use. Enchantment box is not used.\n20. Finally you can paste the text into the Book Text area (use ctrl+v). Once you are ready click ok to save your new book.\n\nThe only thing left to do is to place your book into the game-world. Navigate to your favorite place in the cell window and then drag your book into the render window. Use the \"F\" key to drop the book onto a surface.\nSave your plugin and then before you start oblivion check your esp in the data files and then play!\n\nCongrats, you have created a book in Oblivion!\n\n===============\nInstall:\n===============\n\n1. Extract the OblivionBookCreator.jar file, OblivionBookCreatorReadme.txt, and the textures folder.\n2. Copy files to (install folder)\\Oblivion\\Data\\. NOTE: The textures folder in the archive is meant to provide you with the fancy font textures if you have not unpacked your textures.bsa. If you already have the fancy fonts in your textures\\menus\\book\\fancy_font folder (unpacked from your textures.bsa) then you do not have to copy over the textures folder from the archive. However, it doesn't hurt to overwrite these files either.\n3. Make sure you have the java JRE. You most likely already have it, but you can get the latest version from
http://java.sun.com/javase/downloads/index.jsp\n4. Double click the OblivionBookCreator.jar file to start the application.\n\n===============\nUn-Install:\n===============\n\nDelete the OblivionBookCreator.jar and OblivionBookCreator.txt files. You do not need to delete the fancy font textures, as they are used in oblivion without this application.\n\n===============\nLinks:\n===============\n\nThese links may help you if you need any further help about Oblivion Book Format:\n*
http://java.sun.com/javase/downloads/index.jsp - To download the latest java JRE.\n*
http://cs.elderscrolls.com/constwiki/in ... Formatting - The CS Wiki article on book formatting.\n*
http://www.computerhope.com/htmcolor.htm - HTML color codes, Oblivion uses the same codes for coloring book font, just paste the code of the color you want in the code for coloring code created by the Oblivion Book Creator to change the color (minus the # sign).\n*
http://cs.elderscrolls.com/constwiki/in ... tures_only - Useful information on images in oblivion books.\n*
http://cs.elderscrolls.com/constwiki/in ... /DDS_Files - If you are unfamiliar with working with .dds files, see this page.\n*
http://www.invision.tesalliance.org/for ... php?/index - Helpful TES forum I frequent, come here if you are having troubles with any aspect of modding.\n\n===============\nCompatibility:\n===============\n\nThis should not conflict with anything, as it is a stand-alone java application. Just make sure you have the latest java JRE (version 6 or higher, a lower version may not be a problem, but it is best to get the latest version).\n\n===============\nBugs/Issues:\n===============\n\nNone found at time of release. Please contact me if you find a bug.\n\n===============\nHistory:\n===============\n\n0.9 - 1/3/2010 - Initial Beta Version.\n1.0 - 1/11/2010 - Version 1.0\n\t* Added a close button on the main interface to give the user a second way to exit.\n\t* Removed the requirement that you need to convert before using many of the features.\n\t* Updated readme (also added guide to making books in Oblivion)\n\n===============\nContact:\n===============\n\nContact me via PM on the Bethesda Official Forums or TES Alliance (my username on both is Critterman)\nOr\nContact me via e-mail at
critterman9@hotmail.com\n\n===============\nCredits:\n===============\n\nThanks to Bethesda for creating Oblivion.\nThanks to Sun Microsystems for making Java.\nThanks to the people who made NetBeans, and the ever useful Swing Component.\nThanks to InsanitySorrow for the Oblivion tool kit used to generate this readme and for inspiration to make this application.\n\n===============\nTools Used:\n===============\n\nNetBeans IDE 6.8\nOblivion Tool Kit\n\n===============\nLicense/Legal:\n===============\n\nYou can use this application and the source code for any of your non-commercial projects/mods. In fact, I invite you to use this as much as possible. If you are just using it to convert text, credit is not necessary; but if you are using the source code it would be nice for you to credit me in your readme.\n"); //translate
readmeTextArea.setWrapStyleWord(true);
readmeScrollPane.setViewportView(readmeTextArea);
javax.swing.GroupLayout readmeFrameLayout = new javax.swing.GroupLayout(readmeFrame.getContentPane());
readmeFrame.getContentPane().setLayout(readmeFrameLayout);
readmeFrameLayout.setHorizontalGroup(
readmeFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 796, Short.MAX_VALUE)
.addGroup(readmeFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(readmeFrameLayout.createSequentialGroup()
.addContainerGap()
.addComponent(readmeScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 776, Short.MAX_VALUE)
.addContainerGap()))
);
readmeFrameLayout.setVerticalGroup(
readmeFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 584, Short.MAX_VALUE)
.addGroup(readmeFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(readmeFrameLayout.createSequentialGroup()
.addContainerGap()
.addComponent(readmeScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 562, Short.MAX_VALUE)
.addContainerGap()))
);
previewScrollPage01.setViewportView(previewPage01);
previewScrollPage02.setViewportView(previewPage02);
javax.swing.GroupLayout previewFrameLayout = new javax.swing.GroupLayout(previewFrame.getContentPane());
previewFrame.getContentPane().setLayout(previewFrameLayout);
previewFrameLayout.setHorizontalGroup(
previewFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(previewFrameLayout.createSequentialGroup()
.addContainerGap()
.addComponent(previewScrollPage01, javax.swing.GroupLayout.PREFERRED_SIZE, 308, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(341, Short.MAX_VALUE))
.addGroup(previewFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, previewFrameLayout.createSequentialGroup()
.addContainerGap(340, Short.MAX_VALUE)
.addComponent(previewScrollPage02, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap()))
);
previewFrameLayout.setVerticalGroup(
previewFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(previewFrameLayout.createSequentialGroup()
.addContainerGap()
.addComponent(previewScrollPage01, javax.swing.GroupLayout.DEFAULT_SIZE, 424, Short.MAX_VALUE)
.addContainerGap())
.addGroup(previewFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, previewFrameLayout.createSequentialGroup()
.addContainerGap()
.addComponent(previewScrollPage02, javax.swing.GroupLayout.DEFAULT_SIZE, 424, Short.MAX_VALUE)
.addContainerGap()))
);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Oblivion Book Creator"); //translate
convertButton.setText("Convert"); //translate
convertButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
convertButtonActionPerformed(evt);
}
});
normalTextArea.setColumns(20);
normalTextArea.setRows(5);
normalTextArea.addInputMethodListener(new java.awt.event.InputMethodListener() {
public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {
}
public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
normalTextAreaInputMethodTextChanged(evt);
}
});
normalScrollPane.setViewportView(normalTextArea);
closeButton.setText("Close"); //translate
closeButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
closeButtonActionPerformed(evt);
}
});
previewButton.setText("Preview"); //translate
previewButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
previewButtonActionPerformed(evt);
}
});
fileMenu.setText("File"); //translate
fileMenu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fileMenuActionPerformed(evt);
}
});
openMenuItem.setText("Open..."); //translate
openMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
openMenuItemActionPerformed(evt);
}
});
fileMenu.add(openMenuItem);
fileMenu.add(openSaveSeparator);
saveMenuItem.setText("Save"); //translate
saveMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveMenuItemActionPerformed(evt);
}
});
fileMenu.add(saveMenuItem);
saveAsMenuItem.setText("Save as..."); //translate
saveAsMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveAsMenuItemActionPerformed(evt);
}
});
fileMenu.add(saveAsMenuItem);
menuBar.add(fileMenu);
editMenu.setText("Edit"); //translate
undoMenuItem.setText("Undo"); //translate
undoMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
undoMenuItemActionPerformed(evt);
}
});
editMenu.add(undoMenuItem);
editMenu.add(undoCopySeparator);
copyMenuItem.setText("Copy"); //translate
copyMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
copyMenuItemActionPerformed(evt);
}
});
editMenu.add(copyMenuItem);
pasteMenuItem.setText("Paste"); //translate
pasteMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pasteMenuItemActionPerformed(evt);
}
});
editMenu.add(pasteMenuItem);
menuBar.add(editMenu);
fontMenu.setText("Font"); //translate
changeFontSubMenu.setText("Change Font"); //translate
font01MenuItem.setText("Kingthings Regular"); //translate?
font01MenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
font01MenuItemActionPerformed(evt);
}
});
changeFontSubMenu.add(font01MenuItem);
font02MenuItem.setText("Kingthings Shadowed"); //translate?
font02MenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
font02MenuItemActionPerformed(evt);
}
});
changeFontSubMenu.add(font02MenuItem);
font03MenuItem.setText("Tahoma Bold Small"); //translate?
font03MenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
font03MenuItemActionPerformed(evt);
}
});
changeFontSubMenu.add(font03MenuItem);
font04MenuItem.setText("Daedric"); //translate?
font04MenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
font04MenuItemActionPerformed(evt);
}
});
changeFontSubMenu.add(font04MenuItem);
font05MenuItem.setText("Handwritten"); //translate?
font05MenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
font05MenuItemActionPerformed(evt);
}
});
changeFontSubMenu.add(font05MenuItem);
fontMenu.add(changeFontSubMenu);
changeSizeSubMenu.setText("Change Size"); //translate
size01MenuItem.setText("Size 1"); //translate
size01MenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
size01MenuItemActionPerformed(evt);
}
});
changeSizeSubMenu.add(size01MenuItem);
size02MenuItem.setText("Size 2"); //translate
size02MenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
size02MenuItemActionPerformed(evt);
}
});
changeSizeSubMenu.add(size02MenuItem);
size03MenuItem.setText("Size 3"); //translate
size03MenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
size03MenuItemActionPerformed(evt);
}
});
changeSizeSubMenu.add(size03MenuItem);
size04MenuItem.setText("Size 4"); //translate
size04MenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
size04MenuItemActionPerformed(evt);
}
});
changeSizeSubMenu.add(size04MenuItem);
size05MenuItem.setText("Size 5"); //translate
size05MenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
size05MenuItemActionPerformed(evt);
}
});
changeSizeSubMenu.add(size05MenuItem);
fontMenu.add(changeSizeSubMenu);
changeColorMenuItem.setText("Change Color"); //translate
color01MenuItem.setText("Black"); //translate
color01MenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
color01MenuItemActionPerformed(evt);
}
});
changeColorMenuItem.add(color01MenuItem);
color02MenuItem.setText("White"); //translate
color02MenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
color02MenuItemActionPerformed(evt);
}
});
changeColorMenuItem.add(color02MenuItem);
color03MenuItem.setText("Grey"); //translate
color03MenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
color03MenuItemActionPerformed(evt);
}
});
changeColorMenuItem.add(color03MenuItem);
color04MenuItem.setText("Red"); //translate
color04MenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
color04MenuItemActionPerformed(evt);
}
});
changeColorMenuItem.add(color04MenuItem);
color05MenuItem.setText("Green"); //translate
color05MenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
color05MenuItemActionPerformed(evt);
}
});
changeColorMenuItem.add(color05MenuItem);
color06MenuItem.setText("Blue"); //translate
color06MenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
color06MenuItemActionPerformed(evt);
}
});
changeColorMenuItem.add(color06MenuItem);
color07MenuItem.setText("Yellow"); //translate
color07MenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
color07MenuItemActionPerformed(evt);
}
});
changeColorMenuItem.add(color07MenuItem);
color08MenuItem.setText("Pink"); //translate
color08MenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
color08MenuItemActionPerformed(evt);
}
});
changeColorMenuItem.add(color08MenuItem);
fontMenu.add(changeColorMenuItem);
menuBar.add(fontMenu);
imageMenu.setText("Image"); //translate
insertImageMenuItem.setText("Insert Image from File..."); //translate
insertImageMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
insertImageMenuItemActionPerformed(evt);
}
});
imageMenu.add(insertImageMenuItem);
insertFancyMenuItem.setText("Insert Fancy Font..."); //translate
insertFancyMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
insertFancyMenuItemActionPerformed(evt);
}
});
imageMenu.add(insertFancyMenuItem);
menuBar.add(imageMenu);
formatMenu.setText("Format"); //translate
centerMenuItem.setText("Center Align Text"); //translate
centerMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
centerMenuItemActionPerformed(evt);
}
});
formatMenu.add(centerMenuItem);
leftMenuItem.setText("Left Align Text"); //translate
leftMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
leftMenuItemActionPerformed(evt);
}
});
formatMenu.add(leftMenuItem);
rightMenuItem.setText("Right Align Text"); //translate
rightMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rightMenuItemActionPerformed(evt);
}
});
formatMenu.add(rightMenuItem);
formatMenu.add(jSeparator1);
lineBreakMenuItem.setText("Line Break"); //translate
lineBreakMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
lineBreakMenuItemActionPerformed(evt);
}
});
formatMenu.add(lineBreakMenuItem);
pageBreakMenuItem.setText("Page Break"); //translate
pageBreakMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pageBreakMenuItemActionPerformed(evt);
}
});
formatMenu.add(pageBreakMenuItem);
menuBar.add(formatMenu);
helpMenu.setText("Help");
readmeMenuItem.setText("Readme File"); //translate
readmeMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
readmeMenuItemActionPerformed(evt);
}
});
helpMenu.add(readmeMenuItem);
menuBar.add(helpMenu);
setJMenuBar(menuBar);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(normalScrollPane, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 463, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(closeButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 256, Short.MAX_VALUE)
.addComponent(previewButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(convertButton)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(normalScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(convertButton)
.addComponent(closeButton)
.addComponent(previewButton))
.addContainerGap())
);
pack();
}// </editor-fold>
int count = 0;
String undoRef;
String savePath;
int saved = 0;
StyledDocument document = new DefaultStyledDocument();
private void fileMenuActionPerformed(java.awt.event.ActionEvent evt) {
//nothing, delete me
}
private void openMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
int returnVal = openFileChooser.showOpenDialog(openFileFrame);
if (returnVal == JFileChooser.APPROVE_OPTION) {
try {
File file = openFileChooser.getSelectedFile();
Scanner scanner = new Scanner(file);
scanner.useDelimiter("\\A");
String content = scanner.next();
scanner.close();
normalTextArea.setText(content);
} catch (FileNotFoundException ex) {
Logger.getLogger(OblivionBookCreator.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
private void convertButtonActionPerformed(java.awt.event.ActionEvent evt) {
String convertedLine = "";
String str;
int lines;
int index = 0;
BufferedReader reader = new BufferedReader(
new StringReader(normalTextArea.getText()));
try {
lines = normalTextArea.getLineCount();
str = reader.readLine();
normalTextArea.setText("");
while (str != null){
for(int i = 0; i<lines; i++)
{
try {
index = normalTextArea.getLineEndOffset(i);
} catch (BadLocationException ex) {
Logger.getLogger(OblivionBookCreator.class.getName()).log(Level.SEVERE, null, ex);
}
if (str.endsWith("<BR>") == false && str.endsWith("<br>") == false){
convertedLine = str.concat("<BR>");
normalTextArea.insert(convertedLine + "\n", index);
}
else{
normalTextArea.insert(str + "\n", index);
}
str = reader.readLine();
}
}
} catch (IOException ex) {
Logger.getLogger(OblivionBookCreator.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void font01MenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<FONT face=Kingthings_Regular>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</FONT>";
normalTextArea.insert(fontend, end);
}
private void font02MenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<FONT face=Kingthings_Shadowed>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</FONT>";
normalTextArea.insert(fontend, end);
}
private void font03MenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<FONT face=Tahoma_Bold_Small>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</FONT>";
normalTextArea.insert(fontend, end);
}
private void font04MenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<FONT face=Daedric_Font>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</FONT>";
normalTextArea.insert(fontend, end);
}
private void font05MenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<FONT face=Handwritten>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</FONT>";
normalTextArea.insert(fontend, end);
}
private void size01MenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<FONT face=1>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</FONT>";
normalTextArea.insert(fontend, end);
}
private void size02MenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<FONT face=2>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</FONT>";
normalTextArea.insert(fontend, end);
}
private void size03MenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<FONT face=3>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</FONT>";
normalTextArea.insert(fontend, end);
}
private void size04MenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<FONT face=4>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</FONT>";
normalTextArea.insert(fontend, end);
}
private void size05MenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<FONT face=5>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</FONT>";
normalTextArea.insert(fontend, end);
}
private void color01MenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<FONT color=000000>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</FONT>";
normalTextArea.insert(fontend, end);
}
private void color02MenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<FONT color=FFFFFF>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</FONT>";
normalTextArea.insert(fontend, end);
}
private void color03MenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<FONT color=C0C0C0>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</FONT>";
normalTextArea.insert(fontend, end);
}
private void color04MenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<FONT color=FF0000>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</FONT>";
normalTextArea.insert(fontend, end);
}
private void color05MenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<FONT color=00FF00>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</FONT>";
normalTextArea.insert(fontend, end);
}
private void color06MenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<FONT color=0000FF>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</FONT>";
normalTextArea.insert(fontend, end);
}
private void color07MenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<FONT color=FFFF00>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</FONT>";
normalTextArea.insert(fontend, end);
}
private void color08MenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<FONT color=FF00FF>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</FONT>";
normalTextArea.insert(fontend, end);
}
private void undoMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
normalTextArea.setText(undoRef);
}
private void normalTextAreaInputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
undoRef = normalTextArea.getText();
}
private void copyMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
Clipboard clipboard = getToolkit().getSystemClipboard();
StringSelection data = new StringSelection(normalTextArea.getText());
clipboard.setContents(data, data);
}
private void pasteMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
Clipboard clipboard = getToolkit().getSystemClipboard();
Transferable clipData = clipboard.getContents(this);
String s;
try {
s = (String) (clipData.getTransferData(DataFlavor.stringFlavor));
}
catch (Exception ex) {
s = ex.toString();
}
normalTextArea.setText(s);
}
private void insertImageMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
String size = null;
Object[] possibilities = {"32x32", "64x64", "128x128", "256x256"};
String option = (String)JOptionPane.showInputDialog(
openImageFrame,
"Select image size:\n",
"Image Size",
JOptionPane.PLAIN_MESSAGE,
null,
possibilities,
"64x64"); //translate
if (option.equals("32x32"))
{
size = "width=32 height=32>";
}
else if (option.equals("64x64"))
{
size = "width=64 height=64>";
}
else if (option.equals("128x128"))
{
size = "width=128 height=128>";
}
else if (option.equals("256x256"))
{
size = "width=256 height=256>";
}
int returnVal = openImageChooser.showOpenDialog(openImageFrame);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = openImageChooser.getSelectedFile();
String path = file.getPath();
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<IMG src=" + path + " " + size;
normalTextArea.insert(fontStart, start);
}
}
private void insertFancyMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
String size = null;
int returnVal = openFancyChooser.showOpenDialog(openFancyFrame);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = openFancyChooser.getSelectedFile();
String path = file.getPath();
if (file.getName().equals("a_70x61.dds"))
{
size = "width=70 height=61";
}
else if (file.getName().equals("b_60x61.dds"))
{
size = "width=60 height=61";
}
else if (file.getName().equals("c_59x61.dds"))
{
size = "width=59 height=61";
}
else if (file.getName().equals("d_80x61.dds"))
{
size = "width=80 height=61";
}
else if (file.getName().equals("e_78x61.dds"))
{
size = "width=78 height=61";
}
else if (file.getName().equals("f_59x61.dds"))
{
size = "width=59 height=61";
}
else if (file.getName().equals("g_68x61.dds"))
{
size = "width=68 height=61";
}
else if (file.getName().equals("h_62x62.dds"))
{
size = "width=62 height=62";
}
else if (file.getName().equals("i_51x61.dds"))
{
size = "width=51 height=61";
}
else if (file.getName().equals("j_60x61.dds"))
{
size = "width=60 height=61";
}
else if (file.getName().equals("k_61x61.dds"))
{
size = "width=61 height=61";
}
else if (file.getName().equals("l_61x61.dds"))
{
size = "width=61 height=61";
}
else if (file.getName().equals("m_65x62.dds"))
{
size = "width=65 height=62";
}
else if (file.getName().equals("n_63x62.dds"))
{
size = "width=63 height=62";
}
else if (file.getName().equals("o_69x62.dds"))
{
size = "width=69 height=62";
}
else if (file.getName().equals("p_59x62.dds"))
{
size = "width=59 height=62";
}
else if (file.getName().equals("q_67x62.dds"))
{
size = "width=67 height=62";
}
else if (file.getName().equals("r_73x62.dds"))
{
size = "width=73 height=62";
}
else if (file.getName().equals("s_61x62.dds"))
{
size = "width=61 height=62";
}
else if (file.getName().equals("t_52x61.dds"))
{
size = "width=52 height=61";
}
else if (file.getName().equals("u_66x62.dds"))
{
size = "width=66 height=62";
}
else if (file.getName().equals("v_63x62.dds"))
{
size = "width=63 height=62";
}
else if (file.getName().equals("w_69x62.dds"))
{
size = "width=69 height=62";
}
else if (file.getName().equals("x_69x62.dds"))
{
size = "width=69 height=62";
}
else if (file.getName().equals("y_62x62.dds"))
{
size = "width=62 height=62";
}
else if (file.getName().equals("z_66x62.dds"))
{
size = "width=66 height=62";
}
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<IMG src=" + path + " " + size + ">";
normalTextArea.insert(fontStart, start);
}
}
private void saveMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
if (saved == 0)
{
count++;
try {
FileWriter out = new FileWriter("OblivionBook" + count + ".txt"); //translate
BufferedWriter writer = new BufferedWriter(out);
BufferedReader reader = new BufferedReader(new StringReader(normalTextArea.getText()));
try {
String line = null; //not declared within while loop
while (( line = reader.readLine()) != null){
writer.write(line + "\n");
}
}
finally {
writer.close();
}
}
catch (IOException ex){
ex.printStackTrace();
}
}
else
{
try {
FileWriter out = new FileWriter(savePath);
BufferedWriter writer = new BufferedWriter(out);
BufferedReader reader = new BufferedReader(new StringReader(normalTextArea.getText()));
try {
String line = null;
while (( line = reader.readLine()) != null){
writer.write(line + "\n");
}
}
finally {
writer.close();
saved = 1;
}
}
catch (IOException ex){
ex.printStackTrace();
}
}
}
private void saveAsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
int returnVal = saveFileChooser.showSaveDialog(saveFileFrame);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = saveFileChooser.getSelectedFile();
savePath = file.getPath();
}
try {
FileWriter out = new FileWriter(savePath);
BufferedWriter writer = new BufferedWriter(out);
BufferedReader reader = new BufferedReader(new StringReader(normalTextArea.getText()));
try {
String line = null;
while (( line = reader.readLine()) != null){
writer.write(line + "\n");
}
}
finally {
writer.close();
saved = 1;
}
}
catch (IOException ex){
ex.printStackTrace();
}
}
private void saveFileChooserInputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
//nothing, delete me
}
private void readmeMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
readmeFrame.show();
}
private void centerMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<DIV align=center>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</DIV>";
normalTextArea.insert(fontend, end);
}
private void leftMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<DIV align=left>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</DIV>";
normalTextArea.insert(fontend, end);
}
private void rightMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<DIV align=right>";
normalTextArea.insert(fontStart, start);
int end = normalTextArea.getSelectionEnd();
String fontend = "</DIV>";
normalTextArea.insert(fontend, end);
}
private void lineBreakMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<BR>";
normalTextArea.insert(fontStart, start);
}
private void pageBreakMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
undoRef = normalTextArea.getText();
int start = normalTextArea.getSelectionStart();
String fontStart = "<HR>";
normalTextArea.insert(fontStart, start);
}
private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void previewButtonActionPerformed(java.awt.event.ActionEvent evt) {
StringReader r = new StringReader(normalTextArea.getText());
HTMLEditorKit.Parser parse = new HTMLParse().getParser();
HTMLEditorKit.ParserCallback callback = new Parser();
try {
parse.parse(r, callback, true);
} catch (IOException ex) {
Logger.getLogger(OblivionBookCreator.class.getName()).log(Level.SEVERE, null, ex);
System.out.println("IOException!!!!");
}
previewFrame.setVisible(true);
previewPage01.setDocument(document);
}
public class HTMLParse extends HTMLEditorKit{
/**
* Call to obtain a HTMLEditorKit.Parser object.
*
* @return A new HTMLEditorKit.Parser object.
*/
@Override
public HTMLEditorKit.Parser getParser(){
return super.getParser();
}
}
public class Parser extends HTMLEditorKit.ParserCallback {
String face = "none";
String color = "none";
String align = "none";
@Override
public void handleEndTag(HTML.Tag tag,int pos){
if (tag == HTML.Tag.FONT){
System.out.println("FONT end tag found");
face = "none";
color = "none";
}
else if (tag == HTML.Tag.DIV){
System.out.println("DIV end tag found");
align = "none";
}
}
@Override
public void handleSimpleTag(HTML.Tag tag,MutableAttributeSet attrs,int pos){
String src = "none";
if (tag == HTML.Tag.BR){
try {
document.insertString(document.getLength(), "\n", attrs);
} catch (BadLocationException ex) {
Logger.getLogger(OblivionBookCreator.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println("BR tag found");
}
else if (tag == HTML.Tag.HR){
System.out.println("HR tag found");
}
else if (tag == HTML.Tag.IMG){
src = attrs.getAttribute(HTML.Attribute.SRC).toString();
System.out.println("IMG tag found. SRC = " + src);
}
}
@Override
public void handleStartTag(HTML.Tag tag, MutableAttributeSet attrs,int pos){
if (tag == HTML.Tag.FONT){
if (attrs.getAttribute(HTML.Attribute.FACE) != null){
face = attrs.getAttribute(HTML.Attribute.FACE).toString();
}
if (attrs.getAttribute(HTML.Attribute.COLOR) != null){
color = attrs.getAttribute(HTML.Attribute.COLOR).toString();
}
System.out.println("FONT start tag found. FACE = " + face + " COLOR = " + color);
}
else if (tag == HTML.Tag.DIV){
align = attrs.getAttribute(HTML.Attribute.ALIGN).toString();
System.out.println("DIV start tag found. ALIGN = " + align);
}
}
@Override
public void handleText(char[] data,int pos){
SimpleAttributeSet style = new SimpleAttributeSet();
if (!face.equals("none")){
style.addAttribute(StyleConstants.CharacterConstants.FontFamily, Font.MONOSPACED);
}
else if (!color.equals("none")){
color = "0x" + color;
Color colorVal = Color.decode(color);
style.addAttribute(StyleConstants.CharacterConstants.Foreground, colorVal);
}
else if (!align.equals("none")){
if (align.equals("center")){
style.addAttribute(StyleConstants.Alignment, StyleConstants.ALIGN_CENTER);
}
else if (align.equals("left")){
style.addAttribute(StyleConstants.Alignment, StyleConstants.ALIGN_LEFT);
}
else if (align.equals("right")){
style.addAttribute(StyleConstants.Alignment, StyleConstants.ALIGN_RIGHT);
}
}
String dataString = new String(data);
try {
int start = document.getLength();
document.insertString(start, dataString, style);
document.setParagraphAttributes(start, document.getLength(), style, false);
} catch (BadLocationException ex) {
Logger.getLogger(OblivionBookCreator.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new OblivionBookCreator().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JMenuItem centerMenuItem;
private javax.swing.JMenu changeColorMenuItem;
private javax.swing.JMenu changeFontSubMenu;
private javax.swing.JMenu changeSizeSubMenu;
private javax.swing.JButton closeButton;
private javax.swing.JMenuItem color01MenuItem;
private javax.swing.JMenuItem color02MenuItem;
private javax.swing.JMenuItem color03MenuItem;
private javax.swing.JMenuItem color04MenuItem;
private javax.swing.JMenuItem color05MenuItem;
private javax.swing.JMenuItem color06MenuItem;
private javax.swing.JMenuItem color07MenuItem;
private javax.swing.JMenuItem color08MenuItem;
private javax.swing.JButton convertButton;
private javax.swing.JMenuItem copyMenuItem;
private javax.swing.JMenu editMenu;
private javax.swing.JOptionPane errorBox;
private javax.swing.JFrame errorFrame;
private javax.swing.JMenu fileMenu;
private javax.swing.JMenuItem font01MenuItem;
private javax.swing.JMenuItem font02MenuItem;
private javax.swing.JMenuItem font03MenuItem;
private javax.swing.JMenuItem font04MenuItem;
private javax.swing.JMenuItem font05MenuItem;
private javax.swing.JMenu fontMenu;
private javax.swing.JMenu formatMenu;
private javax.swing.JMenu helpMenu;
private javax.swing.JMenu imageMenu;
private javax.swing.JMenuItem insertFancyMenuItem;
private javax.swing.JMenuItem insertImageMenuItem;
private javax.swing.JPopupMenu.Separator jSeparator1;
private javax.swing.JMenuItem leftMenuItem;
private javax.swing.JMenuItem lineBreakMenuItem;
private javax.swing.JMenuBar menuBar;
private javax.swing.JScrollPane normalScrollPane;
private javax.swing.JTextArea normalTextArea;
private javax.swing.JFileChooser openFancyChooser;
private javax.swing.JFrame openFancyFrame;
private javax.swing.JFileChooser openFileChooser;
private javax.swing.JFrame openFileFrame;
private javax.swing.JFileChooser openImageChooser;
private javax.swing.JFrame openImageFrame;
private javax.swing.JMenuItem openMenuItem;
private javax.swing.JPopupMenu.Separator openSaveSeparator;
private javax.swing.JMenuItem pageBreakMenuItem;
private javax.swing.JMenuItem pasteMenuItem;
private javax.swing.JButton previewButton;
private javax.swing.JFrame previewFrame;
private javax.swing.JTextPane previewPage01;
private javax.swing.JTextPane previewPage02;
private javax.swing.JScrollPane previewScrollPage01;
private javax.swing.JScrollPane previewScrollPage02;
private javax.swing.JFrame questionSizeFrame;
private javax.swing.JOptionPane questionSizeOptionPane;
private javax.swing.JFrame readmeFrame;
private javax.swing.JMenuItem readmeMenuItem;
private javax.swing.JScrollPane readmeScrollPane;
private javax.swing.JTextArea readmeTextArea;
private javax.swing.JMenuItem rightMenuItem;
private javax.swing.JMenuItem saveAsMenuItem;
private javax.swing.JFileChooser saveFileChooser;
private javax.swing.JFrame saveFileFrame;
private javax.swing.JMenuItem saveMenuItem;
private javax.swing.JMenuItem size01MenuItem;
private javax.swing.JMenuItem size02MenuItem;
private javax.swing.JMenuItem size03MenuItem;
private javax.swing.JMenuItem size04MenuItem;
private javax.swing.JMenuItem size05MenuItem;
private javax.swing.JPopupMenu.Separator undoCopySeparator;
private javax.swing.JMenuItem undoMenuItem;
// End of variables declaration
}