fix cellpanel issues

master
shark 6 years ago
parent 643e49df2e
commit 69db8aeda9

@ -26,7 +26,7 @@ public class CellPanel extends javax.swing.JPanel implements ActionListener, Cha
private int count = 0;
private boolean draw = false;
ArrayList<Cell> cells = new ArrayList<Cell>();
ArrayList<Cell> cells = new ArrayList<Cell>(10000000);
Graphics g2;
Image canvas;
@ -40,7 +40,7 @@ public class CellPanel extends javax.swing.JPanel implements ActionListener, Cha
//Cell t1 = new Cell(300, 100, Color.RED);
//choice1.addItem(t1);
//cells.add(t1);
Cell t2 = new Cell(475, 475, new Color(255, 0, 0));
Cell t2 = new Cell(475, 475);
//choice1.addItem(t2);
cells.add(t2);
//choice2.addItem(t2);
@ -104,13 +104,13 @@ public class CellPanel extends javax.swing.JPanel implements ActionListener, Cha
{
Cell t = cells.get(k);
/*if(k > cells.size() / 4) {
g.setColor(t.getColor());
//g.setColor(t.getColor());
g.fillOval(t.getX(), t.getY(), 50, 50);
} else*/
//if (draw || cells.size() > 100000000) {
if (draw || cells.size() > 10000000) {
g.drawImage(t.getImage(), t.getX(), t.getY(), this);
//swingTimer.stop();
//}
swingTimer.stop();
}
}
jLabel1.setText("Delay: " + delay + "ms. Hours since start: " + count + ". Cell Count: " + cells.size());
@ -126,7 +126,7 @@ public class CellPanel extends javax.swing.JPanel implements ActionListener, Cha
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents()
{
@ -184,29 +184,29 @@ public class CellPanel extends javax.swing.JPanel implements ActionListener, Cha
.add(org.jdesktop.layout.GroupLayout.LEADING, speed, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(967, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
}// </editor-fold>
private void speedMouseReleased(java.awt.event.MouseEvent evt)//GEN-FIRST:event_speedMouseReleased
{//GEN-HEADEREND:event_speedMouseReleased
private void speedMouseReleased(java.awt.event.MouseEvent evt)
{
// TODO add your handling code here:
delay = speed.getValue();
//swingTimer.setDelay(1000);
super.repaint();
}//GEN-LAST:event_speedMouseReleased
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton1ActionPerformed
{//GEN-HEADEREND:event_jButton1ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
swingTimer.setDelay(delay);
swingTimer.start();
}//GEN-LAST:event_jButton1ActionPerformed
}
// Variables declaration - do not modify//GEN-BEGIN:variables
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JSlider speed;
// End of variables declaration//GEN-END:variables
// End of variables declaration
}

Loading…
Cancel
Save