white blood cells

master
ThirstyShark 6 years ago
parent c57fe1d821
commit 98f6c0f768

@ -1,4 +1,4 @@
#Tue, 05 Feb 2019 18:09:27 -0600 #Thu, 07 Feb 2019 21:38:24 -0600
C\:\\Users\\cd109\\Desktop\\CancerGrowth= C\:\\Users\\cd109\\Desktop\\temp2\\CancerGrowth=

@ -3,9 +3,9 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group> <group>
<file>file:/C:/Users/cd109/Desktop/CancerGrowth/src/cancergrowth/Cell.java</file> <file>file:/C:/Users/cd109/Desktop/temp2/CancerGrowth/src/cancergrowth/CellPanel.java</file>
<file>file:/C:/Users/cd109/Desktop/CancerGrowth/src/cancergrowth/CancerGrowth.java</file> <file>file:/C:/Users/cd109/Desktop/temp2/CancerGrowth/src/cancergrowth/Cell.java</file>
<file>file:/C:/Users/cd109/Desktop/CancerGrowth/src/cancergrowth/CellPanel.java</file> <file>file:/C:/Users/cd109/Desktop/temp2/CancerGrowth/src/cancergrowth/CancerGrowth.java</file>
</group> </group>
</open-files> </open-files>
</project-private> </project-private>

@ -104,16 +104,16 @@ public class Cell extends Object
Graphics gg0 = g0.getGraphics(); Graphics gg0 = g0.getGraphics();
if (transparent) if (transparent)
{ {
gg0.setColor(new Color(80, 80, 80, 127)); gg0.setColor(new Color(165, 0, 255, 127));
} }
else else
{ {
gm.setColor(new Color(80, 80, 80)); gm.setColor(new Color(165, 0, 255));
} }
gg0.fillOval(0, 0, 50, 50); gg0.fillOval(0, 0, 50, 50);
gg0.setColor(Color.BLACK); gg0.setColor(Color.BLACK);
gg0.drawOval(0, 0, 50, 50); gg0.drawOval(0, 0, 50, 50);
gg0.drawString("G0", 18, 30); gg0.drawString("WBC", 12, 30);
p0 = g0; p0 = g0;
} }

@ -21,7 +21,9 @@
<Component id="speed" min="-2" max="-2" attributes="0"/> <Component id="speed" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/> <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="593" max="32767" attributes="0"/> <EmptySpace pref="513" max="32767" attributes="0"/>
<Component id="jButton3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jButton2" min="-2" pref="63" max="-2" attributes="0"/> <Component id="jButton2" min="-2" pref="63" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/> <Component id="jButton1" min="-2" max="-2" attributes="0"/>
@ -38,6 +40,7 @@
<Component id="jButton1" alignment="3" pref="0" max="32767" attributes="0"/> <Component id="jButton1" alignment="3" pref="0" max="32767" attributes="0"/>
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButton3" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Component id="speed" alignment="0" max="32767" attributes="0"/> <Component id="speed" alignment="0" max="32767" attributes="0"/>
</Group> </Group>
@ -89,5 +92,16 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JButton" name="jButton3">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="14" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="Stable"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton3ActionPerformed"/>
</Events>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

@ -25,6 +25,7 @@ public class CellPanel extends javax.swing.JPanel implements ActionListener, Cha
private boolean growing = false; private boolean growing = false;
private int count = 0; private int count = 0;
private boolean kill = false; private boolean kill = false;
private boolean dontkill = false;
private int pacmanx, pacmany; private int pacmanx, pacmany;
private int cycle; private int cycle;
private boolean cycledir = true; private boolean cycledir = true;
@ -106,7 +107,7 @@ public class CellPanel extends javax.swing.JPanel implements ActionListener, Cha
g.fillOval(t.getX(), t.getY(), 50, 50); g.fillOval(t.getX(), t.getY(), 50, 50);
} else*/ } else*/
//if (cells.size() > 10000000) { // we can simulate until 10000000 first to see what happens isntead of waiting //if (cells.size() > 10000000) { // we can simulate until 10000000 first to see what happens isntead of waiting
if(kill && (Math.abs(pacmanx + 40 - t.getX()) < 50) && (Math.abs(pacmany + 25 - t.getY()) < 75)) { if(kill && !dontkill && (Math.abs(pacmanx + 40 - t.getX()) < 50) && (Math.abs(pacmany + 25 - t.getY()) < 75)) {
cells.remove(t); // If pacman is here, have him eat the cell cells.remove(t); // If pacman is here, have him eat the cell
} }
else g.drawImage(t.getImage(), t.getX(), t.getY(), this); // otherwise, draw the cell else g.drawImage(t.getImage(), t.getX(), t.getY(), this); // otherwise, draw the cell
@ -114,7 +115,7 @@ public class CellPanel extends javax.swing.JPanel implements ActionListener, Cha
//swingTimer.stop(); //swingTimer.stop();
//} //}
} }
if(kill) { // draw pacman if he needs to be drawn if(kill && !dontkill) { // draw pacman if he needs to be drawn
g.setColor(Color.YELLOW); g.setColor(Color.YELLOW);
g.fillArc(pacmanx, pacmany, 100, 100, 220 - cycle * 2, 280 + cycle * 4); g.fillArc(pacmanx, pacmany, 100, 100, 220 - cycle * 2, 280 + cycle * 4);
if (pacmanx > -100) { if (pacmanx > -100) {
@ -155,6 +156,7 @@ public class CellPanel extends javax.swing.JPanel implements ActionListener, Cha
jLabel1 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton(); jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
speed.setMaximum(1000); speed.setMaximum(1000);
speed.setMinimum(1); speed.setMinimum(1);
@ -192,6 +194,16 @@ public class CellPanel extends javax.swing.JPanel implements ActionListener, Cha
} }
}); });
jButton3.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
jButton3.setText("Stable");
jButton3.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
jButton3ActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
@ -201,7 +213,9 @@ public class CellPanel extends javax.swing.JPanel implements ActionListener, Cha
.add(speed, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(speed, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jLabel1) .add(jLabel1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 593, Short.MAX_VALUE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 513, Short.MAX_VALUE)
.add(jButton3)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 63, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 63, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jButton1) .add(jButton1)
@ -215,7 +229,8 @@ public class CellPanel extends javax.swing.JPanel implements ActionListener, Cha
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.add(jLabel1) .add(jLabel1)
.add(jButton2)) .add(jButton2)
.add(jButton3))
.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(959, Short.MAX_VALUE)) .addContainerGap(959, Short.MAX_VALUE))
); );
@ -236,30 +251,51 @@ public class CellPanel extends javax.swing.JPanel implements ActionListener, Cha
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton2ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton2ActionPerformed
{//GEN-HEADEREND:event_jButton2ActionPerformed {//GEN-HEADEREND:event_jButton2ActionPerformed
if(kill) { // if we press the kill button, then begin the killing if(dontkill) {
dontkill = false;
kill = true;
swingTimer.setDelay(10);
try {
FileInputStream fileInputStream = new FileInputStream("lib/pacman.mp3");
Player player = new Player(fileInputStream); // play pacman sound effect
player.play();
} catch (FileNotFoundException e) {
e.printStackTrace(); // catch any errors with the mp3
} catch (JavaLayerException e) {
e.printStackTrace();
}
}
else if(kill) { // if we press the kill button, then begin the killing
kill = false; kill = false;
swingTimer.setDelay(delay); swingTimer.setDelay(delay);
} }
else { else {
kill = true; kill = true;
swingTimer.setDelay(10); swingTimer.setDelay(10);
try { try {
FileInputStream fileInputStream = new FileInputStream("lib/pacman.mp3"); FileInputStream fileInputStream = new FileInputStream("lib/pacman.mp3");
Player player = new Player(fileInputStream); // play pacman sound effect Player player = new Player(fileInputStream); // play pacman sound effect
player.play(); player.play();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); // catch any errors with the mp3 e.printStackTrace(); // catch any errors with the mp3
} catch (JavaLayerException e) { } catch (JavaLayerException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
}//GEN-LAST:event_jButton2ActionPerformed }//GEN-LAST:event_jButton2ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton3ActionPerformed
{//GEN-HEADEREND:event_jButton3ActionPerformed
// TODO add your handling code here:
kill = true;
dontkill = true;
}//GEN-LAST:event_jButton3ActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1; private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2; private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
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//GEN-END:variables

Loading…
Cancel
Save