-
Notifications
You must be signed in to change notification settings - Fork 2
Currently refactoring and making changes to interface. Doing bug fixes. #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SpinnerX
wants to merge
13
commits into
abcucberkeley:main
Choose a base branch
from
SpinnerX:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ccf80a1
Currently refactoring and making changes to interface. Doing bug fixes.
SpinnerX b7756d1
Refactored interface and added an error message dialog if files not zarr
SpinnerX c152a1d
Refactored interface and added an error message dialog if files not zarr
SpinnerX cdfb832
Refactor and fixed not updating text box, when user types in filepath…
SpinnerX 248f2ef
Made some finalized changes and did some more refactoring and minor b…
SpinnerX 0af4bc6
Merge branch 'abcucberkeley:main' into main
SpinnerX 4c8ad35
Changed save button to just say "Save"
MattHazard ff3be95
Finalizing changes and refactored the save button.
SpinnerX c7fe3f8
Made some changes by refactoring the submit function
SpinnerX 2c47c0a
Merge branch 'abcucberkeley:main' into main
SpinnerX 50b16a9
Merge branch 'abcucberkeley:main' into main
SpinnerX e01ad04
Refactored and allow widgets to be resizable and adjustable, and made…
972c873
Added dropdown menu feature to show compression options
SpinnerX File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| import java.awt.event.ActionEvent; | ||
|
|
||
| import java.io.File; | ||
| import java.nio.file.Files; | ||
|
|
||
| /* | ||
| * PREVIOUS MEETING DISCUSSION | ||
|
|
@@ -53,6 +54,31 @@ | |
| * - Compressor default is lz4 not iz4. | ||
| */ | ||
|
|
||
| /* | ||
| * HOW TO RESIZES WIDGETS (MEETING NOTES) | ||
| * --> Using custom grid layouts. (For future ref, for resizeable widgets) | ||
| * | ||
| * FLow should work (Refactor) | ||
|
|
||
| What should the interface do actually do? | ||
|
|
||
| * - Remove crop button. (Should use coordinates) [DONE] | ||
| * 1.) Should be able to browse even without typing the filepath [DONE] | ||
| * 2.) Filepath taking in the value from file.getPath(). [???] | ||
| * 3.) Update text area and this.filepath when browsing to a file. [DONE] | ||
| * 4.) Keep in mind: lz4 should be an editable text box (like the filepath text area) [DONE] | ||
| * 5.) Save changes to submit, and set location to be at the bottom of the window. | ||
| * 6.) Submit button clicked, then should quit out of the form. (Close this JFrame only, not the entire software) | ||
| * | ||
| * VARIABLES | ||
| * - Add in the constructor params ImageStack array, in the constructor. | ||
| * - Take out default values variables in update table. | ||
| * | ||
| * What to check for? (Error Checking) | ||
| * - Check for only .zarr file. (If not, then display error message), these are the only error-checking required right now. | ||
| * | ||
| */ | ||
|
|
||
| /* | ||
| C++ MAIN PROJECT. | ||
| * 1.) Release and get matlab working with C++ Qt (version, 6.2.4) | ||
|
|
@@ -62,16 +88,16 @@ public class PWZGUI implements ActionListener{ | |
| JFrame window; | ||
| JPanel textAreaPanel; | ||
|
|
||
| JButton browse; | ||
|
|
||
| // Crop check box | ||
| JLabel checkboxLabel; | ||
| JCheckBox checkBox; | ||
| JButton browse; // Browse specific filepath. | ||
|
|
||
| // Text box | ||
| JLabel textAreaLabel; | ||
| JTextArea textArea; | ||
|
|
||
| // For compressor lz4 | ||
| JTextArea compressTextArea;// Compressor Text Area | ||
| JLabel compressorLabel; // Default Compressor | ||
|
|
||
| // Starting and ending XYZ | ||
| JTable table; | ||
| JScrollPane scrollPane; | ||
|
|
@@ -89,17 +115,23 @@ public class PWZGUI implements ActionListener{ | |
| // Also, not reusing other starting and ending, so doesnt alter those variables. | ||
| public long chunkSizeX=256, chunkSizeY=256, chunkSizeZ=256; | ||
|
|
||
| public ImageStack imageStack; | ||
|
|
||
| public Object[] cImageObj; | ||
|
|
||
| public int bits; | ||
|
|
||
| JTable chunkTable; // Displaying the chunk sizes that are the default XYZ coords. (Though not expected to be changed.) | ||
| JScrollPane chunkScrollPane; // Scroll pane, to help display the default values of the chunk size. | ||
|
|
||
| // Default Compressor | ||
| JLabel compressorLabel; | ||
|
|
||
|
|
||
| JButton saveChangesButton; // To save changes when | ||
| JButton submitButton; // To submit changes, then close this specific interface. (Not the entire software.) | ||
|
|
||
| public PWZGUI() { | ||
| filepath = ""; | ||
| compressor = "lz4"; // Compressor is lz4. (NOTE, this value does not change by default whatsoever) | ||
| imageStack = null; | ||
|
|
||
| // Starting coords | ||
| // Starting and ending coordinates are the expected values to be changed by user using the intercface. | ||
|
|
@@ -117,6 +149,8 @@ public PWZGUI() { | |
| chunkSizeY = 256; | ||
| chunkSizeZ = 256; | ||
|
|
||
| bits = 0; | ||
|
|
||
| // Creates a thread. Lets be called and execute object in its own instance. | ||
| // Basically like its own thread. | ||
| Runnable r = new Runnable() { | ||
|
|
@@ -133,9 +167,11 @@ public void run(){ | |
|
|
||
| // This commented constructor was just an idea (will deleted, if this implementation may not be needed.) | ||
| // public PWZGUI(String filepath, Coords starting, Coords ending, String compressor){ | ||
| public PWZGUI(String filepath, long startX, long startY, long startZ, long endX, long endY, long endZ, long chunkSizeX, long chunkSizeY, long chunkSizeZ, String compressor){ | ||
| public PWZGUI(String filepath, ImageStack imageStack, long startX, long startY, long startZ, long endX, long endY, long endZ, long chunkSizeX, long chunkSizeY, long chunkSizeZ, String compressor, int bits){ | ||
| this.filepath = filepath; | ||
| this.compressor = compressor; | ||
| this.imageStack = imageStack; | ||
| this.cImageObj = imageStack.getImageArray(); // Is this how we want to pass in an array | ||
|
|
||
| // Starting coords | ||
| this.startX = startX; | ||
|
|
@@ -150,6 +186,8 @@ public PWZGUI(String filepath, long startX, long startY, long startZ, long endX, | |
| this.chunkSizeY = chunkSizeY; | ||
| this.chunkSizeZ = chunkSizeZ; | ||
|
|
||
| this.bits = bits; | ||
|
|
||
| // Creates a thread. Lets be called and execute object in its own instance. | ||
| // Basically like its own thread. | ||
| Runnable r = new Runnable(){ | ||
|
|
@@ -167,14 +205,14 @@ private void init(){ | |
| window = new JFrame("Write Zarr"); | ||
| textAreaPanel = new JPanel(); // Main Panel | ||
| compressorLabel = new JLabel(); | ||
| compressTextArea = new JTextArea(); | ||
|
|
||
|
|
||
|
|
||
| setupTextProperties(); // Handling button widget | ||
| setupCropProperties(); // User type text label, and text box field. | ||
| grabCoordinates(); | ||
| chunkAndCompressorProperties(); | ||
| saveChangesButton(); // update the table changes. | ||
| submitButton(); // Submit button: What this does is submit the given changes, then close this specific interface. | ||
| show(); // Handling adding all the widgets into the panel, while panel is being referred by the JFrame. | ||
|
|
||
| // Setting window/jframe properties | ||
|
|
@@ -197,23 +235,17 @@ private void setupTextProperties(){ | |
| textArea.setLayout(new FlowLayout()); | ||
|
|
||
| } | ||
|
|
||
| // Setup cropping properties and JLabels corresponding to given check box widget. | ||
| private void setupCropProperties(){ | ||
| // User type text label, and text box field. | ||
| checkBox = new JCheckBox("Crop"); | ||
| checkBox.setBounds(160, 110, 75, 15); // Higher x is more to the right we go, lower value y is the more we go upwards. | ||
| checkBox.addActionListener(this); | ||
| } | ||
|
|
||
| private void grabCoordinates(){ | ||
| // Labels allowing the user using the interface to know | ||
| startCoordsLabel = new JLabel("Start"); | ||
| endCoordsLabel = new JLabel("End"); | ||
|
|
||
| startCoordsLabel.setBounds(115, 90, 150, 150); | ||
| endCoordsLabel.setBounds(115, 110, 150, 150); | ||
|
|
||
| // startCoordsLabel.setBounds(115, 90, 150, 150); | ||
| // endCoordsLabel.setBounds(115, 110, 150, 150); | ||
| startCoordsLabel.setBounds(140, 5, 150, 150); | ||
| endCoordsLabel.setBounds(145, 20, 150, 150); | ||
|
|
||
| Object[][] data = { | ||
| {startX, startY, startZ}, | ||
| {endX, endY, endZ}, | ||
|
|
@@ -228,7 +260,8 @@ public boolean isCellEditable(int row, int col) { | |
| }; | ||
|
|
||
| table = new JTable(tableModel); | ||
| table.setBounds(30, 30, 950, 950); | ||
| // table.setBounds(30, 30, 950, 950); | ||
| table.setBounds(235, 55, 115, 25); | ||
|
|
||
| // Adding columns to the table | ||
| tableModel.addColumn("X"); | ||
|
|
@@ -240,7 +273,8 @@ public boolean isCellEditable(int row, int col) { | |
|
|
||
| scrollPane = new JScrollPane(table); | ||
| scrollPane.setPreferredSize(new Dimension(250, 100)); // Actually setting how large the scroll pane is. | ||
| scrollPane.setBounds(172, 145, 250, 53); // Set where we want the JTable to be located in the JFrame. (Actually adjusts X and Y coords, and width and height) | ||
| // scrollPane.setBounds(172, 145, 250, 53); // Set where we want the JTable to be located in the JFrame. (Actually adjusts X and Y coords, and width and height) | ||
| scrollPane.setBounds(195, 55, 230, 53); | ||
| scrollPane.setVisible(true); | ||
| } | ||
|
|
||
|
|
@@ -261,20 +295,33 @@ private void chunkAndCompressorProperties(){ | |
| chunkScrollPane = new JScrollPane(chunkTable); | ||
| // Original width = 210, height = 75 | ||
| chunkScrollPane.setPreferredSize(new Dimension(200, 100)); // Actually setting how large the scroll pane is. | ||
| chunkScrollPane.setBounds(170, 205, 255, 40); // Set where we want the JTable to be located in the JFrame. (This line is what updates the X, Y coordinates of widget) | ||
| // chunkScrollPane.setBounds(170, 205, 255, 40); // Set where we want the JTable to be located in the JFrame. (This line is what updates the X, Y coordinates of widget) | ||
| chunkScrollPane.setBounds(195, 125, 230, 53); // Set where we want the JTable to be located in the JFrame. (This line is what updates the X, Y coordinates of widget) | ||
| chunkScrollPane.setVisible(true); | ||
|
|
||
| compressorLabel.setText("Compressor: " + compressor); | ||
| compressorLabel.setBounds(180, 245, 130, 20); // NOTE: Higher the Y-axis lower widgets are positioned. Higher X axis, more to right the widgets positioned at. | ||
| // Compressor = default is lz4 (though the user, should also be able to change the default as an option as well) | ||
| compressorLabel.setText("Compressor: "); | ||
| compressorLabel.setBounds(180, 195, 130, 20); // NOTE: Higher the Y-axis lower widgets are positioned. Higher X axis, more to right the widgets positioned at. | ||
|
|
||
| compressTextArea.setText(compressor); | ||
| // compressTextArea.setBounds(265,245, 65, 19); | ||
| compressTextArea.setBounds(265,195, 65, 19); | ||
| } | ||
|
|
||
| // Function to help organize the widget that handles the saving changes button. | ||
| private void saveChangesButton() { | ||
| saveChangesButton = new JButton("Save Changes"); | ||
| private void submitButton() { | ||
| submitButton = new JButton("Save Changes"); | ||
| // saveChangesButton.setBounds(230, 55, 115, 25); | ||
| saveChangesButton.setBounds(235, 55, 115, 25); | ||
| // submitButton.setBounds(212, 55, 115, 25); | ||
| submitButton.setBounds(175, 225, 115, 25); | ||
| submitButton.addActionListener(this); | ||
| } | ||
|
|
||
| saveChangesButton.addActionListener(this); | ||
| // Display error message window, if the file is not a zarr file. | ||
| private void errorMessage(){ | ||
| String message = "File must be a zarr file"; | ||
| // JOptionPane.showInputDialog(message); | ||
| JOptionPane.showMessageDialog(window, message); | ||
| } | ||
|
|
||
| // show function, has keeps track of all the added components into JFrame -> going to -> JPanel -> widgets/checkboxes/etc. | ||
|
|
@@ -289,51 +336,39 @@ private void show(){ | |
| textAreaPanel.setSize(50, 50); | ||
|
|
||
| // Adds the other widgets into the JFrame window themselves. | ||
| window.add(checkBox); // UPDATE: Add this into the window frame. So we can move this widget however we see fit. | ||
| window.add(startCoordsLabel); | ||
| window.add(endCoordsLabel); | ||
| window.add(scrollPane); | ||
| window.add(chunkScrollPane); | ||
| window.add(compressorLabel); | ||
| window.add(compressTextArea); | ||
|
|
||
|
|
||
| window.add(saveChangesButton); | ||
| window.add(submitButton); | ||
|
|
||
|
|
||
|
|
||
|
|
||
| // Setting window/jframe properties | ||
| window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
| // window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
| window.add(textAreaPanel, BorderLayout.CENTER); // This is how the TextArea and Labels, are being centered to the TOP of the interface. | ||
| window.pack(); | ||
| window.setLocation(new Point(900, 250)); // Hopefully puts the screen in the center of the monitor (vary depending on monitoring) | ||
| window.setVisible(true); | ||
| // window.setResizable(false); | ||
| } | ||
|
|
||
| // Handling events happening with the interface. | ||
| @Override | ||
| public void actionPerformed(ActionEvent e){ | ||
| String filepath = textArea.getText(); | ||
| boolean emptyString = filepath.equals(""); // We dont want to browse anything that isn't a string. (Don't assume, everyone will type the right input. Just precautionary) | ||
|
|
||
| // Just add this just in case, we do not want empty characters | ||
| if(emptyString) return; | ||
|
|
||
| if(e.getSource() == browse){ | ||
| // We want to check if the checkbox is clicked before we compress that file. | ||
| if(checkBox.isSelected()) checkboxClicked(); | ||
| if(!emptyString) loadfile(filepath); | ||
| } | ||
|
|
||
| if(e.getSource() == browse) loadfile(); // We want to check if the checkbox is clicked before we compress that file. | ||
| // Updates and clears the table. | ||
| if(e.getSource() == saveChangesButton) updateTable(); | ||
| if(e.getSource() == submitButton) updateTable(); // Updates the table when we submit the changes, and then is the function that quits out the JFrame for this specific interface. | ||
| } | ||
|
|
||
| // Loading filepath given. | ||
| private void loadfile(String filepath){ | ||
| private void loadfile(){ | ||
| // File Handling stuff. (Referenced PWZ.java) | ||
| // PWZC pwzc = new PWZC(); | ||
| // PWZC pwzc = new PWZC(); // This code is only used to call the C-functionality... (Wont work on mac, so comment out in the meantime.) | ||
| JFileChooser chooser = new JFileChooser(); | ||
| chooser.setApproveButtonText("Save"); | ||
| chooser.setDialogTitle("Save as Zarr"); | ||
|
|
@@ -348,36 +383,28 @@ private void loadfile(String filepath){ | |
|
|
||
| if(cImagePlus == null) return; | ||
|
|
||
| ImageStack cImageStack = cImagePlus.getImageStack(); | ||
| Object[] cImageObj = cImageStack.getImageArray(); | ||
| // pwzc.parallelWriteZarr(this.filepath, this.cImageObj, this.startX, this.startY, this.startZ, this.endX, this.endY, this.endZ, this.chunkSizeX, this.chunkSizeY, this.chunkSizeZ, 1, this.compressor, 1, this.bits); | ||
| } | ||
|
|
||
| private boolean checkExtension(String path){ | ||
| String extension = ""; | ||
| int i = path.lastIndexOf('.'); | ||
|
|
||
| if(i != -1) extension = path.substring(i+1); | ||
|
|
||
| // System.out.println("LOGGER: " + extension + ", i = " + i); // For debugging purposes. | ||
|
|
||
| int bits = cImageStack.getBitDepth(); // May need to get bits another way | ||
| String fileName = file.getPath(); | ||
| int x = cImageStack.getWidth(); | ||
| int y = cImageStack.getHeight(); | ||
| int z = cImageStack.getSize(); | ||
| if(extension.equals("zarr")) return true; | ||
|
|
||
| // pwzc.parallelWriteZarr(fileName, cImageObj, 0, 0, 0, y, x, z, 256, 256, 256, 1, "lz4", 1, bits); | ||
| return false; | ||
| } | ||
|
|
||
|
|
||
| private void checkboxClicked(){ System.out.println("[DEBUGGING]: Check Box Clicked!"); } // Does smthing when this check box is clicked. | ||
|
|
||
| // When "Save Changes" button is clicked, the given inputted information is updated | ||
| // Little redundant, for now was trying to get interface working with updating the JTable. | ||
| // When "Submit changes" button is clicked, the given inputted information is updated | ||
| private void updateTable(){ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function should call my function but I can write that in myself when I pull this since I'll be testing it. |
||
| startX = 123; | ||
| startY = 456; | ||
| startZ = 890; | ||
|
|
||
| endX = 1024; | ||
| endY = 1036; | ||
| endZ = 1048; | ||
|
|
||
| chunkSizeX = 256; | ||
| chunkSizeY = 256; | ||
| chunkSizeZ = 256; | ||
| // Checks if the text area box is a zarr file, or the filepath we load in from the browser button are a zarr file. If not display error message. | ||
| if(!checkExtension(this.filepath) && !checkExtension(textArea.getText())) errorMessage(); | ||
| textArea.setText(this.filepath); | ||
|
|
||
| table.getModel().setValueAt(startX, 0, 0); | ||
| table.getModel().setValueAt(startY, 0, 1); | ||
|
|
@@ -389,8 +416,10 @@ private void updateTable(){ | |
| chunkTable.getModel().setValueAt(chunkSizeX, 0, 0); | ||
| chunkTable.getModel().setValueAt(chunkSizeY, 0, 1); | ||
| chunkTable.getModel().setValueAt(chunkSizeZ, 0, 2); | ||
|
|
||
| window.dispose(); // Dispose() is how we will exit, once the submit changes have been made. | ||
| } | ||
|
|
||
| // For testing and debugging the interface with a main method. | ||
| // public static void main(String[] args) { new PWZGUI(); } | ||
| // public static void main(String[] args) { new PWZGUI(); } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.