net.fractalkiss.util
Class Fragger

java.lang.Object
  |
  +--net.fractalkiss.util.Util
        |
        +--net.fractalkiss.util.Fragger

public class Fragger
extends Util

Utility class that performs fragmentation of frames.


Constructor Summary
Fragger()
          Creates new Fragger with 8 default levels
Fragger(int levels)
          Creates new Fragger with given levels
 
Method Summary
 char frag(int n, int b, int pos)
          Gets a fragmented of frame b from level n at byte position pos
 char[] frag(java.util.LinkedList frames, int n, int b)
          FRAG(n,b) implementation
 void fragAll(java.util.LinkedList frames, int levels)
          Makes sure all necessary fragments are in memory
 char[] inand(java.util.LinkedList frames, int n, int b)
          Implementation of INAND(n,b) or iterative nand
 char[] ixor(int n, int b)
          convenience method to retreive stored IXOR from LinkedList
 char[] ixor(java.util.LinkedList frames, int n, int b)
          Implementation of IXOR(n,b) or recursive xor
 boolean nextFrame(char[] frame)
          Stores a frame in the intermal buffer and calls fragAll when buffer is full, removes a frame when buffer overflows.
 void workCube(char[][][] cube, int frame)
          Populates fractal 3D table from internal frag table
 void workPlane(char[][] plane, int frame)
          Populates given fractal table from internal frag buffer.
 
Methods inherited from class net.fractalkiss.util.Util
and, fill02, fill03, nand, or, writeBytes, writePlane, xor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Fragger

public Fragger()
Creates new Fragger with 8 default levels

Fragger

public Fragger(int levels)
Creates new Fragger with given levels
Parameters:
levels - number of fragmentation levels
Method Detail

frag

public char frag(int n,
                 int b,
                 int pos)
Gets a fragmented of frame b from level n at byte position pos
Parameters:
n - fragmentation level
b - frame number
pos - position in frame array
Returns:
returns requested byte

nextFrame

public boolean nextFrame(char[] frame)
Stores a frame in the intermal buffer and calls fragAll when buffer is full, removes a frame when buffer overflows.
Parameters:
frame - char array representing frame bytes
Returns:
returns true if fragAll was called, false otherwise

workPlane

public void workPlane(char[][] plane,
                      int frame)
Populates given fractal table from internal frag buffer.
Parameters:
plane - 2D char array
frame - number of bytes per frame

workCube

public void workCube(char[][][] cube,
                     int frame)
Populates fractal 3D table from internal frag table
Parameters:
cube - 3D char array
frame - number of bytes per frame

fragAll

public void fragAll(java.util.LinkedList frames,
                    int levels)
Makes sure all necessary fragments are in memory
Parameters:
frames - bytes per frame
levels - buffer size, 8

frag

public char[] frag(java.util.LinkedList frames,
                   int n,
                   int b)
FRAG(n,b) implementation
 FRAG(n,b) = INAND(n-1,b) NAND FRAME(b)
 FRAG(0,b) = FRAME(b)
 
Parameters:
frames - bytes per frame
n - fragmentation level
b - frame number
Returns:
frame b fragmented at level n

inand

public char[] inand(java.util.LinkedList frames,
                    int n,
                    int b)
Implementation of INAND(n,b) or iterative nand
 INAND(n,b) = IXOR(n,b) NAND IXOR(n-1,b) NAND...NAND IXOR(0,b)
 INAND(0,b) = IXOR(0,b)
 iterates nanding xor masks from bottom to top
 
Parameters:
frames - bytes per frame
n - nand level
b - frame number
Returns:
dividing shape

ixor

public char[] ixor(int n,
                   int b)
convenience method to retreive stored IXOR from LinkedList
Parameters:
n - xor level
b - frame number
Returns:
xor mask for every byte

ixor

public char[] ixor(java.util.LinkedList frames,
                   int n,
                   int b)
Implementation of IXOR(n,b) or recursive xor
 IXOR(n,b) = IXOR(n-1,b) XOR IXOR(n-1,b plus 1) (go figure, plus sign doesn't show)
 IXOR(0,b) = FRAME(b) XOR FRAME (b plus 1)
 
calculates xor masks of shapes and their movements
Parameters:
frames - bytes per frame
n - xor level
b - frame number
Returns:
xor mask