@@ -70,73 +70,14 @@ public MainGui() {
7070 welcomeLabel .setHorizontalAlignment (SwingConstants .CENTER );
7171 localPanel .add (welcomeLabel );
7272
73- JButton autocropButton = new JButton ("Autocrop" );
74- localPanel .add (autocropButton );
75-
76- JButton segmentationButton = new JButton ("Segmentation" );
77- localPanel .add (segmentationButton );
78-
79- JButton coordsCropButton = new JButton ("Crop From Coordinates" );
80- localPanel .add (coordsCropButton );
81-
82- JButton overlayButton = new JButton ("Overlay" );
83- localPanel .add (overlayButton );
84-
85- JButton computeParamsButton = new JButton ("Compute Parameters Nuc" );
86- localPanel .add (computeParamsButton );
87-
88- JButton nodeJButton = new JButton ("NODeJ" );
89- localPanel .add (nodeJButton );
90-
91- JButton ccSegmentButton = new JButton ("Chromocenter Segmentation" );
92- localPanel .add (ccSegmentButton );
93-
94- JButton computeCCParamsBtn = new JButton ("Compute Parameters Spots" );
95- localPanel .add (computeCCParamsBtn );
73+ for (PluginButton button : PluginButton .values ()) {
74+ JButton jButton = new JButton (button .getLabel ());
75+ jButton .addActionListener (e -> button .getPlugin ().run ("" ));
76+ localPanel .add (jButton );
77+ }
9678
9779 container .add (localPanel );
9880
99- // Action listeners for buttons
100- autocropButton .addActionListener (e -> {
101- PlugIn autocrop = new Autocrop_ ();
102- autocrop .run ("" );
103- });
104-
105- segmentationButton .addActionListener (e -> {
106- PlugIn segmentation = new Segmentation_ ();
107- segmentation .run ("" );
108- });
109-
110- coordsCropButton .addActionListener (e -> {
111- PlugIn cropFromCoordinates = new CropFromCoordinates_ ();
112- cropFromCoordinates .run ("" );
113- });
114-
115- overlayButton .addActionListener (e -> {
116- PlugIn overlay = new GenerateOverlay_ ();
117- overlay .run ("" );
118- });
119-
120- computeParamsButton .addActionListener (e -> {
121- PlugIn computeParameters = new ComputeParametersPlugin_ ();
122- computeParameters .run ("" );
123- });
124-
125- nodeJButton .addActionListener (e -> {
126- PlugIn nodej = new NODeJ ();
127- nodej .run ("" );
128- });
129-
130- ccSegmentButton .addActionListener (e -> {
131- PlugIn ccSegmentation = new ChromocenterSegmentationBatchPlugin_ ();
132- ccSegmentation .run ("" );
133- });
134-
135- computeCCParamsBtn .addActionListener (e -> {
136- PlugIn computeCcParameters = new ChromocentersAnalysisBatchPlugin_ ();
137- computeCcParameters .run ("" );
138- });
139-
14081 // Repack GUI to ensure all components are laid out correctly
14182 super .pack ();
14283
@@ -151,4 +92,49 @@ public MainGui() {
15192 LOGGER .info ("Main GUI initialized" );
15293 }
15394
95+
96+ /** Enumeration of plugin buttons with their labels and associated plugins. */
97+ private enum PluginButton {
98+ AUTOCROP ("Autocrop" , new Autocrop_ ()),
99+ SEGMENTATION ("Segmentation" , new Segmentation_ ()),
100+ CROP_COORDS ("Crop From Coordinates" , new CropFromCoordinates_ ()),
101+ OVERLAY ("Overlay" , new GenerateOverlay_ ()),
102+ COMPUTE_PARAMS ("Compute Parameters Nuc" , new ComputeParametersPlugin_ ()),
103+ NODEJ ("NODeJ" , new NODeJ ()),
104+ CC_SEGMENT ("Chromocenter Segmentation" , new ChromocenterSegmentationBatchPlugin_ ()),
105+ COMPUTE_CC_PARAMS ("Compute Parameters Spots" , new ChromocentersAnalysisBatchPlugin_ ());
106+
107+ private final String label ;
108+ private final PlugIn plugin ;
109+
110+ /**
111+ * Constructor for PluginButton.
112+ *
113+ * @param label the label of the button
114+ * @param plugin the plugin instance to be executed when the button is clicked
115+ */
116+ PluginButton (String label , PlugIn plugin ) {
117+ this .label = label ;
118+ this .plugin = plugin ;
119+ }
120+
121+ /**
122+ * Returns the label of the action button.
123+ *
124+ * @return the label of the button
125+ */
126+ public String getLabel () {
127+ return label ;
128+ }
129+
130+ /**
131+ * Returns the plugin associated with this action button.
132+ *
133+ * @return the plugin instance
134+ */
135+ public PlugIn getPlugin () {
136+ return plugin ;
137+ }
138+ }
139+
154140}
0 commit comments