1 package org.woehlke.computer.kurzweil.tabs.cca.views; 2 3 import lombok.EqualsAndHashCode; 4 import lombok.Getter; 5 import lombok.ToString; 6 import lombok.extern.java.Log; 7 import org.woehlke.computer.kurzweil.commons.widgets.SubTabImpl; 8 import org.woehlke.computer.kurzweil.tabs.cca.config.CyclicCellularAutomaton; 9 import org.woehlke.computer.kurzweil.tabs.cca.canvas.CyclicCellularAutomatonCanvas; 10 11 import javax.swing.*; 12 import javax.swing.border.CompoundBorder; 13 import java.awt.*; 14 15 @Log 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 static final long serialVersionUID = 7526471155622776147L; 22 23 private final JLabel neighborhoodLabel; 24 private final JRadioButton buttonVonNeumann; 25 private final JRadioButton buttonMoore; 26 private final JRadioButton buttonWoehlke; 27 private final JButton buttonRestart = new JButton("Restart"); 28 private final ButtonGroup bgroup = new ButtonGroup(); 29 30 private final CyclicCellularAutomatonCanvas canvas; 31 32 public PanelNeighbourhoodButtons( 33 CyclicCellularAutomatonCanvas canvas 34 ) { 35 super( 36 canvas.getTabCtx().getCtx().getProperties().getCca().getView().getNeighborhood().getTitle(), 37 canvas.getTabCtx().getCtx().getProperties() 38 ); 39 this.canvas = canvas; 40 41 String buttonLabelVonNeumann = this.canvas.getTabCtx().getCtx().getProperties().getCca().getView().getNeighborhood().getTypeVonNeumann(); 42 String buttonLabelMoore =this.canvas.getTabCtx().getCtx().getProperties().getCca().getView().getNeighborhood().getTypeMoore(); 43 String buttonLabelWoehlke =this.canvas.getTabCtx().getCtx().getProperties().getCca().getView().getNeighborhood().getTypeWoehlke(); 44 45 this.neighborhoodLabel = new JLabel("Neighbourhood:"); 46 this.buttonVonNeumann = new JRadioButton(buttonLabelVonNeumann, true); 47 this.buttonMoore = new JRadioButton(buttonLabelMoore); 48 this.buttonWoehlke = new JRadioButton(buttonLabelWoehlke); 49 50 bgroup.add(buttonVonNeumann); 51 bgroup.add(buttonMoore); 52 bgroup.add(buttonWoehlke); 53 54 CompoundBorder cyclicCellularAutomatonButtonsBorder = this.canvas.getTabCtx().getCtx().getBottomButtonsPanelBorder(super.getTitle()); 55 FlowLayout cyclicCellularAutomatonButtonsLayout = new FlowLayout(); 56 this.setBorder(cyclicCellularAutomatonButtonsBorder); 57 this.setLayout(cyclicCellularAutomatonButtonsLayout); 58 59 this.add(neighborhoodLabel); 60 this.add(buttonVonNeumann); 61 this.add(buttonMoore); 62 this.add(buttonWoehlke); 63 this.add(buttonRestart); 64 } 65 }