From e1c8fdd5d42e7dcc6fb60266db1b104965ea5f03 Mon Sep 17 00:00:00 2001
From: AmlanDalai
Date: Fri, 6 Mar 2026 04:47:14 +0530
Subject: [PATCH 1/3] fix: remove duplicates .classpath entry and add missing
db/model file patterns to .gitignore
---
.gitignore | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
index 997be619..5b33b67b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,9 +15,11 @@
*.xref
/.temp-Active_Segmentation_-classpathOnly-1581890621933.jar
.classpath
-.classpath
-.classpath
.idea/
*.iml
resources/META-INF/
+*.db
+*.dbs
+*.dbs.bak
+*.sqbpro
From dc05224c54a77d48b31e5adf646cbf274a164c14 Mon Sep 17 00:00:00 2001
From: AmlanDalai
Date: Sat, 7 Mar 2026 17:44:18 +0530
Subject: [PATCH 2/3] refactor(GuiPanel): replace absolute layout with
GridBagLayout
- Replace setLayout(null) + setBounds() with BorderLayout/GridBagLayout
- Makes UI responsive to window resizing
- Fixes WindowBuilder parsing: all 9 buttons now visible in Design view
- Extract createButton() helper; remove coordinate parameters
- Remove System.out.println debug statements
- Add full Javadoc to all methods
---
src/activeSegmentation/gui/GuiPanel.java | 460 +++++++++++++----------
1 file changed, 262 insertions(+), 198 deletions(-)
diff --git a/src/activeSegmentation/gui/GuiPanel.java b/src/activeSegmentation/gui/GuiPanel.java
index 5ee73423..88ee9923 100644
--- a/src/activeSegmentation/gui/GuiPanel.java
+++ b/src/activeSegmentation/gui/GuiPanel.java
@@ -1,198 +1,262 @@
-package activeSegmentation.gui;
-
-import activeSegmentation.ASCommon;
-import activeSegmentation.feature.FeatureManager;
-import activeSegmentation.learning.ClassifierManager;
-import activeSegmentation.prj.ProjectManager;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-
-/**
- * Selector GUI class
- * @author Sumit Vohra, Dimiter Prodanov
- *
- */
-public class GuiPanel extends JFrame implements ASCommon {
-
- private JFrame mainFrame;
- private JPanel controlPanel;
- private LearningPanel learningPanel;
- private FilterPanel filterPanel;
- private FeaturePanel featurePanel;
- private ViewFilterOutputPanel filterOutputPanel;
-
-
- final ActionEvent FEATURE_BUTTON_PRESSED = new ActionEvent(this, 0, "Feature" );
- final ActionEvent FILTER_BUTTON_PRESSED = new ActionEvent(this, 1, "Filter" );
- final ActionEvent LEARNING_BUTTON_PRESSED = new ActionEvent(this, 2, "Learning" );
- final ActionEvent EVALUATION_BUTTON_PRESSED = new ActionEvent(this, 3, "Evaluation");
- final ActionEvent FILTERVIS_BUTTON_PRESSED = new ActionEvent(this, 4, "FilterVis" );
- final ActionEvent SESSIONGUI_BUTTON_PRESSED = new ActionEvent(this, 5, "SessionGUI");
- final ActionEvent VISUALIZATION_BUTTON_PRESSED = new ActionEvent(this, 8, "Visualization");
- final ActionEvent BACK_BUTTON_PRESSED = new ActionEvent(this, 6, "Back");
- final ActionEvent EXIT_BUTTON_PRESSED = new ActionEvent(this, 7, "Exit");
-
-
- private FeatureManager featureManager;
- private ClassifierManager learningManager;
- private ProjectManager projectManager;
- private EvaluationPanel evaluationPanel;
- private VisualizationPanel visualizationPanel;
-
- /**
- *
- * @param projectManager
- */
- public GuiPanel(ProjectManager projectManager) {
- System.out.println("..GuiPanel...");
- this.projectManager = projectManager;
- System.out.println("ClassifierManager init");
- learningManager = new ClassifierManager(this.projectManager);
- System.out.println("FeatureManager init");
- featureManager=new FeatureManager(this.projectManager, this.learningManager);
-
- System.out.println("init Project GuiPanel ");
- initGUI();
- }
-
- public JPanel getMainPanel() {
- return controlPanel;
- }
-
- public void doAction(ActionEvent event) {
- if ((event == this.FILTER_BUTTON_PRESSED)) {
- //if(this.filterPanel == null) {
- // for time being feature manager is passed , will think
- // of better design later
- filterPanel = new FilterPanel(projectManager,featureManager);
- //}
- SwingUtilities.invokeLater(filterPanel);
- }
-
- if(event==this.FILTERVIS_BUTTON_PRESSED){
- //if (this.filterOutputPanel==null) {
- filterOutputPanel=new ViewFilterOutputPanel(projectManager,featureManager);
- //}
- SwingUtilities.invokeLater(this.filterOutputPanel);
- }
-
- if ((event == this.FEATURE_BUTTON_PRESSED)) {
- //if (this.featurePanel == null) {
- featurePanel=new FeaturePanel(featureManager);
- //}
- SwingUtilities.invokeLater(this.featurePanel);
- }
-
- if (event == this.LEARNING_BUTTON_PRESSED) {
- //if (this.learningPanel == null) {
- learningPanel = new LearningPanel(projectManager, learningManager);
- //}
- SwingUtilities.invokeLater(learningPanel);
- }
-
- if (event == this.EVALUATION_BUTTON_PRESSED) {
- //if (evaluationPanel==null) {
- evaluationPanel = new EvaluationPanel(projectManager, null);
- //}
- SwingUtilities.invokeLater(evaluationPanel);
-
- }
-
- if (event == this.SESSIONGUI_BUTTON_PRESSED) {
- new SessionGUI(projectManager); // Create and display the SessionGUI instance
- }
-
- if (event == this.VISUALIZATION_BUTTON_PRESSED) {
- SwingUtilities.invokeLater(() -> {
- JFrame frame = new JFrame("Visualization Panel");
- frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
- frame.setSize(800, 600);
- frame.setLocationRelativeTo(null); // Center the frame
- frame.add(new VisualizationPanel());
- frame.setVisible(true);
- });
- }
-
- if (event == this.BACK_BUTTON_PRESSED) {
- mainFrame.dispose(); // Close the current window
- new CreateOpenProjectGUI(projectManager).run(); // Reopen the main window
- }
-
- // Confirm Exit
- if (event == this.EXIT_BUTTON_PRESSED) {
- int response = JOptionPane.showConfirmDialog(mainFrame, "Are you sure you want to exit?", "Confirm Exit",
- JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
- if (response == JOptionPane.YES_OPTION) {
- System.exit(0);
- }
- }
-
- }
-
-
- /**
- *
- */
- private void initGUI() {
- this.mainFrame = new JFrame("Active Segmentation v." + version);
- this.mainFrame.getContentPane().setBackground(Color.LIGHT_GRAY);
- this.mainFrame.setLocationRelativeTo(null);
- this.mainFrame.setSize(frameWidth, frameHeight);
- this.mainFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // Prevent the default close operation
-
- // Confirm Exit to intercept the window close event
- mainFrame.addWindowListener(new java.awt.event.WindowAdapter() {
- @Override
- public void windowClosing(java.awt.event.WindowEvent windowEvent) {
- if (JOptionPane.showConfirmDialog(mainFrame,
- "Are you sure you want to exit?", "Confirm Exit",
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION){
- System.exit(0);
- }
- }
- });
-
- this.controlPanel = new JPanel();
- this.controlPanel.setLayout(null);
- this.controlPanel.setBackground(Color.GRAY);
-
- JLabel label = new JLabel("Active Segmentation");
- label.setFont(largeFONT);
- label.setBounds(130, 5, 450, 100);
- label.setForeground(Color.ORANGE);
- this.controlPanel.add(label);
- this.controlPanel.add(addButton("Select Filters", null, 70, 100, 200, 50, this.FILTER_BUTTON_PRESSED));
- this.controlPanel.add(addButton("Filter Visualization", null, 310, 100, 200, 50, this.FILTERVIS_BUTTON_PRESSED));
- this.controlPanel.add(addButton("Feature Extraction", null, 70, 170, 200, 50, this.FEATURE_BUTTON_PRESSED));
- this.controlPanel.add(addButton("Model Learning", null, 310, 170, 200, 50, this.LEARNING_BUTTON_PRESSED));
- this.controlPanel.add(addButton("Evaluation", null, 70, 240, 200, 50, this.EVALUATION_BUTTON_PRESSED));
- this.controlPanel.add(addButton("View Sessions", null, 310, 240, 200, 50, this.SESSIONGUI_BUTTON_PRESSED));
- this.controlPanel.add(addButton("Visualization", null, 70, 310, 200, 50, this.VISUALIZATION_BUTTON_PRESSED));
- this.controlPanel.add(addButton("Back", null, 310, 310, 98, 50, this.BACK_BUTTON_PRESSED));
- this.controlPanel.add(addButton("Exit", null, 413, 310, 98, 50, this.EXIT_BUTTON_PRESSED));
-
- }
-
-
- private JButton addButton(String label, ImageIcon icon, int x, int y, int width, int height, final ActionEvent action) {
- JButton button = new JButton(label, icon);
- button.setFont(labelFONT);
- button.setBorderPainted(false);
- button.setFocusPainted(false);
- button.setBackground(buttonBGColor);
- button.setForeground(Color.WHITE);
- button.setBounds(x, y, width, height);
- button.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- doAction(action);
- }
- });
- return button;
- }
-}
+package activeSegmentation.gui;
+
+import activeSegmentation.ASCommon;
+import activeSegmentation.feature.FeatureManager;
+import activeSegmentation.learning.ClassifierManager;
+import activeSegmentation.prj.ProjectManager;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+/**
+ * Selector GUI class.
+ *
+ * Refactored to use {@link GridBagLayout} instead of absolute positioning,
+ * making the panel responsive and fully compatible with visual UI designers
+ * such as Eclipse WindowBuilder.
+ *
+ * @author Sumit Vohra, Dimiter Prodanov
+ */
+public class GuiPanel extends JFrame implements ASCommon {
+
+ private JFrame mainFrame;
+ private JPanel controlPanel;
+ private LearningPanel learningPanel;
+ private FilterPanel filterPanel;
+ private FeaturePanel featurePanel;
+ private ViewFilterOutputPanel filterOutputPanel;
+
+ final ActionEvent FEATURE_BUTTON_PRESSED = new ActionEvent(this, 0, "Feature" );
+ final ActionEvent FILTER_BUTTON_PRESSED = new ActionEvent(this, 1, "Filter" );
+ final ActionEvent LEARNING_BUTTON_PRESSED = new ActionEvent(this, 2, "Learning" );
+ final ActionEvent EVALUATION_BUTTON_PRESSED = new ActionEvent(this, 3, "Evaluation" );
+ final ActionEvent FILTERVIS_BUTTON_PRESSED = new ActionEvent(this, 4, "FilterVis" );
+ final ActionEvent SESSIONGUI_BUTTON_PRESSED = new ActionEvent(this, 5, "SessionGUI" );
+ final ActionEvent VISUALIZATION_BUTTON_PRESSED = new ActionEvent(this, 8, "Visualization");
+ final ActionEvent BACK_BUTTON_PRESSED = new ActionEvent(this, 6, "Back" );
+ final ActionEvent EXIT_BUTTON_PRESSED = new ActionEvent(this, 7, "Exit" );
+
+ private FeatureManager featureManager;
+ private ClassifierManager learningManager;
+ private ProjectManager projectManager;
+ private EvaluationPanel evaluationPanel;
+ private VisualizationPanel visualizationPanel;
+
+ /**
+ * Constructs a {@code GuiPanel} and initialises all sub-managers and the UI.
+ *
+ * @param projectManager the active project manager instance
+ */
+ public GuiPanel(ProjectManager projectManager) {
+ this.projectManager = projectManager;
+ learningManager = new ClassifierManager(this.projectManager);
+ featureManager = new FeatureManager(this.projectManager, this.learningManager);
+ initGUI();
+ }
+
+ /**
+ * Returns the main control panel.
+ *
+ * @return the {@link JPanel} containing all navigation controls
+ */
+ public JPanel getMainPanel() {
+ return controlPanel;
+ }
+
+ /**
+ * Dispatches a button-press action to the appropriate panel.
+ *
+ * @param event the {@link ActionEvent} representing the button that was pressed
+ */
+ public void doAction(ActionEvent event) {
+ if (event.equals(this.FILTER_BUTTON_PRESSED)) {
+ filterPanel = new FilterPanel(projectManager, featureManager);
+ SwingUtilities.invokeLater(filterPanel);
+ }
+
+ if (event.equals(this.FILTERVIS_BUTTON_PRESSED)) {
+ filterOutputPanel = new ViewFilterOutputPanel(projectManager, featureManager);
+ SwingUtilities.invokeLater(this.filterOutputPanel);
+ }
+
+ if (event.equals(this.FEATURE_BUTTON_PRESSED)) {
+ featurePanel = new FeaturePanel(featureManager);
+ SwingUtilities.invokeLater(this.featurePanel);
+ }
+
+ if (event.equals(this.LEARNING_BUTTON_PRESSED)) {
+ learningPanel = new LearningPanel(projectManager, learningManager);
+ SwingUtilities.invokeLater(learningPanel);
+ }
+
+ if (event.equals(this.EVALUATION_BUTTON_PRESSED)) {
+ evaluationPanel = new EvaluationPanel(projectManager, null);
+ SwingUtilities.invokeLater(evaluationPanel);
+ }
+
+ if (event.equals(this.SESSIONGUI_BUTTON_PRESSED)) {
+ new SessionGUI(projectManager);
+ }
+
+ if (event.equals(this.VISUALIZATION_BUTTON_PRESSED)) {
+ SwingUtilities.invokeLater(() -> {
+ JFrame frame = new JFrame("Visualization Panel");
+ frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
+ frame.setSize(800, 600);
+ frame.setLocationRelativeTo(null);
+ frame.add(new VisualizationPanel());
+ frame.setVisible(true);
+ });
+ }
+
+ if (event.equals(this.BACK_BUTTON_PRESSED)) {
+ mainFrame.dispose();
+ new CreateOpenProjectGUI(projectManager).run();
+ }
+
+ if (event.equals(this.EXIT_BUTTON_PRESSED)) {
+ int response = JOptionPane.showConfirmDialog(
+ mainFrame,
+ "Are you sure you want to exit?",
+ "Confirm Exit",
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+ if (response == JOptionPane.YES_OPTION) {
+ System.exit(0);
+ }
+ }
+ }
+
+ // -------------------------------------------------------------------------
+ // Private helpers
+ // -------------------------------------------------------------------------
+
+ /**
+ * Initialises and displays the main application window.
+ *
+ * The control panel uses a {@link BorderLayout} at the frame level and a
+ * {@link GridBagLayout} for the button grid, replacing the former
+ * absolute-positioning approach. This makes the layout responsive to
+ * window resizing and fully parseable by visual designers such as Eclipse
+ * WindowBuilder.
+ */
+ private void initGUI() {
+ // --- Main frame setup ------------------------------------------------
+ this.mainFrame = new JFrame("Active Segmentation v." + version);
+ this.mainFrame.getContentPane().setBackground(Color.LIGHT_GRAY);
+ this.mainFrame.setLocationRelativeTo(null);
+ this.mainFrame.setSize(frameWidth, frameHeight);
+ this.mainFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+
+ this.mainFrame.addWindowListener(new java.awt.event.WindowAdapter() {
+ @Override
+ public void windowClosing(java.awt.event.WindowEvent windowEvent) {
+ if (JOptionPane.showConfirmDialog(
+ mainFrame,
+ "Are you sure you want to exit?",
+ "Confirm Exit",
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
+ System.exit(0);
+ }
+ }
+ });
+
+ // --- Control panel ---------------------------------------------------
+ this.controlPanel = new JPanel(new BorderLayout(10, 10));
+ this.controlPanel.setBackground(Color.GRAY);
+ this.controlPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 20, 20));
+
+ // Title label (NORTH)
+ JLabel titleLabel = new JLabel("Active Segmentation", SwingConstants.CENTER);
+ titleLabel.setFont(largeFONT);
+ titleLabel.setForeground(Color.ORANGE);
+ titleLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
+ this.controlPanel.add(titleLabel, BorderLayout.NORTH);
+
+ // Button grid (CENTER) ------------------------------------------------
+ JPanel buttonGrid = new JPanel(new GridBagLayout());
+ buttonGrid.setBackground(Color.GRAY);
+
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.fill = GridBagConstraints.HORIZONTAL;
+ gbc.insets = new Insets(6, 6, 6, 6);
+ gbc.weightx = 0.5;
+ gbc.ipadx = 20;
+ gbc.ipady = 10;
+
+ // Row 0
+ addButtonGBC(buttonGrid, gbc, "Select Filters", 0, 0, this.FILTER_BUTTON_PRESSED);
+ addButtonGBC(buttonGrid, gbc, "Filter Visualization", 1, 0, this.FILTERVIS_BUTTON_PRESSED);
+
+ // Row 1
+ addButtonGBC(buttonGrid, gbc, "Feature Extraction", 0, 1, this.FEATURE_BUTTON_PRESSED);
+ addButtonGBC(buttonGrid, gbc, "Model Learning", 1, 1, this.LEARNING_BUTTON_PRESSED);
+
+ // Row 2
+ addButtonGBC(buttonGrid, gbc, "Evaluation", 0, 2, this.EVALUATION_BUTTON_PRESSED);
+ addButtonGBC(buttonGrid, gbc, "View Sessions", 1, 2, this.SESSIONGUI_BUTTON_PRESSED);
+
+ // Row 3
+ addButtonGBC(buttonGrid, gbc, "Visualization", 0, 3, this.VISUALIZATION_BUTTON_PRESSED);
+
+ // Back and Exit share the right column of row 3 in a sub-panel
+ JPanel backExitPanel = new JPanel(new GridLayout(1, 2, 6, 0));
+ backExitPanel.setBackground(Color.GRAY);
+ backExitPanel.add(createButton("Back", this.BACK_BUTTON_PRESSED));
+ backExitPanel.add(createButton("Exit", this.EXIT_BUTTON_PRESSED));
+
+ gbc.gridx = 1;
+ gbc.gridy = 3;
+ buttonGrid.add(backExitPanel, gbc);
+
+ this.controlPanel.add(buttonGrid, BorderLayout.CENTER);
+
+ // --- Attach and show -------------------------------------------------
+ this.mainFrame.setContentPane(this.controlPanel);
+ this.mainFrame.setVisible(true);
+ }
+
+ /**
+ * Creates a styled {@link JButton} and adds it to {@code panel} at the
+ * grid position specified by {@code col} and {@code row}.
+ *
+ * @param panel the target {@link JPanel} using {@link GridBagLayout}
+ * @param gbc the shared {@link GridBagConstraints} (gridx/gridy are set here)
+ * @param label the button text
+ * @param col the column index in the grid
+ * @param row the row index in the grid
+ * @param action the {@link ActionEvent} to dispatch when the button is clicked
+ */
+ private void addButtonGBC(JPanel panel, GridBagConstraints gbc,
+ String label, int col, int row, ActionEvent action) {
+ gbc.gridx = col;
+ gbc.gridy = row;
+ panel.add(createButton(label, action), gbc);
+ }
+
+ /**
+ * Creates and returns a fully styled {@link JButton}.
+ *
+ * @param label the button text
+ * @param action the {@link ActionEvent} to dispatch on click
+ * @return a configured {@link JButton}
+ */
+ private JButton createButton(String label, final ActionEvent action) {
+ JButton button = new JButton(label);
+ button.setFont(labelFONT);
+ button.setBorderPainted(false);
+ button.setFocusPainted(false);
+ button.setBackground(buttonBGColor);
+ button.setForeground(Color.WHITE);
+ button.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ doAction(action);
+ }
+ });
+ return button;
+ }
+}
From f2862533923ebc8f46e0b7a2f35ab8d2acef85d3 Mon Sep 17 00:00:00 2001
From: AmlanDalai
Date: Sat, 7 Mar 2026 18:15:36 +0530
Subject: [PATCH 3/3] fix(GuiPanel): use separate GridBagConstraints per button
for WindowBuilder compatibility
---
src/activeSegmentation/gui/GuiPanel.java | 203 ++++++++++++++---------
1 file changed, 120 insertions(+), 83 deletions(-)
diff --git a/src/activeSegmentation/gui/GuiPanel.java b/src/activeSegmentation/gui/GuiPanel.java
index 88ee9923..f69f864a 100644
--- a/src/activeSegmentation/gui/GuiPanel.java
+++ b/src/activeSegmentation/gui/GuiPanel.java
@@ -17,6 +17,10 @@
* making the panel responsive and fully compatible with visual UI designers
* such as Eclipse WindowBuilder.
*
+ * Each navigation button is declared as an explicit named field, and each
+ * uses its own {@link GridBagConstraints} instance so that Eclipse WindowBuilder
+ * can parse, display, and edit all components correctly in Design view.
+ *
* @author Sumit Vohra, Dimiter Prodanov
*/
public class GuiPanel extends JFrame implements ASCommon {
@@ -28,15 +32,26 @@ public class GuiPanel extends JFrame implements ASCommon {
private FeaturePanel featurePanel;
private ViewFilterOutputPanel filterOutputPanel;
- final ActionEvent FEATURE_BUTTON_PRESSED = new ActionEvent(this, 0, "Feature" );
- final ActionEvent FILTER_BUTTON_PRESSED = new ActionEvent(this, 1, "Filter" );
- final ActionEvent LEARNING_BUTTON_PRESSED = new ActionEvent(this, 2, "Learning" );
- final ActionEvent EVALUATION_BUTTON_PRESSED = new ActionEvent(this, 3, "Evaluation" );
- final ActionEvent FILTERVIS_BUTTON_PRESSED = new ActionEvent(this, 4, "FilterVis" );
- final ActionEvent SESSIONGUI_BUTTON_PRESSED = new ActionEvent(this, 5, "SessionGUI" );
+ // Navigation buttons — declared as named fields for WindowBuilder compatibility
+ private JButton btnSelectFilters;
+ private JButton btnFilterVisualization;
+ private JButton btnFeatureExtraction;
+ private JButton btnModelLearning;
+ private JButton btnEvaluation;
+ private JButton btnViewSessions;
+ private JButton btnVisualization;
+ private JButton btnBack;
+ private JButton btnExit;
+
+ final ActionEvent FEATURE_BUTTON_PRESSED = new ActionEvent(this, 0, "Feature" );
+ final ActionEvent FILTER_BUTTON_PRESSED = new ActionEvent(this, 1, "Filter" );
+ final ActionEvent LEARNING_BUTTON_PRESSED = new ActionEvent(this, 2, "Learning" );
+ final ActionEvent EVALUATION_BUTTON_PRESSED = new ActionEvent(this, 3, "Evaluation" );
+ final ActionEvent FILTERVIS_BUTTON_PRESSED = new ActionEvent(this, 4, "FilterVis" );
+ final ActionEvent SESSIONGUI_BUTTON_PRESSED = new ActionEvent(this, 5, "SessionGUI" );
final ActionEvent VISUALIZATION_BUTTON_PRESSED = new ActionEvent(this, 8, "Visualization");
- final ActionEvent BACK_BUTTON_PRESSED = new ActionEvent(this, 6, "Back" );
- final ActionEvent EXIT_BUTTON_PRESSED = new ActionEvent(this, 7, "Exit" );
+ final ActionEvent BACK_BUTTON_PRESSED = new ActionEvent(this, 6, "Back" );
+ final ActionEvent EXIT_BUTTON_PRESSED = new ActionEvent(this, 7, "Exit" );
private FeatureManager featureManager;
private ClassifierManager learningManager;
@@ -75,31 +90,25 @@ public void doAction(ActionEvent event) {
filterPanel = new FilterPanel(projectManager, featureManager);
SwingUtilities.invokeLater(filterPanel);
}
-
if (event.equals(this.FILTERVIS_BUTTON_PRESSED)) {
filterOutputPanel = new ViewFilterOutputPanel(projectManager, featureManager);
SwingUtilities.invokeLater(this.filterOutputPanel);
}
-
if (event.equals(this.FEATURE_BUTTON_PRESSED)) {
featurePanel = new FeaturePanel(featureManager);
SwingUtilities.invokeLater(this.featurePanel);
}
-
if (event.equals(this.LEARNING_BUTTON_PRESSED)) {
learningPanel = new LearningPanel(projectManager, learningManager);
SwingUtilities.invokeLater(learningPanel);
}
-
if (event.equals(this.EVALUATION_BUTTON_PRESSED)) {
evaluationPanel = new EvaluationPanel(projectManager, null);
SwingUtilities.invokeLater(evaluationPanel);
}
-
if (event.equals(this.SESSIONGUI_BUTTON_PRESSED)) {
new SessionGUI(projectManager);
}
-
if (event.equals(this.VISUALIZATION_BUTTON_PRESSED)) {
SwingUtilities.invokeLater(() -> {
JFrame frame = new JFrame("Visualization Panel");
@@ -110,12 +119,10 @@ public void doAction(ActionEvent event) {
frame.setVisible(true);
});
}
-
if (event.equals(this.BACK_BUTTON_PRESSED)) {
mainFrame.dispose();
new CreateOpenProjectGUI(projectManager).run();
}
-
if (event.equals(this.EXIT_BUTTON_PRESSED)) {
int response = JOptionPane.showConfirmDialog(
mainFrame,
@@ -129,21 +136,15 @@ public void doAction(ActionEvent event) {
}
}
- // -------------------------------------------------------------------------
- // Private helpers
- // -------------------------------------------------------------------------
-
/**
* Initialises and displays the main application window.
*
- * The control panel uses a {@link BorderLayout} at the frame level and a
- * {@link GridBagLayout} for the button grid, replacing the former
- * absolute-positioning approach. This makes the layout responsive to
- * window resizing and fully parseable by visual designers such as Eclipse
- * WindowBuilder.
+ * Uses {@link BorderLayout} at the frame level and {@link GridBagLayout}
+ * for the button grid, replacing the former absolute-positioning approach.
+ * Each button uses its own {@link GridBagConstraints} instance for full
+ * Eclipse WindowBuilder Design view compatibility.
*/
private void initGUI() {
- // --- Main frame setup ------------------------------------------------
this.mainFrame = new JFrame("Active Segmentation v." + version);
this.mainFrame.getContentPane().setBackground(Color.LIGHT_GRAY);
this.mainFrame.setLocationRelativeTo(null);
@@ -164,88 +165,125 @@ public void windowClosing(java.awt.event.WindowEvent windowEvent) {
}
});
- // --- Control panel ---------------------------------------------------
+ // Control panel with BorderLayout
this.controlPanel = new JPanel(new BorderLayout(10, 10));
this.controlPanel.setBackground(Color.GRAY);
this.controlPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 20, 20));
- // Title label (NORTH)
+ // Title label in NORTH
JLabel titleLabel = new JLabel("Active Segmentation", SwingConstants.CENTER);
titleLabel.setFont(largeFONT);
titleLabel.setForeground(Color.ORANGE);
titleLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
this.controlPanel.add(titleLabel, BorderLayout.NORTH);
- // Button grid (CENTER) ------------------------------------------------
+ // Button grid with GridBagLayout in CENTER
JPanel buttonGrid = new JPanel(new GridBagLayout());
buttonGrid.setBackground(Color.GRAY);
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.insets = new Insets(6, 6, 6, 6);
- gbc.weightx = 0.5;
- gbc.ipadx = 20;
- gbc.ipady = 10;
-
- // Row 0
- addButtonGBC(buttonGrid, gbc, "Select Filters", 0, 0, this.FILTER_BUTTON_PRESSED);
- addButtonGBC(buttonGrid, gbc, "Filter Visualization", 1, 0, this.FILTERVIS_BUTTON_PRESSED);
-
- // Row 1
- addButtonGBC(buttonGrid, gbc, "Feature Extraction", 0, 1, this.FEATURE_BUTTON_PRESSED);
- addButtonGBC(buttonGrid, gbc, "Model Learning", 1, 1, this.LEARNING_BUTTON_PRESSED);
-
- // Row 2
- addButtonGBC(buttonGrid, gbc, "Evaluation", 0, 2, this.EVALUATION_BUTTON_PRESSED);
- addButtonGBC(buttonGrid, gbc, "View Sessions", 1, 2, this.SESSIONGUI_BUTTON_PRESSED);
-
- // Row 3
- addButtonGBC(buttonGrid, gbc, "Visualization", 0, 3, this.VISUALIZATION_BUTTON_PRESSED);
-
- // Back and Exit share the right column of row 3 in a sub-panel
+ // Row 0 - col 0
+ btnSelectFilters = new JButton("Select Filters");
+ styleButton(btnSelectFilters, FILTER_BUTTON_PRESSED);
+ GridBagConstraints gbc00 = new GridBagConstraints();
+ gbc00.fill = GridBagConstraints.HORIZONTAL;
+ gbc00.insets = new Insets(6, 6, 6, 6);
+ gbc00.weightx = 0.5; gbc00.ipadx = 20; gbc00.ipady = 10;
+ gbc00.gridx = 0; gbc00.gridy = 0;
+ buttonGrid.add(btnSelectFilters, gbc00);
+
+ // Row 0 - col 1
+ btnFilterVisualization = new JButton("Filter Visualization");
+ styleButton(btnFilterVisualization, FILTERVIS_BUTTON_PRESSED);
+ GridBagConstraints gbc01 = new GridBagConstraints();
+ gbc01.fill = GridBagConstraints.HORIZONTAL;
+ gbc01.insets = new Insets(6, 6, 6, 6);
+ gbc01.weightx = 0.5; gbc01.ipadx = 20; gbc01.ipady = 10;
+ gbc01.gridx = 1; gbc01.gridy = 0;
+ buttonGrid.add(btnFilterVisualization, gbc01);
+
+ // Row 1 - col 0
+ btnFeatureExtraction = new JButton("Feature Extraction");
+ styleButton(btnFeatureExtraction, FEATURE_BUTTON_PRESSED);
+ GridBagConstraints gbc10 = new GridBagConstraints();
+ gbc10.fill = GridBagConstraints.HORIZONTAL;
+ gbc10.insets = new Insets(6, 6, 6, 6);
+ gbc10.weightx = 0.5; gbc10.ipadx = 20; gbc10.ipady = 10;
+ gbc10.gridx = 0; gbc10.gridy = 1;
+ buttonGrid.add(btnFeatureExtraction, gbc10);
+
+ // Row 1 - col 1
+ btnModelLearning = new JButton("Model Learning");
+ styleButton(btnModelLearning, LEARNING_BUTTON_PRESSED);
+ GridBagConstraints gbc11 = new GridBagConstraints();
+ gbc11.fill = GridBagConstraints.HORIZONTAL;
+ gbc11.insets = new Insets(6, 6, 6, 6);
+ gbc11.weightx = 0.5; gbc11.ipadx = 20; gbc11.ipady = 10;
+ gbc11.gridx = 1; gbc11.gridy = 1;
+ buttonGrid.add(btnModelLearning, gbc11);
+
+ // Row 2 - col 0
+ btnEvaluation = new JButton("Evaluation");
+ styleButton(btnEvaluation, EVALUATION_BUTTON_PRESSED);
+ GridBagConstraints gbc20 = new GridBagConstraints();
+ gbc20.fill = GridBagConstraints.HORIZONTAL;
+ gbc20.insets = new Insets(6, 6, 6, 6);
+ gbc20.weightx = 0.5; gbc20.ipadx = 20; gbc20.ipady = 10;
+ gbc20.gridx = 0; gbc20.gridy = 2;
+ buttonGrid.add(btnEvaluation, gbc20);
+
+ // Row 2 - col 1
+ btnViewSessions = new JButton("View Sessions");
+ styleButton(btnViewSessions, SESSIONGUI_BUTTON_PRESSED);
+ GridBagConstraints gbc21 = new GridBagConstraints();
+ gbc21.fill = GridBagConstraints.HORIZONTAL;
+ gbc21.insets = new Insets(6, 6, 6, 6);
+ gbc21.weightx = 0.5; gbc21.ipadx = 20; gbc21.ipady = 10;
+ gbc21.gridx = 1; gbc21.gridy = 2;
+ buttonGrid.add(btnViewSessions, gbc21);
+
+ // Row 3 - col 0
+ btnVisualization = new JButton("Visualization");
+ styleButton(btnVisualization, VISUALIZATION_BUTTON_PRESSED);
+ GridBagConstraints gbc30 = new GridBagConstraints();
+ gbc30.fill = GridBagConstraints.HORIZONTAL;
+ gbc30.insets = new Insets(6, 6, 6, 6);
+ gbc30.weightx = 0.5; gbc30.ipadx = 20; gbc30.ipady = 10;
+ gbc30.gridx = 0; gbc30.gridy = 3;
+ buttonGrid.add(btnVisualization, gbc30);
+
+ // Row 3 - col 1: Back and Exit side by side
JPanel backExitPanel = new JPanel(new GridLayout(1, 2, 6, 0));
backExitPanel.setBackground(Color.GRAY);
- backExitPanel.add(createButton("Back", this.BACK_BUTTON_PRESSED));
- backExitPanel.add(createButton("Exit", this.EXIT_BUTTON_PRESSED));
- gbc.gridx = 1;
- gbc.gridy = 3;
- buttonGrid.add(backExitPanel, gbc);
+ btnBack = new JButton("Back");
+ styleButton(btnBack, BACK_BUTTON_PRESSED);
+ backExitPanel.add(btnBack);
+
+ btnExit = new JButton("Exit");
+ styleButton(btnExit, EXIT_BUTTON_PRESSED);
+ backExitPanel.add(btnExit);
+
+ GridBagConstraints gbc31 = new GridBagConstraints();
+ gbc31.fill = GridBagConstraints.HORIZONTAL;
+ gbc31.insets = new Insets(6, 6, 6, 6);
+ gbc31.weightx = 0.5; gbc31.ipadx = 20; gbc31.ipady = 10;
+ gbc31.gridx = 1; gbc31.gridy = 3;
+ buttonGrid.add(backExitPanel, gbc31);
this.controlPanel.add(buttonGrid, BorderLayout.CENTER);
- // --- Attach and show -------------------------------------------------
this.mainFrame.setContentPane(this.controlPanel);
this.mainFrame.setVisible(true);
}
/**
- * Creates a styled {@link JButton} and adds it to {@code panel} at the
- * grid position specified by {@code col} and {@code row}.
- *
- * @param panel the target {@link JPanel} using {@link GridBagLayout}
- * @param gbc the shared {@link GridBagConstraints} (gridx/gridy are set here)
- * @param label the button text
- * @param col the column index in the grid
- * @param row the row index in the grid
- * @param action the {@link ActionEvent} to dispatch when the button is clicked
- */
- private void addButtonGBC(JPanel panel, GridBagConstraints gbc,
- String label, int col, int row, ActionEvent action) {
- gbc.gridx = col;
- gbc.gridy = row;
- panel.add(createButton(label, action), gbc);
- }
-
- /**
- * Creates and returns a fully styled {@link JButton}.
+ * Applies consistent visual styling to a {@link JButton} and registers
+ * its action listener.
*
- * @param label the button text
- * @param action the {@link ActionEvent} to dispatch on click
- * @return a configured {@link JButton}
+ * @param button the button to style
+ * @param action the {@link ActionEvent} to dispatch when clicked
*/
- private JButton createButton(String label, final ActionEvent action) {
- JButton button = new JButton(label);
+ private void styleButton(JButton button, final ActionEvent action) {
button.setFont(labelFONT);
button.setBorderPainted(false);
button.setFocusPainted(false);
@@ -257,6 +295,5 @@ public void actionPerformed(ActionEvent e) {
doAction(action);
}
});
- return button;
}
}