Skip to content

Commit

Permalink
fixed #5
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaswoehlke committed Feb 19, 2020
1 parent ba1a266 commit 0f67722
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.woehlke.computer.kurzweil.tabs.evolution.cell.CellLifeCycle;

import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import java.awt.*;
import java.beans.Transient;
Expand Down Expand Up @@ -65,6 +66,14 @@ public CompoundBorder getBorder(String label){
);
}

public Border getCanvasBorder() {
int top = 24;
int left = 0;
int bottom = 24;
int right = 0;
return BorderFactory.createEmptyBorder(top,left,bottom,right);
}

@Transient
public Rectangle getFrameBounds(){
int x = this.properties.getAllinone().getLattice().getWidth();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,18 @@
*/
@Log
@Getter
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper=true)
@ToString(callSuper = true, exclude = {"tabCtx","border","preferredSize","layout","colorScheme","lattice"})
@EqualsAndHashCode(callSuper=true, exclude = {"tabCtx","border","preferredSize","layout","colorScheme","lattice"})
public class CyclicCellularAutomatonCanvas extends JComponent implements
Serializable, TabCanvas, TabModel {

private static final long serialVersionUID = -3057254130516052936L;

@ToString.Exclude
private final CyclicCellularAutomatonContext tabCtx;
@ToString.Exclude
private final CyclicCellularAutomatonColorScheme colorScheme;
@ToString.Exclude
private final CompoundBorder border;
@ToString.Exclude
private final CanvasLayout layout;
@ToString.Exclude
private final Border border;
private final Dimension preferredSize;

@ToString.Exclude
private final CanvasLayout layout;
private final CyclicCellularAutomatonColorScheme colorScheme;
private volatile int[][][] lattice;
private volatile int source;
private volatile int target;
Expand All @@ -66,21 +59,18 @@ public class CyclicCellularAutomatonCanvas extends JComponent implements

public CyclicCellularAutomatonCanvas(CyclicCellularAutomatonContext tabCtx) {
this.tabCtx = tabCtx;
this.border = this.tabCtx.getCtx().getCanvasBorder();
this.worldX = this.tabCtx.getCtx().getWorldDimensions().getX();
this.worldY = this.tabCtx.getCtx().getWorldDimensions().getY();
this.border = this.tabCtx.getCtx().getBorder();
//Rectangle r = this.tabCtx.getCtx().getCanvasBounds();
this.layout = new CanvasLayout(this);
this.preferredSize = new Dimension(worldX,worldY);
this.versions = 2;
this.colorScheme = new CyclicCellularAutomatonColorScheme();
//this.setBorder(border);
this.setLayout(layout);
this.setPreferredSize(preferredSize);
this.setMinimumSize(preferredSize);
this.setMaximumSize(preferredSize);
this.setSize(this.worldX,this.worldY);
//this.setBounds(r);
this.startWithNeighbourhoodVonNeumann();
this.resetLattice();
this.running = Boolean.FALSE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
@Log
@Getter
@ToString(callSuper = true, exclude = {"tabCtx","border","preferredSize","layout","particles"})
@EqualsAndHashCode(callSuper=true)
@EqualsAndHashCode(callSuper=true, exclude = {"tabCtx","border","preferredSize","layout","particles"})
public class DiffusionLimitedAggregationCanvas extends JComponent implements
Serializable, TabCanvas, TabModel {

private final DiffusionLimitedAggregationContext tabCtx;
private final CompoundBorder border;
private final Border border;
private final Dimension preferredSize;
private final CanvasLayout layout;
private volatile List<LatticePoint> particles = new ArrayList<>();
Expand All @@ -59,22 +59,19 @@ public DiffusionLimitedAggregationCanvas(
DiffusionLimitedAggregationContext tabCtx
) {
this.tabCtx = tabCtx;
this.border = this.tabCtx.getCtx().getCanvasBorder();
worldX = this.tabCtx.getCtx().getWorldDimensions().getX();
worldY = this.tabCtx.getCtx().getWorldDimensions().getY();
border = this.tabCtx.getCtx().getBorder();
//Rectangle r = this.tabCtx.getCtx().getCanvasBounds();
this.layout = new CanvasLayout(this);
this.preferredSize = new Dimension(worldX,worldY);
this.initialNumberOfParticles = this.tabCtx.getCtx().getProperties().getDla().getControl().getNumberOfParticles();
this.worldMap = new int[this.worldX][this.worldY];
//this.setBorder(border);
this.setBackground(MEDIUM);
this.setLayout(layout);
this.setPreferredSize(preferredSize);
this.setMinimumSize(preferredSize);
this.setMaximumSize(preferredSize);
this.setSize(worldX,worldY);
//this.setBounds(r);
int x;
int y;
//create moving Particles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,17 @@
*/
@Log
@Getter
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper=true)
@ToString(callSuper = true, exclude={"tabCtx","border","preferredSize","layout","tab"})
@EqualsAndHashCode(callSuper=true, exclude={"tabCtx","border","preferredSize","layout","tab"})
public class SimulatedEvolutionCanvas extends JComponent implements
Serializable, TabCanvas, Startable {

private static final long serialVersionUID = -27002509360079509L;

@ToString.Exclude
private final SimulatedEvolutionContext tabCtx;
@ToString.Exclude
private final CompoundBorder border;
@ToString.Exclude
private final Border border;
private final CanvasLayout layout;
@ToString.Exclude
private final Dimension preferredSize;
@ToString.Exclude
private final SimulatedEvolutionTab tab;
private final PopulationStatistics statisticsPanel;
private final SimulatedEvolutionCanvasButtons buttonRowPanel;
Expand All @@ -69,23 +64,20 @@ public SimulatedEvolutionCanvas(
) {
this.tab = tab;
this.tabCtx = tab.getTabCtx();
this.border = this.tabCtx.getCtx().getCanvasBorder();
this.worldX = this.tabCtx.getCtx().getWorldDimensions().getWidth();
this.worldY = this.tabCtx.getCtx().getWorldDimensions().getHeight();
this.border = this.tabCtx.getCtx().getBorder();
//Rectangle r = this.tabCtx.getCtx().getCanvasBounds();
this.world = new SimulatedEvolutionWorld(this.tabCtx);
this.statisticsPanel = new PopulationStatistics(this.tabCtx);
this.buttonRowPanel = new SimulatedEvolutionCanvasButtons(this.tabCtx);
this.preferredSize = new Dimension(worldX,worldY);
this.layout = new CanvasLayout(this);
//this.setBorder(border);
this.setLayout(layout);
this.setBackground(COLOR_WATER.getColor());
this.setSize(preferredSize);
this.setPreferredSize(preferredSize);
this.setMinimumSize(preferredSize);
this.setMaximumSize(preferredSize);
//this.setBounds(r);
}

public void toggleGardenOfEden() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,15 @@
*/
@Log
@Getter
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper=true)
@ToString(callSuper = true,exclude={"tabCtx","border","preferredSize","layout","gaussianNumberPlaneBaseJulia","gaussianNumberPlaneMandelbrot"})
@EqualsAndHashCode(callSuper=true,exclude={"tabCtx","border","preferredSize","layout","gaussianNumberPlaneBaseJulia","gaussianNumberPlaneMandelbrot"})
public class MandelbrotCanvas extends JComponent implements TabCanvas, MouseListener {

@ToString.Exclude
private final MandelbrotContext tabCtx;
@ToString.Exclude
private final CompoundBorder border;
@ToString.Exclude
private final Border border;
private final Dimension preferredSize;
@ToString.Exclude
private final CanvasLayout layout;
@ToString.Exclude
private final GaussianNumberPlaneBaseJulia gaussianNumberPlaneBaseJulia;
@ToString.Exclude
private final GaussianNumberPlaneMandelbrot gaussianNumberPlaneMandelbrot;
private final Mandelbrot mandelbrot;

Expand All @@ -58,22 +52,20 @@ public MandelbrotCanvas(
MandelbrotContext tabCtx
) {
this.tabCtx = tabCtx;
this.border = this.tabCtx.getCtx().getBorder();
this.border = this.tabCtx.getCtx().getCanvasBorder();
this.worldX = this.tabCtx.getCtx().getWorldDimensions().getWidth();
this.worldY = this.tabCtx.getCtx().getWorldDimensions().getHeight();
this.layout = new CanvasLayout(this);
// Rectangle r = this.tabCtx.getCtx().getCanvasBounds();
this.gaussianNumberPlaneBaseJulia = new GaussianNumberPlaneBaseJulia( this.tabCtx);
this.gaussianNumberPlaneMandelbrot = new GaussianNumberPlaneMandelbrot( this.tabCtx);
this.mandelbrot = new Mandelbrot(this.tabCtx);
this.preferredSize = new Dimension(worldX, worldY);
//this.setBorder(border);
this.setBorder(border);
this.setLayout(layout);
this.setSize(this.preferredSize);
this.setPreferredSize(this.preferredSize);
this.setMinimumSize(preferredSize);
this.setMaximumSize(preferredSize);
//this.setBounds(r);
}

public CellStatus getCellStatusFor(int x, int y) {
Expand Down
2 changes: 1 addition & 1 deletion allinone/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ allinone:
copyright: '(c) 2020 Thomas Woehlke'
borderPaddingX: 5
borderPaddingY: 5
titleHeight: 30
titleHeight: 60
startStopp: 'Start / Stop'
start: 'Start'
stop: 'Stop'
Expand Down

0 comments on commit 0f67722

Please sign in to comment.