Skip to content

Commit

Permalink
Fractal dimension output with sensible popup
Browse files Browse the repository at this point in the history
  • Loading branch information
sjpollard committed Nov 19, 2018
1 parent 52052e1 commit fd63d7f
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 78 deletions.
112 changes: 44 additions & 68 deletions .idea/workspace.xml

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

6 changes: 6 additions & 0 deletions src/mandelbrot/DimensionFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ public void updateGridlines() {
logOfNoBoxes[iteration - 1] = Math.log(boxes);
logOfSideLengths[iteration - 1] = Math.log(1.0 / argandDiagram.currentLength);
}
else if (!argandDiagram.start) {

String output = "Box counting dimension: " + new RegressionCalculator(logOfSideLengths, logOfNoBoxes).calculateGradient();
JOptionPane.showMessageDialog(this, output, "Fractal dimension", JOptionPane.PLAIN_MESSAGE);

}
argandDiagram.repaint();

}
Expand Down
16 changes: 6 additions & 10 deletions src/mandelbrot/GridArgandDiagram.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,16 @@ public void paintComponent(Graphics g) {
/**Draws gridlines across the screen for the DimensionFrame to count from*/
public void drawGridlines(Graphics g) {

if (start) {
g.setColor(colours.getInverse());
for (int x = 0; x < this.getWidth(); x += currentLength - 1) {
g.setColor(colours.getInverse());
for (int x = 0; x < this.getWidth(); x += currentLength - 1) {

g.drawLine(x, 0, x, this.getHeight());
g.drawLine(x, 0, x, this.getHeight());

}
for (int y = 0; y < this.getHeight(); y += currentLength - 1) {
}
for (int y = 0; y < this.getHeight(); y += currentLength - 1) {

g.drawLine(0, y, this.getWidth(), y);
g.drawLine(0, y, this.getWidth(), y);

}
}

}
Expand All @@ -102,8 +100,6 @@ public void drawBoxes(Graphics g) {
public void mouseClicked(MouseEvent mouseEvent) {

dimensionFrame.updateGridlines();
RegressionCalculator dimensionRegression = new RegressionCalculator(dimensionFrame.logOfSideLengths, dimensionFrame.logOfNoBoxes);
System.out.println(dimensionRegression.calculateGradient());

}

Expand Down

0 comments on commit fd63d7f

Please sign in to comment.