Skip to content

Commit

Permalink
New annotation and changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sjpollard committed Nov 16, 2018
1 parent d6737f0 commit 52052e1
Show file tree
Hide file tree
Showing 9 changed files with 188 additions and 57 deletions.
72 changes: 53 additions & 19 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 37 additions & 15 deletions src/mandelbrot/DimensionFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,39 @@
import java.awt.*;
import java.util.ArrayList;

/**
* Secondary JFrame that allows for the user to be able to find the estimated fractal dimension of a fractal.
* This object uses the box counting method to find the approximate Minkowski–Bouligand dimension of the boundary.
* As well as this, it graphically shows the user what is happening on each iteration of the box counting method.
* The more self similar the fractal, the higher the expected fractal dimension.
*/

public class DimensionFrame extends JFrame {

FractalSet fractalSet;
/**The fractal set to be measured*/
private FractalSet fractalSet;

/**Graphical component to display gridlines*/
private GridArgandDiagram argandDiagram;

private Dimension screensize;

GridArgandDiagram argandDiagram;
/**The current step of the iteration*/
private int iteration;

Dimension screensize;
/**The initial side length of the drawn boxes*/
private int initialLength;

int iteration;
int initialStep;
int boxes;
/*The total number of boxes counted in each iteration**/
private int boxes;

/**Array of log(N) where N is number of boxes*/
double[] logOfNoBoxes;

/**Array of log(1/ε) where ε is box side length*/
double[] logOfSideLengths;

/**Constucts a DimensionFrame that initially just displays the selected fractal*/
public DimensionFrame(FractalSet fractalSet, FractalColours colours, DrawingConditions conditions) {

super("Box Counting Calculator");
Expand All @@ -31,12 +50,12 @@ public DimensionFrame(FractalSet fractalSet, FractalColours colours, DrawingCond

this.fractalSet = fractalSet;
this.iteration = 0;
this.initialStep = 512;
this.initialLength = 512;
this.boxes = 0;

setupComponents(colours, conditions);

int size = (int)((Math.log(initialStep)/Math.log(2)) - 1);
int size = (int)((Math.log(initialLength)/Math.log(2)) - 1);
this.logOfNoBoxes = new double[size];
this.logOfSideLengths = new double[size];

Expand All @@ -48,6 +67,7 @@ public DimensionFrame(FractalSet fractalSet, FractalColours colours, DrawingCond

}

/**Sets up the components of this object*/
public void setupComponents(FractalColours colours, DrawingConditions conditions) {

if (fractalSet.getType() == FractalType.MANDELBROT) conditions.drawJulia = false;
Expand All @@ -57,39 +77,41 @@ public void setupComponents(FractalColours colours, DrawingConditions conditions
conditions.readyToDrawCoords = false;
conditions.readyToDrawInfo = false;

this.argandDiagram = new GridArgandDiagram(this, fractalSet, conditions, colours, screensize, initialStep);
this.argandDiagram = new GridArgandDiagram(this, fractalSet, conditions, colours, screensize, initialLength);

this.add(argandDiagram);
this.pack();

}

/**Draws the next iteration of gridlines by halving box side length*/
public void updateGridlines() {

if (!argandDiagram.finished) {
iteration++;
argandDiagram.currentStep /= 2;
argandDiagram.currentLength /= 2;
argandDiagram.start = true;
updateGrids();
logOfNoBoxes[iteration - 1] = Math.log(boxes);
logOfSideLengths[iteration - 1] = Math.log(1.0 / argandDiagram.currentStep);
logOfSideLengths[iteration - 1] = Math.log(1.0 / argandDiagram.currentLength);
}
argandDiagram.repaint();

}

/**Counts the number of grids that cover the boundary of the fractal and queues them for drawing*/
public void updateGrids() {

boxes = 0;
for (int y = 0; y < argandDiagram.getHeight(); y += argandDiagram.currentStep - 1) {
for (int y = 0; y < argandDiagram.getHeight(); y += argandDiagram.currentLength - 1) {

for (int x = 0; x < argandDiagram.getWidth(); x += argandDiagram.currentStep - 1) {
for (int x = 0; x < argandDiagram.getWidth(); x += argandDiagram.currentLength - 1) {

boolean found = false;

for (int boxY = y; boxY <= y + argandDiagram.currentStep - 1 && boxY < argandDiagram.getHeight() && !found; boxY++) {
for (int boxY = y; boxY <= y + argandDiagram.currentLength - 1 && boxY < argandDiagram.getHeight() && !found; boxY++) {

for (int boxX = x; boxX <= x + argandDiagram.currentStep - 1 && boxX < argandDiagram.getWidth() && !found; boxX++) {
for (int boxX = x; boxX <= x + argandDiagram.currentLength - 1 && boxX < argandDiagram.getWidth() && !found; boxX++) {

if (argandDiagram.getColorAtPixel(boxX, boxY).equals(argandDiagram.colours.getInner())) {

Expand Down
1 change: 1 addition & 0 deletions src/mandelbrot/DrawingConditions.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public DrawingConditions() {

}

/**Clones the current object and outputs it to separate references*/
public DrawingConditions clone() {

DrawingConditions clone = new DrawingConditions();
Expand Down
2 changes: 1 addition & 1 deletion src/mandelbrot/FractalColours.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public Color getInner() {
public void setInner(Color inner) {

this.inner = inner;
this.invertColour(inner);
invertColour(inner);

}

Expand Down
1 change: 1 addition & 0 deletions src/mandelbrot/FractalSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public interface FractalSet {

FractalType getType();

/**Clones the fractal set to separate reference*/
FractalSet clone();

void setAllValues(FractalDataSerializable fractalData);
Expand Down
Loading

0 comments on commit 52052e1

Please sign in to comment.