aboutsummaryrefslogtreecommitdiff
path: root/Week8/src/qtrees/GreyNode.java
diff options
context:
space:
mode:
authorCamil Staps2015-04-18 13:44:44 +0200
committerCamil Staps2015-04-18 13:44:44 +0200
commit6a44b074f0169a1b0f9e92347af929c5e471746e (patch)
treeae5663fe7c69881bf4ecfedbef99c2505f8ec964 /Week8/src/qtrees/GreyNode.java
parentAdded copyright to docs (diff)
Reorganised projects
Diffstat (limited to 'Week8/src/qtrees/GreyNode.java')
-rw-r--r--Week8/src/qtrees/GreyNode.java59
1 files changed, 0 insertions, 59 deletions
diff --git a/Week8/src/qtrees/GreyNode.java b/Week8/src/qtrees/GreyNode.java
deleted file mode 100644
index 326b0af..0000000
--- a/Week8/src/qtrees/GreyNode.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package qtrees;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/**
- * A "grey" node (contains both black and white leaves)
- *
- * @author Camil Staps, s4498062
- */
-public class GreyNode extends QTNode {
-
- /** The four children, starting at North West, counting clockwise */
- private final QTNode children[];
-
- public GreyNode() {
- children = new QTNode[4];
- }
-
- @Override
- public void fillBitmap(int x, int y, int width, Bitmap bitmap) {
- children[0].fillBitmap(x, y, width / 2, bitmap);
- children[1].fillBitmap(x + width / 2, y, width / 2, bitmap);
- children[2].fillBitmap(x + width / 2, y + width / 2, width / 2, bitmap);
- children[3].fillBitmap(x, y + width / 2, width / 2, bitmap);
- }
-
- @Override
- public void writeNode(Writer out) throws IOException {
- out.write("1");
- for (QTNode child : children)
- child.writeNode(out);
- }
-
- /**
- * Set one of the children nodes
- * @param index the position of the child: 0 = NW; 1 = NE; 2 = SE; 3 = SW
- * @param child the child node
- */
- public void setChild(int index, QTNode child) {
- assert (index >= 0 && index <= 3);
-
- children[index] = child;
- }
-
- /**
- * Compress the current node
- * @return a BlackLeaf if all the children are black, a WhiteLeaf if all the
- * children are white, or itself otherwise.
- */
- QTNode compress() {
- if (children[0].getClass() == children[1].getClass()
- && children[1].getClass() == children[2].getClass()
- && children[2].getClass() == children[3].getClass())
- return children[0];
- return this;
- }
-
-}