@ -23,10 +23,17 @@
* /
* /
package eu.smoser.dungeongenerator.main ;
package eu.smoser.dungeongenerator.main ;
import com.lowagie.text.BadElementException ;
import com.lowagie.text.Document ;
import com.lowagie.text.DocumentException ;
import com.lowagie.text.Element ;
import com.lowagie.text.Font ;
import com.lowagie.text.Image ;
import com.lowagie.text.PageSize ;
import com.lowagie.text.Paragraph ;
import com.lowagie.text.pdf.PdfWriter ;
import eu.smoser.dungeongenerator.dungeon.Dungeon ;
import eu.smoser.dungeongenerator.dungeon.Dungeon ;
import javax.swing.* ;
import javax.swing.* ;
import java.awt.* ;
import java.net.* ;
import java.net.* ;
import java.io.* ;
import java.io.* ;
import java.util.* ;
import java.util.* ;
@ -34,12 +41,20 @@ import java.util.logging.*;
import com.mxgraph.layout.* ;
import com.mxgraph.layout.* ;
import com.mxgraph.util.* ;
import com.mxgraph.util.* ;
import com.mxgraph.swing.mxGraphComponent ;
import com.mxgraph.swing.mxGraphComponent ;
import java.awt.BorderLayout ;
import java.awt.CardLayout ;
import java.awt.Color ;
import java.awt.Desktop ;
import java.awt.HeadlessException ;
import java.awt.Label ;
import java.nio.file.* ;
import java.nio.file.* ;
import javax.imageio.ImageIO ;
import javax.imageio.ImageIO ;
import javax.swing.filechooser.FileNameExtensionFilter ;
import javax.swing.filechooser.FileNameExtensionFilter ;
import org.jgrapht.UndirectedGraph ;
import org.jgrapht.UndirectedGraph ;
import org.jgrapht.ext.* ;
import org.jgrapht.ext.* ;
import java.awt.image.BufferedImage ;
import java.awt.image.BufferedImage ;
import org.apache.pdfbox.io.MemoryUsageSetting ;
import org.apache.pdfbox.multipdf.PDFMergerUtility ;
/ * *
/ * *
*
*
@ -95,10 +110,14 @@ public class DungeonGeneratorUI extends javax.swing.JFrame {
jMenuBar = new javax . swing . JMenuBar ( ) ;
jMenuBar = new javax . swing . JMenuBar ( ) ;
jMenu = new javax . swing . JMenu ( ) ;
jMenu = new javax . swing . JMenu ( ) ;
jMenuNew = new javax . swing . JMenuItem ( ) ;
jMenuNew = new javax . swing . JMenuItem ( ) ;
jMenuSave = new javax . swing . JMenuItem ( ) ;
jMenuDescription = new javax . swing . JMenu ( ) ;
jMenuDescTxt = new javax . swing . JMenuItem ( ) ;
jMenuDescPdf = new javax . swing . JMenuItem ( ) ;
jMenuGraph = new javax . swing . JMenu ( ) ;
jMenuGraph = new javax . swing . JMenu ( ) ;
jMenuExport = new javax . swing . JMenuItem ( ) ;
jMenuGraphGml = new javax . swing . JMenuItem ( ) ;
jMenuImage = new javax . swing . JMenuItem ( ) ;
jMenuGraphPng = new javax . swing . JMenuItem ( ) ;
jMenuGraphPdf = new javax . swing . JMenuItem ( ) ;
jMenuPdf = new javax . swing . JMenuItem ( ) ;
jMenuClose = new javax . swing . JMenuItem ( ) ;
jMenuClose = new javax . swing . JMenuItem ( ) ;
jMenuHelp = new javax . swing . JMenu ( ) ;
jMenuHelp = new javax . swing . JMenu ( ) ;
jMenuItemHelp = new javax . swing . JMenuItem ( ) ;
jMenuItemHelp = new javax . swing . JMenuItem ( ) ;
@ -137,11 +156,6 @@ public class DungeonGeneratorUI extends javax.swing.JFrame {
jPanelSettings . add ( filler1 ) ;
jPanelSettings . add ( filler1 ) ;
jCheckBoxExp . setText ( "<html>\n<b>Experimenteller Modus</b><br/>\nschränkt Raumzahl nicht direkt ein, sondern ändert die Zufallsfunktion so, dass ihr Erwartungswert der Raumanzahl entspricht" ) ;
jCheckBoxExp . setText ( "<html>\n<b>Experimenteller Modus</b><br/>\nschränkt Raumzahl nicht direkt ein, sondern ändert die Zufallsfunktion so, dass ihr Erwartungswert der Raumanzahl entspricht" ) ;
jCheckBoxExp . addActionListener ( new java . awt . event . ActionListener ( ) {
public void actionPerformed ( java . awt . event . ActionEvent evt ) {
jCheckBoxExpActionPerformed ( evt ) ;
}
} ) ;
jPanelSettings . add ( jCheckBoxExp ) ;
jPanelSettings . add ( jCheckBoxExp ) ;
jLabel1 . setHorizontalAlignment ( javax . swing . SwingConstants . CENTER ) ;
jLabel1 . setHorizontalAlignment ( javax . swing . SwingConstants . CENTER ) ;
@ -211,37 +225,64 @@ public class DungeonGeneratorUI extends javax.swing.JFrame {
} ) ;
} ) ;
jMenu . add ( jMenuNew ) ;
jMenu . add ( jMenuNew ) ;
jMenuSave . setAccelerator ( javax . swing . KeyStroke . getKeyStroke ( java . awt . event . KeyEvent . VK_S , java . awt . event . InputEvent . CTRL_MASK ) ) ;
jMenuDescription . setText ( "Beschreibung exportieren" ) ;
jMenuSave . setText ( "Beschreibung speichern" ) ;
jMenuDescription . addActionListener ( new java . awt . event . ActionListener ( ) {
jMenuSave . setEnabled ( false ) ;
jMenuSave . addActionListener ( new java . awt . event . ActionListener ( ) {
public void actionPerformed ( java . awt . event . ActionEvent evt ) {
public void actionPerformed ( java . awt . event . ActionEvent evt ) {
jMenu Save ActionPerformed( evt ) ;
jMenuDescriptionActionPerformed ( evt ) ;
}
}
} ) ;
} ) ;
jMenu . add ( jMenuSave ) ;
jMenuDescTxt . setText ( "Textdokument" ) ;
jMenuDescTxt . setEnabled ( false ) ;
jMenuDescTxt . addActionListener ( new java . awt . event . ActionListener ( ) {
public void actionPerformed ( java . awt . event . ActionEvent evt ) {
jMenuDescTxtActionPerformed ( evt ) ;
}
} ) ;
jMenuDescription . add ( jMenuDescTxt ) ;
jMenuDescPdf . setText ( "PDF-Dokument" ) ;
jMenuDescription . add ( jMenuDescPdf ) ;
jMenu . add ( jMenuDescription ) ;
jMenuGraph . setText ( "Graph exportieren" ) ;
jMenuGraph . setText ( "Graph exportieren" ) ;
jMenuGraph . setEnabled ( false ) ;
jMenuGraph . setEnabled ( false ) ;
jMenuExport . setText ( ".GML-Datei" ) ;
jMenuGraphGml . setText ( ".GML-Datei" ) ;
jMenuExport . addActionListener ( new java . awt . event . ActionListener ( ) {
jMenuGraphGml . addActionListener ( new java . awt . event . ActionListener ( ) {
public void actionPerformed ( java . awt . event . ActionEvent evt ) {
jMenuGraphGmlActionPerformed ( evt ) ;
}
} ) ;
jMenuGraph . add ( jMenuGraphGml ) ;
jMenuGraphPng . setText ( "Bilddatei" ) ;
jMenuGraphPng . addActionListener ( new java . awt . event . ActionListener ( ) {
public void actionPerformed ( java . awt . event . ActionEvent evt ) {
public void actionPerformed ( java . awt . event . ActionEvent evt ) {
jMenuExportActionPerformed ( evt ) ;
jMenu GraphPng ActionPerformed( evt ) ;
}
}
} ) ;
} ) ;
jMenuGraph . add ( jMenuExport ) ;
jMenuGraph . add ( jMenu GraphPng ) ;
jMenuImage . setText ( "Bilddatei" ) ;
jMenu GraphPdf. setText ( "PDF-Dokument ") ;
jMenuImage . addActionListener ( new java . awt . event . ActionListener ( ) {
jMenu GraphPdf . addActionListener ( new java . awt . event . ActionListener ( ) {
public void actionPerformed ( java . awt . event . ActionEvent evt ) {
public void actionPerformed ( java . awt . event . ActionEvent evt ) {
jMenu Image ActionPerformed( evt ) ;
jMenu GraphPdf ActionPerformed( evt ) ;
}
}
} ) ;
} ) ;
jMenuGraph . add ( jMenu Image ) ;
jMenuGraph . add ( jMenu GraphPdf ) ;
jMenu . add ( jMenuGraph ) ;
jMenu . add ( jMenuGraph ) ;
jMenuPdf . setText ( "PDF erstellen" ) ;
jMenuPdf . addActionListener ( new java . awt . event . ActionListener ( ) {
public void actionPerformed ( java . awt . event . ActionEvent evt ) {
jMenuPdfActionPerformed ( evt ) ;
}
} ) ;
jMenu . add ( jMenuPdf ) ;
jMenuClose . setAccelerator ( javax . swing . KeyStroke . getKeyStroke ( java . awt . event . KeyEvent . VK_X , java . awt . event . InputEvent . CTRL_MASK ) ) ;
jMenuClose . setAccelerator ( javax . swing . KeyStroke . getKeyStroke ( java . awt . event . KeyEvent . VK_X , java . awt . event . InputEvent . CTRL_MASK ) ) ;
jMenuClose . setText ( "Beenden" ) ;
jMenuClose . setText ( "Beenden" ) ;
jMenuClose . addActionListener ( new java . awt . event . ActionListener ( ) {
jMenuClose . addActionListener ( new java . awt . event . ActionListener ( ) {
@ -332,16 +373,16 @@ public class DungeonGeneratorUI extends javax.swing.JFrame {
jLabelStatus2 . setText ( "Type: " + type . toString ( ) ) ;
jLabelStatus2 . setText ( "Type: " + type . toString ( ) ) ;
jLabelStatus3 . setText ( "Mode: " + mode . toString ( ) ) ;
jLabelStatus3 . setText ( "Mode: " + mode . toString ( ) ) ;
jMenuSave . setEnabled ( true ) ;
jMenuNew . setEnabled ( true ) ;
jMenuNew . setEnabled ( true ) ;
jMenuDescription . setEnabled ( true ) ;
jMenuGraph . setEnabled ( true ) ;
jMenuGraph . setEnabled ( true ) ;
CardLayout cl = ( CardLayout ) jPanelCards . getLayout ( ) ;
CardLayout cl = ( CardLayout ) jPanelCards . getLayout ( ) ;
cl . show ( jPanelCards , "show" ) ;
cl . show ( jPanelCards , "show" ) ;
} //GEN-LAST:event_jButtonGenerateActionPerformed
} //GEN-LAST:event_jButtonGenerateActionPerformed
private void jMenuNewActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jMenuNewActionPerformed
private void jMenuNewActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jMenuNewActionPerformed
jMenuSave . setEnabled ( false ) ;
jMenuNew . setEnabled ( false ) ;
jMenuNew . setEnabled ( false ) ;
jMenuDescription . setEnabled ( false ) ;
jMenuGraph . setEnabled ( false ) ;
jMenuGraph . setEnabled ( false ) ;
CardLayout cl = ( CardLayout ) jPanelCards . getLayout ( ) ;
CardLayout cl = ( CardLayout ) jPanelCards . getLayout ( ) ;
cl . show ( jPanelCards , "new" ) ;
cl . show ( jPanelCards , "new" ) ;
@ -351,7 +392,7 @@ public class DungeonGeneratorUI extends javax.swing.JFrame {
jLabelStatus3 . setText ( "Mode: -" ) ;
jLabelStatus3 . setText ( "Mode: -" ) ;
} //GEN-LAST:event_jMenuNewActionPerformed
} //GEN-LAST:event_jMenuNewActionPerformed
private void jMenu Save ActionPerformed( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jMenu Save ActionPerformed
private void jMenu DescTxt ActionPerformed( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jMenu DescTxt ActionPerformed
JFileChooser fileChooser = new JFileChooser ( ) ;
JFileChooser fileChooser = new JFileChooser ( ) ;
FileNameExtensionFilter filter = new FileNameExtensionFilter ( "Textdateien" , "txt" ) ;
FileNameExtensionFilter filter = new FileNameExtensionFilter ( "Textdateien" , "txt" ) ;
fileChooser . setFileFilter ( filter ) ;
fileChooser . setFileFilter ( filter ) ;
@ -377,9 +418,9 @@ public class DungeonGeneratorUI extends javax.swing.JFrame {
Logger . getLogger ( DungeonGeneratorUI . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ;
Logger . getLogger ( DungeonGeneratorUI . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ;
}
}
}
}
} //GEN-LAST:event_jMenu Save ActionPerformed
} //GEN-LAST:event_jMenu DescTxt ActionPerformed
private void jMenu Export ActionPerformed( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jMenu Export ActionPerformed
private void jMenu GraphGml ActionPerformed( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jMenu GraphGml ActionPerformed
JFileChooser fileChooser = new JFileChooser ( ) ;
JFileChooser fileChooser = new JFileChooser ( ) ;
FileNameExtensionFilter filter = new FileNameExtensionFilter ( "Graph Modelling Files" , "gml" ) ;
FileNameExtensionFilter filter = new FileNameExtensionFilter ( "Graph Modelling Files" , "gml" ) ;
fileChooser . setFileFilter ( filter ) ;
fileChooser . setFileFilter ( filter ) ;
@ -409,9 +450,9 @@ public class DungeonGeneratorUI extends javax.swing.JFrame {
Logger . getLogger ( DungeonGeneratorUI . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ;
Logger . getLogger ( DungeonGeneratorUI . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ;
}
}
}
}
} //GEN-LAST:event_jMenu Export ActionPerformed
} //GEN-LAST:event_jMenu GraphGml ActionPerformed
private void jMenu Image ActionPerformed( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jMenu Image ActionPerformed
private void jMenu GraphPng ActionPerformed( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jMenu GraphPng ActionPerformed
JFileChooser fileChooser = new JFileChooser ( ) ;
JFileChooser fileChooser = new JFileChooser ( ) ;
FileNameExtensionFilter filter = new FileNameExtensionFilter ( "Bilddateien" , ".png" ) ;
FileNameExtensionFilter filter = new FileNameExtensionFilter ( "Bilddateien" , ".png" ) ;
fileChooser . setFileFilter ( filter ) ;
fileChooser . setFileFilter ( filter ) ;
@ -430,14 +471,14 @@ public class DungeonGeneratorUI extends javax.swing.JFrame {
}
}
file . delete ( ) ;
file . delete ( ) ;
}
}
BufferedImage image = mxCellRenderer . createBufferedImage ( mGraphComponent . getGraph ( ) , null , 1 , Color . WHITE , true , null ) ;
BufferedImage image = mxCellRenderer . createBufferedImage ( mGraphComponent . getGraph ( ) , null , 1 0 , Color . WHITE , true , null ) ;
ImageIO . write ( image , "PNG" , file ) ;
ImageIO . write ( image , "PNG" , file ) ;
JOptionPane . showMessageDialog ( this , "Gespeichert!" ) ;
JOptionPane . showMessageDialog ( this , "Gespeichert!" ) ;
} catch ( IOException ex ) {
} catch ( IOException ex ) {
Logger . getLogger ( DungeonGeneratorUI . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ;
Logger . getLogger ( DungeonGeneratorUI . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ;
}
}
}
}
} //GEN-LAST:event_jMenu Image ActionPerformed
} //GEN-LAST:event_jMenu GraphPng ActionPerformed
private void jMenuItemAboutActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jMenuItemAboutActionPerformed
private void jMenuItemAboutActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jMenuItemAboutActionPerformed
ResourceBundle vprops = ResourceBundle . getBundle ( "version" , Locale . getDefault ( ) ) ;
ResourceBundle vprops = ResourceBundle . getBundle ( "version" , Locale . getDefault ( ) ) ;
@ -475,13 +516,6 @@ public class DungeonGeneratorUI extends javax.swing.JFrame {
+ "<html>Icons made by <a href='http://www.flaticon.com/authors/revicon'>Revicon</a>" , "Über" , JOptionPane . QUESTION_MESSAGE ) ;
+ "<html>Icons made by <a href='http://www.flaticon.com/authors/revicon'>Revicon</a>" , "Über" , JOptionPane . QUESTION_MESSAGE ) ;
} //GEN-LAST:event_jMenuItemAboutActionPerformed
} //GEN-LAST:event_jMenuItemAboutActionPerformed
private void jCheckBoxExpActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jCheckBoxExpActionPerformed
int a = JOptionPane . showConfirmDialog ( this , "Diese Option kann zu einer Endlosschleife führen" , "Achtung" , JOptionPane . OK_CANCEL_OPTION , JOptionPane . WARNING_MESSAGE ) ;
if ( a = = JOptionPane . CANCEL_OPTION ) {
jCheckBoxExp . setSelected ( false ) ;
}
} //GEN-LAST:event_jCheckBoxExpActionPerformed
private void jMenuItemContactActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jMenuItemContactActionPerformed
private void jMenuItemContactActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jMenuItemContactActionPerformed
try {
try {
Desktop . getDesktop ( ) . mail ( new URI ( "mailto:info@smoser.eu?subject=DungeonGenerator" ) ) ;
Desktop . getDesktop ( ) . mail ( new URI ( "mailto:info@smoser.eu?subject=DungeonGenerator" ) ) ;
@ -506,6 +540,128 @@ public class DungeonGeneratorUI extends javax.swing.JFrame {
}
}
} //GEN-LAST:event_jMenuItemGithubActionPerformed
} //GEN-LAST:event_jMenuItemGithubActionPerformed
private void jMenuPdfActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jMenuPdfActionPerformed
JFileChooser fileChooser = new JFileChooser ( ) ;
FileNameExtensionFilter filter = new FileNameExtensionFilter ( "Portable Document Format" , ".pdf" ) ;
fileChooser . setFileFilter ( filter ) ;
fileChooser . setDialogTitle ( "Speicherort wählen" ) ;
int userSelection = fileChooser . showSaveDialog ( this ) ;
if ( userSelection = = JFileChooser . APPROVE_OPTION ) {
try {
File file = fileChooser . getSelectedFile ( ) ;
if ( ! file . getName ( ) . endsWith ( ".pdf" ) ) {
file = new File ( file . getCanonicalPath ( ) + ".pdf" ) ;
}
if ( file . exists ( ) ) {
int result = JOptionPane . showConfirmDialog ( this , "Existierende Datei überschreiben?" ) ;
if ( result ! = JOptionPane . YES_OPTION ) {
return ;
}
file . delete ( ) ;
}
File tmpDesc = File . createTempFile ( "desc" , ".pdf" ) ;
File tmpGraph = File . createTempFile ( "graph" , ".pdf" ) ;
CreateDescPDF ( tmpDesc ) ;
CreateGraphPDF ( tmpGraph ) ;
PDFMergerUtility merger = new PDFMergerUtility ( ) ;
merger . setDestinationFileName ( file . getCanonicalPath ( ) ) ;
merger . addSource ( tmpGraph ) ;
merger . addSource ( tmpDesc ) ;
merger . mergeDocuments ( MemoryUsageSetting . setupMainMemoryOnly ( ) ) ;
tmpDesc . delete ( ) ;
tmpGraph . delete ( ) ;
JOptionPane . showMessageDialog ( this , "Gespeichert!" ) ;
} catch ( IOException | HeadlessException | DocumentException ex ) {
Logger . getLogger ( DungeonGeneratorUI . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ;
}
}
} //GEN-LAST:event_jMenuPdfActionPerformed
private void jMenuGraphPdfActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jMenuGraphPdfActionPerformed
JFileChooser fileChooser = new JFileChooser ( ) ;
FileNameExtensionFilter filter = new FileNameExtensionFilter ( "Portable Document Format" , ".pdf" ) ;
fileChooser . setFileFilter ( filter ) ;
fileChooser . setDialogTitle ( "Speicherort wählen" ) ;
int userSelection = fileChooser . showSaveDialog ( this ) ;
if ( userSelection = = JFileChooser . APPROVE_OPTION ) {
try {
File file = fileChooser . getSelectedFile ( ) ;
if ( ! file . getName ( ) . endsWith ( ".pdf" ) ) {
file = new File ( file . getCanonicalPath ( ) + ".pdf" ) ;
}
if ( file . exists ( ) ) {
int result = JOptionPane . showConfirmDialog ( this , "Existierende Datei überschreiben?" ) ;
if ( result ! = JOptionPane . YES_OPTION ) {
return ;
}
file . delete ( ) ;
}
CreateGraphPDF ( file ) ;
JOptionPane . showMessageDialog ( this , "Gespeichert!" ) ;
} catch ( IOException | HeadlessException | DocumentException ex ) {
Logger . getLogger ( DungeonGeneratorUI . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ;
}
}
} //GEN-LAST:event_jMenuGraphPdfActionPerformed
private void jMenuDescriptionActionPerformed ( java . awt . event . ActionEvent evt ) { //GEN-FIRST:event_jMenuDescriptionActionPerformed
JFileChooser fileChooser = new JFileChooser ( ) ;
FileNameExtensionFilter filter = new FileNameExtensionFilter ( "Portable Document Format" , ".pdf" ) ;
fileChooser . setFileFilter ( filter ) ;
fileChooser . setDialogTitle ( "Speicherort wählen" ) ;
int userSelection = fileChooser . showSaveDialog ( this ) ;
if ( userSelection = = JFileChooser . APPROVE_OPTION ) {
try {
File file = fileChooser . getSelectedFile ( ) ;
if ( ! file . getName ( ) . endsWith ( ".pdf" ) ) {
file = new File ( file . getCanonicalPath ( ) + ".pdf" ) ;
}
if ( file . exists ( ) ) {
int result = JOptionPane . showConfirmDialog ( this , "Existierende Datei überschreiben?" ) ;
if ( result ! = JOptionPane . YES_OPTION ) {
return ;
}
file . delete ( ) ;
}
CreateDescPDF ( file ) ;
JOptionPane . showMessageDialog ( this , "Gespeichert!" ) ;
} catch ( IOException | HeadlessException | DocumentException ex ) {
Logger . getLogger ( DungeonGeneratorUI . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ;
}
}
} //GEN-LAST:event_jMenuDescriptionActionPerformed
private void CreateGraphPDF ( File file ) throws BadElementException , IOException , DocumentException {
Document document = new Document ( PageSize . A4 ) ;
Image image = Image . getInstance ( mxCellRenderer . createBufferedImage ( mGraphComponent . getGraph ( ) , null , 10 , Color . WHITE , true , null ) , Color . WHITE ) ;
image . scaleToFit ( document . getPageSize ( ) . getWidth ( ) - document . leftMargin ( ) - document . rightMargin ( ) , document . getPageSize ( ) . getHeight ( ) - document . topMargin ( ) - document . bottomMargin ( ) ) ;
PdfWriter . getInstance ( document , new FileOutputStream ( file ) ) ;
document . open ( ) ;
document . add ( image ) ;
document . close ( ) ;
}
private void CreateDescPDF ( File file ) throws BadElementException , IOException , DocumentException {
Document document = new Document ( PageSize . A4 ) ;
Image image = Image . getInstance ( mxCellRenderer . createBufferedImage ( mGraphComponent . getGraph ( ) , null , 10 , Color . WHITE , true , null ) , Color . WHITE ) ;
image . scaleToFit ( document . getPageSize ( ) . getWidth ( ) - document . leftMargin ( ) - document . rightMargin ( ) , document . getPageSize ( ) . getHeight ( ) - document . topMargin ( ) - document . bottomMargin ( ) ) ;
PdfWriter . getInstance ( document , new FileOutputStream ( file ) ) ;
document . open ( ) ;
Font myfont = new Font ( ) ;
myfont . setStyle ( Font . NORMAL ) ;
myfont . setSize ( 11 ) ;
document . add ( new Paragraph ( "\n" ) ) ;
String [ ] outputString = mDungeon . toString ( ) . split ( "\n" ) ;
for ( String s : outputString ) {
Paragraph para = new Paragraph ( s + "\n" , myfont ) ;
para . setAlignment ( Element . ALIGN_JUSTIFIED ) ;
document . add ( para ) ;
}
document . close ( ) ;
}
/ * *
/ * *
* @param args the command line arguments
* @param args the command line arguments
* /
* /
@ -580,16 +736,20 @@ public class DungeonGeneratorUI extends javax.swing.JFrame {
private javax . swing . JMenu jMenu ;
private javax . swing . JMenu jMenu ;
private javax . swing . JMenuBar jMenuBar ;
private javax . swing . JMenuBar jMenuBar ;
private javax . swing . JMenuItem jMenuClose ;
private javax . swing . JMenuItem jMenuClose ;
private javax . swing . JMenuItem jMenuExport ;
private javax . swing . JMenuItem jMenuDescPdf ;
private javax . swing . JMenuItem jMenuDescTxt ;
private javax . swing . JMenu jMenuDescription ;
private javax . swing . JMenu jMenuGraph ;
private javax . swing . JMenu jMenuGraph ;
private javax . swing . JMenuItem jMenuGraphGml ;
private javax . swing . JMenuItem jMenuGraphPdf ;
private javax . swing . JMenuItem jMenuGraphPng ;
private javax . swing . JMenu jMenuHelp ;
private javax . swing . JMenu jMenuHelp ;
private javax . swing . JMenuItem jMenuImage ;
private javax . swing . JMenuItem jMenuItemAbout ;
private javax . swing . JMenuItem jMenuItemAbout ;
private javax . swing . JMenuItem jMenuItemContact ;
private javax . swing . JMenuItem jMenuItemContact ;
private javax . swing . JMenuItem jMenuItemGithub ;
private javax . swing . JMenuItem jMenuItemGithub ;
private javax . swing . JMenuItem jMenuItemHelp ;
private javax . swing . JMenuItem jMenuItemHelp ;
private javax . swing . JMenuItem jMenuNew ;
private javax . swing . JMenuItem jMenuNew ;
private javax . swing . JMenuItem jMenu Save ;
private javax . swing . JMenuItem jMenu Pdf ;
private javax . swing . JPanel jPanelCardDraw ;
private javax . swing . JPanel jPanelCardDraw ;
private javax . swing . JPanel jPanelCardNew ;
private javax . swing . JPanel jPanelCardNew ;
private javax . swing . JPanel jPanelCardShow ;
private javax . swing . JPanel jPanelCardShow ;