Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package edu.ksu.cs.a4vm.bse.reporter; import java.awt.geom.Rectangle2D; import com.itextpdf.awt.DefaultFontMapper; import com.itextpdf.awt.PdfGraphics2D; //import com.itextpdf.awt.geom.Rectangle2D; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.general.DefaultPieDataset; import com.itextpdf.text.BaseColor; import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.itextpdf.text.Element; import com.itextpdf.text.Font; import com.itextpdf.text.FontFactory; import com.itextpdf.text.Image; import com.itextpdf.text.PageSize; import com.itextpdf.text.Paragraph; import com.itextpdf.text.Phrase; import com.itextpdf.text.pdf.PdfContentByte; import com.itextpdf.text.pdf.PdfPCell; import com.itextpdf.text.pdf.PdfPTable; import com.itextpdf.text.pdf.PdfTemplate; import com.itextpdf.text.pdf.PdfWriter; import java.awt.Graphics2D; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.text.DecimalFormat; import java.util.Arrays; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.swing.DefaultListModel; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.filechooser.FileSystemView; import org.icepdf.ri.common.ComponentKeyBinding; import org.icepdf.ri.common.SwingController; import org.icepdf.ri.common.SwingViewBuilder; /** * * @author Shubh Chopra */ public class Reporter extends javax.swing.JFrame { String header[]; String Bulls[]; File f; String bull1[][]; BufferedReader br1; String File3; int number_of_rows = 0; String newhead[] = { "age", "ageType", "brand", "breed", "DOB", "Lot_num", "RFID", "Tag", "Tattoo", "other", "Eyes", "Eyes_Nor", "Scrotum", "Scrotum_Nor", "feet", "Feet_Nor", "Legs", "Legs_Nor", "Testicles", "Testicals_Nor", "SexGlands", "SexGlands_Nor", "Inguinal", "Inguinal_Nor", "Scrotal", "Scrotal_Nor", "epidydimides", "epidydimides_Nor", "Penis", "Penis_Nor", "Prepuce", "Prepuce_Nor", "collectionNum", "completed", "datePerformed", "classification", "Info_comments", "Mating_comments", "performence", "Performence_dis", "seasons_used", "sirePastureType", "Morfology_comments", "Motality_comments", "grossMotilityCategory", "individualMotility", "motilityPercent", "bodyCondition", "Physical_comments", "frameScore", "hipHeight", "hipHeightUnit", "pelvicX", "pelvicY", "scrotalCircumference", "ranch_add1", "ranch_add2", "ranch_city", "ranch_email", "ranch_phone", "ranch_state", "ranch_zip", "rancher_Name", "ranch_surname", "ranch_name", "uuid", "vet_add1", "vet_add2", "vet_city", "vet_email", "vet_phone", "vet_state", "vet_zip", "Clinic_name", "vet_Name", "vet_surname", "threshold" }; /** * Creates new form DynamicReporter */ public Reporter() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jPanel1 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jTextField1 = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jList1 = new javax.swing.JList(); jButton2 = new javax.swing.JButton(); jScrollPane2 = new javax.swing.JScrollPane(); jList2 = new javax.swing.JList(); jButton4 = new javax.swing.JButton(); jButton6 = new javax.swing.JButton(); jButton11 = new javax.swing.JButton(); jLabel4 = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); jLabel3 = new javax.swing.JLabel(); jScrollPane3 = new javax.swing.JScrollPane(); jList3 = new javax.swing.JList(); jButton3 = new javax.swing.JButton(); jScrollPane4 = new javax.swing.JScrollPane(); jList4 = new javax.swing.JList(); jButton5 = new javax.swing.JButton(); jButton7 = new javax.swing.JButton(); jCheckBox1 = new javax.swing.JCheckBox(); jCheckBox2 = new javax.swing.JCheckBox(); jButton8 = new javax.swing.JButton(); jButton9 = new javax.swing.JButton(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jButton1.setText("Select CSV File"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jTextField1.setText("File path"); jTextField1.setToolTipText(""); jLabel1.setText("Step 1 Please Select a CSV File"); jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel5.setText("Reporter"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(23, 23, 23) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel1) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(22, Short.MAX_VALUE)) .addGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup().addContainerGap(70, Short.MAX_VALUE) .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(51, 51, 51)))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap(167, Short.MAX_VALUE) .addComponent(jLabel1).addGap(86, 86, 86) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(53, 53, 53).addComponent(jButton1).addGap(67, 67, 67)) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(10, 10, 10).addComponent(jLabel5) .addContainerGap(403, Short.MAX_VALUE)))); jLabel2.setText("Step 2 Please select Columns"); jScrollPane1.setViewportView(jList1); jButton2.setText("Add ->"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jScrollPane2.setViewportView(jList2); jButton4.setText("Next"); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } }); jButton6.setText("Remove ->"); jButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton6ActionPerformed(evt); } }); jButton11.setText("Preview"); jButton11.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton11ActionPerformed(evt); } }); jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel4.setText("Reporter"); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout .createSequentialGroup().addGroup(jPanel2Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING).addGroup( jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addGap(81, 81, 81).addComponent(jButton2)) .addGroup( jPanel2Layout.createSequentialGroup().addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout .createSequentialGroup() .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 214, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE) .addComponent(jButton11)) .addGroup(jPanel2Layout .createSequentialGroup().addComponent(jButton6) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton4)) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) .addContainerGap()) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(126, 126, 126))); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap(32, Short.MAX_VALUE) .addComponent(jLabel4).addGap(18, 18, 18).addComponent(jLabel2).addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jButton2) .addGap(18, 18, 18) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton11, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton6).addComponent(jButton4)) .addGap(22, 22, 22))); jLabel3.setText("Step 3 Please select bulls"); jScrollPane3.setViewportView(jList3); jButton3.setText("Add ->"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jScrollPane4.setViewportView(jList4); jButton5.setText("Save"); jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton5ActionPerformed(evt); } }); jButton7.setText("Remove ->"); jButton7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton7ActionPerformed(evt); } }); jCheckBox1.setText("Single bull Graph"); jCheckBox2.setText("Multi-Bull Graph"); jCheckBox2.setToolTipText(""); jButton8.setText("Preview"); jButton8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton8ActionPerformed(evt); } }); jButton9.setText("Back"); jButton9.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton9ActionPerformed(evt); } }); jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel6.setText("Reporter"); jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel7.setText("Reporter"); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addGap(11, 11, 11).addComponent(jButton7) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup().addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(1, 1, 1).addComponent(jButton9)) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 66, Short.MAX_VALUE) .addComponent(jButton8)) .addGroup(jPanel3Layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE).addComponent(jCheckBox1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jCheckBox2) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton5))) .addGap(81, 81, 81)))) .addGroup(jPanel3Layout.createSequentialGroup().addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(jButton3) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addGap(174, 174, 174) .addComponent(jLabel7)) .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addComponent( jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addGap(192, 192, 192) .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(193, Short.MAX_VALUE)))); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addGap(32, 32, 32).addComponent(jLabel7) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3).addComponent(jButton9)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(6, 6, 6).addComponent(jButton3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton8)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton7).addComponent(jButton5).addComponent(jCheckBox2) .addComponent(jCheckBox1)) .addContainerGap()) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addGap(214, 214, 214).addComponent(jLabel6) .addContainerGap(215, Short.MAX_VALUE)))); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))); pack(); }// </editor-fold> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: jTextField1.setText(""); JFileChooser choose = new JFileChooser(); choose.showOpenDialog(null); f = choose.getSelectedFile(); String path = f.getAbsolutePath(); jTextField1.setText(path); jPanel2.setVisible(true); header = new String[120]; for (int x = 0; x < 120; x++) { header[x] = ""; } String line = ""; BufferedReader br2 = null; try { br2 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { Logger.getLogger(Reporter.class.getName()).log(Level.SEVERE, null, ex); } try { while ((line = br2.readLine()) != null) { // use comma as separator String Bull[] = line.split(","); // System.out.println(Bull.length); if (number_of_rows == 0) { for (int i = 0; i < Bull.length; i++) { header[i] = Bull[i]; } } number_of_rows++; } } catch (IOException ex) { Logger.getLogger(Reporter.class.getName()).log(Level.SEVERE, null, ex); } Bulls = new String[number_of_rows - 1]; for (int x = 0; x < Bulls.length; x++) { Bulls[x] = ""; } BufferedReader br3 = null; try { br3 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { Logger.getLogger(Reporter.class.getName()).log(Level.SEVERE, null, ex); } try { int k = 0; while ((line = br3.readLine()) != null) { // use comma as separator String Bull[] = line.split(","); // System.out.println(Bull.length); if (k != 0) { if (!Bull[2].equals("")) { Bulls[k - 1] += Bull[2] + ("(Brand) "); } if (!Bull[6].equals("")) { Bulls[k - 1] += Bull[6] + ("(RFID) "); } if (!Bull[7].equals("")) { Bulls[k - 1] += Bull[7] + ("(Tag) "); } if (!Bull[8].equals("")) { Bulls[k - 1] += Bull[8] + ("(Tattoo) "); } if (!Bull[9].equals("")) { Bulls[k - 1] += Bull[9] + ("(Other) "); } Bulls[k - 1] += ":" + k; } k++; } } catch (IOException ex) { Logger.getLogger(Reporter.class.getName()).log(Level.SEVERE, null, ex); } for (int y = 0; y < Bulls.length; y++) { System.out.print(Bulls[y]); } DefaultListModel dlm = new DefaultListModel(); for (int y = 0; y < header.length; y++) { if (header[y].equals("")) break; if (y != 2 && y != 7 && y != 8 && y != 6 && y != 9 && y != 34) { if (y < 55 || y > 75) { dlm.addElement(header[y] + ": " + y); } } } jList1.setModel(dlm); jPanel1.setVisible(false); pack(); } DefaultListModel dlm2 = new DefaultListModel(); DefaultListModel dlm3 = new DefaultListModel(); private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { Object obj[] = jList1.getSelectedValues(); int temp[] = new int[obj.length]; for (int j = 0; j < obj.length; j++) { for (int i = 0; i < dlm2.getSize(); i++) { if (obj[j].equals(dlm2.getElementAt(i))) { temp[j] = 1; } } } for (int j = 0; j < obj.length; j++) { if (temp[j] == 0) { dlm2.addElement(obj[j]); jList2.setModel(dlm2); } } } private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) { int selectedIndex = jList2.getSelectedIndex(); if (selectedIndex != -1) { dlm2.remove(selectedIndex); } jList2.setModel(dlm2); } private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) { int selectedIndex = jList4.getSelectedIndex(); if (selectedIndex != -1) { dlm3.remove(selectedIndex); } jList4.setModel(dlm3); } private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) { jPanel3.setVisible(true); DefaultListModel dlm = new DefaultListModel(); for (int y = 0; y < Bulls.length; y++) { dlm.addElement(Bulls[y]); } jList3.setModel(dlm); jPanel2.setVisible(false); pack(); } private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { Object obj[] = jList3.getSelectedValues(); int temp[] = new int[obj.length]; for (int j = 0; j < obj.length; j++) { for (int i = 0; i < dlm3.getSize(); i++) { if (obj[j].equals(dlm3.getElementAt(i))) { temp[j] = 1; } } } for (int j = 0; j < obj.length; j++) { if (temp[j] == 0) { dlm3.addElement(obj[j]); jList4.setModel(dlm3); } } } private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = new JFileChooser(); int option = chooser.showSaveDialog(null); if (option == JFileChooser.APPROVE_OPTION) { if (chooser.getSelectedFile() != null) { File3 = chooser.getSelectedFile().getAbsolutePath(); } try { br1 = new BufferedReader(new FileReader(f)); BufferedReader b1 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { } String line = ""; bull1 = new String[number_of_rows - 1][]; int k = 0; BufferedReader br3 = null; try { br3 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { } try { while ((line = br3.readLine()) != null) { // use comma as separator String Bull[] = line.split(","); if (k != 0) { System.out.println(Bull.length); bull1[k - 1] = new String[Bull.length]; for (int j = 0; j < Bull.length; j++) { bull1[k - 1][j] = Bull[j]; } } k++; } } catch (IOException ex) { } Document doc = new Document(); PdfWriter docWriter = null; DecimalFormat df = new DecimalFormat("0.00"); try { //special font sizes Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.BOLD, new BaseColor(0, 0, 0)); Font bf12 = new Font(Font.FontFamily.TIMES_ROMAN, 6); Font bfBold20 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); Font bfBold25 = new Font(Font.FontFamily.TIMES_ROMAN, 15, Font.BOLD); //file path docWriter = PdfWriter.getInstance(doc, new FileOutputStream(File3)); //document header attributes doc.addAuthor("Shubh Chopra"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("Shubh Chopra"); doc.addTitle("BES"); doc.setPageSize(PageSize.LETTER.rotate()); //open document doc.open(); //create a paragraph Paragraph paragraph = new Paragraph("BULL EVALUATION\n\n"); paragraph.setFont(bfBold25); paragraph.setAlignment(Element.ALIGN_CENTER); Image img = Image.getInstance("VETMED.png"); img.scaleToFit(300f, 150f); doc.add(paragraph); PdfPTable table1 = new PdfPTable(2); table1.setWidthPercentage(100); PdfPCell cell = new PdfPCell(img); cell.setBorder(PdfPCell.NO_BORDER); table1.addCell(cell); String temp1 = "\tOwner: " + bull1[1][62] + " " + bull1[1][63] + "\n\n\tRanch: " + bull1[1][64] + "\n\n\tAddress: " + bull1[1][55] + "\n\n\tCity: " + bull1[1][57] + "\n\n\tState: " + bull1[1][60] + "\tZip: " + bull1[1][61] + "\n\n\tPhone: " + bull1[1][59] + "\n\n"; table1.addCell(getCell(temp1, PdfPCell.ALIGN_LEFT)); doc.add(table1); if (dlm3.size() == 1) { String str; str = dlm3.get(0).toString(); String[] parts = str.split(":"); String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; String[][] temp = new String[25][6]; temp[0][0] = "Tag"; temp[0][1] = bull1[row][7]; temp[0][2] = "Comments"; temp[0][3] = ""; temp[0][4] = "Total Count"; temp[0][5] = ""; temp[1][0] = "Tatoo"; temp[1][1] = bull1[row][8]; temp[1][2] = "All Normal"; temp[1][3] = "Yes"; temp[2][0] = "RFID"; temp[2][1] = bull1[row][6]; temp[2][2] = "Eyes"; temp[2][3] = bull1[row][10]; temp[3][0] = "Lot#"; temp[3][1] = bull1[row][5]; temp[3][2] = "Feet"; temp[3][3] = bull1[row][12]; temp[4][0] = "Brand"; temp[4][1] = bull1[row][2]; temp[4][2] = "Legs"; temp[4][3] = bull1[row][14]; temp[5][0] = "Date of Birth"; temp[5][1] = bull1[row][4]; temp[5][2] = "Testicals"; temp[5][3] = bull1[row][16]; temp[6][0] = "Age"; temp[6][1] = bull1[row][0]; temp[6][2] = "Accessory Sex Glands"; temp[6][3] = bull1[row][18]; temp[7][0] = "Breed"; temp[7][1] = bull1[row][3]; temp[7][2] = "Inguinal"; temp[7][3] = bull1[row][20]; temp[8][0] = "Other"; temp[8][1] = bull1[row][9]; temp[8][2] = "Scrotal"; temp[8][3] = bull1[row][22]; temp[9][0] = "Clinic Info"; temp[9][1] = "xx"; temp[9][2] = "Epidydimides"; temp[9][3] = bull1[row][24]; temp[10][4] = "Measurements"; temp[10][5] = "xx"; temp[10][0] = "Clinic Name"; temp[10][1] = bull1[row][73]; temp[10][2] = "Penis"; temp[10][3] = bull1[row][26]; temp[11][4] = "Scrotal Cirumference"; temp[11][5] = bull1[row][54]; temp[11][0] = "Veterinarian Name"; temp[11][1] = bull1[row][74] + " " + bull1[row][74]; temp[11][2] = "Prepuce"; temp[11][3] = bull1[row][28]; temp[12][4] = "Body Condition"; temp[12][5] = bull1[row][47]; temp[12][0] = "Address"; temp[12][1] = bull1[row][66] + " " + bull1[row][67]; temp[12][2] = "Scrotum"; temp[12][3] = bull1[row][30]; temp[13][4] = "Pelvic X Measure"; temp[13][5] = bull1[row][52]; temp[13][0] = "City"; temp[13][1] = bull1[row][68]; temp[13][2] = "Sex Drive"; temp[13][3] = "xx"; temp[14][4] = "Pelvic Y Measure"; temp[14][5] = bull1[row][53]; temp[14][0] = "State"; temp[14][1] = bull1[row][71]; temp[14][2] = "Breeding seasons used"; temp[14][3] = bull1[row][40]; temp[15][4] = "Hip Hight"; temp[15][5] = bull1[row][50]; temp[15][0] = "Zip Code"; temp[15][1] = bull1[row][72]; temp[15][2] = "Performance last season"; temp[15][3] = bull1[row][38]; temp[16][4] = "Frame Score"; temp[16][5] = bull1[row][49]; temp[16][0] = "Email"; temp[16][1] = bull1[row][69]; temp[16][2] = "Single or Multi sire"; temp[16][3] = bull1[row][41]; temp[17][4] = "Other"; temp[17][5] = bull1[row][48]; temp[17][0] = "Phone"; temp[17][1] = bull1[row][70]; temp[17][2] = "Other"; temp[17][3] = bull1[row][39]; temp[18][4] = "Motility"; temp[18][5] = "xx"; temp[18][0] = "Classification"; temp[18][1] = bull1[row][35]; temp[18][2] = "Comments"; temp[18][3] = bull1[row][37]; temp[19][4] = "Individual Motility"; temp[19][5] = bull1[row][45]; temp[19][0] = "Comments"; temp[19][1] = bull1[row][36]; temp[19][2] = ""; temp[19][3] = ""; temp[20][4] = "Motility %"; temp[20][5] = bull1[row][46]; temp[20][0] = ""; temp[20][1] = ""; temp[20][2] = ""; temp[20][3] = ""; temp[21][4] = "Gross Motility"; temp[21][5] = bull1[row][44]; temp[21][0] = ""; temp[21][1] = ""; temp[21][2] = ""; temp[21][3] = ""; for (int i = 9; i <= 29; i += 2) { if (bull1[row][i].equals("FALSE")) { temp[1][4] = "No"; break; } } int i; int total = 0; for (i = 77; i < header.length && i < bull1[row].length; i++) { temp[i - 76][4] = header[i].split("_")[1]; temp[i - 76][5] = bull1[row][i]; total += Integer.parseInt(bull1[row][i]); } temp[0][5] = Integer.toString(total); for (int j = i; j <= 85; j++) { temp[j - 76][4] = ""; temp[j - 76][5] = ""; } PdfPTable table = new PdfPTable(6); PdfPCell cell11, cell12, cell13; cell11 = new PdfPCell( new Phrase("Bull Info", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell11.setColspan(2); cell11.setHorizontalAlignment(Element.ALIGN_CENTER); cell11.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell11); cell12 = new PdfPCell( new Phrase("Physical Exam", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell12.setColspan(2); cell12.setHorizontalAlignment(Element.ALIGN_CENTER); cell12.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell12); cell13 = new PdfPCell( new Phrase("Morphology", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell13.setColspan(2); cell13.setHorizontalAlignment(Element.ALIGN_CENTER); cell13.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell13); for (int l = 0; l <= 21; l++) { for (int j = 0; j < 6; j++) { // System.out.println(l+" "+j); if (!temp[l][j].equals("xx") && temp[l][j] != null) { cell = new PdfPCell( new Phrase(temp[l][j], FontFactory.getFont(FontFactory.TIMES_ROMAN, 10))); cell.setBorder(PdfPCell.NO_BORDER); if ((l == 9 && j == 0) || (l == 13 && j == 2) || (l == 10 && j == 4) || (l == 18 && j == 4)) { cell = new PdfPCell(new Phrase(temp[l][j], FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); } table.addCell(cell); } } } table.setWidthPercentage(90f); Reporter re; re = new Reporter(); doc.add(table); if (jCheckBox2.isSelected() || jCheckBox1.isSelected()) doc.newPage(); } else { //specify column widths int temp = dlm2.size(); float[] columnWidths = new float[temp]; for (int x = 0; x < columnWidths.length; x++) { columnWidths[x] = 2f; } //create PDF table with the given widths PdfPTable table = new PdfPTable(columnWidths); // set table width a percentage of the page width table.setWidthPercentage(90f); Reporter re; re = new Reporter(); re.insertCell(table, "Bull Info", Element.ALIGN_CENTER, 1, bfBold12); for (int i = 0; i < dlm2.size(); i++) { String[] parts = dlm2.get(i).toString().split(": "); String part2 = parts[1]; re.insertCell(table, newhead[Integer.parseInt(part2)], Element.ALIGN_CENTER, 1, bfBold12); } table.setHeaderRows(1); //insert an empty row //create section heading by cell merging //just some random data to fill for (int x = 0; x < dlm3.size(); x++) { String str = dlm3.get(x).toString(); //System.out.println(str); String[] parts = str.split(":"); String part2 = parts[1]; // System.out.println(part2); int row = Integer.parseInt(part2) - 1; re.insertCell(table, Bulls[row], Element.ALIGN_CENTER, 1, bf12); for (int i = 0; i < dlm2.getSize(); i++) { for (int j = 0; j < header.length && j < bull1[row].length; j++) { String str1 = dlm2.get(i).toString(); String[] p1 = str1.split(": "); String p2 = p1[0]; if (p2.equals(header[j])) { re.insertCell(table, bull1[row][j], Element.ALIGN_CENTER, 1, bf12); } } } // re.insertCell(table, bull1[x][7] , Element.ALIGN_CENTER, 1, bf12); } doc.add(table); } if (jCheckBox2.isSelected()) { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); for (int i = 0; i < dlm3.size(); i++) { String str = dlm3.get(i).toString(); System.out.println(str); String[] parts = str.split(":"); String part1 = parts[0]; String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; float total = (float) 0.0; for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (bull1[row][j].equals("")) { continue; } else { total += Integer.parseInt(bull1[row][j]); } } System.out.println(total); for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (!bull1[row][j].equals("")) { String[] Parts = header[j].split("_"); String Part2 = Parts[1]; dataSet.setValue((Integer.parseInt(bull1[row][j]) * 100) / total, Part2, part1); } else { dataSet.setValue(0, "Percent", header[j]); } } } JFreeChart chart = ChartFactory.createBarChart("Multi Bull Morphology Chart ", "Morphology", "Percent", dataSet, PlotOrientation.VERTICAL, true, true, false); if (dlm3.size() > 12) { doc.newPage(); } PdfContentByte contentByte = docWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(325, 250); PdfGraphics2D graphics2d = new PdfGraphics2D(template, 325, 250); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 325, 250); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 0, 0); } if (jCheckBox1.isSelected()) { for (int i = 0; i < dlm3.size(); i++) { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); String str = dlm3.get(i).toString(); System.out.println(str); String[] parts = str.split(":"); String part1 = parts[0]; String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; float total = (float) 0.0; for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (bull1[row][j].equals("")) { continue; } else { total += Integer.parseInt(bull1[row][j]); } } System.out.println(total); for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (!bull1[row][j].equals("")) { String[] Parts = header[j].split("_"); String Part2 = Parts[1]; dataSet.setValue((Integer.parseInt(bull1[row][j]) * 100) / total, "Percent", Part2); } else { dataSet.setValue(0, "Percent", header[j]); } } JFreeChart chart = ChartFactory.createBarChart("Single Bull Morphology Chart " + part1, "Morphology", "Percent", dataSet, PlotOrientation.VERTICAL, false, true, false); if ((dlm3.size() > 12 && i == 0) || jCheckBox2.isSelected()) { doc.newPage(); } PdfContentByte contentByte = docWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(325, 250); PdfGraphics2D graphics2d = new PdfGraphics2D(template, 325, 250); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 325, 250); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 0, 0); doc.newPage(); } } } catch (DocumentException dex) { dex.printStackTrace(); } catch (FileNotFoundException ex) { Logger.getLogger(ReporterArchive.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ReporterArchive.class.getName()).log(Level.SEVERE, null, ex); } finally { if (doc != null) { //close the document doc.close(); } if (docWriter != null) { //close the writer docWriter.close(); } } } // TODO add your handling code here: } private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: // build a controller SwingController controller = new SwingController(); // Build a SwingViewFactory configured with the controller SwingViewBuilder factory = new SwingViewBuilder(controller); // Use the factory to build a JPanel that is pre-configured //with a complete, active Viewer UI. JPanel viewerComponentPanel = factory.buildViewerPanel(); // add copy keyboard command ComponentKeyBinding.install(controller, viewerComponentPanel); // add interactive mouse link annotation support via callback controller.getDocumentViewController().setAnnotationCallback( new org.icepdf.ri.common.MyAnnotationCallback(controller.getDocumentViewController())); // Create a JFrame to display the panel in JFrame window = new JFrame("Using the Viewer Component"); window.getContentPane().add(viewerComponentPanel); window.pack(); window.setVisible(true); String Path; JFileChooser chooser = new JFileChooser(); FileSystemView view = chooser.getFileSystemView(); Path = view.getDefaultDirectory() + "/reporter.pdf"; try { br1 = new BufferedReader(new FileReader(f)); BufferedReader b1 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { } String line = ""; bull1 = new String[number_of_rows - 1][]; int k = 0; BufferedReader br3 = null; try { br3 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { } try { while ((line = br3.readLine()) != null) { // use comma as separator String Bull[] = line.split(","); if (k != 0) { System.out.println(Bull.length); bull1[k - 1] = new String[Bull.length]; for (int j = 0; j < Bull.length; j++) { bull1[k - 1][j] = Bull[j]; } } k++; } } catch (IOException ex) { } Document doc = new Document(); PdfWriter docWriter = null; DecimalFormat df = new DecimalFormat("0.00"); try { //special font sizes Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.BOLD, new BaseColor(0, 0, 0)); Font bf12 = new Font(Font.FontFamily.TIMES_ROMAN, 6); Font bfBold20 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); //file path docWriter = PdfWriter.getInstance(doc, new FileOutputStream(Path)); //document header attributes doc.addAuthor("Shubh Chopra"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("Shubh Chopra"); doc.addTitle("BES"); doc.setPageSize(PageSize.LETTER.rotate()); //open document doc.open(); //create a paragraph Paragraph paragraph = new Paragraph("BULL EVALUATION\n\n"); paragraph.setFont(bfBold20); paragraph.setAlignment(Element.ALIGN_CENTER); Image img = Image.getInstance("VETMED.png"); img.scaleToFit(300f, 150f); doc.add(paragraph); PdfPTable table1 = new PdfPTable(2); table1.setWidthPercentage(100); PdfPCell cell = new PdfPCell(img); cell.setBorder(PdfPCell.NO_BORDER); table1.addCell(cell); String temp1 = "\tOwner: " + bull1[1][62] + " " + bull1[1][63] + "\n\n\tRanch: " + bull1[1][64] + "\n\n\tAddress: " + bull1[1][55] + "\n\n\tCity: " + bull1[1][57] + "\n\n\tState: " + bull1[1][60] + "\tZip: " + bull1[1][61] + "\n\n\tPhone: " + bull1[1][59] + "\n\n"; table1.addCell(getCell(temp1, PdfPCell.ALIGN_LEFT)); doc.add(table1); if (dlm3.size() == 1) { String str; str = dlm3.get(0).toString(); String[] parts = str.split(":"); String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; String[][] temp = new String[25][6]; temp[0][0] = "Tag"; temp[0][1] = bull1[row][7]; temp[0][2] = "Comments"; temp[0][3] = ""; temp[0][4] = "Total Count"; temp[0][5] = ""; temp[1][0] = "Tatoo"; temp[1][1] = bull1[row][8]; temp[1][2] = "All Normal"; temp[1][3] = "Yes"; temp[2][0] = "RFID"; temp[2][1] = bull1[row][6]; temp[2][2] = "Eyes"; temp[2][3] = bull1[row][10]; temp[3][0] = "Lot#"; temp[3][1] = bull1[row][5]; temp[3][2] = "Feet"; temp[3][3] = bull1[row][12]; temp[4][0] = "Brand"; temp[4][1] = bull1[row][2]; temp[4][2] = "Legs"; temp[4][3] = bull1[row][14]; temp[5][0] = "Date of Birth"; temp[5][1] = bull1[row][4]; temp[5][2] = "Testicals"; temp[5][3] = bull1[row][16]; temp[6][0] = "Age"; temp[6][1] = bull1[row][0]; temp[6][2] = "Accessory Sex Glands"; temp[6][3] = bull1[row][18]; temp[7][0] = "Breed"; temp[7][1] = bull1[row][3]; temp[7][2] = "Inguinal"; temp[7][3] = bull1[row][20]; temp[8][0] = "Other"; temp[8][1] = bull1[row][9]; temp[8][2] = "Scrotal"; temp[8][3] = bull1[row][22]; temp[9][0] = "Clinic Info"; temp[9][1] = "xx"; temp[9][2] = "Epidydimides"; temp[9][3] = bull1[row][24]; temp[10][4] = "Measurements"; temp[10][5] = "xx"; temp[10][0] = "Clinic Name"; temp[10][1] = bull1[row][73]; temp[10][2] = "Penis"; temp[10][3] = bull1[row][26]; temp[11][4] = "Scrotal Cirumference"; temp[11][5] = bull1[row][54]; temp[11][0] = "Veterinarian Name"; temp[11][1] = bull1[row][74] + " " + bull1[row][74]; temp[11][2] = "Prepuce"; temp[11][3] = bull1[row][28]; temp[12][4] = "Body Condition"; temp[12][5] = bull1[row][47]; temp[12][0] = "Address"; temp[12][1] = bull1[row][66] + " " + bull1[row][67]; temp[12][2] = "Scrotum"; temp[12][3] = bull1[row][30]; temp[13][4] = "Pelvic X Measure"; temp[13][5] = bull1[row][52]; temp[13][0] = "City"; temp[13][1] = bull1[row][68]; temp[13][2] = "Sex Drive"; temp[13][3] = "xx"; temp[14][4] = "Pelvic Y Measure"; temp[14][5] = bull1[row][53]; temp[14][0] = "State"; temp[14][1] = bull1[row][71]; temp[14][2] = "Breeding seasons used"; temp[14][3] = bull1[row][40]; temp[15][4] = "Hip Hight"; temp[15][5] = bull1[row][50]; temp[15][0] = "Zip Code"; temp[15][1] = bull1[row][72]; temp[15][2] = "Performance last season"; temp[15][3] = bull1[row][38]; temp[16][4] = "Frame Score"; temp[16][5] = bull1[row][49]; temp[16][0] = "Email"; temp[16][1] = bull1[row][69]; temp[16][2] = "Single or Multi sire"; temp[16][3] = bull1[row][41]; temp[17][4] = "Other"; temp[17][5] = bull1[row][48]; temp[17][0] = "Phone"; temp[17][1] = bull1[row][70]; temp[17][2] = "Other"; temp[17][3] = bull1[row][39]; temp[18][4] = "Motility"; temp[18][5] = "xx"; temp[18][0] = "Classification"; temp[18][1] = bull1[row][35]; temp[18][2] = "Comments"; temp[18][3] = bull1[row][37]; temp[19][4] = "Individual Motility"; temp[19][5] = bull1[row][45]; temp[19][0] = "Comments"; temp[19][1] = bull1[row][36]; temp[19][2] = ""; temp[19][3] = ""; temp[20][4] = "Motility %"; temp[20][5] = bull1[row][46]; temp[20][0] = ""; temp[20][1] = ""; temp[20][2] = ""; temp[20][3] = ""; temp[21][4] = "Gross Motility"; temp[21][5] = bull1[row][44]; temp[21][0] = ""; temp[21][1] = ""; temp[21][2] = ""; temp[21][3] = ""; for (int i = 9; i <= 29; i += 2) { if (bull1[row][i].equals("FALSE")) { temp[1][4] = "No"; break; } } int i; int total = 0; for (i = 77; i < header.length && i < bull1[row].length; i++) { temp[i - 76][4] = header[i].split("_")[1]; temp[i - 76][5] = bull1[row][i]; total += Integer.parseInt(bull1[row][i]); } temp[0][5] = Integer.toString(total); for (int j = i; j <= 85; j++) { temp[j - 76][4] = ""; temp[j - 76][5] = ""; } PdfPTable table = new PdfPTable(6); PdfPCell cell11, cell12, cell13; cell11 = new PdfPCell(new Phrase("Bull Info", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell11.setColspan(2); cell11.setHorizontalAlignment(Element.ALIGN_CENTER); cell11.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell11); cell12 = new PdfPCell( new Phrase("Physical Exam", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell12.setColspan(2); cell12.setHorizontalAlignment(Element.ALIGN_CENTER); cell12.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell12); cell13 = new PdfPCell(new Phrase("Morphology", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell13.setColspan(2); cell13.setHorizontalAlignment(Element.ALIGN_CENTER); cell13.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell13); for (int l = 0; l <= 21; l++) { for (int j = 0; j < 6; j++) { // System.out.println(l+" "+j); if (!temp[l][j].equals("xx") && temp[l][j] != null) { cell = new PdfPCell( new Phrase(temp[l][j], FontFactory.getFont(FontFactory.TIMES_ROMAN, 10))); cell.setBorder(PdfPCell.NO_BORDER); if ((l == 9 && j == 0) || (l == 13 && j == 2) || (l == 10 && j == 4) || (l == 18 && j == 4)) { cell = new PdfPCell( new Phrase(temp[l][j], FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); } table.addCell(cell); } } } table.setWidthPercentage(90f); Reporter re; re = new Reporter(); doc.add(table); if (jCheckBox2.isSelected() || jCheckBox1.isSelected()) doc.newPage(); } else { //specify column widths int temp = dlm2.size(); float[] columnWidths = new float[temp + 1]; for (int x = 0; x < columnWidths.length; x++) { columnWidths[x] = 2f; } //create PDF table with the given widths PdfPTable table = new PdfPTable(columnWidths); // set table width a percentage of the page width table.setWidthPercentage(90f); Reporter re; re = new Reporter(); re.insertCell(table, "Bull Info", Element.ALIGN_CENTER, 1, bfBold12); for (int i = 0; i < dlm2.size(); i++) { String[] parts = dlm2.get(i).toString().split(": "); String part2 = parts[1]; re.insertCell(table, newhead[Integer.parseInt(part2)], Element.ALIGN_CENTER, 1, bfBold12); } table.setHeaderRows(1); //insert an empty row //create section heading by cell merging //just some random data to fill for (int x = 0; x < dlm3.size(); x++) { String str = dlm3.get(x).toString(); //System.out.println(str); String[] parts = str.split(":"); String part2 = parts[1]; // System.out.println(part2); int row = Integer.parseInt(part2) - 1; re.insertCell(table, Bulls[row], Element.ALIGN_CENTER, 1, bf12); for (int i = 0; i < dlm2.getSize(); i++) { for (int j = 0; j < header.length && j < bull1[row].length; j++) { String str1 = dlm2.get(i).toString(); String[] p1 = str1.split(": "); String p2 = p1[0]; if (p2.equals(header[j])) { re.insertCell(table, bull1[row][j], Element.ALIGN_CENTER, 1, bf12); } } } // re.insertCell(table, bull1[x][7] , Element.ALIGN_CENTER, 1, bf12); } doc.add(table); } if (jCheckBox2.isSelected()) { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); for (int i = 0; i < dlm3.size(); i++) { String str = dlm3.get(i).toString(); System.out.println(str); String[] parts = str.split(":"); String part1 = parts[0]; String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; float total = (float) 0.0; for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (bull1[row][j].equals("")) { continue; } else { total += Integer.parseInt(bull1[row][j]); } } System.out.println(total); for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (!bull1[row][j].equals("")) { String[] Parts = header[j].split("_"); String Part2 = Parts[1]; dataSet.setValue((Integer.parseInt(bull1[row][j]) * 100) / total, Part2, part1); } else { dataSet.setValue(0, "Percent", header[j]); } } } JFreeChart chart = ChartFactory.createBarChart("Multi Bull Morphology Chart ", "Morphology", "Percent", dataSet, PlotOrientation.VERTICAL, true, true, false); if (dlm3.size() > 12) { doc.newPage(); } PdfContentByte contentByte = docWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(325, 250); PdfGraphics2D graphics2d = new PdfGraphics2D(template, 325, 250); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 325, 250); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 0, 0); } if (jCheckBox1.isSelected()) { for (int i = 0; i < dlm3.size(); i++) { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); String str = dlm3.get(i).toString(); System.out.println(str); String[] parts = str.split(":"); String part1 = parts[0]; String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; float total = (float) 0.0; for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (bull1[row][j].equals("")) { continue; } else { total += Integer.parseInt(bull1[row][j]); } } System.out.println(total); for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (!bull1[row][j].equals("")) { String[] Parts = header[j].split("_"); String Part2 = Parts[1]; dataSet.setValue((Integer.parseInt(bull1[row][j]) * 100) / total, "Percent", Part2); } else { dataSet.setValue(0, "Percent", header[j]); } } JFreeChart chart = ChartFactory.createBarChart("Single Bull Morphology Chart " + part1, "Morphology", "Percent", dataSet, PlotOrientation.VERTICAL, false, true, false); if ((dlm3.size() > 12 && i == 0) || jCheckBox2.isSelected()) { doc.newPage(); } PdfContentByte contentByte = docWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(325, 250); PdfGraphics2D graphics2d = new PdfGraphics2D(template, 325, 250); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 325, 250); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 0, 0); doc.newPage(); } } } catch (DocumentException dex) { dex.printStackTrace(); JOptionPane.showMessageDialog(null, dex); } catch (FileNotFoundException ex) { Logger.getLogger(ReporterArchive.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(null, ex); } catch (IOException ex) { Logger.getLogger(ReporterArchive.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(null, "ex"); } finally { if (doc != null) { //close the document doc.close(); } if (docWriter != null) { //close the writer docWriter.close(); } } controller.openDocument(Path); } private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: // build a controller SwingController controller = new SwingController(); // Build a SwingViewFactory configured with the controller SwingViewBuilder factory = new SwingViewBuilder(controller); // Use the factory to build a JPanel that is pre-configured //with a complete, active Viewer UI. JPanel viewerComponentPanel = factory.buildViewerPanel(); // add copy keyboard command ComponentKeyBinding.install(controller, viewerComponentPanel); // add interactive mouse link annotation support via callback controller.getDocumentViewController().setAnnotationCallback( new org.icepdf.ri.common.MyAnnotationCallback(controller.getDocumentViewController())); // Create a JFrame to display the panel in JFrame window = new JFrame("Using the Viewer Component"); window.getContentPane().add(viewerComponentPanel); window.pack(); window.setVisible(true); String Path; JFileChooser fr = new JFileChooser(); FileSystemView fw = fr.getFileSystemView(); // System.out.println(fw.getDefaultDirectory()); Path = fw.getDefaultDirectory() + "/reporter.pdf"; try { br1 = new BufferedReader(new FileReader(f)); BufferedReader b1 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { } String line = ""; bull1 = new String[number_of_rows - 1][]; int k = 0; BufferedReader br3 = null; try { br3 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { } try { while ((line = br3.readLine()) != null) { // use comma as separator String Bull[] = line.split(","); if (k != 0) { System.out.println(Bull.length); bull1[k - 1] = new String[Bull.length]; for (int j = 0; j < Bull.length; j++) { bull1[k - 1][j] = Bull[j]; } } k++; } } catch (IOException ex) { } Document doc = new Document(); PdfWriter docWriter = null; DecimalFormat df = new DecimalFormat("0.00"); try { //special font sizes Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.BOLD, new BaseColor(0, 0, 0)); Font bf12 = new Font(Font.FontFamily.TIMES_ROMAN, 6); Font bfBold20 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); //file path docWriter = PdfWriter.getInstance(doc, new FileOutputStream(Path)); //document header attributes doc.addAuthor("Shubh Chopra"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("Shubh Chopra"); doc.addTitle("BES"); doc.setPageSize(PageSize.LETTER.rotate()); //open document doc.open(); //create a paragraph Paragraph paragraph = new Paragraph("BULL EVALUATION\n\n"); paragraph.setFont(bfBold20); paragraph.setAlignment(Element.ALIGN_CENTER); Image img = Image.getInstance("VETMED.png"); img.scaleToFit(300f, 150f); doc.add(paragraph); PdfPTable table1 = new PdfPTable(2); table1.setWidthPercentage(100); PdfPCell cell = new PdfPCell(img); cell.setBorder(PdfPCell.NO_BORDER); table1.addCell(cell); String temp1 = "\tOwner: " + bull1[1][62] + " " + bull1[1][63] + "\n\n\tRanch: " + bull1[1][64] + "\n\n\tAddress: " + bull1[1][55] + "\n\n\tCity: " + bull1[1][57] + "\n\n\tState: " + bull1[1][60] + "\tZip: " + bull1[1][61] + "\n\n\tPhone: " + bull1[1][59] + "\n\n"; table1.addCell(getCell(temp1, PdfPCell.ALIGN_LEFT)); doc.add(table1); if (dlm3.size() == 1) { String str; str = dlm3.get(0).toString(); String[] parts = str.split(":"); String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; String[][] temp = new String[25][6]; temp[0][0] = "Tag"; temp[0][1] = bull1[row][7]; temp[0][2] = "Comments"; temp[0][3] = ""; temp[0][4] = "Total Count"; temp[0][5] = ""; temp[1][0] = "Tatoo"; temp[1][1] = bull1[row][8]; temp[1][2] = "All Normal"; temp[1][3] = "Yes"; temp[2][0] = "RFID"; temp[2][1] = bull1[row][6]; temp[2][2] = "Eyes"; temp[2][3] = bull1[row][10]; temp[3][0] = "Lot#"; temp[3][1] = bull1[row][5]; temp[3][2] = "Feet"; temp[3][3] = bull1[row][12]; temp[4][0] = "Brand"; temp[4][1] = bull1[row][2]; temp[4][2] = "Legs"; temp[4][3] = bull1[row][14]; temp[5][0] = "Date of Birth"; temp[5][1] = bull1[row][4]; temp[5][2] = "Testicals"; temp[5][3] = bull1[row][16]; temp[6][0] = "Age"; temp[6][1] = bull1[row][0]; temp[6][2] = "Accessory Sex Glands"; temp[6][3] = bull1[row][18]; temp[7][0] = "Breed"; temp[7][1] = bull1[row][3]; temp[7][2] = "Inguinal"; temp[7][3] = bull1[row][20]; temp[8][0] = "Other"; temp[8][1] = bull1[row][9]; temp[8][2] = "Scrotal"; temp[8][3] = bull1[row][22]; temp[9][0] = "Clinic Info"; temp[9][1] = "xx"; temp[9][2] = "Epidydimides"; temp[9][3] = bull1[row][24]; temp[10][4] = "Measurements"; temp[10][5] = "xx"; temp[10][0] = "Clinic Name"; temp[10][1] = bull1[row][73]; temp[10][2] = "Penis"; temp[10][3] = bull1[row][26]; temp[11][4] = "Scrotal Cirumference"; temp[11][5] = bull1[row][54]; temp[11][0] = "Veterinarian Name"; temp[11][1] = bull1[row][74] + " " + bull1[row][75]; temp[11][2] = "Prepuce"; temp[11][3] = bull1[row][28]; temp[12][4] = "Body Condition"; temp[12][5] = bull1[row][47]; temp[12][0] = "Address"; temp[12][1] = bull1[row][66] + " " + bull1[row][67]; temp[12][2] = "Scrotum"; temp[12][3] = bull1[row][30]; temp[13][4] = "Pelvic X Measure"; temp[13][5] = bull1[row][52]; temp[13][0] = "City"; temp[13][1] = bull1[row][68]; temp[13][2] = "Sex Drive"; temp[13][3] = "xx"; temp[14][4] = "Pelvic Y Measure"; temp[14][5] = bull1[row][53]; temp[14][0] = "State"; temp[14][1] = bull1[row][71]; temp[14][2] = "Breeding seasons used"; temp[14][3] = bull1[row][40]; temp[15][4] = "Hip Hight"; temp[15][5] = bull1[row][50]; temp[15][0] = "Zip Code"; temp[15][1] = bull1[row][72]; temp[15][2] = "Performance last season"; temp[15][3] = bull1[row][38]; temp[16][4] = "Frame Score"; temp[16][5] = bull1[row][49]; temp[16][0] = "Email"; temp[16][1] = bull1[row][69]; temp[16][2] = "Single or Multi sire"; temp[16][3] = bull1[row][41]; temp[17][4] = "Other"; temp[17][5] = bull1[row][48]; temp[17][0] = "Phone"; temp[17][1] = bull1[row][70]; temp[17][2] = "Other"; temp[17][3] = bull1[row][39]; temp[18][4] = "Motility"; temp[18][5] = "xx"; temp[18][0] = "Classification"; temp[18][1] = bull1[row][35]; temp[18][2] = "Comments"; temp[18][3] = bull1[row][37]; temp[19][4] = "Individual Motility"; temp[19][5] = bull1[row][45]; temp[19][0] = "Comments"; temp[19][1] = bull1[row][36]; temp[19][2] = ""; temp[19][3] = ""; temp[20][4] = "Motility %"; temp[20][5] = bull1[row][46]; temp[20][0] = ""; temp[20][1] = ""; temp[20][2] = ""; temp[20][3] = ""; temp[21][4] = "Gross Motility"; temp[21][5] = bull1[row][44]; temp[21][0] = ""; temp[21][1] = ""; temp[21][2] = ""; temp[21][3] = ""; for (int i = 9; i <= 29; i += 2) { if (bull1[row][i].equals("FALSE")) { temp[1][4] = "No"; break; } } int i; int total = 0; for (i = 77; i < header.length && i < bull1[row].length; i++) { temp[i - 76][4] = header[i].split("_")[1]; temp[i - 76][5] = bull1[row][i]; total += Integer.parseInt(bull1[row][i]); } temp[0][5] = Integer.toString(total); for (int j = i; j <= 85; j++) { temp[j - 76][4] = ""; temp[j - 76][5] = ""; } PdfPTable table = new PdfPTable(6); PdfPCell cell11, cell12, cell13; cell11 = new PdfPCell(new Phrase("Bull Info", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell11.setColspan(2); cell11.setHorizontalAlignment(Element.ALIGN_CENTER); cell11.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell11); cell12 = new PdfPCell( new Phrase("Physical Exam", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell12.setColspan(2); cell12.setHorizontalAlignment(Element.ALIGN_CENTER); cell12.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell12); cell13 = new PdfPCell(new Phrase("Morphology", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell13.setColspan(2); cell13.setHorizontalAlignment(Element.ALIGN_CENTER); cell13.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell13); for (int l = 0; l <= 21; l++) { for (int j = 0; j < 6; j++) { // System.out.println(l+" "+j); if (!temp[l][j].equals("xx") && temp[l][j] != null) { cell = new PdfPCell( new Phrase(temp[l][j], FontFactory.getFont(FontFactory.TIMES_ROMAN, 10))); cell.setBorder(PdfPCell.NO_BORDER); if ((l == 9 && j == 0) || (l == 13 && j == 2) || (l == 10 && j == 4) || (l == 18 && j == 4)) { cell = new PdfPCell( new Phrase(temp[l][j], FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); } table.addCell(cell); } } } table.setWidthPercentage(90f); Reporter re; re = new Reporter(); doc.add(table); if (jCheckBox2.isSelected() || jCheckBox1.isSelected()) doc.newPage(); } else { //specify column widths int temp = dlm2.size(); float[] columnWidths = new float[temp]; for (int x = 0; x < columnWidths.length; x++) { columnWidths[x] = 2f; } //create PDF table with the given widths PdfPTable table = new PdfPTable(columnWidths); // set table width a percentage of the page width table.setWidthPercentage(90f); Reporter re; re = new Reporter(); re.insertCell(table, "Bull Info", Element.ALIGN_CENTER, 1, bfBold12); for (int i = 0; i < dlm2.size(); i++) { String[] parts = dlm2.get(i).toString().split(": "); String part2 = parts[1]; re.insertCell(table, newhead[Integer.parseInt(part2)], Element.ALIGN_CENTER, 1, bfBold12); } table.setHeaderRows(1); //insert an empty row //create section heading by cell merging //just some random data to fill for (int x = 0; x < dlm3.size(); x++) { String str = dlm3.get(x).toString(); //System.out.println(str); String[] parts = str.split(":"); String part2 = parts[1]; // System.out.println(part2); int row = Integer.parseInt(part2) - 1; re.insertCell(table, Bulls[row], Element.ALIGN_CENTER, 1, bf12); for (int i = 0; i < dlm2.getSize(); i++) { for (int j = 0; j < header.length && j < bull1[row].length; j++) { String str1 = dlm2.get(i).toString(); String[] p1 = str1.split(": "); String p2 = p1[0]; if (p2.equals(header[j])) { re.insertCell(table, bull1[row][j], Element.ALIGN_CENTER, 1, bf12); } } } // re.insertCell(table, bull1[x][7] , Element.ALIGN_CENTER, 1, bf12); } doc.add(table); } if (jCheckBox2.isSelected()) { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); for (int i = 0; i < dlm3.size(); i++) { String str = dlm3.get(i).toString(); System.out.println(str); String[] parts = str.split(":"); String part1 = parts[0]; String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; float total = (float) 0.0; for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (bull1[row][j].equals("")) { continue; } else { total += Integer.parseInt(bull1[row][j]); } } System.out.println(total); for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (!bull1[row][j].equals("")) { String[] Parts = header[j].split("_"); String Part2 = Parts[1]; dataSet.setValue((Integer.parseInt(bull1[row][j]) * 100) / total, Part2, part1); } else { dataSet.setValue(0, "Percent", header[j]); } } } JFreeChart chart = ChartFactory.createBarChart("Multi Bull Morphology Chart ", "Morphology", "Percent", dataSet, PlotOrientation.VERTICAL, true, true, false); if (dlm3.size() > 12) { doc.newPage(); } PdfContentByte contentByte = docWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(325, 250); PdfGraphics2D graphics2d = new PdfGraphics2D(template, 325, 250); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 325, 250); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 0, 0); } if (jCheckBox1.isSelected()) { for (int i = 0; i < dlm3.size(); i++) { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); String str = dlm3.get(i).toString(); System.out.println(str); String[] parts = str.split(":"); String part1 = parts[0]; String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; float total = (float) 0.0; for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (bull1[row][j].equals("")) { continue; } else { total += Integer.parseInt(bull1[row][j]); } } System.out.println(total); for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (!bull1[row][j].equals("")) { String[] Parts = header[j].split("_"); String Part2 = Parts[1]; dataSet.setValue((Integer.parseInt(bull1[row][j]) * 100) / total, "Percent", Part2); } else { dataSet.setValue(0, "Percent", header[j]); } } JFreeChart chart = ChartFactory.createBarChart("Single Bull Morphology Chart " + part1, "Morphology", "Percent", dataSet, PlotOrientation.VERTICAL, false, true, false); if ((dlm3.size() > 12 && i == 0) || jCheckBox2.isSelected()) { doc.newPage(); } PdfContentByte contentByte = docWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(325, 250); PdfGraphics2D graphics2d = new PdfGraphics2D(template, 325, 250); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 325, 250); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 0, 0); doc.newPage(); } } } catch (DocumentException dex) { dex.printStackTrace(); } catch (FileNotFoundException ex) { Logger.getLogger(ReporterArchive.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ReporterArchive.class.getName()).log(Level.SEVERE, null, ex); } finally { if (doc != null) { //close the document doc.close(); } if (docWriter != null) { //close the writer docWriter.close(); } } controller.openDocument(Path); } private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) { jPanel3.setVisible(false); pack(); jPanel2.setVisible(true); pack(); jButton11.setVisible(true); pack(); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Reporter.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Reporter.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Reporter.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Reporter.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { Reporter obj = new Reporter(); obj.jPanel2.setVisible(false); obj.jPanel3.setVisible(false); obj.setVisible(true); obj.jButton11.setVisible(false); obj.pack(); } }); } public PdfPCell getCell(String text, int alignment) { PdfPCell cell = new PdfPCell(new Phrase(text)); cell.setPadding(0); cell.setHorizontalAlignment(alignment); cell.setBorder(PdfPCell.NO_BORDER); return cell; } private void insertCell(PdfPTable table, String text, int align, int colspan, Font font) { //create a new cell with the specified Text and Font PdfPCell cell = new PdfPCell(new Phrase(text.trim(), font)); //set the cell alignment cell.setHorizontalAlignment(align); //set the cell column span in case you want to merge two or more cells cell.setColspan(colspan); //in case there is no text and you wan to create an empty row if (text.trim().equalsIgnoreCase("")) { cell.setMinimumHeight(10f); } //add the call to the table table.addCell(cell); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton11; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JButton jButton5; private javax.swing.JButton jButton6; private javax.swing.JButton jButton7; private javax.swing.JButton jButton8; private javax.swing.JButton jButton9; private javax.swing.JCheckBox jCheckBox1; private javax.swing.JCheckBox jCheckBox2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JList jList1; private javax.swing.JList jList2; private javax.swing.JList jList3; private javax.swing.JList jList4; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JScrollPane jScrollPane4; private javax.swing.JTextField jTextField1; // End of variables declaration }