Java tutorial
/* * Copyright 2008-2010 The Zoocen Development Team * * This file is part of Zoocen. * * Zoocen is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. * * Zoocen is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with * Zoocen; if not, write to the Free Software Foundation, Inc., 51 Franklin St, * Fifth Floor, Boston, MA 02110-1301 USA */ package graphics; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.util.List; import java.util.Hashtable; import java.util.Vector; import javax.swing.*; import zoocen.Cell; import zoocen.world; import graphics.configuration.AddSpecieFrame; import graphics.configuration.AddCellFrame; import graphics.configuration.GlobalConfiguration; import graphics.configuration.SetDifusionRates; import java.awt.Dimension; import java.awt.event.MouseListener; import org.jfree.chart.ChartPanel; import zoocen.GlobalParametersStruct; /** * * @author sandra */ public class MainWindow extends javax.swing.JFrame implements ActionListener { private AddSpecieFrame AddSpecieWindow; private AddCellFrame AddCellWindow; private SetDifusionRates setDifusionWindows; private GlobalParametersStruct globalParameters; private GlobalConfiguration setGlobalWindows; public world World; private Thread thread; private JButton[] buttonDifusion; Hashtable<Integer, Cell> cells; /** Creates new form MainWindow */ public MainWindow() { this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.AddSpecieWindow = new AddSpecieFrame(); this.AddCellWindow = new AddCellFrame(this); this.cells = new Hashtable<Integer, Cell>(); initComponents(); this.createLabels(); this.globalParameters = new GlobalParametersStruct(); this.setGlobalWindows = new GlobalConfiguration(this.globalParameters); this.World = new world(this.globalParameters); this.buttonDifusion = new JButton[16]; } private void createLabels() { this.createOneLabel(this.jPanelpos1, "1"); this.createOneLabel(this.jPanelpos2, "2"); this.createOneLabel(this.jPanelpos3, "3"); this.createOneLabel(this.jPanelpos4, "4"); this.createOneLabel(this.jPanelpos5, "5"); this.createOneLabel(this.jPanelpos6, "6"); this.createOneLabel(this.jPanelpos7, "7"); this.createOneLabel(this.jPanelpos8, "8"); this.createOneLabel(this.jPanelpos9, "9"); this.createOneLabel(this.jPanelpos10, "10"); this.createOneLabel(this.jPanelpos11, "11"); this.createOneLabel(this.jPanelpos12, "12"); this.createOneLabel(this.jPanelpos13, "13"); this.createOneLabel(this.jPanelpos14, "14"); this.createOneLabel(this.jPanelpos15, "15"); this.createOneLabel(this.jPanelpos16, "16"); } private void createOneLabel(JPanel panel, String slabel) { JLabel label = new JLabel(slabel); JPanel plabel = new JPanel(); plabel.add(label, BorderLayout.CENTER); panel.add("Label", plabel); } /** 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. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new javax.swing.JPanel(); jPanelpos1 = new javax.swing.JPanel(); jPanelpos2 = new javax.swing.JPanel(); jPanelpos3 = new javax.swing.JPanel(); jPanelpos4 = new javax.swing.JPanel(); jPanelpos5 = new javax.swing.JPanel(); jPanelpos6 = new javax.swing.JPanel(); jPanelpos7 = new javax.swing.JPanel(); jPanelpos8 = new javax.swing.JPanel(); jPanelpos9 = new javax.swing.JPanel(); jPanelpos10 = new javax.swing.JPanel(); jPanelpos11 = new javax.swing.JPanel(); jPanelpos12 = new javax.swing.JPanel(); jPanelpos13 = new javax.swing.JPanel(); jPanelpos14 = new javax.swing.JPanel(); jPanelpos15 = new javax.swing.JPanel(); jPanelpos16 = new javax.swing.JPanel(); jMenuBar6 = new javax.swing.JMenuBar(); jMenu6 = new javax.swing.JMenu(); Start = new javax.swing.JMenuItem(); PauseMenuItem = new javax.swing.JCheckBoxMenuItem(); Stop = new javax.swing.JMenuItem(); Exit = new javax.swing.JMenuItem(); jMenu1 = new javax.swing.JMenu(); SimulationConf = new javax.swing.JMenuItem(); AddSpecie = new javax.swing.JMenuItem(); AddCell = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu(); Help = new javax.swing.JMenuItem(); About = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jPanel1.setLayout(new java.awt.GridLayout(4, 4)); jPanelpos1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jPanelpos1.setLayout(new java.awt.CardLayout()); jPanel1.add(jPanelpos1); jPanelpos2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jPanelpos2.setLayout(new java.awt.CardLayout()); jPanel1.add(jPanelpos2); jPanelpos3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jPanelpos3.setLayout(new java.awt.CardLayout()); jPanel1.add(jPanelpos3); jPanelpos4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jPanelpos4.setLayout(new java.awt.CardLayout()); jPanel1.add(jPanelpos4); jPanelpos5.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jPanelpos5.setLayout(new java.awt.CardLayout()); jPanel1.add(jPanelpos5); jPanelpos6.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jPanelpos6.setLayout(new java.awt.CardLayout()); jPanel1.add(jPanelpos6); jPanelpos7.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jPanelpos7.setLayout(new java.awt.CardLayout()); jPanel1.add(jPanelpos7); jPanelpos8.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jPanelpos8.setLayout(new java.awt.CardLayout()); jPanel1.add(jPanelpos8); jPanelpos9.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jPanelpos9.setLayout(new java.awt.CardLayout()); jPanel1.add(jPanelpos9); jPanelpos10.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jPanelpos10.setLayout(new java.awt.CardLayout()); jPanel1.add(jPanelpos10); jPanelpos11.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jPanelpos11.setLayout(new java.awt.CardLayout()); jPanel1.add(jPanelpos11); jPanelpos12.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jPanelpos12.setLayout(new java.awt.CardLayout()); jPanel1.add(jPanelpos12); jPanelpos13.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jPanelpos13.setLayout(new java.awt.CardLayout()); jPanel1.add(jPanelpos13); jPanelpos14.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jPanelpos14.setLayout(new java.awt.CardLayout()); jPanel1.add(jPanelpos14); jPanelpos15.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jPanelpos15.setLayout(new java.awt.CardLayout()); jPanel1.add(jPanelpos15); jPanelpos16.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jPanelpos16.setLayout(new java.awt.CardLayout()); jPanel1.add(jPanelpos16); jMenu6.setText("Simulation"); Start.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK)); Start.setText("Start"); Start.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { StartActionPerformed(evt); } }); jMenu6.add(Start); PauseMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK)); PauseMenuItem.setText("Pause"); PauseMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { PauseMenuItemActionPerformed(evt); } }); jMenu6.add(PauseMenuItem); Stop.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); Stop.setText("Stop"); Stop.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { StopActionPerformed(evt); } }); jMenu6.add(Stop); Exit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK)); Exit.setText("Exit"); Exit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ExitActionPerformed(evt); } }); jMenu6.add(Exit); jMenuBar6.add(jMenu6); jMenu1.setText("Edit"); SimulationConf.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK)); SimulationConf.setText("Simulation Configuration"); SimulationConf.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SimulationConfActionPerformed(evt); } }); jMenu1.add(SimulationConf); AddSpecie.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); AddSpecie.setText("Add New Specie"); AddSpecie.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AddSpecieActionPerformed(evt); } }); jMenu1.add(AddSpecie); AddCell.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK)); AddCell.setText("Add New Cell"); AddCell.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AddCellActionPerformed(evt); } }); jMenu1.add(AddCell); jMenuBar6.add(jMenu1); jMenu2.setText("Help"); Help.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_H, java.awt.event.InputEvent.CTRL_MASK)); Help.setText("Help"); jMenu2.add(Help); About.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); About.setText("About"); jMenu2.add(About); jMenuBar6.add(jMenu2); setJMenuBar(jMenuBar6); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout .createSequentialGroup().addGap(66, 66, 66).addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 468, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(76, Short.MAX_VALUE))); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout .createSequentialGroup().addGap(47, 47, 47).addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 439, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(60, Short.MAX_VALUE))); pack(); }// </editor-fold>//GEN-END:initComponents private void ExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExitActionPerformed this.setVisible(false); this.dispose(); }//GEN-LAST:event_ExitActionPerformed private void AddSpecieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddSpecieActionPerformed this.AddSpecieWindow.setVisible(true); }//GEN-LAST:event_AddSpecieActionPerformed private void AddCellActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddCellActionPerformed try { List<SpecieData> SData = this.AddSpecieWindow.getSpecieData(); if (!SData.isEmpty()) { this.AddCellWindow.setSpecieCombo(SData); this.AddCellWindow.setVisible(true); } else { System.out.println("Error, no hay especies definidas"); } } catch (Exception exception) { System.out.println("MainWindow.java---> AddCellActionPerformed() " + exception); } }//GEN-LAST:event_AddCellActionPerformed private void StartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StartActionPerformed try { if (this.World != null) { this.World.setStopSignal(true); } this.World = new world(this.globalParameters); this.World.makeChart(); thread = new Thread(this.World); thread.start(); for (int i = 0; i < this.World.cells.size(); i++) { this.setChartPanelCell(this.World.cells.elementAt(i).cellID, i); } } catch (Exception e) { } }//GEN-LAST:event_StartActionPerformed private void PauseMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PauseMenuItemActionPerformed try { if (this.PauseMenuItem.isSelected()) { this.World.setPauseSignal(true); } else { this.World.setPauseSignal(false); } } catch (Exception e) { } }//GEN-LAST:event_PauseMenuItemActionPerformed private void StopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StopActionPerformed try { this.World.setStopSignal(true); } catch (Exception e) { } }//GEN-LAST:event_StopActionPerformed private void SimulationConfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SimulationConfActionPerformed this.setGlobalWindows.setVisible(true); }//GEN-LAST:event_SimulationConfActionPerformed /** * * @param cell * @param posCell */ public void setPanelCell(int posCell) { // this.cells.put(new Integer(posCell), cell); switch (posCell) { case 0: this.createSecondPanel(this.jPanelpos1, posCell); break; case 1: this.createSecondPanel(this.jPanelpos2, posCell); break; case 2: this.createSecondPanel(this.jPanelpos3, posCell); break; case 3: this.createSecondPanel(this.jPanelpos4, posCell); break; case 4: this.createSecondPanel(this.jPanelpos5, posCell); break; case 5: this.createSecondPanel(this.jPanelpos6, posCell); break; case 6: this.createSecondPanel(this.jPanelpos7, posCell); break; case 7: this.createSecondPanel(this.jPanelpos8, posCell); break; case 8: this.createSecondPanel(this.jPanelpos9, posCell); break; case 9: this.createSecondPanel(this.jPanelpos10, posCell); break; case 10: this.createSecondPanel(this.jPanelpos11, posCell); break; case 11: this.createSecondPanel(this.jPanelpos12, posCell); break; case 12: this.createSecondPanel(this.jPanelpos13, posCell); break; case 13: this.createSecondPanel(this.jPanelpos14, posCell); break; case 14: this.createSecondPanel(this.jPanelpos15, posCell); break; case 15: this.createSecondPanel(this.jPanelpos16, posCell); break; } } /** * * @param cell * @param posCell */ public void setChartPanelCell(int posCell, int chart) { // this.cells.put(new Integer(posCell), cell); switch (posCell) { case 0: this.createChartPanel(this.jPanelpos1, chart); break; case 1: this.createChartPanel(this.jPanelpos2, chart); break; case 2: this.createChartPanel(this.jPanelpos3, chart); break; case 3: this.createChartPanel(this.jPanelpos4, chart); break; case 4: this.createChartPanel(this.jPanelpos5, chart); break; case 5: this.createChartPanel(this.jPanelpos6, chart); break; case 6: this.createChartPanel(this.jPanelpos7, chart); break; case 7: this.createChartPanel(this.jPanelpos8, chart); break; case 8: this.createChartPanel(this.jPanelpos9, chart); break; case 9: this.createChartPanel(this.jPanelpos10, chart); break; case 10: this.createChartPanel(this.jPanelpos11, chart); break; case 11: this.createChartPanel(this.jPanelpos12, chart); break; case 12: this.createChartPanel(this.jPanelpos13, chart); break; case 13: this.createChartPanel(this.jPanelpos14, chart); break; case 14: this.createChartPanel(this.jPanelpos15, chart); break; case 15: this.createChartPanel(this.jPanelpos16, chart); break; } } public void setCell(Cell cell) { int index = cell.cellID; boolean Mark = true; for (int i = 0; i < this.World.cells.size(); i++) { int index2 = this.World.cells.elementAt(i).cellID; if (index == index2) { Cell oldCell = this.World.cells.elementAt(i); this.setSameParameters(cell, oldCell); this.World.cells.setElementAt(cell, i); Mark = false; } } if (Mark) { System.out.println("cell n; " + cell.cellID); this.World.cells.addElement(cell); } } private void createSecondPanel(JPanel panel, int pos) { JPanel secondPanel = new JPanel(); secondPanel.setBackground(new Color(157, 191, 160)); panel.add("FieldPanel", secondPanel); JPanel Panel = new JPanel(); Panel.setBackground(new Color(157, 191, 160)); this.buttonDifusion[pos] = new JButton("Difusion Rates"); this.buttonDifusion[pos].addActionListener(this); Panel.add(this.buttonDifusion[pos]); panel.add("DifusionPanel", Panel); ((CardLayout) panel.getLayout()).show(panel, "DifusionPanel"); } private void createChartPanel(JPanel panel, final int pos) { JPanel Panel = new JPanel(); Panel.setBackground(new Color(157, 191, 160)); final ChartPanel chart = this.World.getChart(pos); chart.setPreferredSize(new Dimension(100, 100)); Panel.add(chart); chart.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent arg0) { World.showChart(pos); } public void mousePressed(MouseEvent arg0) { World.showChart(pos); } public void mouseReleased(MouseEvent arg0) { World.showChart(pos); } public void mouseEntered(MouseEvent arg0) { } public void mouseExited(MouseEvent arg0) { } }); panel.add("ChartPanel", Panel); ((CardLayout) panel.getLayout()).show(panel, "ChartPanel"); } public void actionPerformed(ActionEvent arg0) { if (arg0.getSource() == this.buttonDifusion[0]) { this.DifusionRates(0, "Cell 1"); } if (arg0.getSource() == this.buttonDifusion[1]) { this.DifusionRates(1, "Cell 2"); } if (arg0.getSource() == this.buttonDifusion[2]) { this.DifusionRates(2, "Cell 3"); } if (arg0.getSource() == this.buttonDifusion[3]) { this.DifusionRates(3, "Cell 4"); } if (arg0.getSource() == this.buttonDifusion[4]) { this.DifusionRates(4, "Cell 5"); } if (arg0.getSource() == this.buttonDifusion[5]) { this.DifusionRates(5, "Cell 6"); } if (arg0.getSource() == this.buttonDifusion[6]) { this.DifusionRates(6, "Cell 7"); } if (arg0.getSource() == this.buttonDifusion[7]) { this.DifusionRates(7, "Cell 8"); } if (arg0.getSource() == this.buttonDifusion[8]) { this.DifusionRates(8, "Cell 9"); } if (arg0.getSource() == this.buttonDifusion[9]) { this.DifusionRates(9, "Cell 10"); } if (arg0.getSource() == this.buttonDifusion[10]) { this.DifusionRates(10, "Cell 11"); } if (arg0.getSource() == this.buttonDifusion[11]) { this.DifusionRates(11, "Cell 12"); } if (arg0.getSource() == this.buttonDifusion[12]) { this.DifusionRates(12, "Cell 13"); } if (arg0.getSource() == this.buttonDifusion[13]) { this.DifusionRates(13, "Cell 14"); } if (arg0.getSource() == this.buttonDifusion[14]) { this.DifusionRates(14, "Cell 15"); } if (arg0.getSource() == this.buttonDifusion[15]) { this.DifusionRates(15, "Cell 1"); } } private void DifusionRates(int CellID, String Name) { this.setDifusionWindows = new SetDifusionRates(this.World, CellID, Name, this.setNeighbours(CellID)); Vector n = this.setNeighbours(CellID); this.setDifusionWindows.setCellCombobox(); this.setDifusionWindows.setVisible(true); } private Vector setNeighbours(int CellID) { Vector<Integer> neighbours = new Vector<Integer>(); int ID = CellID - 1; if (ID >= 0 && this.World.contain(ID)) { neighbours.addElement(new Integer(ID)); } ID = CellID + 1; if (ID < 16 && this.World.contain(ID)) { neighbours.addElement(new Integer(ID)); } ID = CellID - 4; if (ID >= 0 && this.World.contain(ID)) { neighbours.addElement(new Integer(ID)); } ID = CellID + 4; if (ID < 16 && this.World.contain(ID)) { neighbours.addElement(new Integer(ID)); } return neighbours; } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JMenuItem About; private javax.swing.JMenuItem AddCell; private javax.swing.JMenuItem AddSpecie; private javax.swing.JMenuItem Exit; private javax.swing.JMenuItem Help; private javax.swing.JCheckBoxMenuItem PauseMenuItem; private javax.swing.JMenuItem SimulationConf; private javax.swing.JMenuItem Start; private javax.swing.JMenuItem Stop; private javax.swing.JMenu jMenu1; private javax.swing.JMenu jMenu2; private javax.swing.JMenu jMenu6; private javax.swing.JMenuBar jMenuBar6; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanelpos1; private javax.swing.JPanel jPanelpos10; private javax.swing.JPanel jPanelpos11; private javax.swing.JPanel jPanelpos12; private javax.swing.JPanel jPanelpos13; private javax.swing.JPanel jPanelpos14; private javax.swing.JPanel jPanelpos15; private javax.swing.JPanel jPanelpos16; private javax.swing.JPanel jPanelpos2; private javax.swing.JPanel jPanelpos3; private javax.swing.JPanel jPanelpos4; private javax.swing.JPanel jPanelpos5; private javax.swing.JPanel jPanelpos6; private javax.swing.JPanel jPanelpos7; private javax.swing.JPanel jPanelpos8; private javax.swing.JPanel jPanelpos9; // End of variables declaration//GEN-END:variables //tengo que copiar la configuracin de una celda a la otra para que no se pierda cuando aades ms especies private void setSameParameters(Cell cell, Cell oldCell) { for (int i = 0; i < oldCell.getNSpecies(); i++) { } } }