From 0f67722e40b83d1f3b8657c2c9b0c642a8687357 Mon Sep 17 00:00:00 2001 From: thomaswoehlke Date: Wed, 19 Feb 2020 20:58:58 +0100 Subject: [PATCH] fixed #5 --- .../ComputerKurzweilApplicationContext.java | 9 ++++++++ .../cca/CyclicCellularAutomatonCanvas.java | 22 +++++-------------- .../DiffusionLimitedAggregationCanvas.java | 9 +++----- .../evolution/SimulatedEvolutionCanvas.java | 16 ++++---------- .../tabs/mandelbrot/MandelbrotCanvas.java | 18 +++++---------- allinone/src/main/resources/application.yml | 2 +- 6 files changed, 28 insertions(+), 48 deletions(-) diff --git a/allinone/src/main/java/org/woehlke/computer/kurzweil/application/ComputerKurzweilApplicationContext.java b/allinone/src/main/java/org/woehlke/computer/kurzweil/application/ComputerKurzweilApplicationContext.java index 6f0eb7a1..b0f8a3cf 100644 --- a/allinone/src/main/java/org/woehlke/computer/kurzweil/application/ComputerKurzweilApplicationContext.java +++ b/allinone/src/main/java/org/woehlke/computer/kurzweil/application/ComputerKurzweilApplicationContext.java @@ -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; @@ -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(); diff --git a/allinone/src/main/java/org/woehlke/computer/kurzweil/tabs/cca/CyclicCellularAutomatonCanvas.java b/allinone/src/main/java/org/woehlke/computer/kurzweil/tabs/cca/CyclicCellularAutomatonCanvas.java index bca0817e..a6251048 100644 --- a/allinone/src/main/java/org/woehlke/computer/kurzweil/tabs/cca/CyclicCellularAutomatonCanvas.java +++ b/allinone/src/main/java/org/woehlke/computer/kurzweil/tabs/cca/CyclicCellularAutomatonCanvas.java @@ -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; @@ -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; diff --git a/allinone/src/main/java/org/woehlke/computer/kurzweil/tabs/dla/DiffusionLimitedAggregationCanvas.java b/allinone/src/main/java/org/woehlke/computer/kurzweil/tabs/dla/DiffusionLimitedAggregationCanvas.java index f55091cd..9385a604 100644 --- a/allinone/src/main/java/org/woehlke/computer/kurzweil/tabs/dla/DiffusionLimitedAggregationCanvas.java +++ b/allinone/src/main/java/org/woehlke/computer/kurzweil/tabs/dla/DiffusionLimitedAggregationCanvas.java @@ -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 particles = new ArrayList<>(); @@ -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 diff --git a/allinone/src/main/java/org/woehlke/computer/kurzweil/tabs/evolution/SimulatedEvolutionCanvas.java b/allinone/src/main/java/org/woehlke/computer/kurzweil/tabs/evolution/SimulatedEvolutionCanvas.java index 50dc796c..acdb6525 100644 --- a/allinone/src/main/java/org/woehlke/computer/kurzweil/tabs/evolution/SimulatedEvolutionCanvas.java +++ b/allinone/src/main/java/org/woehlke/computer/kurzweil/tabs/evolution/SimulatedEvolutionCanvas.java @@ -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; @@ -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() { diff --git a/allinone/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrot/MandelbrotCanvas.java b/allinone/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrot/MandelbrotCanvas.java index e2f3e4c6..e6edc4e7 100644 --- a/allinone/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrot/MandelbrotCanvas.java +++ b/allinone/src/main/java/org/woehlke/computer/kurzweil/tabs/mandelbrot/MandelbrotCanvas.java @@ -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; @@ -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) { diff --git a/allinone/src/main/resources/application.yml b/allinone/src/main/resources/application.yml index 6439e522..3a5a1027 100644 --- a/allinone/src/main/resources/application.yml +++ b/allinone/src/main/resources/application.yml @@ -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'