Skip to content

Commit

Permalink
Data Reduction GUI Update
Browse files Browse the repository at this point in the history
Have the data reduction GUI be more coherent, and select range only be available for "Open In Memory"
  • Loading branch information
AvocadoMoon committed Oct 25, 2024
1 parent ce35f52 commit b6fea45
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,33 @@
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
import java.awt.*;

public class AdvancedFeatures extends JPanel {
public final JCheckBox inMemory;
public final JCheckBox dataReduction;
public final JCheckBox rangeSelection;
public final JButton copyLink;
public final JButton useN5Link;


public AdvancedFeatures(){
Border lowerEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);


inMemory = new JCheckBox("Open In Memory");
dataReduction = new JCheckBox("Data Reduction");
rangeSelection = new JCheckBox("Select Range");
dataReduction = new JCheckBox("Run Measurement Script");
JPanel checkBoxPanel = new JPanel();
checkBoxPanel.add(dataReduction);

JPanel buttonPanel = new JPanel();
copyLink = new JButton("Copy Link");
useN5Link = new JButton("Use N5 Link");
buttonPanel.add(copyLink);
buttonPanel.add(useN5Link);

add(inMemory);
add(dataReduction);
add(rangeSelection);
setLayout(new BorderLayout());
add(buttonPanel, BorderLayout.NORTH);
add(checkBoxPanel, BorderLayout.SOUTH);
this.setBorder(BorderFactory.createTitledBorder(lowerEtchedBorder, " Advanced Features "));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
public class ControlButtonsPanel extends JPanel implements ActionListener {

private static JButton openOrCancel;
private JButton openInMemory;
// private final JButton openLocal = new JButton("Open N5 Local");
private final JButton copyLink;
private final JButton useN5Link;
private final JButton questionMark;

public final JCheckBox includeExampleExports;
Expand All @@ -30,9 +29,8 @@ public ControlButtonsPanel(){

displayAdvancedFeatures = new JCheckBox("Advanced Features");

openOrCancel = new JButton("Open");
copyLink = new JButton("Copy Link");
useN5Link = new JButton("Use N5 Link");
openOrCancel = new JButton("Open Virtually");
openInMemory = new JButton("Open In Memory");
questionMark = new JButton("?");
questionMark.setPreferredSize(new Dimension(20, 20));

Expand All @@ -44,12 +42,9 @@ public ControlButtonsPanel(){
topRow.add(openOrCancel, gridBagConstraints);

gridBagConstraints.gridx = 1;
topRow.add(copyLink, gridBagConstraints);
topRow.add(openInMemory, gridBagConstraints);

gridBagConstraints.gridx = 2;
topRow.add(useN5Link, gridBagConstraints);

gridBagConstraints.gridx = 3;
topRow.add(questionMark);

JPanel bottomRow = new JPanel(new GridBagLayout());
Expand All @@ -72,7 +67,7 @@ public ControlButtonsPanel(){


int paneWidth = 800;
this.setPreferredSize(new Dimension(paneWidth, 80));
this.setPreferredSize(new Dimension(paneWidth, 110));
this.setLayout(new BorderLayout());
// topBar.add(openLocal);
Border lowerEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
Expand All @@ -84,16 +79,18 @@ public ControlButtonsPanel(){


openOrCancel.addActionListener(this);
copyLink.addActionListener(this);
advancedFeatures.copyLink.addActionListener(this);
questionMark.addActionListener(this);
useN5Link.addActionListener(this);
advancedFeatures.useN5Link.addActionListener(this);
// openLocal.addActionListener(this);
includeExampleExports.addActionListener(this);
displayAdvancedFeatures.addActionListener(this);
openInMemory.addActionListener(this);


openOrCancel.setEnabled(false);
copyLink.setEnabled(false);
openInMemory.setEnabled(false);
advancedFeatures.copyLink.setEnabled(false);
}

public void initialize(N5ExportTable n5ExportTable, RemoteFileSelection remoteFileSelection){
Expand All @@ -103,17 +100,17 @@ public void initialize(N5ExportTable n5ExportTable, RemoteFileSelection remoteFi

@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(openOrCancel)){
if(e.getSource().equals(openOrCancel) || e.getSource().equals(openInMemory)){
if (openOrCancel.getText().equals("Cancel")){
n5ExportTable.removeFromLoadingRows();
} else {
n5ExportTable.openSelectedRows();
n5ExportTable.openSelectedRows(e.getSource().equals(openInMemory));
}
} else if (e.getSource().equals(copyLink)) {
} else if (e.getSource().equals(advancedFeatures.copyLink)) {
n5ExportTable.copySelectedRowLink();
} else if (e.getSource().equals(questionMark)) {
new HelpExplanation().displayHelpMenu();
} else if (e.getSource().equals(useN5Link)) {
} else if (e.getSource().equals(advancedFeatures.useN5Link)) {
remoteFileSelection.setVisible(true);
} else if (e.getSource().equals(includeExampleExports)){
n5ExportTable.updateTableData();
Expand All @@ -124,25 +121,28 @@ public void actionPerformed(ActionEvent e) {

public void allowCancel(boolean allow){
openOrCancel.setEnabled(true);
copyLink.setEnabled(true);
useN5Link.setEnabled(true);
advancedFeatures.copyLink.setEnabled(true);
advancedFeatures.useN5Link.setEnabled(true);
remoteFileSelection.submitS3Info.setEnabled(true);
openInMemory.setEnabled(!allow);
if (allow){
openOrCancel.setText("Cancel");
} else {
openOrCancel.setText("Open");
openOrCancel.setText("Open Virtually");
}
}

public void enableRowContextDependentButtons(boolean enable){
openOrCancel.setEnabled(enable);
copyLink.setEnabled(enable);
advancedFeatures.copyLink.setEnabled(enable);
openInMemory.setEnabled(enable);
}

public void enableCriticalButtons(boolean enable){
useN5Link.setEnabled(enable);
advancedFeatures.useN5Link.setEnabled(enable);
openOrCancel.setEnabled(enable);
copyLink.setEnabled(enable);
advancedFeatures.copyLink.setEnabled(enable);
remoteFileSelection.submitS3Info.setEnabled(enable);
openInMemory.setEnabled(enable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public MainPanel(){
filters.add(searchBar, BorderLayout.SOUTH);
parentPanel.add(filters, BorderLayout.SOUTH);

parentPanel.setPreferredSize(new Dimension(paneWidth, 650));
parentPanel.setPreferredSize(new Dimension(paneWidth, 750));
JOptionPane pane = new JOptionPane(parentPanel, JOptionPane.PLAIN_MESSAGE, 0, null, new Object[]{"Close"});
exportTableDialog = pane.createDialog("VCell Exports");
exportTableDialog.setModal(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private void automaticRefresh(){
refreshTableThread.start();
}

public void openSelectedRows(){
public void openSelectedRows(boolean openInMemory){
ArrayList<SimResultsLoader> filesToOpen = new ArrayList<>();
for(int row: exportListTable.getSelectedRows()){
String uri = n5ExportTableModel.getRowData(row).uri;
Expand All @@ -164,8 +164,8 @@ public void openSelectedRows(){
filesToOpen.add(simResultsLoader);
}
AdvancedFeatures advancedFeatures = MainPanel.controlButtonsPanel.advancedFeatures;
N5ImageHandler.loadingManager.openN5FileDataset(filesToOpen, advancedFeatures.inMemory.isSelected(),
advancedFeatures.rangeSelection.isSelected(), advancedFeatures.dataReduction.isSelected());
N5ImageHandler.loadingManager.openN5FileDataset(filesToOpen, openInMemory,
advancedFeatures.dataReduction.isSelected());
}

public void copySelectedRowLink(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void actionPerformed(ActionEvent e) {
SimResultsLoader simResultsLoader = new SimResultsLoader(getS3URL(), "", -1, "");
AdvancedFeatures advancedFeatures = MainPanel.controlButtonsPanel.advancedFeatures;
N5ImageHandler.loadingManager.openN5FileDataset(new ArrayList<SimResultsLoader>(){{add(simResultsLoader);}},
advancedFeatures.inMemory.isSelected(), advancedFeatures.rangeSelection.isSelected(),
advancedFeatures.inMemory.isSelected(),
advancedFeatures.dataReduction.isSelected());
this.setVisible(false);
}
Expand Down
Loading

0 comments on commit b6fea45

Please sign in to comment.