1 package org.woehlke.computer.kurzweil.tabs.dla; 2 3 import lombok.EqualsAndHashCode; 4 import lombok.Getter; 5 import lombok.ToString; 6 import lombok.extern.log4j.Log4j2; 7 import org.woehlke.computer.kurzweil.tabs.ComputerKurzweilTabbedPane; 8 import org.woehlke.computer.kurzweil.tabs.TabPanel; 9 import org.woehlke.computer.kurzweil.tabs.Tab; 10 11 import java.awt.event.ActionEvent; 12 13 @Log4j2 14 @Getter 15 @ToString(callSuper = true, exclude = {"tabCtx","canvas"}) 16 @EqualsAndHashCode(callSuper=true, exclude = {"tabCtx","canvas"}) 17 public class DiffusionLimitedAggregationTab extends TabPanel implements Tab, DiffusionLimitedAggregation { 18 19 private final DiffusionLimitedAggregationContext tabCtx; 20 private final DiffusionLimitedAggregationCanvas canvas; 21 private final DiffusionLimitedAggregationModel tabModel; 22 private final DiffusionLimitedAggregationTabPane diffusionLimitedAggregationTabPane; 23 24 public DiffusionLimitedAggregationTab(ComputerKurzweilTabbedPane tabbedPane) { 25 super(tabbedPane, TAB_TYPE ); 26 this.tabCtx = new DiffusionLimitedAggregationContext(this ); 27 this.diffusionLimitedAggregationTabPane = new DiffusionLimitedAggregationTabPane( this ); 28 this.canvas = this.tabCtx.getCanvas(); 29 this.tabModel = this.canvas.getTabModel(); 30 this.add(this.panelSubtitle); 31 this.add(this.canvas); 32 this.add(this.diffusionLimitedAggregationTabPane); 33 this.tabModel.stop(); 34 this.diffusionLimitedAggregationTabPane.stop(); 35 } 36 37 @Override 38 public void start() { 39 log.info("start"); 40 this.tabModel.start(); 41 this.diffusionLimitedAggregationTabPane.start(); 42 this.tabCtx.startController(); 43 this.ctx.getFrame().pack(); 44 int x = this.canvas.getWidth(); 45 int y = this.canvas.getHeight(); 46 super.ctx.getFrame().showMe(); 47 log.info("started with canvas x="+x+" y="+y); 48 } 49 50 @Override 51 public void stop() { 52 log.info("stop"); 53 this.tabModel.stop(); 54 this.tabCtx.stopController(); 55 this.diffusionLimitedAggregationTabPane.stop(); 56 int x = this.canvas.getWidth(); 57 int y = this.canvas.getHeight(); 58 super.ctx.getFrame().showMe(); 59 log.info("stopped with canvas x="+x+" y="+y); 60 } 61 62 @Override 63 public void actionPerformed(ActionEvent ae) { 64 if(ae.getSource() == this.diffusionLimitedAggregationTabPane.getStartButton()){ 65 super.ctx.getFrame().start(); 66 } 67 if(ae.getSource() == this.diffusionLimitedAggregationTabPane.getStopButton()){ 68 super.ctx.getFrame().stop(); 69 } 70 } 71 }