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 in.co.itasca.geu; import in.co.itasca.geu.bl.PopularityBLModel; import in.co.itasca.geu.model.GraphData; import in.co.itasca.geu.model.GraphListTableModel; import in.co.itasca.geu.model.Popularity; import in.co.itasca.geu.model.PopularityGraphDM; import in.co.itasca.geu.model.PopulatryTableModel; import java.awt.Component; import java.util.HashMap; import java.util.Iterator; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PiePlot3D; import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.PieDataset; import org.jfree.util.Rotation; /** * * @author student */ public class Main extends javax.swing.JFrame { /** * Creates new form Main */ public Main() { 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">//GEN-BEGIN:initComponents private void initComponents() { buttonGroup1 = new javax.swing.ButtonGroup(); jTabbedPane1 = new javax.swing.JTabbedPane(); populationTab = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); yearComboBox = new javax.swing.JComboBox(); jPanel2 = new javax.swing.JPanel(); RankedTopLabel3 = new javax.swing.JLabel(); rankedSpinner = new javax.swing.JSpinner(); jLabel1 = new javax.swing.JLabel(); jPanel1 = new javax.swing.JPanel(); femaleCheckBox = new javax.swing.JCheckBox(); bothCheckBox = new javax.swing.JCheckBox(); maleCheckBox4 = new javax.swing.JCheckBox(); jScrollPane1 = new javax.swing.JScrollPane(); jTable = new javax.swing.JTable(); jButtonSearch = new javax.swing.JButton(); jButtonReset = new javax.swing.JButton(); polpularityPane = new javax.swing.JPanel(); yearComboBox1 = new javax.swing.JComboBox(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); particalInput = new javax.swing.JTextField(); jPanel3 = new javax.swing.JPanel(); femaleCheckBox1 = new javax.swing.JCheckBox(); maleCheckBox5 = new javax.swing.JCheckBox(); jLabel6 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); jTable2 = new javax.swing.JTable(); jButton2 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setBackground(new java.awt.Color(204, 204, 204)); setIconImages(null); setLocationByPlatform(true); jTabbedPane1.setBackground(new java.awt.Color(255, 255, 0)); jLabel2.setForeground(new java.awt.Color(51, 51, 51)); jLabel2.setText("Please Select year"); yearComboBox.setForeground(new java.awt.Color(51, 51, 51)); yearComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2013", "2012", "2011", "2010", "2009", "2008", "2007", "2006", "2005", "2004", "2003", "2002", "2001", "2000", "1999", "1998", "1997", "1996", "1995", "1994", "1993", "1992", "1991", "1990", "1989", "1988", "1987", "1986", "1985", "1984", "1983", "1982", "1981", "1980", "1979", "1978", "1977", "1976", "1975", "1974", "1973", "1972", "1971", "1970", "1969", "1968", "1967", "1966", "1965", "1964", "1963", "1962", "1961", "1960", "1959", "1958", "1957", "1956", "1955", "1954", "1953", "1952", "1951", "1950", "1949", "1948", "1947", "1946", "1945", "1944", " " })); jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder()); RankedTopLabel3.setForeground(new java.awt.Color(51, 51, 51)); RankedTopLabel3.setText("Ranked Top"); rankedSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, 2000, 10)); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addComponent(RankedTopLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(rankedSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(RankedTopLabel3).addComponent(rankedSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N jLabel1.setForeground(new java.awt.Color(102, 102, 102)); jLabel1.setText("Mini Project"); jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); buttonGroup1.add(femaleCheckBox); femaleCheckBox.setForeground(new java.awt.Color(51, 51, 51)); femaleCheckBox.setText("Female"); buttonGroup1.add(bothCheckBox); bothCheckBox.setForeground(new java.awt.Color(51, 51, 51)); bothCheckBox.setText("Both"); buttonGroup1.add(maleCheckBox4); maleCheckBox4.setForeground(new java.awt.Color(51, 51, 51)); maleCheckBox4.setText("Male"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout .setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(femaleCheckBox).addGap(18, 18, 18) .addComponent(maleCheckBox4, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bothCheckBox, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(femaleCheckBox) .addComponent(maleCheckBox4, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bothCheckBox)) .addGap(0, 0, Short.MAX_VALUE))); jTable.setModel( new javax.swing.table.DefaultTableModel(new Object[][] { { null, null, null }, { null, null, null }, { null, null, null }, { null, null, null } }, new String[] { "Name", "Year", "Amount" })); jTable.setFillsViewportHeight(true); jTable.setRowSelectionAllowed(false); jScrollPane1.setViewportView(jTable); jButtonSearch.setText("Search"); jButtonSearch.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButtonSearchMouseClicked(evt); } }); jButtonReset.setText("Reset"); jButtonReset.setEnabled(false); jButtonReset.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButtonResetMouseClicked(evt); } }); jButtonReset.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonResetActionPerformed(evt); } }); javax.swing.GroupLayout populationTabLayout = new javax.swing.GroupLayout(populationTab); populationTab.setLayout(populationTabLayout); populationTabLayout.setHorizontalGroup(populationTabLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(populationTabLayout.createSequentialGroup().addContainerGap().addGroup(populationTabLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, populationTabLayout .createSequentialGroup().addGap(0, 0, Short.MAX_VALUE) .addGroup(populationTabLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, populationTabLayout .createSequentialGroup() .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(240, 240, 240)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, populationTabLayout .createSequentialGroup().addComponent(jButtonReset) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonSearch).addGap(204, 204, 204)))) .addGroup( populationTabLayout.createSequentialGroup().addComponent(jLabel2).addGap(27, 27, 27) .addComponent(yearComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(22, 22, 22) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 229, 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) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) .addGroup(populationTabLayout .createSequentialGroup().addGap(51, 51, 51).addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 561, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 18, Short.MAX_VALUE))); populationTabLayout.setVerticalGroup(populationTabLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(populationTabLayout.createSequentialGroup().addGroup(populationTabLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(populationTabLayout.createSequentialGroup().addGap(79, 79, 79) .addGroup(populationTabLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2).addComponent(yearComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(populationTabLayout.createSequentialGroup().addContainerGap() .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(populationTabLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(populationTabLayout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(9, 9, 9))) .addGap(70, 70, 70) .addGroup(populationTabLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButtonSearch).addComponent(jButtonReset)))) .addGap(18, 18, 18).addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(142, Short.MAX_VALUE))); jTabbedPane1.addTab("Population", populationTab); polpularityPane.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); yearComboBox1.setForeground(new java.awt.Color(51, 51, 51)); yearComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2013", "2012", "2011", "2010", "2009", "2008", "2007", "2006", "2005", "2004", "2003", "2002", "2001", "2000", "1999", "1998", "1997", "1996", "1995", "1994", "1993", "1992", "1991", "1990", "1989", "1988", "1987", "1986", "1985", "1984", "1983", "1982", "1981", "1980", "1979", "1978", "1977", "1976", "1975", "1974", "1973", "1972", "1971", "1970", "1969", "1968", "1967", "1966", "1965", "1964", "1963", "1962", "1961", "1960", "1959", "1958", "1957", "1956", "1955", "1954", "1953", "1952", "1951", "1950", "1949", "1948", "1947", "1946", "1945", "1944", " " })); polpularityPane.add(yearComboBox1, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 20, 70, -1)); jLabel3.setText("Popularity"); polpularityPane.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 495, 630, -1)); jLabel4.setText("Select Year :"); polpularityPane.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 30, -1, 10)); jLabel5.setText("Enter A Name :"); polpularityPane.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 0, 0)); jButton1.setText("Search"); jButton1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton1MouseClicked(evt); } }); polpularityPane.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(470, 20, 70, 20)); polpularityPane.add(particalInput, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 20, 180, -1)); jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder()); buttonGroup1.add(femaleCheckBox1); femaleCheckBox1.setForeground(new java.awt.Color(51, 51, 51)); femaleCheckBox1.setText("Female"); buttonGroup1.add(maleCheckBox5); maleCheckBox5.setForeground(new java.awt.Color(51, 51, 51)); maleCheckBox5.setSelected(true); maleCheckBox5.setText("Male"); 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(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(femaleCheckBox1).addGap(18, 18, 18).addComponent(maleCheckBox5, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(99, 99, 99))); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(femaleCheckBox1).addComponent(maleCheckBox5, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(0, 0, Short.MAX_VALUE))); polpularityPane.add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 50, 200, -1)); jLabel6.setText("Enter Name"); polpularityPane.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 20, -1, -1)); jTable2.setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null, null }, { null, null }, { null, null }, { null, null } }, new String[] { "Name", "Amount" })); jTable2.setFillsViewportHeight(true); jTable2.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jTable2MouseClicked(evt); } }); jScrollPane2.setViewportView(jTable2); polpularityPane.add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 120, 530, 300)); jButton2.setText("Reset"); jButton2.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton2MouseClicked(evt); } }); polpularityPane.add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 20, -1, -1)); jTabbedPane1.addTab("Popularity", polpularityPane); 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(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 635, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 81, Short.MAX_VALUE))); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jTabbedPane1)); jTabbedPane1.getAccessibleContext().setAccessibleName("Population"); pack(); }// </editor-fold>//GEN-END:initComponents private void jButtonSearchMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonSearchMouseClicked // TODO add your handling code here: jButtonSearch.setEnabled(false); jButtonSearch.setSelected(false); jButtonReset.setEnabled(true); jButtonReset.setSelected(false); jTable.removeAll(); jTable.setVisible(true); try { boolean choiceMale = maleCheckBox4.isSelected(); boolean choiceFemale = femaleCheckBox.isSelected(); boolean choiceBoth = bothCheckBox.isSelected(); String year = (String) yearComboBox.getSelectedItem(); Integer rankChoice = (Integer) rankedSpinner.getModel().getValue(); PopularityBLModel blModel = new PopularityBLModel(); Popularity[] models = blModel.getData(choiceMale, choiceFemale, choiceBoth, year, rankChoice); int rows = models.length; String[] columnHeaders = { "Name", "Amount", "Position" }; PopulatryTableModel model = new PopulatryTableModel(rows, columnHeaders); for (int i = 0; i < rows; i++) { Popularity pModel = models[i]; model.setValueAt(pModel.getName(), i, 0); model.setValueAt(pModel.getAmount(), i, 1); model.setValueAt(pModel.getPosition(), i, 2); } jTable.setModel(model); int i = 0; } catch (Exception e) { } }//GEN-LAST:event_jButtonSearchMouseClicked private void jButtonResetMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonResetMouseClicked // TODO add your handling code here: jTable.invalidate(); jTable.removeAll(); jTable.setVisible(false); jButtonReset.setEnabled(false); jButtonSearch.setEnabled(true); jButtonSearch.setSelected(false); }//GEN-LAST:event_jButtonResetMouseClicked private void jButtonResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonResetActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jButtonResetActionPerformed private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked // TODO add your handling code here: String inputText = particalInput.getText(); boolean result = inputText.contains("*"); String year = (String) yearComboBox1.getSelectedItem(); if (inputText.length() == 0) return; boolean femaleChoice = femaleCheckBox1.isSelected(); boolean maleChoice = maleCheckBox5.isSelected(); boolean sexChoiceforMale = femaleChoice; if (maleChoice == false) sexChoiceforMale = false; if (femaleChoice == false) sexChoiceforMale = true; PopularityBLModel bl = new PopularityBLModel(); // HashMap<String, PopularityGraphDM> searchedPopularName = bl.getSearchedName(year, inputText, sexChoiceforMale); java.util.Set<String> keyset = searchedPopularName.keySet(); int count = keyset.size(); String[] columnHeaders = { "Name" }; GraphListTableModel mapModel = new GraphListTableModel(count, columnHeaders); int location = 0; for (Iterator<String> iterator = keyset.iterator(); iterator.hasNext();) { String next = iterator.next(); mapModel.setValueAt(next, location, 0); location++; } jTable2.setVisible(true); jTable2.setModel(mapModel); // setContentPane(chartPanel); }//GEN-LAST:event_jButton1MouseClicked private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked // TODO add your handling code here: int len = jTabbedPane1.getComponents().length; while (len > 2) { jTabbedPane1.remove(len - 1); len = jTabbedPane1.getComponents().length; } jTable2.removeAll(); jTable2.invalidate(); jTable2.setVisible(false); jTable2.repaint(); jScrollPane2.repaint(); // jTable2.setVisible(false); }//GEN-LAST:event_jButton2MouseClicked private void jTable2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable2MouseClicked // TODO add your handling code here: int row = jTable2.rowAtPoint(evt.getPoint()); String value = (String) jTable2.getValueAt(row, 0); PopularityGraphDM gt = (PopularityGraphDM) searchedPopularName.get(value); GraphData[] array = gt.getAsArray(); PieDataset dataset = createDataset(array); // based on the dataset we create the chart JFreeChart chart = createChart(dataset, "Name Popularity of " + value); ChartPanel chartPanel = new ChartPanel(chart); jTabbedPane1.add(chartPanel, value); }//GEN-LAST:event_jTable2MouseClicked /** * @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(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Main().setVisible(true); } }); } private PieDataset createDataset(GraphData[] models) { DefaultPieDataset result = new DefaultPieDataset(); int total = 0; for (int i = 0; i < models.length; i++) { GraphData model = models[i]; String amountStr = model.getAmount(); int amount = Integer.parseInt(amountStr); total = total + amount; } for (int i = 0; i < models.length; i++) { GraphData model = models[i]; String amountStr = model.getAmount(); int amount = Integer.parseInt(amountStr); int percentage = amount * 100 / total; result.setValue(model.getName(), percentage); } // result.setValue("2013", 29); // result.setValue("2012", 20); // result.setValue("2011", 51); return result; } /** * Creates a chart */ private JFreeChart createChart(PieDataset dataset, String title) { JFreeChart chart = ChartFactory.createPieChart3D(title, // chart title dataset, // data true, // include legend true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); return chart; } private HashMap<String, PopularityGraphDM> searchedPopularName = null; // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel RankedTopLabel3; private javax.swing.JCheckBox bothCheckBox; private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JCheckBox femaleCheckBox; private javax.swing.JCheckBox femaleCheckBox1; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButtonReset; private javax.swing.JButton jButtonSearch; 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.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.JTabbedPane jTabbedPane1; private javax.swing.JTable jTable; private javax.swing.JTable jTable2; private javax.swing.JCheckBox maleCheckBox4; private javax.swing.JCheckBox maleCheckBox5; private javax.swing.JTextField particalInput; private javax.swing.JPanel polpularityPane; private javax.swing.JPanel populationTab; private javax.swing.JSpinner rankedSpinner; private javax.swing.JComboBox yearComboBox; private javax.swing.JComboBox yearComboBox1; // End of variables declaration//GEN-END:variables }