1 package org.woehlke.computer.kurzweil.tabs.cca.canvas; 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.commons.widgets.SubTabImpl; 8 import org.woehlke.computer.kurzweil.tabs.cca.CyclicCellularAutomaton; 9 import org.woehlke.computer.kurzweil.tabs.cca.CyclicCellularAutomatonCanvas; 10 11 import javax.swing.*; 12 import javax.swing.border.CompoundBorder; 13 import java.awt.*; 14 15 @Log4j2 16 @Getter 17 @ToString(callSuper = true, exclude = {"buttonVonNeumann","buttonMoore","buttonWoehlke","canvas"}) 18 @EqualsAndHashCode(callSuper=true, exclude = {"buttonVonNeumann","buttonMoore","buttonWoehlke","canvas"}) 19 public class PanelNeighbourhoodButtons extends SubTabImpl implements CyclicCellularAutomaton { 20 21 private final JButton buttonVonNeumann; 22 private final JButton buttonMoore; 23 private final JButton buttonWoehlke; 24 private final String buttonLabelVonNeumann; 25 private final String buttonLabelMoore; 26 private final String buttonLabelWoehlke; 27 private final CyclicCellularAutomatonCanvas canvas; 28 private final CompoundBorder cyclicCellularAutomatonButtonsBorder; 29 private final FlowLayout cyclicCellularAutomatonButtonsLayout; 30 31 public PanelNeighbourhoodButtons( 32 CyclicCellularAutomatonCanvas canvas 33 ) { 34 super(canvas.getTabCtx().getCtx().getProperties().getCca().getView().getNeighborhood().getTitle(),canvas.getTabCtx().getCtx().getProperties()); 35 this.canvas = canvas; 36 this.buttonLabelVonNeumann = this.canvas.getTabCtx().getCtx().getProperties().getCca().getView().getNeighborhood().getTypeVonNeumann(); 37 this.buttonLabelMoore =this.canvas.getTabCtx().getCtx().getProperties().getCca().getView().getNeighborhood().getTypeMoore(); 38 this.buttonLabelWoehlke =this.canvas.getTabCtx().getCtx().getProperties().getCca().getView().getNeighborhood().getTypeWoehlke(); 39 this.buttonVonNeumann = new JButton(this.buttonLabelVonNeumann); 40 this.buttonMoore = new JButton(this.buttonLabelMoore ); 41 this.buttonWoehlke = new JButton(this.buttonLabelWoehlke); 42 this.cyclicCellularAutomatonButtonsBorder = this.canvas.getTabCtx().getCtx().getBottomButtonsPanelBorder(super.getTitle()); 43 this.cyclicCellularAutomatonButtonsLayout = new FlowLayout(); 44 this.setBorder(cyclicCellularAutomatonButtonsBorder); 45 this.setLayout(cyclicCellularAutomatonButtonsLayout); 46 this.add(this.buttonVonNeumann); 47 this.add(this.buttonMoore); 48 this.add(this.buttonWoehlke); 49 } 50 51 }