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

Loading…
Cancel
Save