initial commit
This commit is contained in:
commit
558139141c
73
build.xml
Normal file
73
build.xml
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- You may freely edit this file. See commented blocks below for -->
|
||||||
|
<!-- some examples of how to customize the build. -->
|
||||||
|
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||||
|
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||||
|
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||||
|
<!-- the Compile on Save feature is turned off for the project. -->
|
||||||
|
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||||
|
<!-- in the project's Project Properties dialog box.-->
|
||||||
|
<project name="CancerGrowth" default="default" basedir=".">
|
||||||
|
<description>Builds, tests, and runs the project CancerGrowth.</description>
|
||||||
|
<import file="nbproject/build-impl.xml"/>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
There exist several targets which are by default empty and which can be
|
||||||
|
used for execution of your tasks. These targets are usually executed
|
||||||
|
before and after some main targets. They are:
|
||||||
|
|
||||||
|
-pre-init: called before initialization of project properties
|
||||||
|
-post-init: called after initialization of project properties
|
||||||
|
-pre-compile: called before javac compilation
|
||||||
|
-post-compile: called after javac compilation
|
||||||
|
-pre-compile-single: called before javac compilation of single file
|
||||||
|
-post-compile-single: called after javac compilation of single file
|
||||||
|
-pre-compile-test: called before javac compilation of JUnit tests
|
||||||
|
-post-compile-test: called after javac compilation of JUnit tests
|
||||||
|
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||||
|
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||||
|
-pre-jar: called before JAR building
|
||||||
|
-post-jar: called after JAR building
|
||||||
|
-post-clean: called after cleaning build products
|
||||||
|
|
||||||
|
(Targets beginning with '-' are not intended to be called on their own.)
|
||||||
|
|
||||||
|
Example of inserting an obfuscator after compilation could look like this:
|
||||||
|
|
||||||
|
<target name="-post-compile">
|
||||||
|
<obfuscate>
|
||||||
|
<fileset dir="${build.classes.dir}"/>
|
||||||
|
</obfuscate>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
For list of available properties check the imported
|
||||||
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
|
||||||
|
Another way to customize the build is by overriding existing main targets.
|
||||||
|
The targets of interest are:
|
||||||
|
|
||||||
|
-init-macrodef-javac: defines macro for javac compilation
|
||||||
|
-init-macrodef-junit: defines macro for junit execution
|
||||||
|
-init-macrodef-debug: defines macro for class debugging
|
||||||
|
-init-macrodef-java: defines macro for class execution
|
||||||
|
-do-jar: JAR building
|
||||||
|
run: execution of project
|
||||||
|
-javadoc-build: Javadoc generation
|
||||||
|
test-report: JUnit report generation
|
||||||
|
|
||||||
|
An example of overriding the target for project execution could look like this:
|
||||||
|
|
||||||
|
<target name="run" depends="CancerGrowth-impl.jar">
|
||||||
|
<exec dir="bin" executable="launcher.exe">
|
||||||
|
<arg file="${dist.jar}"/>
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
Notice that the overridden target depends on the jar target and not only on
|
||||||
|
the compile target as the regular run target does. Again, for a list of available
|
||||||
|
properties which you can use, check the target you are overriding in the
|
||||||
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
-->
|
||||||
|
</project>
|
4
build/built-jar.properties
Normal file
4
build/built-jar.properties
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#Wed, 30 Jan 2019 20:03:25 -0600
|
||||||
|
|
||||||
|
|
||||||
|
C\:\\Users\\cd109\\Desktop\\apcs\\Projects\\chapter-03\\CancerGrowth=
|
BIN
build/classes/cancergrowth/CancerGrowth$1.class
Normal file
BIN
build/classes/cancergrowth/CancerGrowth$1.class
Normal file
Binary file not shown.
BIN
build/classes/cancergrowth/CancerGrowth.class
Normal file
BIN
build/classes/cancergrowth/CancerGrowth.class
Normal file
Binary file not shown.
BIN
build/classes/cancergrowth/Cell.class
Normal file
BIN
build/classes/cancergrowth/Cell.class
Normal file
Binary file not shown.
BIN
build/classes/cancergrowth/CellPanel$1.class
Normal file
BIN
build/classes/cancergrowth/CellPanel$1.class
Normal file
Binary file not shown.
BIN
build/classes/cancergrowth/CellPanel$2.class
Normal file
BIN
build/classes/cancergrowth/CellPanel$2.class
Normal file
Binary file not shown.
BIN
build/classes/cancergrowth/CellPanel.class
Normal file
BIN
build/classes/cancergrowth/CellPanel.class
Normal file
Binary file not shown.
BIN
build/classes/cancergrowth/ComboBoxRenderer.class
Normal file
BIN
build/classes/cancergrowth/ComboBoxRenderer.class
Normal file
Binary file not shown.
BIN
build/classes/cancergrowth/createImage.class
Normal file
BIN
build/classes/cancergrowth/createImage.class
Normal file
Binary file not shown.
BIN
build/classes/cancergrowth/main.class
Normal file
BIN
build/classes/cancergrowth/main.class
Normal file
Binary file not shown.
BIN
build/classes/cancergrowth/main2.class
Normal file
BIN
build/classes/cancergrowth/main2.class
Normal file
Binary file not shown.
BIN
dist/CancerGrowth.jar
vendored
Normal file
BIN
dist/CancerGrowth.jar
vendored
Normal file
Binary file not shown.
32
dist/README.TXT
vendored
Normal file
32
dist/README.TXT
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
========================
|
||||||
|
BUILD OUTPUT DESCRIPTION
|
||||||
|
========================
|
||||||
|
|
||||||
|
When you build an Java application project that has a main class, the IDE
|
||||||
|
automatically copies all of the JAR
|
||||||
|
files on the projects classpath to your projects dist/lib folder. The IDE
|
||||||
|
also adds each of the JAR files to the Class-Path element in the application
|
||||||
|
JAR files manifest file (MANIFEST.MF).
|
||||||
|
|
||||||
|
To run the project from the command line, go to the dist folder and
|
||||||
|
type the following:
|
||||||
|
|
||||||
|
java -jar "CancerGrowth.jar"
|
||||||
|
|
||||||
|
To distribute this project, zip up the dist folder (including the lib folder)
|
||||||
|
and distribute the ZIP file.
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
* If two JAR files on the project classpath have the same name, only the first
|
||||||
|
JAR file is copied to the lib folder.
|
||||||
|
* Only JAR files are copied to the lib folder.
|
||||||
|
If the classpath contains other types of files or folders, these files (folders)
|
||||||
|
are not copied.
|
||||||
|
* If a library on the projects classpath also has a Class-Path element
|
||||||
|
specified in the manifest,the content of the Class-Path element has to be on
|
||||||
|
the projects runtime path.
|
||||||
|
* To set a main class in a standard Java project, right-click the project node
|
||||||
|
in the Projects window and choose Properties. Then click Run and enter the
|
||||||
|
class name in the Main Class field. Alternatively, you can manually type the
|
||||||
|
class name in the manifest Main-Class element.
|
BIN
dist/lib/swing-layout-1.0.4.jar
vendored
Normal file
BIN
dist/lib/swing-layout-1.0.4.jar
vendored
Normal file
Binary file not shown.
3
manifest.mf
Normal file
3
manifest.mf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
X-COMMENT: Main-Class will be added automatically by build
|
||||||
|
|
1420
nbproject/build-impl.xml
Normal file
1420
nbproject/build-impl.xml
Normal file
File diff suppressed because it is too large
Load Diff
8
nbproject/genfiles.properties
Normal file
8
nbproject/genfiles.properties
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
build.xml.data.CRC32=fac1c412
|
||||||
|
build.xml.script.CRC32=cb6c7ccd
|
||||||
|
build.xml.stylesheet.CRC32=8064a381@1.80.1.48
|
||||||
|
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||||
|
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||||
|
nbproject/build-impl.xml.data.CRC32=fac1c412
|
||||||
|
nbproject/build-impl.xml.script.CRC32=0dd90c6f
|
||||||
|
nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
|
0
nbproject/private/config.properties
Normal file
0
nbproject/private/config.properties
Normal file
6
nbproject/private/private.properties
Normal file
6
nbproject/private/private.properties
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
compile.on.save=false
|
||||||
|
do.depend=false
|
||||||
|
do.jar=true
|
||||||
|
javac.debug=true
|
||||||
|
javadoc.preview=true
|
||||||
|
user.properties.file=C:\\Users\\cd109\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
|
11
nbproject/private/private.xml
Normal file
11
nbproject/private/private.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||||
|
<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">
|
||||||
|
<group>
|
||||||
|
<file>file:/C:/Users/cd109/Desktop/apcs/Projects/chapter-03/CancerGrowth/src/cancergrowth/CellPanel.java</file>
|
||||||
|
<file>file:/C:/Users/cd109/Desktop/apcs/Projects/chapter-03/CancerGrowth/src/cancergrowth/CancerGrowth.java</file>
|
||||||
|
<file>file:/C:/Users/cd109/Desktop/apcs/Projects/chapter-03/CancerGrowth/src/cancergrowth/Cell.java</file>
|
||||||
|
</group>
|
||||||
|
</open-files>
|
||||||
|
</project-private>
|
77
nbproject/project.properties
Normal file
77
nbproject/project.properties
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
annotation.processing.enabled=true
|
||||||
|
annotation.processing.enabled.in.editor=false
|
||||||
|
annotation.processing.processors.list=
|
||||||
|
annotation.processing.run.all.processors=true
|
||||||
|
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||||
|
application.title=CancerGrowth
|
||||||
|
application.vendor=cd109
|
||||||
|
build.classes.dir=${build.dir}/classes
|
||||||
|
build.classes.excludes=**/*.java,**/*.form
|
||||||
|
# This directory is removed when the project is cleaned:
|
||||||
|
build.dir=build
|
||||||
|
build.generated.dir=${build.dir}/generated
|
||||||
|
build.generated.sources.dir=${build.dir}/generated-sources
|
||||||
|
# Only compile against the classpath explicitly listed here:
|
||||||
|
build.sysclasspath=ignore
|
||||||
|
build.test.classes.dir=${build.dir}/test/classes
|
||||||
|
build.test.results.dir=${build.dir}/test/results
|
||||||
|
# Uncomment to specify the preferred debugger connection transport:
|
||||||
|
#debug.transport=dt_socket
|
||||||
|
debug.classpath=\
|
||||||
|
${run.classpath}
|
||||||
|
debug.test.classpath=\
|
||||||
|
${run.test.classpath}
|
||||||
|
# Files in build.classes.dir which should be excluded from distribution jar
|
||||||
|
dist.archive.excludes=
|
||||||
|
# This directory is removed when the project is cleaned:
|
||||||
|
dist.dir=dist
|
||||||
|
dist.jar=${dist.dir}/CancerGrowth.jar
|
||||||
|
dist.javadoc.dir=${dist.dir}/javadoc
|
||||||
|
endorsed.classpath=
|
||||||
|
excludes=
|
||||||
|
includes=**
|
||||||
|
jar.compress=false
|
||||||
|
javac.classpath=\
|
||||||
|
${libs.swing-layout.classpath}
|
||||||
|
# Space-separated list of extra javac options
|
||||||
|
javac.compilerargs=
|
||||||
|
javac.deprecation=false
|
||||||
|
javac.external.vm=true
|
||||||
|
javac.processorpath=\
|
||||||
|
${javac.classpath}
|
||||||
|
javac.source=1.8
|
||||||
|
javac.target=1.8
|
||||||
|
javac.test.classpath=\
|
||||||
|
${javac.classpath}:\
|
||||||
|
${build.classes.dir}
|
||||||
|
javac.test.processorpath=\
|
||||||
|
${javac.test.classpath}
|
||||||
|
javadoc.additionalparam=
|
||||||
|
javadoc.author=false
|
||||||
|
javadoc.encoding=${source.encoding}
|
||||||
|
javadoc.noindex=false
|
||||||
|
javadoc.nonavbar=false
|
||||||
|
javadoc.notree=false
|
||||||
|
javadoc.private=false
|
||||||
|
javadoc.splitindex=true
|
||||||
|
javadoc.use=true
|
||||||
|
javadoc.version=false
|
||||||
|
javadoc.windowtitle=
|
||||||
|
main.class=cancergrowth.CancerGrowth
|
||||||
|
manifest.file=manifest.mf
|
||||||
|
meta.inf.dir=${src.dir}/META-INF
|
||||||
|
mkdist.disabled=false
|
||||||
|
platform.active=default_platform
|
||||||
|
run.classpath=\
|
||||||
|
${javac.classpath}:\
|
||||||
|
${build.classes.dir}
|
||||||
|
# Space-separated list of JVM arguments used when running the project.
|
||||||
|
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
|
||||||
|
# To set system properties for unit tests define test-sys-prop.name=value:
|
||||||
|
run.jvmargs=
|
||||||
|
run.test.classpath=\
|
||||||
|
${javac.test.classpath}:\
|
||||||
|
${build.test.classes.dir}
|
||||||
|
source.encoding=UTF-8
|
||||||
|
src.dir=src
|
||||||
|
test.src.dir=test
|
15
nbproject/project.xml
Normal file
15
nbproject/project.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||||
|
<type>org.netbeans.modules.java.j2seproject</type>
|
||||||
|
<configuration>
|
||||||
|
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||||
|
<name>CancerGrowth</name>
|
||||||
|
<source-roots>
|
||||||
|
<root id="src.dir"/>
|
||||||
|
</source-roots>
|
||||||
|
<test-roots>
|
||||||
|
<root id="test.src.dir"/>
|
||||||
|
</test-roots>
|
||||||
|
</data>
|
||||||
|
</configuration>
|
||||||
|
</project>
|
29
src/cancergrowth/CancerGrowth.java
Normal file
29
src/cancergrowth/CancerGrowth.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package cancergrowth;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* File Name: CancerGrowth.java
|
||||||
|
* Created: Oct 4, 2017
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CancerGrowth extends javax.swing.JFrame
|
||||||
|
{
|
||||||
|
//Constructor code for the frame
|
||||||
|
public CancerGrowth(String s)
|
||||||
|
{
|
||||||
|
super(s);
|
||||||
|
super.setContentPane(new CellPanel());
|
||||||
|
super.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
|
||||||
|
super.setLocation(50, 50);
|
||||||
|
super.setResizable(false);
|
||||||
|
super.pack();
|
||||||
|
}
|
||||||
|
|
||||||
|
//<editor-fold defaultstate="collapsed" desc="--This method will launch your application--">
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
javax.swing.JFrame.setDefaultLookAndFeelDecorated(false);
|
||||||
|
java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new CancerGrowth("Cancer Simulation").setVisible(true); } } );
|
||||||
|
}
|
||||||
|
//</editor-fold>
|
||||||
|
|
||||||
|
}
|
139
src/cancergrowth/Cell.java
Normal file
139
src/cancergrowth/Cell.java
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
package cancergrowth;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.lang.Math;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Scanner;
|
||||||
|
/*
|
||||||
|
* File Name: Cell.java
|
||||||
|
* Created: Nov 7, 2018
|
||||||
|
* Author:
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public class Cell extends Object
|
||||||
|
{
|
||||||
|
|
||||||
|
private int xval;
|
||||||
|
private int yval;
|
||||||
|
private Color myColor;
|
||||||
|
private ArrayList<Integer> stages = new ArrayList<Integer>();
|
||||||
|
private int currentStage;
|
||||||
|
private int currentTime;
|
||||||
|
public Cell(int x, int y, Color C)
|
||||||
|
{
|
||||||
|
xval = x;
|
||||||
|
yval = y;
|
||||||
|
myColor = C;
|
||||||
|
stages.add(10 + (int) (Math.random() * 3 - 1));
|
||||||
|
stages.add(6 + (int) (Math.random() * 3 - 1));
|
||||||
|
stages.add(3 + (int) (Math.random() * 3 - 1));
|
||||||
|
stages.add(1 + (int) (Math.random() * 2));
|
||||||
|
currentTime = 0;
|
||||||
|
currentStage = 0;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "(" + xval + ", " + yval + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getX()
|
||||||
|
{
|
||||||
|
return xval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getY()
|
||||||
|
{
|
||||||
|
return yval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getColor()
|
||||||
|
{
|
||||||
|
return myColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int moveTo(int x, int y)
|
||||||
|
{
|
||||||
|
xval = x;
|
||||||
|
yval = y;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
public Cell performTime() {
|
||||||
|
this.currentTime ++;
|
||||||
|
Cell newcell = this;
|
||||||
|
//System.out.println("Increased Current Time to:" + this.currentTime);
|
||||||
|
if(this.currentTime > stages.get(this.currentStage)) {
|
||||||
|
if(currentStage == 3) {
|
||||||
|
// SPLIT
|
||||||
|
int width = (int) (-50 + Math.random()*101);
|
||||||
|
int height = (int) (-50 + Math.random()*101);
|
||||||
|
while (width < 20 && width > -20) width = (int) (-50 + Math.random()*101);
|
||||||
|
while (height < 20 && height > -20) height = (int) (-50 + Math.random()*101);
|
||||||
|
newcell = new Cell(xval + width, yval + height, new Color(255, 0, 0, 100));
|
||||||
|
//stages = new ArrayList<Integer>();
|
||||||
|
//stages.add(10 + (int) Math.random() * 3 - 1);
|
||||||
|
//stages.add(7 + (int) Math.random() * 3 - 1);
|
||||||
|
//stages.add(3 + (int) Math.random() * 3 - 1);
|
||||||
|
//stages.add(1 + (int) Math.random() * 2);
|
||||||
|
|
||||||
|
xval -= width;
|
||||||
|
yval -= height;
|
||||||
|
currentStage = 0;
|
||||||
|
currentTime = 1;
|
||||||
|
myColor = new Color(255, 0, 0, 100);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.currentStage ++;
|
||||||
|
this.currentTime = 0;
|
||||||
|
if(currentStage == 1) myColor = new Color(255, 255, 0, 100);
|
||||||
|
if(currentStage == 2) myColor = new Color(0, 255, 0, 100);
|
||||||
|
if(currentStage == 3) myColor = new Color(0, 0, 255, 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newcell;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image getImage()
|
||||||
|
{
|
||||||
|
Image canvas = new BufferedImage(50, 50, BufferedImage.TYPE_INT_ARGB);
|
||||||
|
Graphics g = canvas.getGraphics();
|
||||||
|
|
||||||
|
g.setColor(this.getColor());
|
||||||
|
|
||||||
|
int width = 50;
|
||||||
|
int pos = 0;
|
||||||
|
if (currentStage == 0) {
|
||||||
|
width = (int) ((currentTime + 1) * 2 + 22.5);
|
||||||
|
pos = (50 - width) / 2;
|
||||||
|
}
|
||||||
|
g.fillOval(pos, pos, width, width);
|
||||||
|
g.setColor(Color.BLACK);
|
||||||
|
g.drawOval(pos, pos, width, width);
|
||||||
|
StringBuilder x = new StringBuilder("");
|
||||||
|
if(currentStage == 0) x.append("G1");
|
||||||
|
if(currentStage == 1) x.append("S");
|
||||||
|
if(currentStage == 2) x.append("G2");
|
||||||
|
if(currentStage == 3) x.append("M");
|
||||||
|
g.drawString(x.toString(), 20, 30);
|
||||||
|
return canvas;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cell clone(int x, int y)
|
||||||
|
{
|
||||||
|
Cell out = new Cell(x, y, getColor());
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
public Cell combine(Cell in) {
|
||||||
|
int r = (this.getColor().getRed() + in.getColor().getRed()) / 2;
|
||||||
|
int g = (this.getColor().getGreen() + in.getColor().getGreen()) / 2;
|
||||||
|
int b = (this.getColor().getBlue() + in.getColor().getBlue()) / 2;
|
||||||
|
Cell out = new Cell((in.getX() + this.getX())/2, (in.getY() + this.getY())/2, new Color(r, g, b));
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
}
|
79
src/cancergrowth/CellPanel.form
Normal file
79
src/cancergrowth/CellPanel.form
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<Form version="1.3" maxVersion="1.3" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||||
|
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
|
||||||
|
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||||
|
</AuxValues>
|
||||||
|
|
||||||
|
<Layout>
|
||||||
|
<DimensionLayout dim="0">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="speed" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace pref="662" max="32767" attributes="0"/>
|
||||||
|
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Group type="103" groupAlignment="1" max="-2" attributes="0">
|
||||||
|
<Group type="103" alignment="0" groupAlignment="3" attributes="0">
|
||||||
|
<Component id="jButton1" alignment="3" pref="0" max="32767" attributes="0"/>
|
||||||
|
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<Component id="speed" alignment="0" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace pref="967" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<Component class="javax.swing.JSlider" name="speed">
|
||||||
|
<Properties>
|
||||||
|
<Property name="maximum" type="int" value="1000"/>
|
||||||
|
<Property name="minimum" type="int" value="1"/>
|
||||||
|
<Property name="paintLabels" type="boolean" value="true"/>
|
||||||
|
<Property name="paintTicks" type="boolean" value="true"/>
|
||||||
|
<Property name="snapToTicks" type="boolean" value="true"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="mouseReleased" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="speedMouseReleased"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||||
|
<Properties>
|
||||||
|
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||||
|
<Font name="Dialog" size="18" style="1"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="text" type="java.lang.String" value="Delay:"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="jButton1">
|
||||||
|
<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="Start"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Form>
|
218
src/cancergrowth/CellPanel.java
Normal file
218
src/cancergrowth/CellPanel.java
Normal file
@ -0,0 +1,218 @@
|
|||||||
|
package cancergrowth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File Name: CellPanel.java
|
||||||
|
* Created: Oct 02, 2017
|
||||||
|
* Author:
|
||||||
|
*/
|
||||||
|
import java.util.*;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import javax.swing.Timer;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import javax.swing.event.ChangeListener;
|
||||||
|
|
||||||
|
public class CellPanel extends javax.swing.JPanel implements ActionListener, ChangeListener
|
||||||
|
{
|
||||||
|
private Timer swingTimer;
|
||||||
|
//private JButton go;
|
||||||
|
//private JSlider speed;
|
||||||
|
private int delay;
|
||||||
|
private boolean growing = false;
|
||||||
|
int count = 0;
|
||||||
|
long time0 = System.nanoTime();
|
||||||
|
long time1 = time0;
|
||||||
|
private boolean draw = false;
|
||||||
|
|
||||||
|
ArrayList<Cell> cells = new ArrayList<Cell>();
|
||||||
|
|
||||||
|
Graphics g2;
|
||||||
|
Image canvas;
|
||||||
|
|
||||||
|
public CellPanel()
|
||||||
|
{
|
||||||
|
|
||||||
|
super();
|
||||||
|
this.initComponents();
|
||||||
|
|
||||||
|
//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, 100));
|
||||||
|
//choice1.addItem(t2);
|
||||||
|
cells.add(t2);
|
||||||
|
//choice2.addItem(t2);
|
||||||
|
|
||||||
|
//choice1.setRenderer(new ComboBoxRenderer());
|
||||||
|
//choice2.setRenderer(new ComboBoxRenderer());
|
||||||
|
speed.setValue(250);
|
||||||
|
delay = speed.getValue();
|
||||||
|
swingTimer = new Timer(delay, this);
|
||||||
|
//swingTimer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e)
|
||||||
|
{
|
||||||
|
time1 = System.nanoTime() - time0;
|
||||||
|
time0 = System.nanoTime();
|
||||||
|
if (swingTimer.isRunning())
|
||||||
|
{
|
||||||
|
speed.setEnabled(true);
|
||||||
|
//go.setText("Play ");
|
||||||
|
//swingTimer.stop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
speed.setEnabled(false);
|
||||||
|
swingTimer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
//canvas = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
|
||||||
|
//g2 = canvas.getGraphics();
|
||||||
|
for (int k = 0; k < cells.size(); k++)
|
||||||
|
{
|
||||||
|
Cell t = cells.get(k);
|
||||||
|
Cell rec = t.performTime();
|
||||||
|
if (t != rec) {
|
||||||
|
cells.add(rec);
|
||||||
|
}
|
||||||
|
//g2.drawImage(t.getImage(), t.getX(), t.getY(), this);
|
||||||
|
}
|
||||||
|
growing = true;
|
||||||
|
count ++;
|
||||||
|
//System.out.println("ACTION PERFORMED");
|
||||||
|
super.repaint();
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void stateChanged(ChangeEvent ce)
|
||||||
|
{
|
||||||
|
delay = speed.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paintComponent(Graphics g)
|
||||||
|
{
|
||||||
|
super.paintComponent(g);
|
||||||
|
//g.setColor(Color.BLACK);
|
||||||
|
|
||||||
|
|
||||||
|
int x = cells.size() - 1;
|
||||||
|
//g.drawImage(canvas, 0, 0, this);
|
||||||
|
for (int k = x; k >= 0; k--)
|
||||||
|
{
|
||||||
|
Cell t = cells.get(k);
|
||||||
|
/*if(k > cells.size() / 4) {
|
||||||
|
g.setColor(t.getColor());
|
||||||
|
g.fillOval(t.getX(), t.getY(), 50, 50);
|
||||||
|
} else*/
|
||||||
|
//if (draw || cells.size() > 100000000) {
|
||||||
|
g.drawImage(t.getImage(), t.getX(), t.getY(), this);
|
||||||
|
//swingTimer.stop();
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
jLabel1.setText("Delay: " + delay + "ms. Hours since start: " + count + ". Cell Count: " + cells.size());
|
||||||
|
//System.out.println("Speed: " + (int) (delay / (time1 / 100000000.0)) + "%");
|
||||||
|
growing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** This method is called from within the constructor to initialize the form.
|
||||||
|
*
|
||||||
|
* WARNING: Do NOT modify this code by hand. 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()
|
||||||
|
{
|
||||||
|
|
||||||
|
speed = new javax.swing.JSlider();
|
||||||
|
jLabel1 = new javax.swing.JLabel();
|
||||||
|
jButton1 = new javax.swing.JButton();
|
||||||
|
|
||||||
|
speed.setMaximum(1000);
|
||||||
|
speed.setMinimum(1);
|
||||||
|
speed.setPaintLabels(true);
|
||||||
|
speed.setPaintTicks(true);
|
||||||
|
speed.setSnapToTicks(true);
|
||||||
|
speed.addMouseListener(new java.awt.event.MouseAdapter()
|
||||||
|
{
|
||||||
|
public void mouseReleased(java.awt.event.MouseEvent evt)
|
||||||
|
{
|
||||||
|
speedMouseReleased(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
jLabel1.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
|
||||||
|
jLabel1.setText("Delay:");
|
||||||
|
|
||||||
|
jButton1.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
|
||||||
|
jButton1.setText("Start");
|
||||||
|
jButton1.addActionListener(new java.awt.event.ActionListener()
|
||||||
|
{
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt)
|
||||||
|
{
|
||||||
|
jButton1ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
|
||||||
|
this.setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||||
|
.add(layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.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)
|
||||||
|
.add(jLabel1)
|
||||||
|
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 662, Short.MAX_VALUE)
|
||||||
|
.add(jButton1)
|
||||||
|
.add(18, 18, 18))
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||||
|
.add(layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
|
||||||
|
.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(jLabel1))
|
||||||
|
.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
|
||||||
|
|
||||||
|
private void speedMouseReleased(java.awt.event.MouseEvent evt)//GEN-FIRST:event_speedMouseReleased
|
||||||
|
{//GEN-HEADEREND:event_speedMouseReleased
|
||||||
|
// 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
|
||||||
|
// TODO add your handling code here:
|
||||||
|
swingTimer.setDelay(delay);
|
||||||
|
swingTimer.start();
|
||||||
|
|
||||||
|
}//GEN-LAST:event_jButton1ActionPerformed
|
||||||
|
|
||||||
|
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JButton jButton1;
|
||||||
|
private javax.swing.JLabel jLabel1;
|
||||||
|
private javax.swing.JSlider speed;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user