From 514ddbfe1d3c1f773f911d17479094503ab26d95 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 23 Mar 2015 22:20:04 +0100 Subject: Framework week 8 --- .gitignore | 3 +- Week8/build.xml | 73 ++ Week8/nbproject/build-impl.xml | 1413 +++++++++++++++++++++++++++++++++++ Week8/nbproject/genfiles.properties | 8 + Week8/nbproject/project.properties | 71 ++ Week8/nbproject/project.xml | 15 + Week8/src/qtrees/Bitmap.java | 73 ++ Week8/src/qtrees/QTNode.java | 23 + Week8/src/qtrees/QTree.java | 34 + Week8/src/qtrees/Qtrees.java | 24 + 10 files changed, 1736 insertions(+), 1 deletion(-) create mode 100644 Week8/build.xml create mode 100644 Week8/nbproject/build-impl.xml create mode 100644 Week8/nbproject/genfiles.properties create mode 100644 Week8/nbproject/project.properties create mode 100644 Week8/nbproject/project.xml create mode 100644 Week8/src/qtrees/Bitmap.java create mode 100644 Week8/src/qtrees/QTNode.java create mode 100644 Week8/src/qtrees/QTree.java create mode 100644 Week8/src/qtrees/Qtrees.java diff --git a/.gitignore b/.gitignore index 41924c7..3a96f78 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ /Week6/build/ /Week7/build/ /Week5/build/ -/Week4/dist/ \ No newline at end of file +/Week4/dist/ +/Week8/nbproject/private/ \ No newline at end of file diff --git a/Week8/build.xml b/Week8/build.xml new file mode 100644 index 0000000..201f305 --- /dev/null +++ b/Week8/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project Week8. + + + diff --git a/Week8/nbproject/build-impl.xml b/Week8/nbproject/build-impl.xml new file mode 100644 index 0000000..4f2d68b --- /dev/null +++ b/Week8/nbproject/build-impl.xml @@ -0,0 +1,1413 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Week8/nbproject/genfiles.properties b/Week8/nbproject/genfiles.properties new file mode 100644 index 0000000..6c1d314 --- /dev/null +++ b/Week8/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=cc255a7c +build.xml.script.CRC32=28c657a8 +build.xml.stylesheet.CRC32=8064a381@1.75.2.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=cc255a7c +nbproject/build-impl.xml.script.CRC32=2d3c14a2 +nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 diff --git a/Week8/nbproject/project.properties b/Week8/nbproject/project.properties new file mode 100644 index 0000000..9fd49f7 --- /dev/null +++ b/Week8/nbproject/project.properties @@ -0,0 +1,71 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +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}/Week8.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.7 +javac.target=1.7 +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= +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=true +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 diff --git a/Week8/nbproject/project.xml b/Week8/nbproject/project.xml new file mode 100644 index 0000000..75d13e1 --- /dev/null +++ b/Week8/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + Week8 + + + + + + + + + diff --git a/Week8/src/qtrees/Bitmap.java b/Week8/src/qtrees/Bitmap.java new file mode 100644 index 0000000..551c4c4 --- /dev/null +++ b/Week8/src/qtrees/Bitmap.java @@ -0,0 +1,73 @@ +package qtrees; + +/** + * Bitmap: A class for representing bitmap; + * @author Sjaak Smetsers + * @version 18-03-2015 + */ +public class Bitmap { + // each bit is stored into an two dimensional array + private final boolean[][] raster; + private final int bmWidth, bmHeight; + + /** + * Creates an empty bitmap of size width * height + * @param width + * @param height + */ + public Bitmap( int width, int height ) { + raster = new boolean[width][height]; + bmWidth = width; + bmHeight = height; + } + + /** + * Gets a bit at the specified position + * @param x: x coordinate + * @param y: y coordinate + */ + public boolean getBit( int x, int y ) { + return raster[x][y]; + } + + /** + * Sets a bit at the specified position + * @param x: x coordinate + * @param y: y coordinate + * @param val: the bit value + */ + public void setBit( int x, int y, boolean val ){ + raster[x][y] = val; + } + + /** + * Converts a bitmap into a string + * 1 is represented by '*'; 0 by 'O' + * @return the string representation + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + for (int y = 0; y < bmHeight; y++) { + for (int x = 0; x < bmWidth; x++) { + sb.append( raster[x][y] ? '*' : 'O' ); + } + sb.append( '\n' ); + } + return sb.toString(); + } + + /** + * @return the width of the bitmap + */ + public int getWidth() { + return bmWidth; + } + + /** + * @return the height of the bitmap + */ + public int getHeight() { + return bmHeight; + } +} diff --git a/Week8/src/qtrees/QTNode.java b/Week8/src/qtrees/QTNode.java new file mode 100644 index 0000000..4498dff --- /dev/null +++ b/Week8/src/qtrees/QTNode.java @@ -0,0 +1,23 @@ + +package qtrees; + +import java.io.Writer; + +/** + * + * @author Sjaak Smetsers + * @version 18-03-2014 + */ +public abstract class QTNode { + public abstract void fillBitmap( int x, int y, int width, Bitmap bitmap ); + public abstract void writeNode( Writer out ); + public abstract boolean sameLeaf( QTNode other_node ); + + public static void fillArea( int x, int y, int width, Bitmap bitmap, boolean val ){ + for (int i = 0; i < width; i++) { + for (int j = 0; j < width; j++) { + bitmap.setBit(x+i, y+j, val); + } + } + } +} diff --git a/Week8/src/qtrees/QTree.java b/Week8/src/qtrees/QTree.java new file mode 100644 index 0000000..ab11898 --- /dev/null +++ b/Week8/src/qtrees/QTree.java @@ -0,0 +1,34 @@ +package qtrees; + +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; + +public class QTree { + QTNode root; + + public QTree( Reader input ) { + root = readQTree( input ); + } + + public QTree( Bitmap bitmap ) { + root = bitmap2QTree( 0, 0, bitmap.getWidth(), bitmap ); + } + + public void fillBitmap ( Bitmap bitmap ) { + root.fillBitmap(0, 0, bitmap.getWidth(), bitmap); + } + + public void writeQTree( Writer sb ) { + root.writeNode( sb ); + } + + private static QTNode readQTree( Reader input ) { + return null; + } + + public static QTNode bitmap2QTree( int x, int y, int width, Bitmap bitmap ) { + return null; + } + +} diff --git a/Week8/src/qtrees/Qtrees.java b/Week8/src/qtrees/Qtrees.java new file mode 100644 index 0000000..7bd018e --- /dev/null +++ b/Week8/src/qtrees/Qtrees.java @@ -0,0 +1,24 @@ +package qtrees; + +import java.io.StringReader; + +/** + * + * @author Sjaak + */ +public class Qtrees { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + String test_tekst = "10011010001010010001010101100011000101000000"; + StringReader input = new StringReader(test_tekst); + QTree qt = new QTree( input ); + Bitmap bitmap = new Bitmap(8, 8); + qt.fillBitmap( bitmap ); + System.out.println(bitmap); + + } + +} -- cgit v1.2.3