Page MenuHomec4science

No OneTemporary

File Metadata

Created
Mon, Jul 22, 21:20
diff --git a/DeconvolutionLab2/DeconvolutionLab2.config b/DeconvolutionLab2/DeconvolutionLab2.config
index 2735ed7..06d248e 100644
--- a/DeconvolutionLab2/DeconvolutionLab2.config
+++ b/DeconvolutionLab2/DeconvolutionLab2.config
@@ -1,63 +1,63 @@
#DeconvolutionLab2 [Beta 2]
#DeconvolutionLab2 [Beta 2]
-#Thu Mar 02 18:44:42 CET 2017
+#Sat Mar 18 22:03:52 CET 2017
Algorithm.I.gaussian.mean=0.0
Algorithm.I.gaussian.stdev=1.0
Algorithm.I.iterations=10
Algorithm.I.poisson=0.0
Algorithm.I.reg=0.1
Algorithm.I.scale=3
Algorithm.I.step=1.0
Algorithm.I.wavelets=Haar
Algorithm.algorithm=Landweber [LW |\u00A0LLS]
Border.apoxy=Hamming
Border.apoz=Uniform
Border.extxy=1
Border.extz=0
Border.padxy=None
Border.padz=None
Computation.dim=XYZ
Computation.epsilon=1E-6
Computation.fft=Fastest
Computation.normalization=1
Controller.constraint.enable=false
Controller.constraint.value=no
Controller.itmax.enable=true
Controller.reference.enable=false
Controller.reference.value=
Controller.residu.enable=false
Controller.residu.value=0.01
Controller.time.enable=false
Controller.time.value=3600
DeconvolutionLab.MainDialog.location.h=597
DeconvolutionLab.MainDialog.location.w=500
-DeconvolutionLab.MainDialog.location.x=250
-DeconvolutionLab.MainDialog.location.y=45
+DeconvolutionLab.MainDialog.location.x=72
+DeconvolutionLab.MainDialog.location.y=33
Image.image.row0=Cell7.tif;file;/Users/dsage/Desktop/Maria Azevedo/Cell7.tif;null
Image.image.row1=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;\u232B
Image.image.row2=DoG;synthetic;DoG 100.0 0.0 3.0 35.0 size 128 128 32 ;\u232B
Image.image.row3=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;\u232B
Image.image.row4=RandomLines;synthetic;RandomLines 100.0 0.0 300.0 size 512 512 32 ;\u232B
Image.image.row5=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;\u232B
Image.image.row6=Applications;platform;Applications;\u232B
Image.image.row7=Applications;directory;/users/dsage/Applications;\u232B
Image.image.row8=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;\u232B
Image.image.row9=lib;directory;/Users/dsage/git/deconvolution/DeconvolutionLab2/lib;\u232B
Image.image.selected=Cell7.tif;file;/Users/dsage/Desktop/Maria Azevedo/Cell7.tif;null
Language.headless=Run (Headless)
Language.job=Job
Language.language=Command line
Output.output.row0=ortho;OR2;;;;\u2713;\u2713;\u232B
Output.output.selected=ortho;OR2;;;;\u2713;\u2713;\u232B
PSF.psf.row0=AirySimulated;synthetic;AirySimulated 100.0 0.0 1.0 size 128 128 32 ;null
PSF.psf.row1=Chrome Apps.localized;directory;/users/dsage/applications/Chrome Apps.localized;\u232B
PSF.psf.row2=FI1.tif;file;/Users/dsage/git/deconvolution/DeconvolutionLab2/FI1.tif;\u232B
PSF.psf.selected=AirySimulated;synthetic;AirySimulated 100.0 0.0 1.0 size 128 128 32 ;null
Running.Directory=/Users/dsage/Applications
Running.Display=no
Running.Monitor=console table
Running.Multithreading=yes
Running.Path=specify
Running.Stats=show
Running.System=no
Running.Verbose=log
diff --git a/DeconvolutionLab2/src/bilib/component/GridPanelImage.java b/DeconvolutionLab2/src/bilib/component/GridPanelImage.java
deleted file mode 100644
index 8ce6965..0000000
--- a/DeconvolutionLab2/src/bilib/component/GridPanelImage.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * DeconvolutionLab2
- *
- * Conditions of use: You are free to use this software for research or
- * educational purposes. In addition, we expect you to include adequate
- * citations and acknowledgments whenever you present or publish results that
- * are based on it.
- *
- * Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
- * Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
- * R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
- */
-
-/*
- * Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
- *
- * This file is part of DeconvolutionLab2 (DL2).
- *
- * DL2 is free software: you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * DL2. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package bilib.component;
-
-import java.awt.Color;
-import java.awt.Graphics;
-import java.awt.Image;
-
-/**
- * This class extends the JPanel to create grid panel given the possibility to
- * place Java components in an organized manner in the dialog box.
- *
- * @author Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland.
- *
- */
-public class GridPanelImage extends GridPanel {
-
- private Image image;
-
- public GridPanelImage(boolean border, int defaultSpace, String filename) {
- super(border, defaultSpace);
- image = ImageLoader.get(filename);
- }
-
- @Override
- protected void paintComponent(Graphics g) {
- super.paintComponent(g);
- if (image != null) {
- g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
- }
- else {
- g.setColor(Color.DARK_GRAY);
- g.fillRect(0, 0, getWidth(), getHeight());
- }
- }
-}
diff --git a/DeconvolutionLab2/src/bilib/component/JPanelImage.java b/DeconvolutionLab2/src/bilib/component/JPanelImage.java
deleted file mode 100644
index 909c542..0000000
--- a/DeconvolutionLab2/src/bilib/component/JPanelImage.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * DeconvolutionLab2
- *
- * Conditions of use: You are free to use this software for research or
- * educational purposes. In addition, we expect you to include adequate
- * citations and acknowledgments whenever you present or publish results that
- * are based on it.
- *
- * Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
- * Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
- * R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
- */
-
-/*
- * Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
- *
- * This file is part of DeconvolutionLab2 (DL2).
- *
- * DL2 is free software: you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * DL2. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package bilib.component;
-
-import java.awt.Color;
-import java.awt.Graphics;
-import java.awt.Image;
-import java.awt.image.BufferedImage;
-
-import javax.swing.JPanel;
-
-/**
- * This class extends the JPanel to create grid panel given the possibility to
- * place Java components in an organized manner in the dialog box.
- *
- * @author Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland.
- *
- */
-public class JPanelImage extends JPanel {
-
- private Image image;
-
- public JPanelImage() {
- super();
- }
- public JPanelImage(BufferedImage img) {
- super();
- image = img;
- }
-
- public JPanelImage(String filename) {
- super();
- image = ImageLoader.get(filename);
- }
-
- public void setImage(BufferedImage image) {
- this.image = image;
- repaint();
- }
-
-
- @Override
- protected void paintComponent(Graphics g) {
- super.paintComponent(g);
- if (image != null) {
- g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
- }
- else {
- g.setColor(Color.DARK_GRAY);
- g.fillRect(0, 0, getWidth(), getHeight());
- }
- }
-}
diff --git a/DeconvolutionLab2/src/bilib/component/LabelImage.java b/DeconvolutionLab2/src/bilib/component/LabelImage.java
deleted file mode 100644
index c0b2aab..0000000
--- a/DeconvolutionLab2/src/bilib/component/LabelImage.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * DeconvolutionLab2
- *
- * Conditions of use: You are free to use this software for research or
- * educational purposes. In addition, we expect you to include adequate
- * citations and acknowledgments whenever you present or publish results that
- * are based on it.
- *
- * Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
- * Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
- * R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
- */
-
-/*
- * Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
- *
- * This file is part of DeconvolutionLab2 (DL2).
- *
- * DL2 is free software: you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * DL2. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package bilib.component;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics;
-import java.awt.Image;
-
-import javax.swing.JLabel;
-
-public class LabelImage extends JLabel {
-
- private Image image;
-
- public LabelImage(String filename, int width, int height, Color altColor) {
- image = ImageLoader.get(filename);
- setOpaque(true);
- setBackground(altColor);
- setPreferredSize(new Dimension(200, 60));
- }
-
- @Override
- protected void paintComponent(Graphics g) {
- super.paintComponent(g);
- if (image != null)
- g.drawImage(image, 0, 0, getWidth(), getHeight(), this);
- }
-}
diff --git a/DeconvolutionLab2/src/bilib/component/PanelImage.java b/DeconvolutionLab2/src/bilib/component/PanelImage.java
index 8ee743b..304113f 100644
--- a/DeconvolutionLab2/src/bilib/component/PanelImage.java
+++ b/DeconvolutionLab2/src/bilib/component/PanelImage.java
@@ -1,53 +1,64 @@
package bilib.component;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import javax.swing.JPanel;
+import deconvolutionlab.splash.ImageLoader;
+
public class PanelImage extends JPanel {
private Image image;
private int w = -1;
private int h = -1;
+ public PanelImage() {
+ super();
+ }
+
public PanelImage(String filename) {
super();
image = ImageLoader.get(filename);
}
public PanelImage(int w, int h) {
super();
image = null;
this.w = w;
this.h = h;
}
public PanelImage(String filename, int w, int h) {
super();
image = ImageLoader.get(filename);
this.w = w;
this.h = h;
}
-
+
+ public void setImage(BufferedImage image) {
+ this.image = image;
+ repaint();
+ }
+
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (image != null) {
if (w < 0)
g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
else {
g.setColor(Color.WHITE);
g.fillRect(0, 0, getWidth(), getHeight());
g.drawImage(image, (getWidth()-w)/2, 0, w, h, null);
}
}
else {
g.setColor(Color.DARK_GRAY);
g.fillRect(0, 0, getWidth(), getHeight());
}
}
}
diff --git a/DeconvolutionLab2/src/bilib/component/CustomizedColumn.java b/DeconvolutionLab2/src/bilib/table/CustomizedColumn.java
similarity index 98%
rename from DeconvolutionLab2/src/bilib/component/CustomizedColumn.java
rename to DeconvolutionLab2/src/bilib/table/CustomizedColumn.java
index ecca2c4..43fc093 100644
--- a/DeconvolutionLab2/src/bilib/component/CustomizedColumn.java
+++ b/DeconvolutionLab2/src/bilib/table/CustomizedColumn.java
@@ -1,67 +1,67 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package bilib.component;
+package bilib.table;
public class CustomizedColumn {
public Class<?> classe;
public String header;
public int width;
public boolean editable;
public String[] choices; // Combobox
public String button; // Button
public String tooltip;
public CustomizedColumn(String header, Class<?> classe, int width, boolean editable) {
this.classe = classe;
this.header = header;
this.width = width;
this.editable = editable;
}
public CustomizedColumn(String header, Class<?> classe, int width, String[] choices, String tooltip) {
this.classe = classe;
this.header = header;
this.width = width;
this.editable = true;
this.choices = choices;
this.tooltip = tooltip;
}
public CustomizedColumn(String header, Class<?> classe, int width, String button, String tooltip) {
this.classe = classe;
this.header = header;
this.width = width;
this.editable = false;
this.button = button;
this.tooltip = tooltip;
}
}
diff --git a/DeconvolutionLab2/src/bilib/component/CustomizedTable.java b/DeconvolutionLab2/src/bilib/table/CustomizedTable.java
similarity index 99%
rename from DeconvolutionLab2/src/bilib/component/CustomizedTable.java
rename to DeconvolutionLab2/src/bilib/table/CustomizedTable.java
index a53bf91..ae916d9 100644
--- a/DeconvolutionLab2/src/bilib/component/CustomizedTable.java
+++ b/DeconvolutionLab2/src/bilib/table/CustomizedTable.java
@@ -1,298 +1,298 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package bilib.component;
+package bilib.table;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Rectangle;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
public class CustomizedTable extends JTable {
private JScrollPane pane = null;
private ArrayList<CustomizedColumn> columns;
public CustomizedTable(String headers[], boolean sortable) {
ArrayList<CustomizedColumn> colums = new ArrayList<CustomizedColumn>();
for (int i = 0; i < headers.length; i++)
colums.add(new CustomizedColumn(headers[i], String.class, 150, false));
create(colums);
setAutoCreateRowSorter(sortable);
setRowHeight(20);
}
public CustomizedTable(ArrayList<CustomizedColumn> columns, boolean sortable) {
create(columns);
setAutoCreateRowSorter(sortable);
setRowHeight(20);
}
private void create(ArrayList<CustomizedColumn> column) {
columns = column;
DefaultTableModel model = new DefaultTableModel() {
@Override
public boolean isCellEditable(int row, int col) {
return columns.get(col).editable;
}
@Override
public Class<?> getColumnClass(int col) {
return columns.get(col).classe;
}
};
setModel(model);
int n = columns.size();
String headers[] = new String[n];
for (int col = 0; col < n; col++)
headers[col] = columns.get(col).header;
model.setColumnIdentifiers(headers);
setFillsViewportHeight(true);
for (int col = 0; col < n; col++) {
TableColumn tc = getColumnModel().getColumn(col);
tc.setPreferredWidth(columns.get(col).width);
if (columns.get(col).choices != null) {
JComboBox<String> cmb = new JComboBox<String>();
for (String p : columns.get(col).choices) {
cmb.addItem(p);
cmb.setToolTipText(columns.get(col).tooltip);
tc.setCellEditor(new DefaultCellEditor(cmb));
}
}
if (columns.get(col).button != null) {
ButtonRenderer bn = new ButtonRenderer();
bn.setToolTipText(columns.get(col).tooltip);
tc.setCellRenderer(bn);
}
}
getTableHeader().setReorderingAllowed(false);
}
public void setPreferredSize(int width, int height) {
if (pane != null)
pane.setPreferredSize(new Dimension(width, height));
}
public void removeRow(int row) {
if (row >= 0 && row < getRowCount())
((DefaultTableModel) getModel()).removeRow(row);
}
public void removeRows() {
while(getRowCount() > 0)
((DefaultTableModel) getModel()).removeRow(0);
}
public String[] getRow(int row) {
if (row >= 0) {
int ncol = getColumnCount();
String items[] = new String[ncol];
for (int col = 0; col < ncol; col++)
items[col] = (String) getModel().getValueAt(row, col);
return items;
}
return new String[1];
}
public String getCell(int row, int col) {
if (row >= 0 && col >= 0) {
return (String) getModel().getValueAt(row, col);
}
return "";
}
public void setCell(int row, int col, String value) {
if (row >= 0 && col >= 0) {
getModel().setValueAt(value, row, col);
}
}
public String getRowCSV(int row, String seperator) {
if (row >= 0) {
int ncol = getColumnCount();
String items = "";
for (int col = 0; col < ncol - 1; col++) {
if ((String) getModel().getValueAt(row, col) == null)
items += "" + seperator;
else
items += (String) getModel().getValueAt(row, col) + seperator;
}
if (ncol >= 1)
items += (String) getModel().getValueAt(row, ncol - 1);
return items;
}
return "";
}
public void saveCSV(String filename) {
File file = new File(filename);
try {
BufferedWriter buffer = new BufferedWriter(new FileWriter(file));
int nrows = getRowCount();
int ncols = getColumnCount();
String row = "";
for (int c = 0; c < columns.size(); c++)
row += columns.get(c).header + (c == columns.size() - 1 ? "" : ", ");
buffer.write(row + "\n");
for (int r = 0; r < nrows; r++) {
row = "";
for (int c = 0; c < ncols; c++)
row += this.getCell(r, c) + (c == ncols - 1 ? "" : ", ");
buffer.write(row + "\n");
}
buffer.close();
}
catch (IOException ex) {
}
}
public String getSelectedAtColumn(int col) {
int row = getSelectedRow();
if (row >= 0)
return (String) getModel().getValueAt(row, col);
else
return "";
}
public void setSelectedAtColumn(int col, String selection) {
int nrows = this.getRowCount();
for (int i = 0; i < nrows; i++) {
String name = (String) getModel().getValueAt(i, col);
if (name.equals(selection))
this.setRowSelectionInterval(i, i + 1);
}
}
public void append(Object[] row) {
DefaultTableModel model = (DefaultTableModel) getModel();
int i = 0;
try {
model.addRow(row);
i = getRowCount() - 1;
if (i >= 0) {
getSelectionModel().setSelectionInterval(i, i);
scrollRectToVisible(new Rectangle(getCellRect(i, 0, true)));
}
}
catch (Exception e) {
}
repaint();
}
public void insert(Object[] row) {
DefaultTableModel model = (DefaultTableModel) getModel();
int i = 0;
try {
model.insertRow(0, row);
getSelectionModel().setSelectionInterval(i, i);
scrollRectToVisible(new Rectangle(getCellRect(i, 0, true)));
}
catch (Exception e) {
}
repaint();
}
@Override
public int getSelectedRow() {
int row = super.getSelectedRow();
if (row < 0) {
if (getRowCount() > 0) {
setRowSelectionInterval(0, 0);
row = super.getSelectedRow();
}
return row;
}
return row;
}
public void update(ArrayList<String[]> data) {
DefaultTableModel model = (DefaultTableModel) getModel();
model.getDataVector().removeAllElements();
for (String[] row : data)
model.addRow(row);
repaint();
}
public JScrollPane getPane(int width, int height) {
setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
setPreferredScrollableViewportSize(new Dimension(width, height));
setFillsViewportHeight(true);
pane = new JScrollPane(this);
return pane;
}
public JScrollPane getMinimumPane(int width, int height) {
setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
setMinimumSize(new Dimension(width, height));
setShowVerticalLines(true);
setPreferredScrollableViewportSize(new Dimension(width, height));
setFillsViewportHeight(true);
return new JScrollPane(this);
}
public JFrame show(String title, int w, int h) {
JFrame frame = new JFrame(title);
frame.add(getPane(w, h));
frame.pack();
frame.setVisible(true);
return frame;
}
public class ButtonRenderer extends JButton implements TableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
setText((String)value);
setMargin(new Insets(1, 1, 1, 1));
return this;
}
}
}
diff --git a/DeconvolutionLab2/src/bilib/tools/NoiseGenerator.java b/DeconvolutionLab2/src/bilib/tools/NoiseGenerator.java
deleted file mode 100644
index 087f216..0000000
--- a/DeconvolutionLab2/src/bilib/tools/NoiseGenerator.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * DeconvolutionLab2
- *
- * Conditions of use: You are free to use this software for research or
- * educational purposes. In addition, we expect you to include adequate
- * citations and acknowledgments whenever you present or publish results that
- * are based on it.
- *
- * Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
- * Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
- * R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
- */
-
-/*
- * Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
- *
- * This file is part of DeconvolutionLab2 (DL2).
- *
- * DL2 is free software: you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * DL2. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package bilib.tools;
-
-import signal.RealSignal;
-
-public class NoiseGenerator {
-
- private static PsRandom rand = new PsRandom();
-
- private NoiseGenerator() {
- }
-
- public void setSeed(long seed) {
- rand.setSeed(seed);
- }
-
- public static void gaussian(RealSignal x, double mean, double sd) {
- for (int k = 0; k < x.nz; k++) {
- float[] slice = x.getXY(k);
- for (int j = 0; j < x.ny * x.nx; j++)
- slice[j] += (float) rand.nextGaussian(mean, sd);
- }
- }
-
- public static void poisson(RealSignal x, double mean) {
- for (int k = 0; k < x.nz; k++) {
- float[] slice = x.getXY(k);
- for (int j = 0; j < x.ny * x.nx; j++)
- slice[j] += (float) rand.nextPoissonian(mean);
- }
- }
-
-}
diff --git a/DeconvolutionLab2/src/bilib/tools/NumFormat.java b/DeconvolutionLab2/src/bilib/tools/NumFormat.java
index cde37fa..912a246 100644
--- a/DeconvolutionLab2/src/bilib/tools/NumFormat.java
+++ b/DeconvolutionLab2/src/bilib/tools/NumFormat.java
@@ -1,174 +1,129 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package bilib.tools;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class NumFormat {
- public static String[] floatRepresentation(double a) {
- double[] base = { 10, 5, 3, 2 };
- double min = Double.MAX_VALUE;
- double mantisse = 0;
- double exp = 1;
- for (int i = 0; i < base.length; i++) {
- double p = Math.log(a) / Math.log(base[i]);
- double e = roundToNumberOfSignificantDigits(p, 3);
- double b = Math.pow(base[i], e);
- if (Math.abs(a-b) < min) {
- mantisse = base[i];
- exp = e;
- min = Math.abs(a-b);
- }
- }
- return new String[] { "" + mantisse, "" + exp };
- }
-
- public static double roundToNumberOfSignificantDigits(double num, int n) {
- double maxPowerOfTen = Math.floor(Math.log10(Double.MAX_VALUE));
- if (num == 0) {
- return 0;
- }
- final double d = Math.ceil(Math.log10(num < 0 ? -num : num));
- final int power = n - (int) d;
-
- double firstMagnitudeFactor = 1.0;
- double secondMagnitudeFactor = 1.0;
- if (power > maxPowerOfTen) {
- firstMagnitudeFactor = Math.pow(10.0, maxPowerOfTen);
- secondMagnitudeFactor = Math.pow(10.0, (double) power - maxPowerOfTen);
- }
- else {
- firstMagnitudeFactor = Math.pow(10.0, (double) power);
- }
-
- double toBeRounded = num * firstMagnitudeFactor;
- toBeRounded *= secondMagnitudeFactor;
-
- final long shifted = Math.round(toBeRounded);
- double rounded = ((double) shifted) / firstMagnitudeFactor;
- rounded /= secondMagnitudeFactor;
- return rounded;
- }
-
public static double parseNumber(String line, double def) {
double[] numbers = parseNumbers(line);
if (numbers.length >= 1)
return numbers[0];
else
return def;
}
public static double[] parseNumbers(String line) {
ArrayList<String> num = new ArrayList<String>();
Pattern p = Pattern.compile("[-+]?[0-9]+[.]?[0-9]*([eE][-+]?[0-9]+)?");
Matcher m = p.matcher(line);
while (m.find()) {
num.add(m.group());
}
double number[] = new double[num.size()];
for (int i = 0; i < num.size(); i++)
number[i] = Double.parseDouble(num.get(i));
return number;
}
public static String nice(double a) {
double b = Math.abs(a);
String n = a < 0 ? "-" : " ";
if (a == 0)
return "0.0";
if (b > 3000.0)
return String.format(n + "%6.3E", b);
if (b > 300.0)
return String.format(n + "%4.1f", b);
if (b > 30.0)
return String.format(n + "%3.2f", b);
if (b > 3.0)
return String.format(n + "%2.4f", b);
if (b > 0.003)
return String.format(n + "%1.4f", b);
return String.format(n + "%6.3E", b).trim();
}
public static String seconds(double ns) {
return String.format("%5.1f s", ns * 1e-9);
}
public static String time(double ns) {
if (ns < 3000.0)
return String.format("%3.2f ns", ns);
ns *= 0.001;
if (ns < 3000.0)
return String.format("%3.2f us", ns);
ns *= 0.001;
if (ns < 3000.0)
return String.format("%3.2f ms", ns);
ns *= 0.001;
if (ns < 3600.0 * 3)
return String.format("%3.2f s", ns);
ns /= 3600;
return String.format("%3.2f h", ns);
}
public static String bytes(double bytes) {
if (bytes < 3000)
return String.format("%3.0f", bytes);
bytes /= 1024.0;
if (bytes < 3000)
return String.format("%3.1f Kb", bytes);
bytes /= 1024.0;
if (bytes < 3000)
return String.format("%3.1f Mb", bytes);
bytes /= 1024.0;
if (bytes < 3000)
return String.format("%3.1f Gb", bytes);
bytes /= 1024.0;
return String.format("%3.1f Tb", bytes);
}
public static String toPercent(String value) {
try {
return toPercent(Double.parseDouble(value));
}
catch (Exception ex) {
}
return value;
}
public static String toPercent(double value) {
return String.format("%5.3f", value * 100) + "%";
}
}
diff --git a/DeconvolutionLab2/src/bilib/tools/Tools.java b/DeconvolutionLab2/src/bilib/tools/Tools.java
deleted file mode 100644
index 56e8cfe..0000000
--- a/DeconvolutionLab2/src/bilib/tools/Tools.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package bilib.tools;
-
-/*
- * DeconvolutionLab2
- *
- * Conditions of use: You are free to use this software for research or
- * educational purposes. In addition, we expect you to include adequate
- * citations and acknowledgments whenever you present or publish results that
- * are based on it.
- *
- * Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
- * Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
- * R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
- */
-
-/*
- * Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
- *
- * This file is part of DeconvolutionLab2 (DL2).
- *
- * DL2 is free software: you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * DL2. If not, see <http://www.gnu.org/licenses/>.
- */
-
-import java.io.File;
-import java.security.CodeSource;
-
-public class Tools {
-
- public static String[] explodeLower(String line, String regex) {
- String[] items = line.split(regex);
- String[] out = new String[items.length];
- for(int i=0; i<items.length; i++)
- out[i] = items[i].trim().toLowerCase();
- return out;
- }
-
- public static String[] explodeCase(String line, String regex) {
- String[] items = line.split(regex);
- String[] out = new String[items.length];
- for(int i=0; i<items.length; i++)
- out[i] = items[i].trim();
- return out;
- }
-
-
- public static String ellipsis(String text, int length) {
- int l = text.length();
- if (l <= length)
- return text;
- String result =
- text.substring(0,length/2) +
- "..." +
- text.substring(text.length()-length/2+3, text.length());
- return result;
- }
-
- public static String getWorkingPath() {
- try {
- CodeSource codeSource = Tools.class.getProtectionDomain().getCodeSource();
- File jarFile = new File(codeSource.getLocation().toURI().getPath());
- return jarFile.getParentFile().getPath() + File.separator;
- }
- catch(Exception ex) {
- return System.getProperty("user.dir") + File.separator;
- }
- }
-
-}
diff --git a/DeconvolutionLab2/src/course/DeconvolutionLab2_JavaCoding.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_JavaCoding.java
new file mode 100644
index 0000000..bdb1d9b
--- /dev/null
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_JavaCoding.java
@@ -0,0 +1,78 @@
+/*
+ * DeconvolutionLab2
+ *
+ * Conditions of use: You are free to use this software for research or
+ * educational purposes. In addition, we expect you to include adequate
+ * citations and acknowledgments whenever you present or publish results that
+ * are based on it.
+ *
+ * Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
+ * Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
+ * R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
+ */
+
+/*
+ * Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
+ *
+ * This file is part of DeconvolutionLab2 (DL2).
+ *
+ * DL2 is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * DL2. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package course;
+
+import java.io.File;
+
+import javax.swing.filechooser.FileSystemView;
+
+import deconvolution.algorithm.Convolution;
+import deconvolutionlab.Lab;
+import deconvolutionlab.monitor.Monitors;
+import ij.plugin.PlugIn;
+import signal.RealSignal;
+
+public class DeconvolutionLab2_JavaCoding implements PlugIn {
+
+ private String desktop = FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath() + File.separator + "Desktop";
+ private String root = desktop + File.separator + "Deconvolution" + File.separator;
+ private String res = root + "results" + File.separator + "bigradient" + File.separator;
+ private String data = root + "data" + File.separator + "bigradient" + File.separator;
+
+ public DeconvolutionLab2_JavaCoding() {
+
+ Monitors monitors = new Monitors();
+
+ RealSignal image = Lab.openFile(filename);
+
+ Convolution convolution = new Convolution();
+
+
+ RealSignal a = convolution.run(monitors, image, psf, fftlib, pad, apo, norm, threaded);
+
+ }
+
+ private static String out(String root, String name) {
+ return "out stats " + root + name +
+ " -out stack " + root + name + "_32 -out stack " + root + name + "_8 rescaled byte noshow";
+ }
+
+ public static void main(String arg[]) {
+ new DeconvolutionLab2_JavaCoding();
+ }
+
+ @Override
+ public void run(String arg) {
+ new DeconvolutionLab2_JavaCoding();
+ }
+
+}
diff --git a/DeconvolutionLab2/src/course/DeconvolutionLab2_MemoryFootprint.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_MemoryFootprint.java
index d1146a8..6bc3659 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_MemoryFootprint.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_MemoryFootprint.java
@@ -1,103 +1,103 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package course;
-import bilib.component.CustomizedTable;
+import bilib.table.CustomizedTable;
import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
import ij.plugin.PlugIn;
import signal.SignalCollector;
public class DeconvolutionLab2_MemoryFootprint implements PlugIn {
public DeconvolutionLab2_MemoryFootprint() {
CustomizedTable table = new CustomizedTable(new String[] { "Name", "Algo", "Optimized", "Time", "Energy", "Peak Count", "Peak Bytes", "End Count", "End Byte", "Ratio" }, true);
table.show("Memory Footprint", 1100, 300);
run(table, "CONV");
run(table, "FISTA 10 1 1");
run(table, "ICTM 10 1 0.1");
run(table, "I");
run(table, "ISTA 10 1 1");
run(table, "LW 10 1");
run(table, "LLS 10 1");
run(table, "NLLS 10 1");
run(table, "NIF");
run(table, "DIV");
run(table, "RIF 1");
run(table, "RL 10");
run(table, "RLTV 10 1");
run(table, "SIM 1 1 1");
run(table, "BVLS 10 1");
run(table, "TM 10 1 0.1");
run(table, "TRIF 1");
run(table, "VC 10 1");
}
private void run(CustomizedTable table, String cmd) {
int nx = 64;
int ny = 32;
int nz = 12;
String size = " size " + nx + " " + ny + " " + nz;
String image = " -image synthetic Cross 110 0 1 1 80.0 " + size;
String psf = " -psf synthetic Double-Helix 100 0 3 10 10 " + size;
for (int i = 0; i <= 1; i++) {
SignalCollector.resetSignals();
SignalCollector.clear();
Deconvolution d = new Deconvolution("noise", " -algorithm " + cmd + psf + image + " -display no");
boolean optimized = i == 1;
d.getAlgo().setOptimizedMemoryFootprint(optimized);
String n = d.getAlgo().getName();
double chrono = System.nanoTime();
d.run();
String energy = "" + d.getOutput().getEnergy();
String time = NumFormat.time(System.nanoTime() - chrono);
int cp = SignalCollector.getCountPeakSignals();
int cs = SignalCollector.getCountSignals();
long bp = SignalCollector.getBytesPeakSignals();
long bs = SignalCollector.getBytesSignals();
double ratio = (bp + bs) / (nx * ny * nz * 4);
table.append(new String[] { n, cmd, "" + optimized, time, energy, "" + cp, NumFormat.bytes(bp), "" + cs, NumFormat.bytes(bs), NumFormat.nice(ratio) });
}
}
public static void main(String arg[]) {
new DeconvolutionLab2_MemoryFootprint();
}
@Override
public void run(String arg) {
new DeconvolutionLab2_MemoryFootprint();
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java b/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
index 119225a..c99c3d4 100644
--- a/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
+++ b/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
@@ -1,379 +1,379 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JToolBar;
import bilib.component.BorderToggledButton;
-import bilib.component.JPanelImage;
+import bilib.component.PanelImage;
import deconvolution.modules.AlgorithmDModule;
import deconvolution.modules.ImageDModule;
import deconvolution.modules.PSFDModule;
import deconvolution.modules.RecapDModule;
import deconvolution.modules.ReportDModule;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import deconvolutionlab.TableStats;
import deconvolutionlab.monitor.StatusMonitor;
import deconvolutionlab.monitor.TableMonitor;
public class DeconvolutionDialog extends JDialog implements WindowListener, ActionListener, Runnable {
public enum State {
NOTDEFINED, READY, RUN, FINISH
};
public enum Module {
ALL, RECAP, IMAGE, PSF, ALGO
};
private JButton bnStart = new JButton("Run");
private JButton bnStop = new JButton("Stop");
private JButton bnReset = new JButton("Reset");
private JButton bnHelp = new JButton("Help");
private JButton bnQuit = new JButton("Quit");
private BorderToggledButton bnRecap = new BorderToggledButton("Recap");
private BorderToggledButton bnImage = new BorderToggledButton("Image");
private BorderToggledButton bnPSF = new BorderToggledButton("PSF");
private BorderToggledButton bnAlgo = new BorderToggledButton("Algorithm");
private BorderToggledButton bnReport = new BorderToggledButton("Report");
private BorderToggledButton bnMonitor = new BorderToggledButton("Monitor");
private BorderToggledButton bnStats = new BorderToggledButton("Stats");
private Thread thread = null;
private Deconvolution deconvolution;
private JProgressBar progress = new JProgressBar();
public static Point location = new Point(0, 0);
private JPanel cards = new JPanel(new CardLayout());
private boolean flagMonitor = false;
private boolean flagStats = false;
private ImageDModule image;
private PSFDModule psf;
private RecapDModule recap;
private AlgorithmDModule algorithm;
private ReportDModule report;
private TableStats tableStats;
private TableMonitor tableMonitor;
public DeconvolutionDialog(Module module, Deconvolution deconvolution, TableMonitor tableMonitor, TableStats tableStats) {
super(new JFrame(), deconvolution.getName());
this.deconvolution = deconvolution;
this.tableMonitor = tableMonitor;
this.tableStats = tableStats;
image = new ImageDModule(deconvolution);
psf = new PSFDModule(deconvolution);
recap = new RecapDModule(deconvolution);
algorithm = new AlgorithmDModule(deconvolution);
report = new ReportDModule(deconvolution);
// Panel status bar on bottom
progress.setAlignmentX(JLabel.CENTER_ALIGNMENT);
progress.setBorder(BorderFactory.createLoweredBevelBorder());
JToolBar statusBar = new JToolBar();
statusBar.setBorder(BorderFactory.createLoweredBevelBorder());
statusBar.setFloatable(false);
statusBar.setLayout(new BorderLayout());
statusBar.add(bnHelp, BorderLayout.WEST);
statusBar.add(progress, BorderLayout.CENTER);
statusBar.add(bnQuit, BorderLayout.EAST);
// Panel bottom
JPanel bottom = new JPanel();
bottom.setLayout(new BoxLayout(bottom, BoxLayout.PAGE_AXIS));
// Panel buttons
if (module == Module.ALL) {
- JPanelImage buttons = new JPanelImage("celegans.jpg");
+ PanelImage buttons = new PanelImage("celegans.jpg");
buttons.setLayout(new FlowLayout());
buttons.setBorder(BorderFactory.createEtchedBorder());
buttons.add(bnReset);
buttons.add(bnStop);
buttons.add(bnStart);
bottom.add(buttons);
}
bottom.add(statusBar);
// Panel Image
cards.add(recap.getName(), recap.getPane());
cards.add(image.getName(), image.getPane());
cards.add(psf.getName(), psf.getPane());
cards.add(algorithm.getName(), algorithm.getPane());
cards.add(report.getName(), report.getPane());
if (tableMonitor != null)
cards.add("Monitor", tableMonitor.getPanel());
if (tableStats != null)
cards.add("Stats", tableStats.getPanel());
// Panel Main
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(cards, BorderLayout.CENTER);
panel.add(bottom, BorderLayout.SOUTH);
// Panel tool with all buttons
if (module == Module.ALL) {
JToolBar tool = new JToolBar();
tool.setFloatable(false);
tool.setLayout(new GridLayout(1, 6));
tool.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
tool.add(bnRecap);
tool.add(bnImage);
tool.add(bnPSF);
tool.add(bnAlgo);
if (tableMonitor != null)
tool.add(bnMonitor);
if (tableStats != null)
tool.add(bnStats);
tool.add(bnReport);
panel.add(tool, BorderLayout.NORTH);
}
add(panel);
bnReset.addActionListener(this);
bnQuit.addActionListener(this);
bnStart.addActionListener(this);
bnStop.addActionListener(this);
bnHelp.addActionListener(this);
bnImage.addActionListener(this);
bnPSF.addActionListener(this);
bnAlgo.addActionListener(this);
bnRecap.addActionListener(this);
if (tableMonitor != null)
bnMonitor.addActionListener(this);
if (tableStats != null)
bnStats.addActionListener(this);
bnReport.addActionListener(this);
this.addWindowListener(this);
setMinimumSize(new Dimension(Constants.widthGUI, 400));
setPreferredSize(new Dimension(Constants.widthGUI, 400));
pack();
Config.registerFrame("DeconvolutionLab", "DeconvolutionDialog", this);
Rectangle rect = Config.getDialog("DeconvolutionLab.DeconvolutionDialog");
if (rect.x > 0 && rect.y > 0)
setLocation(rect.x, rect.y);
bnStop.setEnabled(false);
if (module == Module.ALL) {
toggle(bnRecap);
recap.update();
}
if (module == Module.IMAGE) {
toggle(bnImage);
deconvolution.monitors.add(new StatusMonitor(getProgressBar()));
image.update();
}
if (module == Module.PSF) {
toggle(bnPSF);
deconvolution.monitors.add(new StatusMonitor(getProgressBar()));
psf.update();
}
if (module == Module.ALGO) {
toggle(bnAlgo);
deconvolution.monitors.add(new StatusMonitor(getProgressBar()));
algorithm.update();
}
if (module == Module.RECAP) {
toggle(bnRecap);
recap.update();
}
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnStart) {
if (flagMonitor)
toggle(bnMonitor);
else if (flagStats)
toggle(bnStats);
if (thread == null) {
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
}
else if (e.getSource() == bnStop) {
toggle(bnReport);
if (deconvolution != null)
deconvolution.abort();
}
else if (e.getSource() == bnImage) {
toggle(bnImage);
image.update();
}
else if (e.getSource() == bnPSF) {
toggle(bnPSF);
psf.update();
}
else if (e.getSource() == bnAlgo) {
toggle(bnAlgo);
algorithm.update();
}
else if (e.getSource() == bnRecap) {
toggle(bnRecap);
recap.update();
}
else if (e.getSource() == bnReport) {
toggle(bnReport);
report.update();
}
else if (e.getSource() == bnReset) {
toggle(bnRecap);
if (tableMonitor != null)
tableMonitor.clear();
if (tableStats != null)
tableStats.clear();
bnStart.setEnabled(true);
}
else if (e.getSource() == bnQuit) {
deconvolution.close();
deconvolution = null;
dispose();
}
else if (e.getSource() == bnHelp)
Lab.help();
else if (e.getSource() == bnMonitor)
toggle(bnMonitor);
else if (e.getSource() == bnStats)
toggle(bnStats);
}
@Override
public void run() {
bnRecap.setEnabled(false);
bnImage.setEnabled(false);
bnPSF.setEnabled(false);
bnAlgo.setEnabled(false);
bnStart.setEnabled(false);
bnStop.setEnabled(true);
deconvolution.setCommand(recap.getCommand());
deconvolution.run();
toggle(bnReport);
bnStop.setEnabled(false);
report.update();
bnRecap.setEnabled(true);
bnAlgo.setEnabled(true);
bnPSF.setEnabled(true);
bnImage.setEnabled(true);
thread = null;
}
public static void setLocationLaunch(Point l) {
location = l;
}
private void toggle(BorderToggledButton bn) {
((CardLayout) (cards.getLayout())).show(cards, bn.getText());
bnRecap.setSelected(false);
bnImage.setSelected(false);
bnPSF.setSelected(false);
bnAlgo.setSelected(false);
bnMonitor.setSelected(false);
bnStats.setSelected(false);
bnReport.setSelected(false);
bn.setSelected(true);
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
deconvolution.close();
deconvolution = null;
dispose();
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
public JProgressBar getProgressBar() {
return progress;
}
}
diff --git a/DeconvolutionLab2/src/bilib/component/RegularizationPanel.java b/DeconvolutionLab2/src/deconvolution/RegularizationPanel.java
similarity index 98%
rename from DeconvolutionLab2/src/bilib/component/RegularizationPanel.java
rename to DeconvolutionLab2/src/deconvolution/RegularizationPanel.java
index 452e89e..d1f116d 100644
--- a/DeconvolutionLab2/src/bilib/component/RegularizationPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/RegularizationPanel.java
@@ -1,83 +1,83 @@
-package bilib.component;
+package deconvolution;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.Hashtable;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.JTextField;
import bilib.tools.NumFormat;
public class RegularizationPanel extends JPanel {
private JSlider slider = new JSlider();
private JTextField txt = new JTextField(10);
private double base = Math.pow(10, 1. / 3.0);
private double logbase = Math.log(base);
public RegularizationPanel(double value) {
setLayout(new BorderLayout());
slider.setMinimum(-54);
slider.setMaximum(30);
slider.setPreferredSize(new Dimension(200, 40));
int p = (int) Math.round(Math.log(Math.abs(value)) / logbase);
slider.setValue(p);
Hashtable<Integer, JLabel> labels = new Hashtable<Integer, JLabel>();
JLabel lbl0 = new JLabel("Off");
JLabel lbl1 = new JLabel("Low");
JLabel lbl2 = new JLabel("High");
JLabel lbl4 = new JLabel("1E-6");
JLabel lbl5 = new JLabel("1.0");
java.awt.Font font = lbl1.getFont();
java.awt.Font small = new java.awt.Font(font.getFamily(), font.getStyle(), font.getSize() - 3);
lbl0.setFont(small);
lbl1.setFont(small);
lbl2.setFont(small);
lbl4.setFont(small);
lbl5.setFont(small);
labels.put(-54, lbl0);
labels.put(-36, lbl1);
labels.put(-18, lbl4);
labels.put(0, lbl5);
labels.put(27, lbl2);
slider.setMinorTickSpacing(3);
// js.setSnapToTicks(true);
slider.setPaintTicks(true);
slider.setPaintLabels(true);
slider.setMajorTickSpacing(9);
slider.setLabelTable(labels);
add(new JLabel("<html>Reg. &lambda;</html>"), BorderLayout.WEST);
add(slider, BorderLayout.CENTER);
add(txt, BorderLayout.EAST);
}
public JSlider getSlider() {
return slider;
}
public JTextField getText() {
return txt;
}
public void updateFromSlider() {
double d = Math.pow(base, slider.getValue());
d = Math.min(d, Math.pow(base, slider.getMaximum()));
d = Math.max(d, Math.pow(base, slider.getMinimum()));
txt.setText(NumFormat.nice(d));
}
public void updateFromText() {
String typed = txt.getText();
double value = NumFormat.parseNumber(typed, 1);
int p = (int) Math.round(Math.log(Math.abs(value)) / logbase);
slider.setValue(p);
}
public double getValue() {
return Math.pow(base, slider.getValue());
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/FISTAPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/FISTAPanel.java
index 66bcaac..a96e210 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/FISTAPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/FISTAPanel.java
@@ -1,167 +1,167 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.GridPanel;
-import bilib.component.RegularizationPanel;
import bilib.component.SpinnerRangeDouble;
import bilib.component.SpinnerRangeInteger;
import bilib.tools.NumFormat;
import deconvolution.Command;
+import deconvolution.RegularizationPanel;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import wavelets.AbstractWavelets;
import wavelets.Wavelets;
public class FISTAPanel extends AbstractAlgorithmPanel implements KeyListener, ActionListener, ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1, "###");
private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1, "#.#");
private RegularizationPanel reg;
private JComboBox<String> cmbWav = new JComboBox<String>(Wavelets.getWaveletsAsArray());
private JComboBox<String> cmbScale = new JComboBox<String>(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" });
private FISTA algo = new FISTA(10, 1, 0.1, "Haar", 3);
@Override
public JPanel getPanelParameters() {
AbstractWavelets wavdef = Wavelets.getDefaultWavelets();
double[] params = algo.getDefaultParameters();
reg = new RegularizationPanel(params[2]);
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
cmbWav.setPreferredSize(Constants.dimParameters);
cmbScale.setPreferredSize(Constants.dimParameters);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
pn.place(2, 0, 5, 1, reg);
pn.place(5, 0, "<html><span \"nowrap\"><b>Wavelets</b></span></html>");
pn.place(5, 2, cmbWav);
pn.place(5, 3, "<html>Scale</html>");
pn.place(5, 4, cmbScale);
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
Config.register("Algorithm." + algo.getShortname(), "wavelets", cmbWav, wavdef.getName());
Config.register("Algorithm." + algo.getShortname(), "scale", cmbScale, wavdef.getScales());
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
cmbWav.addActionListener(this);
cmbScale.addActionListener(this);
return pn;
}
@Override
public String getCommand() {
int iter = spnIter.get();
double gamma = spnStep.get();
double lambda = reg.getValue();
String waveletsName = (String) cmbWav.getSelectedItem();
int scale = Integer.parseInt((String) cmbScale.getSelectedItem());
return iter + " " + NumFormat.nice(gamma) + " " + NumFormat.nice(lambda) + " " + waveletsName + " " + scale;
}
@Override
public void actionPerformed(ActionEvent e) {
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"FISTA"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<h2>Shortname: FISTA</h2>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p></p>";
s += "<h3>Reference: Beck and Teboulle, SIAM <b>2</b> 2009</h3>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/ICTMPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/ICTMPanel.java
index 24e82df..8952d5e 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/ICTMPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/ICTMPanel.java
@@ -1,144 +1,144 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.GridPanel;
-import bilib.component.RegularizationPanel;
import bilib.component.SpinnerRangeDouble;
import bilib.component.SpinnerRangeInteger;
import bilib.tools.NumFormat;
import deconvolution.Command;
+import deconvolution.RegularizationPanel;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
public class ICTMPanel extends AbstractAlgorithmPanel implements KeyListener, ActionListener, ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1, "###");
private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1, "#.#");
private RegularizationPanel reg;
private ICTM algo = new ICTM(10, 0.1, 1);
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
reg = new RegularizationPanel(params[2]);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
pn.place(2, 0, 5, 1, reg);
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
return pn;
}
@Override
public String getCommand() {
double gamma = spnStep.get();
double lambda = reg.getValue();
return spnIter.get() + " " + NumFormat.nice(gamma) + " " + NumFormat.nice(lambda);
}
@Override
public void actionPerformed(ActionEvent e) {
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"ICTM"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/ISTAPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/ISTAPanel.java
index 16ff813..6d52d27 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/ISTAPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/ISTAPanel.java
@@ -1,165 +1,165 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.GridPanel;
-import bilib.component.RegularizationPanel;
import bilib.component.SpinnerRangeDouble;
import bilib.component.SpinnerRangeInteger;
import bilib.tools.NumFormat;
import deconvolution.Command;
+import deconvolution.RegularizationPanel;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import wavelets.AbstractWavelets;
import wavelets.Wavelets;
public class ISTAPanel extends AbstractAlgorithmPanel implements KeyListener, ActionListener, ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1);
private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1);
private RegularizationPanel reg;
private JComboBox<String> cmbWav = new JComboBox<String>(Wavelets.getWaveletsAsArray());
private JComboBox<String> cmbScale = new JComboBox<String>(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" });
private ISTA algo = new ISTA(0, 1, 0.1, "Haar", 3);
@Override
public JPanel getPanelParameters() {
AbstractWavelets wavdef = Wavelets.getDefaultWavelets();
double[] params = algo.getDefaultParameters();
reg = new RegularizationPanel(params[2]);
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
cmbWav.setPreferredSize(Constants.dimParameters);
cmbScale.setPreferredSize(Constants.dimParameters);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
pn.place(2, 0, 5, 1, reg);
pn.place(5, 0, "<html><span \"nowrap\"><b>Wavelets</b></span></html>");
pn.place(5, 2, cmbWav);
pn.place(5, 3, "<html>Scale</html>");
pn.place(5, 4, cmbScale);
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
Config.register("Algorithm." + algo.getShortname(), "wavelets", cmbWav, wavdef.getName());
Config.register("Algorithm." + algo.getShortname(), "scale", cmbScale, wavdef.getScales());
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
cmbWav.addActionListener(this);
cmbScale.addActionListener(this);
return pn;
}
@Override
public String getCommand() {
int iter = spnIter.get();
double gamma = spnStep.get();
double lambda = reg.getValue();
String waveletsName = (String) cmbWav.getSelectedItem();
int scale = Integer.parseInt((String) cmbScale.getSelectedItem());
return iter + " " + NumFormat.nice(gamma) + " " + NumFormat.nice(lambda) + " " + waveletsName + " " + scale;
}
@Override
public void actionPerformed(ActionEvent e) {
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"ISTA"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/RegularizedInverseFilterPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/RegularizedInverseFilterPanel.java
index a36961c..d1c3ec2 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/RegularizedInverseFilterPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/RegularizedInverseFilterPanel.java
@@ -1,115 +1,115 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.GridPanel;
-import bilib.component.RegularizationPanel;
import bilib.tools.NumFormat;
import deconvolution.Command;
+import deconvolution.RegularizationPanel;
import deconvolutionlab.Config;
public class RegularizedInverseFilterPanel extends AbstractAlgorithmPanel implements KeyListener, ChangeListener {
private RegularizationPanel reg;
private RegularizedInverseFilter algo = new RegularizedInverseFilter(0.1);
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
reg = new RegularizationPanel(params[0]);
GridPanel pn = new GridPanel(false);
pn.place(0, 0, reg);
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
return pn;
}
@Override
public String getCommand() {
return NumFormat.nice(reg.getValue());
}
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"RIF", "LRIF"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<h2>Shortname RIF or LRIF</h2>";
s += "<p>Laplacian Regularized Inverse Filter</p>";
s += "<p>This is a inverse filter with a Laplacian regularization that tends to have an effect on high frequency</p>";
s += "<p>It is very fast, non-iterative algorithm</p>";
s += "<p>The regularization blurs the noise and the image. It is controlled by &lambda;</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyTVPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyTVPanel.java
index 1e7a41b..11982b3 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyTVPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyTVPanel.java
@@ -1,130 +1,130 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.GridPanel;
-import bilib.component.RegularizationPanel;
import bilib.component.SpinnerRangeInteger;
import bilib.tools.NumFormat;
import deconvolution.Command;
+import deconvolution.RegularizationPanel;
import deconvolutionlab.Config;
public class RichardsonLucyTVPanel extends AbstractAlgorithmPanel implements KeyListener, ActionListener, ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1);
private RegularizationPanel reg;
private RichardsonLucyTV algo = new RichardsonLucyTV(10, 0.1);
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
reg = new RegularizationPanel(params[1]);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(2, 0, 3, 1, reg);
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
spnIter.addChangeListener(this);
return pn;
}
@Override
public String getCommand() {
double lambda = reg.getValue();
return spnIter.get() + " " + NumFormat.nice(lambda);
}
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
Command.command();
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"RLTV"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<h2> Shortname: RLTV</h2>";
s += "<p>This algorithm is a combinaison of the Richardson–Lucy algorithm with a regularization constraint based on Total Variation, which tends to reduce unstable oscillations while preserving object edges.</p>";
s += "<p>It is a iterative algorithm, relative slow to compute the Total Variation at every iteration.s</p>";
s += "<p>It has a weighted parameter &lamdba; to control the effect of the total variation.</p>";
s += "<p></p>";
s += "<h3>Reference: Dey et al., Microscopy Research and Technics, 2006 " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovMillerPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovMillerPanel.java
index e131cd2..e41b095 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovMillerPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovMillerPanel.java
@@ -1,142 +1,142 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.GridPanel;
-import bilib.component.RegularizationPanel;
import bilib.component.SpinnerRangeDouble;
import bilib.component.SpinnerRangeInteger;
import bilib.tools.NumFormat;
import deconvolution.Command;
+import deconvolution.RegularizationPanel;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
public class TikhonovMillerPanel extends AbstractAlgorithmPanel implements KeyListener, ActionListener, ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1, "###");
private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1, "#.#");
private RegularizationPanel reg;
private TikhonovMiller algo = new TikhonovMiller(10, 1, 0.1);
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
reg = new RegularizationPanel(params[2]);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
pn.place(2, 0, 5, 1, reg);
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
return pn;
}
@Override
public String getCommand() {
double gamma = spnStep.get();
double lambda = reg.getValue();
return spnIter.get() + " " + NumFormat.nice(gamma) + " " + NumFormat.nice(lambda);
}
@Override
public void actionPerformed(ActionEvent e) {
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"TM"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovRegularizationInverseFilterPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovRegularizationInverseFilterPanel.java
index 9c09017..55feebe 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovRegularizationInverseFilterPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovRegularizationInverseFilterPanel.java
@@ -1,123 +1,123 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.GridPanel;
-import bilib.component.RegularizationPanel;
import bilib.tools.NumFormat;
import deconvolution.Command;
+import deconvolution.RegularizationPanel;
import deconvolutionlab.Config;
public class TikhonovRegularizationInverseFilterPanel extends AbstractAlgorithmPanel implements ActionListener, ChangeListener, KeyListener {
private RegularizationPanel reg;
private TikhonovRegularizationInverseFilter algo = new TikhonovRegularizationInverseFilter(0.1);
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
reg = new RegularizationPanel(params[0]);
GridPanel pn = new GridPanel(false);
pn.place(0, 0, reg);
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
return pn;
}
@Override
public String getCommand() {
return NumFormat.nice(reg.getValue());
}
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
Command.command();
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"TRIF"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<h2>Shortname TRIF</h2>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/modules/AlgorithmDModule.java b/DeconvolutionLab2/src/deconvolution/modules/AlgorithmDModule.java
index 3854b6e..7983173 100644
--- a/DeconvolutionLab2/src/deconvolution/modules/AlgorithmDModule.java
+++ b/DeconvolutionLab2/src/deconvolution/modules/AlgorithmDModule.java
@@ -1,153 +1,153 @@
package deconvolution.modules;
import javax.swing.JSplitPane;
-import bilib.component.CustomizedTable;
import bilib.component.HTMLPane;
+import bilib.table.CustomizedTable;
import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
import deconvolution.Features;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolution.algorithm.AbstractAlgorithmPanel;
import deconvolution.algorithm.Algorithm;
import deconvolution.algorithm.Controller;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.FFT;
import signal.ComplexSignal;
import signal.RealSignal;
import signal.SignalCollector;
public class AlgorithmDModule extends AbstractDModule implements Runnable {
private CustomizedTable table;
private HTMLPane doc;
public AlgorithmDModule(Deconvolution deconvolution) {
super(deconvolution);
doc = new HTMLPane(100, 1000);
table = new CustomizedTable(new String[] { "Features", "Values" }, false);
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(200, 200), doc.getPane());
}
public void update() {
if (doc == null)
return;
if (table == null)
return;
table.removeRows();
table.append(new String[] { "PSF", "Waiting for loading ..." });
Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
split.setDividerLocation(300);
}
@Override
public String getName() {
return "Algorithm";
}
@Override
public void run() {
Features features = new Features();
if (deconvolution.algo == null) {
features.add("Algorithm", "No valid algorithm");
return;
}
AbstractAlgorithm algo = deconvolution.algo;
doc.clear();
String name = algo.getShortname();
AbstractAlgorithmPanel algoPanel = Algorithm.getPanel(name);
if (algoPanel != null)
doc.append(algoPanel.getDocumentation());
if (deconvolution.image == null) {
startAsynchronousTimer("Open image", 200);
deconvolution.image = deconvolution.openImage();
stopAsynchronousTimer();
}
if (deconvolution.image == null) {
features.add("Image", "No valid input image");
return;
}
if (deconvolution.pad == null) {
features.add("Padding", "No valid padding");
return;
}
if (deconvolution.apo == null) {
features.add("Apodization", "No valid apodization");
return;
}
if (deconvolution.psf == null) {
startAsynchronousTimer("Open PSF", 200);
deconvolution.psf = deconvolution.openPSF();
stopAsynchronousTimer();
}
if (deconvolution.psf == null) {
features.add("Image", "No valid PSF");
return;
}
Controller controller = deconvolution.algo.getController();
if (controller == null) {
features.add("Controller", "No valid controller");
return;
}
startAsynchronousTimer("Run FFT", 200);
deconvolution.algo.setController(controller);
AbstractFFT f = FFT.getFastestFFT().getDefaultFFT();
double Q = Math.sqrt(2);
if (deconvolution.image != null) {
int mx = deconvolution.image.nx;
int my = deconvolution.image.ny;
int mz = deconvolution.image.nz;
while (mx * my * mz > Math.pow(2, 15)) {
mx = (int)(mx / Q);
my = (int)(my / Q);
mz = (int)(mz / Q);
}
double N = deconvolution.image.nx * deconvolution.image.ny * deconvolution.image.nz;
double M = mx * my * mz;
double ratio = 1;
if (M != 0)
ratio = (N * Math.log(N)) / (M * Math.log(M));
double chrono = System.nanoTime();
RealSignal x = new RealSignal("test", mx, my, mz);
ComplexSignal c = new ComplexSignal("test", mx, my, mz);
f.init(Monitors.createDefaultMonitor(), mx, my, mz);
f.transform(x, c);
SignalCollector.free(x);
SignalCollector.free(c);
chrono = (System.nanoTime() - chrono);
features.add("Tested on", mx + "x" + my + "x" + mz);
features.add("Estimated Time on small", NumFormat.time(chrono) );
chrono = chrono * ratio * algo.getComplexityNumberofFFT();
int n = algo.isIterative() ? controller.getIterationMax() : 1;
features.add("Estimated Time", NumFormat.time(chrono) );
features.add("Estimated Number of FFT / Transform", ""+algo.getComplexityNumberofFFT());
}
else
features.add("Estimated Time", "Error" );
double mem = (algo.getMemoryFootprintRatio() * deconvolution.image.nx * deconvolution.image.ny * deconvolution.image.nz * 4);
features.add("Estimated Memory", NumFormat.bytes(mem));
features.add("Iterative", algo.isIterative() ? "" + controller.getIterationMax() : "Direct");
table.removeRows();
for (String[] feature : features)
table.append(feature);
stopAsynchronousTimer();
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolution/modules/ImageDModule.java b/DeconvolutionLab2/src/deconvolution/modules/ImageDModule.java
index c28a3da..a1832ee 100644
--- a/DeconvolutionLab2/src/deconvolution/modules/ImageDModule.java
+++ b/DeconvolutionLab2/src/deconvolution/modules/ImageDModule.java
@@ -1,109 +1,109 @@
package deconvolution.modules;
import java.awt.Dimension;
import javax.swing.JSplitPane;
-import bilib.component.CustomizedTable;
-import bilib.component.JPanelImage;
+import bilib.component.PanelImage;
+import bilib.table.CustomizedTable;
import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
import deconvolution.Features;
import signal.RealSignal;
import signal.SignalCollector;
public class ImageDModule extends AbstractDModule implements Runnable {
- private JPanelImage pnImage;
+ private PanelImage pnImage;
private CustomizedTable table;
public ImageDModule(Deconvolution deconvolution) {
super(deconvolution);
- pnImage = new JPanelImage();
+ pnImage = new PanelImage();
table = new CustomizedTable(new String[] { "Features", "Values" }, false);
pnImage.setPreferredSize(new Dimension(300, 300));
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(300, 300), pnImage);
}
public void update() {
split.setDividerLocation(300);
if (pnImage == null)
return;
if (table == null)
return;
table.removeRows();
table.append(new String[] {"Image", "Waiting for loading ..."});
Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
@Override
public String getName() {
return "Image";
}
@Override
public void run() {
Features features = new Features();
if (deconvolution.image == null) {
startAsynchronousTimer("Open image", 200);
deconvolution.image = deconvolution.openImage();
stopAsynchronousTimer();
}
if (deconvolution.image == null) {
features.add("Image", "No valid input image");
return;
}
if (deconvolution.pad == null) {
features.add("Padding", "No valid padding");
return;
}
if (deconvolution.apo == null) {
features.add("Apodization", "No valid apodization");
return;
}
startAsynchronousTimer("Preprocessing image", 200);
float stati[] = deconvolution.image.getStats();
int sizi = deconvolution.image.nx * deconvolution.image.ny * deconvolution.image.nz;
float totali = stati[0] * sizi;
features.add("<html><b>Orignal Image</b></html>", "");
features.add("Size", deconvolution.image.dimAsString() + " " + NumFormat.bytes(sizi*4));
features.add("Mean (stdev)", NumFormat.nice(stati[0]) + " (" + NumFormat.nice(stati[3]) + ")");
features.add("Min ... Max", NumFormat.nice(stati[1]) + " ... " + NumFormat.nice(stati[2]));
features.add("Energy (int)", NumFormat.nice(stati[5]) + " (" + NumFormat.nice(totali) + ")");
table.removeRows();
for (String[] feature : features)
table.append(feature);
RealSignal signal = deconvolution.pad.pad(deconvolution.monitors, deconvolution.image);
deconvolution.apo.apodize(deconvolution.monitors, signal);
float stats[] = signal.getStats();
int sizs = signal.nx * signal.ny * signal.nz;
float totals = stats[0] * sizs;
features.add("<html><b>Working Image</b></html>", "");
features.add("Size", signal.dimAsString() + " " + NumFormat.bytes(sizs*4));
features.add("Mean (stdev)", NumFormat.nice(stats[0]) + " (" + NumFormat.nice(stats[3]) + ")");
features.add("Min Max", NumFormat.nice(stats[1]) + " " + NumFormat.nice(stats[2]));
features.add("Energy (int)", NumFormat.nice(stats[5]) + " (" + NumFormat.nice(totals) + ")");
features.add("<html><b>Information</b></html>", "");
features.add("Size Increase ", NumFormat.nice((double)(sizs-sizi)/sizi*100.0));
features.add("Energy Lost", NumFormat.nice((stats[5]-stati[5])/stati[5]*100));
SignalCollector.free(signal);
table.removeRows();
for (String[] feature : features)
table.append(feature);
pnImage.setImage(deconvolution.image.preview());
stopAsynchronousTimer();
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolution/modules/PSFDModule.java b/DeconvolutionLab2/src/deconvolution/modules/PSFDModule.java
index 1fc32d5..1e3d408 100644
--- a/DeconvolutionLab2/src/deconvolution/modules/PSFDModule.java
+++ b/DeconvolutionLab2/src/deconvolution/modules/PSFDModule.java
@@ -1,122 +1,118 @@
package deconvolution.modules;
import java.awt.Dimension;
-import java.awt.image.BufferedImage;
import javax.swing.JSplitPane;
-import bilib.component.CustomizedTable;
-import bilib.component.JPanelImage;
+import bilib.component.PanelImage;
+import bilib.table.CustomizedTable;
import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
import deconvolution.Features;
-import deconvolutionlab.Lab;
-import deconvolutionlab.monitor.Monitors;
-import signal.Constraint;
import signal.RealSignal;
import signal.SignalCollector;
public class PSFDModule extends AbstractDModule implements Runnable {
- private JPanelImage pnImage;
+ private PanelImage pnImage;
private CustomizedTable table;
public PSFDModule(Deconvolution deconvolution) {
super(deconvolution);
- pnImage = new JPanelImage();
+ pnImage = new PanelImage();
table = new CustomizedTable(new String[] { "Features", "Values" }, false);
pnImage.setPreferredSize(new Dimension(300, 300));
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(300, 300), pnImage);
}
public void update() {
split.setDividerLocation(300);
if (pnImage == null)
return;
if (table == null)
return;
table.removeRows();
table.append(new String[] { "PSF", "Waiting for loading ..." });
Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
@Override
public String getName() {
return "PSF";
}
@Override
public void run() {
Features features = new Features();
if (deconvolution.image == null) {
startAsynchronousTimer("Open image", 200);
deconvolution.image = deconvolution.openImage();
stopAsynchronousTimer();
}
if (deconvolution.image == null) {
features.add("Image", "No valid input image");
return;
}
if (deconvolution.pad == null) {
features.add("Padding", "No valid padding");
return;
}
if (deconvolution.apo == null) {
features.add("Apodization", "No valid apodization");
return;
}
if (deconvolution.psf == null) {
startAsynchronousTimer("Open PSF", 200);
deconvolution.psf = deconvolution.openPSF();
stopAsynchronousTimer();
}
if (deconvolution.psf == null) {
features.add("PSF", "No valid PSF");
return;
}
startAsynchronousTimer("Preprocessing PSF", 200);
float stati[] = deconvolution.psf.getStats();
int sizi = deconvolution.psf.nx * deconvolution.psf.ny * deconvolution.psf.nz;
float totali = stati[0] * sizi;
features.add("<html><b>Orignal PSF</b></html>", "");
features.add("Size", deconvolution.psf.dimAsString() + " " + NumFormat.bytes(sizi * 4));
features.add("Mean (stdev)", NumFormat.nice(stati[0]) + " (" + NumFormat.nice(stati[3]) + ")");
features.add("Min ... Max", NumFormat.nice(stati[1]) + " ... " + NumFormat.nice(stati[2]));
features.add("Energy (int)", NumFormat.nice(stati[5]) + " (" + NumFormat.nice(totali) + ")");
table.removeRows();
for (String[] feature : features)
table.append(feature);
RealSignal h = deconvolution.psf.changeSizeAs(deconvolution.image);
h.normalize(deconvolution.norm);
float stats[] = h.getStats();
int sizs = h.nx * h.ny * h.nz;
float totals = stats[0] * sizs;
features.add("<html><b>Working PSF</b></html>", "");
features.add("Size", h.dimAsString() + " " + NumFormat.bytes(sizs * 4));
features.add("Mean (stdev)", NumFormat.nice(stats[0]) + " (" + NumFormat.nice(stats[3]) + ")");
features.add("Min Max", NumFormat.nice(stats[1]) + " " + NumFormat.nice(stats[2]));
features.add("Energy (int)", NumFormat.nice(stats[5]) + " (" + NumFormat.nice(totals) + ")");
features.add("<html><b>Information</b></html>", "");
features.add("Size Increase ", NumFormat.nice((double) (sizs - sizi) / sizi * 100.0));
features.add("Energy Lost", NumFormat.nice((stats[5] - stati[5]) / stati[5] * 100));
SignalCollector.free(h);
table.removeRows();
for (String[] feature : features)
table.append(feature);
pnImage.setImage(deconvolution.psf.preview());
stopAsynchronousTimer();
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolution/modules/RecapDModule.java b/DeconvolutionLab2/src/deconvolution/modules/RecapDModule.java
index 9c04b02..cb0f5c0 100644
--- a/DeconvolutionLab2/src/deconvolution/modules/RecapDModule.java
+++ b/DeconvolutionLab2/src/deconvolution/modules/RecapDModule.java
@@ -1,74 +1,74 @@
package deconvolution.modules;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JSplitPane;
import javax.swing.text.BadLocationException;
-import bilib.component.CustomizedTable;
import bilib.component.HTMLPane;
+import bilib.table.CustomizedTable;
import deconvolution.Deconvolution;
public class RecapDModule extends AbstractDModule implements KeyListener {
private HTMLPane pnCommand;
private CustomizedTable table;
public RecapDModule(Deconvolution deconvolution) {
super(deconvolution);
// Panel command
pnCommand = new HTMLPane("Monaco", "#10FF10", "100020", 100, 100);
pnCommand.append("p", deconvolution.getCommand());
pnCommand.setEditable(true);
pnCommand.addKeyListener(this);
table = new CustomizedTable(new String[] { "Features", "Values" }, false);
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(200, 200), pnCommand.getPane());
}
public void update() {
if (table == null)
return;
table.removeRows();
for (String[] feature : deconvolution.recap())
table.append(feature);
split.setDividerLocation(0.5);
split.repaint();
}
public String getCommand() {
return pnCommand.getText();
}
@Override
public String getName() {
return "Recap";
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
try {
int len = pnCommand.getDocument().getLength();
String command = pnCommand.getDocument().getText(0, len);
deconvolution.setCommand(command);
table.removeRows();
for (String[] feature : deconvolution.recap())
table.append(feature);
}
catch (BadLocationException e1) {
e1.printStackTrace();
}
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolution/modules/ReportDModule.java b/DeconvolutionLab2/src/deconvolution/modules/ReportDModule.java
index ed8dcfc..2a38463 100644
--- a/DeconvolutionLab2/src/deconvolution/modules/ReportDModule.java
+++ b/DeconvolutionLab2/src/deconvolution/modules/ReportDModule.java
@@ -1,51 +1,51 @@
package deconvolution.modules;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import javax.swing.JSplitPane;
-import bilib.component.CustomizedTable;
-import bilib.component.JPanelImage;
+import bilib.component.PanelImage;
+import bilib.table.CustomizedTable;
import deconvolution.Deconvolution;
import signal.RealSignal;
public class ReportDModule extends AbstractDModule {
- private JPanelImage pnImage;
+ private PanelImage pnImage;
private CustomizedTable table;
public ReportDModule(Deconvolution deconvolution) {
super(deconvolution);
- pnImage = new JPanelImage();
+ pnImage = new PanelImage();
table = new CustomizedTable(new String[] { "Output", "Values" }, false);
pnImage.setPreferredSize(new Dimension(300, 300));
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(300, 300), pnImage);
}
public void update() {
split.setDividerLocation(300);
if (pnImage == null)
return;
if (table == null)
return;
table.removeRows();
for (String[] feature : deconvolution.getDeconvolutionReports())
table.append(feature);
RealSignal image = deconvolution.getOutput();
if (image == null) {
table.append(new String[] {"ERROR", "No open output"});
return;
}
pnImage.setImage(image.preview());
for (String[] feature : deconvolution.checkOutput())
table.append(feature);
split.setDividerLocation(300);
}
@Override
public String getName() {
return "Report";
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/Config.java b/DeconvolutionLab2/src/deconvolutionlab/Config.java
index fca3d35..453dd9f 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/Config.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Config.java
@@ -1,385 +1,385 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab;
import java.awt.Rectangle;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Properties;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
-import bilib.component.CustomizedTable;
import bilib.component.SpinnerRangeDouble;
import bilib.component.SpinnerRangeInteger;
+import bilib.table.CustomizedTable;
import bilib.tools.NumFormat;
import deconvolutionlab.monitor.Monitors;
public class Config {
private static String project = Constants.name;
private static String filename;
private static HashMap<String, Object> inits;
private static HashMap<String, JComponent> components = new HashMap<String, JComponent>();
private static HashMap<String, CustomizedTable> tables = new HashMap<String, CustomizedTable>();;
private static HashMap<String, JDialog> dialogs = new HashMap<String, JDialog>();
private static Monitors monitors = Monitors.createDefaultMonitor();
public static Config init(String filename) {
Config.filename = filename;
Config.inits = new HashMap<String, Object>();
Config.components = new HashMap<String, JComponent>();
Config.tables = new HashMap<String, CustomizedTable>();
Config.dialogs = new HashMap<String, JDialog>();
return new Config();
}
public static void setFilename(String filename) {
Config.filename = filename;
}
public static String getFilename() {
return filename;
}
public static boolean check() {
File file = new File(Config.filename);
if (!file.exists())
return false;
if (file.isDirectory())
return false;
return true;
}
public static void register(String module, String key, JComponent component, Object init) {
if (component == null)
return;
components.put(module + "." + key, component);
inits.put(module + "." + key, init);
setValue(key, init);
}
public static void registerTable(String module, String key, CustomizedTable table) {
if (table == null)
return;
tables.put(module + "." + key, table);
}
public static void registerFrame(String module, String key, JDialog dialog) {
if (dialog == null)
return;
dialogs.put(module + "." + key, dialog);
}
public static String getAsString(String key) {
Object object = getValue(key);
if (object instanceof String)
return ((String) object);
else if (object instanceof Double)
return ((Double) object).toString();
else if (object instanceof Integer)
return ((Integer) object).toString();
else if (object instanceof Boolean)
return ((Boolean) object).toString();
return null;
}
public static double getAsDouble(String key) {
Object object = getValue(key);
if (object instanceof Double)
return ((Double) object).doubleValue();
else if (object instanceof Integer)
return ((Integer) object).intValue();
return 0;
}
private static void setValue(String key, Object value) {
JComponent component = components.get(key);
if (component == null)
return;
if (value == null)
value = inits.get(key);
if (component instanceof JTextField) {
JTextField txt = (JTextField) component;
txt.setText(value.toString());
}
else if (component instanceof JComboBox) {
JComboBox<String> cmb = (JComboBox<String>) component;
cmb.setSelectedItem(value.toString());
}
else if (component instanceof JLabel) {
JLabel lbl = (JLabel) component;
lbl.setText(value.toString());
}
else if (component instanceof JCheckBox) {
JCheckBox chk = (JCheckBox) component;
chk.setSelected(value.toString().equals("true"));
}
else if (component instanceof SpinnerRangeDouble) {
SpinnerRangeDouble spn = (SpinnerRangeDouble) component;
if (value instanceof Number) {
Number number = (Number) value;
spn.set(number.doubleValue());
}
else if (value instanceof String) {
try {
spn.set(Double.parseDouble((String) value));
}
catch (NumberFormatException ex) {
}
}
}
else if (component instanceof SpinnerRangeInteger) {
SpinnerRangeInteger spn = (SpinnerRangeInteger) component;
if (value instanceof Number) {
Number number = (Number) value;
spn.set(number.intValue());
}
else if (value instanceof String) {
try {
spn.set((int) Double.parseDouble((String) value));
}
catch (NumberFormatException ex) {
}
}
}
else if (component instanceof JTabbedPane) {
JTabbedPane tab = (JTabbedPane) component;
String source = value.toString();
for (int i = 0; i < tab.getTabCount(); i++)
if (source.equals(tab.getTitleAt(i)))
tab.setSelectedIndex(i);
}
}
private static Object getValue(String key) {
JComponent component = components.get(key);
if (component == null)
return inits.get(key);
if (component instanceof JTextField)
return ((JTextField) component).getText();
else if (component instanceof JComboBox)
return (String) ((JComboBox) component).getSelectedItem();
else if (component instanceof JCheckBox)
return ((JCheckBox) component).isSelected() ? "true" : "false";
else if (component instanceof JLabel)
return ((JLabel) component).getText();
else if (component instanceof SpinnerRangeDouble)
return new Double(((SpinnerRangeDouble) component).get());
else if (component instanceof SpinnerRangeInteger)
return new Integer(((SpinnerRangeInteger) component).get());
else if (component instanceof JTabbedPane) {
JTabbedPane tab = (JTabbedPane) component;
return tab.getTitleAt(tab.getSelectedIndex());
}
return inits.get(key);
}
public static void load() {
Properties props = new Properties();
try {
FileInputStream in = new FileInputStream(filename);
props.load(in);
}
catch (Exception e) {
props = new Properties();
}
for (String key : components.keySet()) {
Object init = inits.get(key);
String value = props.getProperty(key, init.toString());
setValue(key, value);
}
for (String key : tables.keySet()) {
CustomizedTable table = tables.get(key);
for (int i = 0; i < 100; i++) {
String keyrow = key + ".row" + i;
String value = props.getProperty(keyrow, "???");
if (!value.equals("???"))
table.append(value.split(";"));
}
String selected[] = props.getProperty(key + ".selected", "???").split(";");
int ncol = Math.min(table.getColumnCount(), selected.length) - 1;
for (int i = 0; i < table.getRowCount(); i++) {
int n = 0;
for (int j = 0; j < ncol; j++) {
n += table.getCell(i, j).trim().equals(selected[j].trim()) ? 1 : 0;
}
if (n == ncol)
table.setRowSelectionInterval(i, i);
}
}
for (String key : dialogs.keySet()) {
int x = (int) NumFormat.parseNumber(props.getProperty(key + ".location.x", "" + 0), 0);
int y = (int) NumFormat.parseNumber(props.getProperty(key + ".location.y", "" + 0), 0);
int w = (int) NumFormat.parseNumber(props.getProperty(key + ".location.w", "" + 400), 400);
int h = (int) NumFormat.parseNumber(props.getProperty(key + ".location.h", "" + 400), 400);
dialogs.get(key).setSize(w, h);
dialogs.get(key).setLocation(x, y);
}
monitors.log("Load Config from " + filename + " (" + components.size() + " items)");
}
public static boolean store() {
Properties props = new Properties();
for (String key : components.keySet()) {
String s = getAsString(key);
if (s != null)
props.setProperty(key, s);
}
for (String key : tables.keySet()) {
CustomizedTable table = tables.get(key);
int nrows = table.getRowCount();
for (int row = 0; row < nrows; row++)
props.setProperty(key + ".row" + row, table.getRowCSV(row, ";"));
int row = table.getSelectedRow();
if (row >= 0)
props.setProperty(key + ".selected", table.getRowCSV(row, ";"));
}
for (String key : dialogs.keySet()) {
JDialog dialog = dialogs.get(key);
props.setProperty(key + ".location.x", "" + dialog.getLocation().x);
props.setProperty(key + ".location.y", "" + dialog.getLocation().y);
props.setProperty(key + ".location.w", "" + dialog.getSize().width);
props.setProperty(key + ".location.h", "" + dialog.getSize().height);
}
try {
FileOutputStream out = new FileOutputStream(filename);
props.store(out, project);
}
catch (Exception e) {
monitors.error("Store Config to " + filename + " (" + components.size() + " items)");
return false;
}
monitors.log("Store Config to " + filename + " (" + components.size() + " items)");
File file = new File(filename);
if (file.exists()) {
String line = "";
try {
BufferedReader br = new BufferedReader(new FileReader(filename));
ArrayList<String> keys = new ArrayList<String>();
ArrayList<String> headers = new ArrayList<String>();
line = br.readLine();
if (line != null)
if (!line.startsWith("#"))
keys.add(line);
else
headers.add(line);
while (line != null) {
if (!line.startsWith("#"))
keys.add(line);
else
headers.add(line);
line = br.readLine();
}
br.close();
Collections.sort(keys);
BufferedWriter bw = new BufferedWriter(new FileWriter(filename));
for (String ln : headers)
bw.write(ln + "\n");
for (String ln : keys)
bw.write(ln + "\n");
bw.close();
}
catch (Exception ex) {
monitors.error("ERROR " + filename + " line: " + line);
return false;
}
}
return true;
}
public static ArrayList<String> list() {
ArrayList<String> list = new ArrayList<String>();
for (String key : components.keySet()) {
list.add(key + " = " + getValue(key));
}
return list;
}
public static void print() {
ArrayList<String> list = list();
System.out.println("--");
for (String line : list)
System.out.println(line);
System.out.println("--");
}
public static void printInit() {
for (String key : inits.keySet()) {
Object object = inits.get(key);
if (object != null)
System.out.println("Default " + key + " = " + (object.toString()));
}
}
public static Rectangle getDialog(String key) {
Properties props = new Properties();
try {
FileInputStream in = new FileInputStream(filename);
props.load(in);
}
catch (Exception e) {
props = new Properties();
}
int x = (int) NumFormat.parseNumber(props.getProperty(key + ".location.x", "-1"), -1);
int y = (int) NumFormat.parseNumber(props.getProperty(key + ".location.y", "-1"), -1);
int w = (int) NumFormat.parseNumber(props.getProperty(key + ".location.w", "-1"), -1);
int h = (int) NumFormat.parseNumber(props.getProperty(key + ".location.h", "-1"), -1);
return new Rectangle(x, y, w, h);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/LabPanel.java b/DeconvolutionLab2/src/deconvolutionlab/LabPanel.java
index 27a854c..3568db5 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/LabPanel.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/LabPanel.java
@@ -1,294 +1,293 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
-import bilib.component.JPanelImage;
+import bilib.component.PanelImage;
import deconvolution.Command;
import deconvolution.Deconvolution;
-import deconvolution.DeconvolutionDialog;
import deconvolutionlab.dialog.BatchDialog;
import deconvolutionlab.modules.AboutModule;
import deconvolutionlab.modules.AbstractModule;
import deconvolutionlab.modules.AlgorithmModule;
import deconvolutionlab.modules.BatchModule;
import deconvolutionlab.modules.BorderModule;
import deconvolutionlab.modules.CommandModule;
import deconvolutionlab.modules.ConfigModule;
import deconvolutionlab.modules.ControllerModule;
import deconvolutionlab.modules.FFTModule;
import deconvolutionlab.modules.GroupedModulePanel;
import deconvolutionlab.modules.ImageModule;
import deconvolutionlab.modules.LanguageModule;
import deconvolutionlab.modules.LicenceModule;
import deconvolutionlab.modules.OutputModule;
import deconvolutionlab.modules.PSFModule;
import deconvolutionlab.modules.RunningModule;
import deconvolutionlab.system.SystemInfo;
public class LabPanel extends JPanel implements ActionListener, ChangeListener {
private JTabbedPane tab = new JTabbedPane();
private JButton bnHelp = new JButton("Help");
private JButton bnQuit = new JButton("Quit");
private JButton bnSystem = new JButton("System");
private JButton bnBatch = new JButton("Batch");
private JButton bnRun = new JButton("Run");
private JButton bnLaunch = new JButton("Launch");
private JButton bnClose;
private ImageModule image;
private PSFModule psf;
private AlgorithmModule algo;
private AboutModule about;
private LicenceModule licence;
private OutputModule output;
private FFTModule fourier;
private BorderModule border;
private ConfigModule config;
private BatchModule batch;
private LanguageModule language;
private CommandModule command;
private RunningModule running;
private ControllerModule controller;
private GroupedModulePanel panelDeconv;
private GroupedModulePanel panelAdvanc;
private GroupedModulePanel panelScript;
private GroupedModulePanel panelAbout;
private AbstractModule modules[];
public LabPanel(JButton bnClose) {
this.bnClose = bnClose;
image = new ImageModule(false);
psf = new PSFModule(false);
algo = new AlgorithmModule(true);
output = new OutputModule(true);
fourier = new FFTModule(false);
border = new BorderModule(false);
controller = new ControllerModule(false);
batch = new BatchModule(false);
language = new LanguageModule(false);
about = new AboutModule(true);
licence = new LicenceModule(false);
config = new ConfigModule(false);
command = new CommandModule();
running = new RunningModule(false);
modules = new AbstractModule[] { image, psf, algo, output, controller, border, fourier, batch, running };
Command.active(modules, command);
Command.command();
panelDeconv = new GroupedModulePanel(buildDeconvolutionPanel(), this);
panelAdvanc = new GroupedModulePanel(buildAdvancedPanel(), this);
panelScript = new GroupedModulePanel(buildProgrammingPanel(), this);
panelAbout = new GroupedModulePanel(buildAboutPanel(), this);
Border border = BorderFactory.createEmptyBorder(5, 5, 5, 5);
- JPanelImage bottom = new JPanelImage("celegans.jpg");
+ PanelImage bottom = new PanelImage("celegans.jpg");
bottom.setBorder(border);
bottom.setLayout(new GridLayout(1, 6));
bottom.setBorder(border);
bottom.add(bnHelp);
bottom.add(bnSystem);
bottom.add(bnClose);
bottom.add(bnBatch);
bottom.add(bnRun);
bottom.add(bnLaunch);
tab.add("Deconvolution", panelDeconv);
tab.add("Advanced", panelAdvanc);
tab.add("Scripting", panelScript);
tab.add("About", panelAbout);
tab.addChangeListener(this);
setLayout(new BorderLayout());
add(tab, BorderLayout.CENTER);
add(bottom, BorderLayout.SOUTH);
bnBatch.addActionListener(this);
bnRun.addActionListener(this);
bnLaunch.addActionListener(this);
bnClose.addActionListener(this);
bnQuit.addActionListener(this);
bnHelp.addActionListener(this);
bnSystem.addActionListener(this);
((GroupedModulePanel) tab.getSelectedComponent()).organize();
setMinimumSize(new Dimension(500, 500));
Config.load();
running.init();
//sizeModule();
Command.command();
running.update();
image.update();
psf.update();
output.update();
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnHelp)
Lab.help();
else if (e.getSource() == bnClose)
Config.store();
else if (e.getSource() == bnSystem)
SystemInfo.activate();
else if (e.getSource() == bnBatch) {
tab.setSelectedIndex(2);
batch.expand();
sizeModule();
BatchDialog dlg = new BatchDialog(batch);
Lab.setVisible(dlg, true);
}
else if (e.getSource() == bnLaunch) {
String job = language.getJobName() + " " + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date());
Deconvolution d = new Deconvolution(job, Command.command(), Deconvolution.Finish.ALIVE);
d.launch();
}
else if (e.getSource() == bnRun) {
String job = language.getJobName() + " " + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date());
Deconvolution d = new Deconvolution(job, Command.command());
d.deconvolve();
}
}
@Override
public void stateChanged(ChangeEvent e) {
((GroupedModulePanel) tab.getSelectedComponent()).organize();
Command.command();
}
private ArrayList<AbstractModule> buildDeconvolutionPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(image);
list.add(psf);
list.add(algo);
list.add(running);
return list;
}
private ArrayList<AbstractModule> buildAdvancedPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(output);
list.add(controller);
list.add(border);
list.add(fourier);
return list;
}
private ArrayList<AbstractModule> buildProgrammingPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(batch);
list.add(command);
list.add(language);
return list;
}
private ArrayList<AbstractModule> buildAboutPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(about);
list.add(licence);
list.add(config);
return list;
}
public void close() {
for (AbstractModule module : modules)
module.close();
bnLaunch.removeActionListener(this);
bnRun.removeActionListener(this);
bnBatch.removeActionListener(this);
bnClose.removeActionListener(this);
bnHelp.removeActionListener(this);
Lab.close();
}
public void sizeModule() {
if (tab.getSelectedIndex() == 0)
sizePanel(panelDeconv);
if (tab.getSelectedIndex() == 1)
sizePanel(panelAdvanc);
if (tab.getSelectedIndex() == 2)
sizePanel(panelScript);
if (tab.getSelectedIndex() == 3)
sizePanel(panelAbout);
}
private void sizePanel(GroupedModulePanel panel) {
Dimension dim = getSize();
int hpc = 70;
int npc = hpc * panel.getModules().size();
Dimension small = new Dimension(dim.width, hpc);
Dimension large = new Dimension(dim.width, dim.height - npc);
setMinimumSize(new Dimension(Constants.widthGUI, 4*hpc));
for (AbstractModule module : panel.getModules()) {
if (module.isExpanded()) {
module.setPreferredSize(large);
module.setMaximumSize(large);
module.setMinimumSize(small);
module.getExpandedPanel().setPreferredSize(large);
module.getExpandedPanel().setMaximumSize(large);
module.getExpandedPanel().setMinimumSize(small);
}
else {
module.setPreferredSize(small);
module.setMaximumSize(small);
module.setMinimumSize(small);
module.getCollapsedPanel().setPreferredSize(small);
module.getCollapsedPanel().setMaximumSize(small);
module.getCollapsedPanel().setMinimumSize(small);
}
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/TableStats.java b/DeconvolutionLab2/src/deconvolutionlab/TableStats.java
index d511d45..028285f 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/TableStats.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/TableStats.java
@@ -1,89 +1,88 @@
package deconvolutionlab;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.File;
import java.util.ArrayList;
import javax.swing.BorderFactory;
-import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.table.DefaultTableModel;
-import bilib.component.CustomizedColumn;
-import bilib.component.CustomizedTable;
+import bilib.table.CustomizedColumn;
+import bilib.table.CustomizedTable;
import deconvolutionlab.monitor.Monitors;
public class TableStats {
private JPanel panel;
private CustomizedTable table;
private String name;
private boolean save;
private String path;
public TableStats(String name, int width, int height, String path, boolean save) {
this.name = name;
this.save = save;
this.path = path;
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Iterations", String.class, 100, false));
columns.add(new CustomizedColumn("Mean", String.class, 100, false));
columns.add(new CustomizedColumn("Minimum", String.class, 100, false));
columns.add(new CustomizedColumn("Maximum", String.class, 100, false));
columns.add(new CustomizedColumn("Stdev", String.class, 100, false));
columns.add(new CustomizedColumn("Energy", String.class, 100, false));
columns.add(new CustomizedColumn("Time", String.class, 100, false));
columns.add(new CustomizedColumn("Memory", String.class, 100, false));
columns.add(new CustomizedColumn("Signal", String.class, 100, false));
columns.add(new CustomizedColumn("PSNR", String.class, 100, false));
columns.add(new CustomizedColumn("SNR", String.class, 100, false));
columns.add(new CustomizedColumn("Residu", String.class, 100, false));
table = new CustomizedTable(columns, true);
JScrollPane scroll = new JScrollPane(table);
scroll.setPreferredSize(new Dimension(width, height));
JPanel main = new JPanel(new BorderLayout());
main.add(scroll, BorderLayout.CENTER);
panel = new JPanel(new BorderLayout());
panel.add(main);
panel.setBorder(BorderFactory.createEtchedBorder());
}
public String getName() {
return name;
}
public void clear() {
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.setRowCount(0);
}
public void nextStats(Monitors monitors, String[] stats) {
if (table == null)
return;
if (stats == null)
return;
table.append(stats);
monitors.log("Stats ");
}
public void lastStats(Monitors monitors, String[] stats) {
if (stats == null)
return;
if (table == null)
return;
if (save) {
String filename = path + File.separator + name + ".csv";
monitors.log("Stats save " + filename);
table.saveCSV(filename);
}
}
public JPanel getPanel() {
return panel;
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java
index 4abe394..f6ffa22 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java
@@ -1,154 +1,152 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import bilib.component.GridPanel;
import bilib.component.HTMLPane;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolutionlab.Constants;
-import deconvolutionlab.Lab;
import deconvolutionlab.modules.BatchModule;
-import ij.gui.GUI;
public class BatchDialog extends JDialog implements ActionListener, WindowListener {
private JTextField txt = new JTextField("job", 10);
private HTMLPane pnCommand;
private JButton bnAdd = new JButton("Add Job");
private JButton bnCancel = new JButton("Cancel");
private BatchModule module;
public BatchDialog(BatchModule module) {
super(new JFrame(), "Batch");
this.module = module;
txt.setText("job" + module.getCountJob());
Deconvolution deconvolution = new Deconvolution(txt.getText(), Command.command());
pnCommand = new HTMLPane("Monaco", Constants.widthGUI, 100);
pnCommand.append("p", deconvolution.getCommand());
pnCommand.setEditable(true);
GridPanel pn = new GridPanel(true, 5);
pn.place(1, 0, "Job Name");
pn.place(1, 1, txt);
GridPanel bn = new GridPanel(false);
bn.place(11, 0, bnCancel);
bn.place(11, 1, bnAdd);
pn.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.NORTH);
panel.add(pnCommand.getPane(), BorderLayout.CENTER);
panel.add(bn, BorderLayout.SOUTH);
bnAdd.addActionListener(this);
bnCancel.addActionListener(this);
add(panel);
pack();
addWindowListener(this);
setMinimumSize(new Dimension(400, 300));
}
private void addJob() {
module.addJob(txt.getText(), pnCommand.getText());
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnAdd) {
addJob();
bnAdd.removeActionListener(this);
bnCancel.removeActionListener(this);
dispose();
return;
}
else if (e.getSource() == bnCancel) {
bnAdd.removeActionListener(this);
bnCancel.removeActionListener(this);
dispose();
}
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
addJob();
dispose();
return;
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java
index 118070d..4b2c6fb 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java
@@ -1,275 +1,274 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
-import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.GridPanel;
import bilib.component.HTMLPane;
import bilib.component.SpinnerRangeInteger;
import deconvolutionlab.Imaging;
import deconvolutionlab.Output;
import deconvolutionlab.Output.Dynamic;
import deconvolutionlab.Output.View;
import ij.gui.GUI;
public class OutputDialog extends JDialog implements ActionListener, ChangeListener {
private JComboBox<String> cmbDynamic = new JComboBox<String>(new String[] { "intact", "rescaled", "normalized", "clipped" });
private JComboBox<String> cmbType = new JComboBox<String>(new String[] { "float", "short", "byte" });
private JCheckBox chkSave = new JCheckBox("Save output", true);
private JCheckBox chkShow = new JCheckBox("Show output", true);
private SpinnerRangeInteger snpSnapshot = new SpinnerRangeInteger(0, 0, 99999, 1);
private JComboBox<String> cmbSnapshot = new JComboBox<String>(new String[] { "Final Output", "Specify Iterations..." });
private SpinnerRangeInteger spnX = new SpinnerRangeInteger(128, 0, 99999, 1);
private SpinnerRangeInteger spnY = new SpinnerRangeInteger(128, 0, 99999, 1);
private SpinnerRangeInteger spnZ = new SpinnerRangeInteger(32, 0, 99999, 1);
private JTextField txtName = new JTextField("Noname", 18);
private JCheckBox chkCenter = new JCheckBox("Center of the volume", true);
private JButton bnOK = new JButton("OK");
private JButton bnCancel = new JButton("Cancel");
private boolean cancel = false;
private JLabel lblBit = new JLabel("32-bit");
private JLabel lblIter = new JLabel("iterations");
private JLabel lblSnapshot = new JLabel("Iterations");
private Output out;
private View view;
private GridPanel pnOrtho;
private HTMLPane info = new HTMLPane(200, 200);
private static int count = 1;
public OutputDialog(View view) {
super(new JFrame(), "Create a new output");
this.view = view;
lblBit.setBorder(BorderFactory.createEtchedBorder());
lblIter.setBorder(BorderFactory.createEtchedBorder());
txtName.setText(view.name().substring(0, 2) + (count++));
GridPanel pn = new GridPanel(true);
pn.place(0, 0, "Name");
pn.place(0, 1, txtName);
pn.place(1, 0, "Dynamic");
pn.place(1, 1, cmbDynamic);
pn.place(2, 0, "Type");
pn.place(2, 1, cmbType);
pn.place(3, 1, lblBit);
if (view != View.SERIES && view != View.STACK) {
pn.place(4, 0, "Snapshot");
pn.place(4, 1, cmbSnapshot);
pn.place(5, 0, lblSnapshot);
pn.place(5, 1, snpSnapshot);
pn.place(6, 1, lblIter);
}
pn.place(7, 1, 3, 1, chkShow);
pn.place(8, 1, 3, 1, chkSave);
GridPanel main = new GridPanel(false);
main.place(1, 0, 2, 1, pn);
if (view == View.ORTHO || view == View.FIGURE) {
pn.place(9, 1, 3, 1, chkCenter);
pnOrtho = new GridPanel("Keypoint");
pnOrtho.place(4, 0, "Position in X");
pnOrtho.place(4, 1, spnX);
pnOrtho.place(4, 2, "[pixel]");
pnOrtho.place(5, 0, "Position in Y");
pnOrtho.place(5, 1, spnY);
pnOrtho.place(5, 2, "[pixel]");
pnOrtho.place(6, 0, "Position in Z");
pnOrtho.place(6, 1, spnZ);
pnOrtho.place(5, 2, "[pixel]");
main.place(2, 0, 2, 1, pnOrtho);
}
pn.place(10, 0, 2, 1, info.getPane());
main.place(3, 0, bnCancel);
main.place(3, 1, bnOK);
info();
cmbSnapshot.addActionListener(this);
snpSnapshot.addChangeListener(this);
chkCenter.addActionListener(this);
cmbType.addActionListener(this);
bnOK.addActionListener(this);
bnCancel.addActionListener(this);
add(main);
update();
pack();
GUI.center(this);
setModal(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == chkCenter) {
update();
}
else if (e.getSource() == cmbSnapshot) {
update();
}
else if (e.getSource() == cmbType) {
if (cmbType.getSelectedIndex() == 0)
lblBit.setText("32-bits");
if (cmbType.getSelectedIndex() == 1)
lblBit.setText("16-bits");
if (cmbType.getSelectedIndex() == 2)
lblBit.setText("8-bits");
}
else if (e.getSource() == bnCancel) {
dispose();
cancel = true;
return;
}
else if (e.getSource() == bnOK) {
int freq = snpSnapshot.get();
Dynamic dynamic = Output.Dynamic.values()[cmbDynamic.getSelectedIndex()];
Imaging.Type type = Imaging.Type.values()[cmbType.getSelectedIndex()];
boolean show = chkShow.isSelected();
boolean save = chkSave.isSelected();
String name = txtName.getText();
if (chkCenter.isSelected()) {
out = new Output(view, show, save, freq, name, dynamic, type, true);
}
else {
int px = spnX.get();
int py = spnY.get();
int pz = spnZ.get();
out = new Output(view, show, save, freq, name, dynamic, type, px, py, pz);
}
dispose();
cancel = false;
}
}
private void update() {
if (cmbSnapshot.getSelectedIndex() == 0) {
snpSnapshot.set(0);
lblSnapshot.setEnabled(false);
lblIter.setEnabled(false);
lblSnapshot.setEnabled(false);
}
else {
lblSnapshot.setEnabled(true);
lblIter.setEnabled(true);
lblSnapshot.setEnabled(true);
}
if (snpSnapshot.get() == 0)
lblIter.setText("at the end (default)");
else
lblIter.setText("every " + snpSnapshot.get() + " iterations");
if (snpSnapshot.get() == 0)
lblIter.setText("at the end (default)");
else
lblIter.setText("every " + snpSnapshot.get() + " iterations");
boolean b = !chkCenter.isSelected();
if (pnOrtho != null) {
pnOrtho.setEnabled(b);
for (Component c : pnOrtho.getComponents())
c.setEnabled(b);
}
pack();
}
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() == snpSnapshot)
update();
}
public Output getOut() {
return out;
}
public boolean wasCancel() {
return cancel;
}
private void info() {
if (view == View.FIGURE) {
info.append("h1", "figure");
info.append("h2", "Create a view with 2 panels (XY) and (YZ) with a border.");
}
if (view == View.MIP) {
info.append("h1", "mip");
info.append("h2", "Create a view 3 orthogonal projections.");
}
if (view == View.ORTHO) {
info.append("h1", "ortho");
info.append("h2", "Create a view 3 orthogonal section centered on the keypoint.");
}
if (view == View.PLANAR) {
info.append("h1", "ortho");
info.append("h2", "Create a montage of all Z-slice in one large flatten plane.");
}
if (view == View.STACK) {
info.append("h1", "stack");
info.append("h2", "Create a z-stack of image.");
}
if (view == View.SERIES) {
info.append("h1", "series");
info.append("h2", "Create a series of z-slices.");
}
info.append("p", "<b>Name:</b> This string will be used as title of the window in <i>show</i> mode or a filename in <i>save</i> mode.");
info.append("p", "<b>Dynamic:</b> Select the dynamic range used for the display. The default value is <i>intact</i> which preserves the true values.");
info.append("p", "<b>Type:</b> Select the data type. The default value is <i>float</i> which preserves the true values without loosing precision.");
info.append("p", "<b>Snapshot:</b> The output is usually shown (or saved) at the end of the processing, optionally it is possible to specify to show (or save) every N iterations.");
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputPanel.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputPanel.java
index 0a3ab84..74797b5 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputPanel.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputPanel.java
@@ -1,269 +1,267 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
-import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.GridPanel;
import bilib.component.HTMLPane;
import bilib.component.SpinnerRangeInteger;
import deconvolutionlab.Imaging;
import deconvolutionlab.Output;
import deconvolutionlab.Output.Dynamic;
import deconvolutionlab.Output.View;
-import ij.gui.GUI;
public class OutputPanel extends JPanel implements ActionListener, ChangeListener {
private JComboBox<String> cmbDynamic = new JComboBox<String>(new String[] { "intact", "rescaled", "normalized", "clipped" });
private JComboBox<String> cmbType = new JComboBox<String>(new String[] { "float", "short", "byte" });
private JCheckBox chkSave = new JCheckBox("Save output", true);
private JCheckBox chkShow = new JCheckBox("Show output", true);
private SpinnerRangeInteger snpSnapshot = new SpinnerRangeInteger(0, 0, 99999, 1);
private JComboBox<String> cmbSnapshot = new JComboBox<String>(new String[] { "Final Output", "Specify Iterations..." });
private SpinnerRangeInteger spnX = new SpinnerRangeInteger(128, 0, 99999, 1);
private SpinnerRangeInteger spnY = new SpinnerRangeInteger(128, 0, 99999, 1);
private SpinnerRangeInteger spnZ = new SpinnerRangeInteger(32, 0, 99999, 1);
private JTextField txtName = new JTextField("Noname", 18);
private JCheckBox chkCenter = new JCheckBox("Center of the volume", true);
private JButton bnOK = new JButton("OK");
private JButton bnCancel = new JButton("Cancel");
private boolean cancel = false;
private JLabel lblBit = new JLabel("32-bit");
private JLabel lblIter = new JLabel("iterations");
private JLabel lblSnapshot = new JLabel("Iterations");
private Output out;
private View view;
private GridPanel pnOrtho;
private HTMLPane info = new HTMLPane(200, 200);
private static int count = 1;
public OutputPanel(View view) {
this.view = view;
lblBit.setBorder(BorderFactory.createEtchedBorder());
lblIter.setBorder(BorderFactory.createEtchedBorder());
txtName.setText(view.name().substring(0, 2) + (count++));
GridPanel pn = new GridPanel(true);
pn.place(0, 0, "Name");
pn.place(0, 1, txtName);
pn.place(1, 0, "Dynamic");
pn.place(1, 1, cmbDynamic);
pn.place(2, 0, "Type");
pn.place(2, 1, cmbType);
pn.place(3, 1, lblBit);
if (view != View.SERIES && view != View.STACK) {
pn.place(4, 0, "Snapshot");
pn.place(4, 1, cmbSnapshot);
pn.place(5, 0, lblSnapshot);
pn.place(5, 1, snpSnapshot);
pn.place(6, 1, lblIter);
}
pn.place(7, 1, 3, 1, chkShow);
pn.place(8, 1, 3, 1, chkSave);
GridPanel main = new GridPanel(false);
main.place(1, 0, 2, 1, pn);
if (view == View.ORTHO || view == View.FIGURE) {
pn.place(9, 1, 3, 1, chkCenter);
pnOrtho = new GridPanel("Keypoint");
pnOrtho.place(4, 0, "Position in X");
pnOrtho.place(4, 1, spnX);
pnOrtho.place(4, 2, "[pixel]");
pnOrtho.place(5, 0, "Position in Y");
pnOrtho.place(5, 1, spnY);
pnOrtho.place(5, 2, "[pixel]");
pnOrtho.place(6, 0, "Position in Z");
pnOrtho.place(6, 1, spnZ);
pnOrtho.place(5, 2, "[pixel]");
main.place(2, 0, 2, 1, pnOrtho);
}
pn.place(10, 0, 2, 1, info.getPane());
main.place(3, 0, bnCancel);
main.place(3, 1, bnOK);
info();
cmbSnapshot.addActionListener(this);
snpSnapshot.addChangeListener(this);
chkCenter.addActionListener(this);
cmbType.addActionListener(this);
bnOK.addActionListener(this);
bnCancel.addActionListener(this);
add(main);
update();
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == chkCenter) {
update();
}
else if (e.getSource() == cmbSnapshot) {
update();
}
else if (e.getSource() == cmbType) {
if (cmbType.getSelectedIndex() == 0)
lblBit.setText("32-bits");
if (cmbType.getSelectedIndex() == 1)
lblBit.setText("16-bits");
if (cmbType.getSelectedIndex() == 2)
lblBit.setText("8-bits");
}
else if (e.getSource() == bnCancel) {
cancel = true;
return;
}
else if (e.getSource() == bnOK) {
int freq = snpSnapshot.get();
Dynamic dynamic = Output.Dynamic.values()[cmbDynamic.getSelectedIndex()];
Imaging.Type type = Imaging.Type.values()[cmbType.getSelectedIndex()];
boolean show = chkShow.isSelected();
boolean save = chkSave.isSelected();
String name = txtName.getText();
if (chkCenter.isSelected()) {
out = new Output(view, show, save, freq, name, dynamic, type, true);
}
else {
int px = spnX.get();
int py = spnY.get();
int pz = spnZ.get();
out = new Output(view, show, save, freq, name, dynamic, type, px, py, pz);
}
cancel = false;
}
}
private void update() {
if (cmbSnapshot.getSelectedIndex() == 0) {
snpSnapshot.set(0);
lblSnapshot.setEnabled(false);
lblIter.setEnabled(false);
lblSnapshot.setEnabled(false);
}
else {
lblSnapshot.setEnabled(true);
lblIter.setEnabled(true);
lblSnapshot.setEnabled(true);
}
if (snpSnapshot.get() == 0)
lblIter.setText("at the end (default)");
else
lblIter.setText("every " + snpSnapshot.get() + " iterations");
if (snpSnapshot.get() == 0)
lblIter.setText("at the end (default)");
else
lblIter.setText("every " + snpSnapshot.get() + " iterations");
boolean b = !chkCenter.isSelected();
if (pnOrtho != null) {
pnOrtho.setEnabled(b);
for (Component c : pnOrtho.getComponents())
c.setEnabled(b);
}
//pack();
}
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() == snpSnapshot)
update();
}
public Output getOut() {
return out;
}
public boolean wasCancel() {
return cancel;
}
private void info() {
if (view == View.FIGURE) {
info.append("h1", "figure");
info.append("h2", "Create a view with 2 panels (XY) and (YZ) with a border.");
}
if (view == View.MIP) {
info.append("h1", "mip");
info.append("h2", "Create a view 3 orthogonal projections.");
}
if (view == View.ORTHO) {
info.append("h1", "ortho");
info.append("h2", "Create a view 3 orthogonal section centered on the keypoint.");
}
if (view == View.PLANAR) {
info.append("h1", "ortho");
info.append("h2", "Create a montage of all Z-slice in one large flatten plane.");
}
if (view == View.STACK) {
info.append("h1", "stack");
info.append("h2", "Create a z-stack of image.");
}
if (view == View.SERIES) {
info.append("h1", "series");
info.append("h2", "Create a series of z-slices.");
}
info.append("p", "<b>Name:</b> This string will be used as title of the window in <i>show</i> mode or a filename in <i>save</i> mode.");
info.append("p", "<b>Dynamic:</b> Select the dynamic range used for the display. The default value is <i>intact</i> which preserves the true values.");
info.append("p", "<b>Type:</b> Select the data type. The default value is <i>float</i> which preserves the true values without loosing precision.");
info.append("p", "<b>Snapshot:</b> The output is usually shown (or saved) at the end of the processing, optionally it is possible to specify to show (or save) every N iterations.");
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/BatchModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/BatchModule.java
index 69a5878..db5dbd8 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/BatchModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/BatchModule.java
@@ -1,169 +1,169 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.ListSelectionModel;
-import bilib.component.CustomizedColumn;
-import bilib.component.CustomizedTable;
+import bilib.table.CustomizedColumn;
+import bilib.table.CustomizedTable;
import deconvolution.Deconvolution;
import deconvolutionlab.Constants;
public class BatchModule extends AbstractModule implements MouseListener, ActionListener {
private CustomizedTable table;
private JButton bnRun;
private JButton bnLaunch;
public BatchModule(boolean expanded) {
super("Batch", "", "", "", expanded);
}
@Override
public String getCommand() {
return "";
}
@Override
public JPanel buildExpandedPanel() {
bnRun = new JButton("Run Jobs");
bnLaunch = new JButton("Launch Jobs");
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Job", String.class, 120, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI, false));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this job"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(2).setMaxWidth(30);
table.getColumnModel().getColumn(2).setMinWidth(30);
table.addMouseListener(this);
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
JToolBar pn = new JToolBar("Controls Batch");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 2));
pn.setFloatable(false);
pn.add(bnRun);
pn.add(bnLaunch);
JPanel panel = new JPanel(new BorderLayout());
panel.add(table.getPane(100, 100), BorderLayout.CENTER);
panel.add(pn, BorderLayout.SOUTH);
getAction1Button().addActionListener(this);
bnRun.addActionListener(this);
bnLaunch.addActionListener(this);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnRun) {
if (table.getSelectedRows().length == 0)
table.setColumnSelectionInterval(0, table.getRowCount());
int rows[] = table.getSelectedRows();
for (int row : rows)
new Deconvolution("Batch" + table.getCell(row, 0), table.getCell(row, 1)).deconvolve();
}
else if (e.getSource() == bnLaunch) {
if (table.getSelectedRows().length == 0)
table.setColumnSelectionInterval(0, table.getRowCount());
int rows[] = table.getSelectedRows();
for (int row : rows)
new Deconvolution("Batch " + table.getCell(row, 0), table.getCell(row, 1)).launch();
}
}
private void update() {
setSynopsis("" + table.getRowCount() + " jobs");
}
public int getCountJob() {
return table.getRowCount();
}
public void addJob(String name, String command) {
table.append(new String[] { name, command, "" });
update();
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 2) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
}
update();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
getAction1Button().removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/BorderModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/BorderModule.java
index 03f1e66..eb49308 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/BorderModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/BorderModule.java
@@ -1,247 +1,243 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.GridPanel;
import bilib.component.SpinnerRangeInteger;
import bilib.tools.NumFormat;
import deconvolution.Command;
import deconvolution.Deconvolution;
-import deconvolution.Features;
import deconvolutionlab.Config;
import deconvolutionlab.monitor.Monitors;
import signal.RealSignal;
import signal.apodization.AbstractApodization;
import signal.apodization.Apodization;
import signal.apodization.UniformApodization;
import signal.padding.AbstractPadding;
import signal.padding.NoPadding;
import signal.padding.Padding;
public class BorderModule extends AbstractModule implements ActionListener, ChangeListener {
private JComboBox<String> cmbPadXY;
private JComboBox<String> cmbPadZ;
private JComboBox<String> cmbApoXY;
private JComboBox<String> cmbApoZ;
private SpinnerRangeInteger spnExtensionXY;
private SpinnerRangeInteger spnExtensionZ;
private JLabel lblPad;
private JLabel lblApo;
-
- private boolean build = false;
public BorderModule(boolean expanded) {
super("Border", "", "Test", "Default", expanded);
}
@Override
public String getCommand() {
AbstractPadding pxy = Padding.getByName((String) cmbPadXY.getSelectedItem());
AbstractPadding paz = Padding.getByName((String) cmbPadZ.getSelectedItem());
AbstractApodization axy = Apodization.getByName((String) cmbApoXY.getSelectedItem());
AbstractApodization apz = Apodization.getByName((String) cmbApoZ.getSelectedItem());
boolean ext = spnExtensionXY.get() + spnExtensionZ.get() > 0;
String extXY = (ext ? "" + spnExtensionXY.get() : "") + " ";
String extZ = ext ? "" + spnExtensionZ.get() : "";
String cmd = "";
if (!(pxy instanceof NoPadding) || !(paz instanceof NoPadding) || spnExtensionXY.get() > 0 || spnExtensionZ.get() > 0)
cmd += " -pad " + pxy.getShortname() + " " + paz.getShortname() + " " + extXY + extZ;
if (!(axy instanceof UniformApodization) || !(apz instanceof UniformApodization))
cmd += " -apo " + axy.getShortname() + " " + apz.getShortname() + " ";
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
lblPad = new JLabel("Information on padding size");
lblPad.setBorder(BorderFactory.createEtchedBorder());
lblApo = new JLabel("Information on apodization energy");
lblApo.setBorder(BorderFactory.createEtchedBorder());
cmbPadXY = new JComboBox<String>(Padding.getPaddingsAsArray());
cmbPadZ = new JComboBox<String>(Padding.getPaddingsAsArray());
cmbApoXY = new JComboBox<String>(Apodization.getApodizationsAsArray());
cmbApoZ = new JComboBox<String>(Apodization.getApodizationsAsArray());
spnExtensionXY = new SpinnerRangeInteger(0, 0, 99999, 1);
spnExtensionZ = new SpinnerRangeInteger(0, 0, 99999, 1);
GridPanel pnBorder = new GridPanel(false, 3);
pnBorder.place(0, 1, "Lateral (XY)");
pnBorder.place(0, 2, "Axial (Z)");
pnBorder.place(2, 0, "Apodization");
pnBorder.place(2, 1, cmbApoXY);
pnBorder.place(2, 2, cmbApoZ);
pnBorder.place(3, 0, "Padding Extension");
pnBorder.place(3, 1, spnExtensionXY);
pnBorder.place(3, 2, spnExtensionZ);
pnBorder.place(4, 0, "Padding Constraint");
pnBorder.place(4, 1, cmbPadXY);
pnBorder.place(4, 2, cmbPadZ);
pnBorder.place(5, 0, 3, 1, lblPad);
pnBorder.place(6, 0, 3, 1, lblApo);
JScrollPane scroll = new JScrollPane(pnBorder);
scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEtchedBorder());
panel.add(scroll, BorderLayout.CENTER);
Config.register(getName(), "padxy", cmbPadXY, Padding.getDefault().getName());
Config.register(getName(), "padz", cmbPadZ, Padding.getDefault().getName());
Config.register(getName(), "apoxy", cmbApoXY, Apodization.getDefault().getName());
Config.register(getName(), "apoz", cmbApoZ, Apodization.getDefault().getName());
Config.register(getName(), "extxy", spnExtensionXY, "0");
Config.register(getName(), "extz", spnExtensionZ, "0");
spnExtensionXY.addChangeListener(this);
spnExtensionZ.addChangeListener(this);
cmbPadXY.addActionListener(this);
cmbPadZ.addActionListener(this);
cmbApoXY.addActionListener(this);
cmbApoZ.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
- build = true;
return panel;
}
private void update() {
setCommand(getCommand());
boolean ext = spnExtensionXY.get() + spnExtensionZ.get() > 0;
boolean pad = cmbPadXY.getSelectedIndex() + cmbPadZ.getSelectedIndex() > 0;
boolean apo = cmbApoXY.getSelectedIndex() + cmbApoZ.getSelectedIndex() > 0;
if (pad || apo || ext) {
setSynopsis("" + " " + (pad ? "Padding" : "") + " " + (ext ? "Extension" : "") + " " + (apo ? "Apodization" : ""));
}
else {
setSynopsis("Default options");
}
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
update();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == getAction2Button()) {
cmbPadXY.removeActionListener(this);
cmbPadZ.removeActionListener(this);
cmbApoXY.removeActionListener(this);
cmbApoZ.removeActionListener(this);
cmbPadXY.setSelectedIndex(0);
cmbPadZ.setSelectedIndex(0);
cmbApoXY.setSelectedIndex(0);
cmbApoZ.setSelectedIndex(0);
spnExtensionXY.set(0);
spnExtensionZ.set(0);
cmbPadXY.addActionListener(this);
cmbPadZ.addActionListener(this);
cmbApoXY.addActionListener(this);
cmbApoZ.addActionListener(this);
update();
return;
}
if (e.getSource() == getAction1Button()) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
getAction1Button().setEnabled(false);
getAction2Button().setEnabled(false);
Deconvolution d = new Deconvolution("CheckImage", Command.command());
Apodization apo = d.getApodization();
if (apo == null) {
lblApo.setText("Error in Apodization");
return;
}
Padding pad = d.getPadding();
if (pad == null) {
lblPad.setText("Error in Padding");
return;
}
RealSignal x = d.openImage();
if (x == null) {
lblPad.setText("Error in input image");
lblApo.setText("Error in input image");
return;
}
Monitors m = Monitors.createDefaultMonitor();
RealSignal y = pad.pad(m, x);
apo.apodize(m, y);
lblPad.setText(x.dimAsString() + " > " + y.dimAsString());
lblApo.setText(NumFormat.nice(x.getStats()[5]) + " > " + NumFormat.nice(y.getStats()[5]));
getAction1Button().setEnabled(true);
getAction2Button().setEnabled(true);
}
});
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
return;
}
update();
}
@Override
public void close() {
cmbPadXY.removeActionListener(this);
cmbPadZ.removeActionListener(this);
cmbApoXY.removeActionListener(this);
cmbApoZ.removeActionListener(this);
getAction1Button().removeActionListener(this);
getAction2Button().removeActionListener(this);
spnExtensionXY.removeChangeListener(this);
spnExtensionZ.removeChangeListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/CommandModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/CommandModule.java
index 99b0c40..3eb9faf 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/CommandModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/CommandModule.java
@@ -1,100 +1,92 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
-import java.io.File;
-import java.util.ArrayList;
import javax.swing.JPanel;
import bilib.component.HTMLPane;
-import bilib.tools.Files;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolutionlab.Lab;
-import deconvolutionlab.dialog.PatternDialog;
-import deconvolutionlab.dialog.SyntheticDialog;
-import deconvolutionlab.monitor.Monitors;
-import signal.RealSignal;
-import signal.factory.SignalFactory;
public class CommandModule extends AbstractModule {
private HTMLPane window;
public CommandModule() {
super("Command", "", "", "Check", true);
}
public HTMLPane getPane() {
return window;
}
@Override
public JPanel buildExpandedPanel() {
window = new HTMLPane("Monaco", 100, 100);
JPanel panel = new JPanel(new BorderLayout());
panel.add(window.getPane(), BorderLayout.CENTER);
getAction2Button().setToolTipText("Human readable of the command line");
getAction2Button().addActionListener(this);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == getAction2Button()) {
Deconvolution deconvolution = new Deconvolution("Check Command", Command.command());
DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.RECAP, deconvolution, null, null);
Lab.setVisible(d, false);
}
}
@Override
public void close() {
}
@Override
public void setCommand(String command) {
window.clear();
window.append("p", command);
}
@Override
public String getCommand() {
return "";
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/ConfigModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/ConfigModule.java
index dbe63bc..483370d 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/ConfigModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/ConfigModule.java
@@ -1,124 +1,124 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
-import bilib.component.CustomizedColumn;
-import bilib.component.CustomizedTable;
+import bilib.table.CustomizedColumn;
+import bilib.table.CustomizedTable;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
public class ConfigModule extends AbstractModule implements ActionListener {
private JButton bnLoad;
private JButton bnSave;
private CustomizedTable table;
private JLabel lblDefault;
public ConfigModule(boolean expanded) {
super("Config", "", "", "", expanded);
}
@Override
public String getCommand() {
return "";
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Key", String.class, 180, false));
columns.add(new CustomizedColumn("Value", String.class, Constants.widthGUI - 80, true));
table = new CustomizedTable(columns, true);
read();
lblDefault = new JLabel(Config.getFilename());
bnLoad = new JButton("Load");
bnSave = new JButton("Save");
lblDefault.setBorder(BorderFactory.createEtchedBorder());
JPanel button = new JPanel();
button.setLayout(new FlowLayout());
button.add(bnLoad);
button.add(bnSave);
JPanel panel = new JPanel(new BorderLayout());
panel.add(lblDefault, BorderLayout.NORTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
bnLoad.addActionListener(this);
bnSave.addActionListener(this);
return panel;
}
private void read() {
String filename = Config.getFilename();
File file = new File(filename);
if (file.exists()) {
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while ((line = br.readLine()) != null) {
String entry = line.trim();
if (!entry.startsWith("#")) {
String[] parts = entry.split("=");
if (parts.length == 2)
table.append(parts);
}
}
br.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public void close() {
bnLoad.removeActionListener(this);
bnSave.removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/ControllerModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/ControllerModule.java
index 6f48f37..74716db 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/ControllerModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/ControllerModule.java
@@ -1,245 +1,244 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.File;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
-import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.GridPanel;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolutionlab.Config;
import signal.Constraint;
public class ControllerModule extends AbstractModule implements ActionListener, ChangeListener, KeyListener {
private JButton bnBrowse;
private JTextField txtReference;
private JTextField txtResidu;
private JTextField txtTime;
private JTextField txtIterations;
private JComboBox<String> cmbConstraint;
private JCheckBox chkResidu;
private JCheckBox chkReference;
private JCheckBox chkConstraint;
private JCheckBox chkTime;
private JCheckBox chkItermax;
public ControllerModule(boolean expanded) {
super("Controller", "", "Default", "", expanded);
}
@Override
public String getCommand() {
String cmd = "";
if (chkConstraint.isSelected())
cmd += "-constraint " + cmbConstraint.getSelectedItem() + " ";
if (chkReference.isSelected())
cmd += "-reference " + txtReference.getText() + " ";
if (chkResidu.isSelected())
cmd += "-residu " + txtResidu.getText() + " ";
if (chkTime.isSelected())
cmd += "-time " + txtTime.getText() + " ";
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
chkTime = new JCheckBox("Time Limitation (s)");
chkItermax = new JCheckBox("Early Stopping");
chkConstraint = new JCheckBox("Constraint");
chkResidu = new JCheckBox("Residu Minimun");
chkReference = new JCheckBox("Reference");
bnBrowse = new JButton("Browse");
txtReference = new JTextField("");
txtResidu = new JTextField("0.01");
txtTime = new JTextField("3600");
txtIterations = new JTextField("Iteration max (mandatory)");
txtIterations.setEditable(false);
cmbConstraint = new JComboBox<String>(Constraint.getContraintsAsArray());
txtReference.setPreferredSize(new Dimension(200, 20));
GridPanel pn = new GridPanel(true);
pn.place(0, 0, chkItermax);
pn.place(0, 1, txtIterations);
pn.place(1, 0, chkResidu);
pn.place(1, 1, txtResidu);
pn.place(4, 0, chkConstraint);
pn.place(4, 1, cmbConstraint);
pn.place(5, 0, chkTime);
pn.place(5, 1, txtTime);
pn.place(7, 0, chkReference);
pn.place(7, 1, txtReference);
pn.place(8, 0, "Ground-truth file");
pn.place(8, 1, bnBrowse);
JScrollPane scroll = new JScrollPane(pn);
scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEtchedBorder());
panel.add(scroll, BorderLayout.CENTER);
Config.register(getName(), "residu.enable", chkResidu, false);
Config.register(getName(), "reference.enable", chkReference, false);
Config.register(getName(), "constraint.enable", chkConstraint, false);
Config.register(getName(), "time.enable", chkTime, false);
Config.register(getName(), "itmax.enable", chkItermax, true);
Config.register(getName(), "reference.value", txtReference, "");
Config.register(getName(), "residu.value", txtResidu, "0.01");
Config.register(getName(), "time.value", txtTime, "3600");
Config.register(getName(), "constraint.value", cmbConstraint, "No");
chkItermax.setSelected(true);
bnBrowse.addActionListener(this);
chkResidu.addChangeListener(this);
chkReference.addChangeListener(this);
chkConstraint.addChangeListener(this);
chkTime.addChangeListener(this);
chkItermax.addChangeListener(this);
txtResidu.addKeyListener(this);
txtReference.addKeyListener(this);
txtTime.addKeyListener(this);
cmbConstraint.addActionListener(this);
getAction1Button().addActionListener(this);
return panel;
}
private void update() {
chkItermax.setSelected(true);
setCommand(getCommand());
int count = 0;
count += (chkResidu.isSelected() ? 1 : 0);
count += (chkConstraint.isSelected() ? 1 : 0);
count += (chkTime.isSelected() ? 1 : 0);
count += (chkItermax.isSelected() ? 1 : 0);
setSynopsis("" + count + " stopping criteria");
Command.command();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnBrowse) {
File file = Files.browseFile(Command.getPath());
if (file != null)
txtReference.setText(file.getAbsolutePath());
}
if (e.getSource() == getAction1Button()) {
chkResidu.removeChangeListener(this);
chkReference.removeChangeListener(this);
chkConstraint.removeChangeListener(this);
chkTime.removeChangeListener(this);
chkItermax.removeChangeListener(this);
chkResidu.setSelected(false);
chkReference.setSelected(false);
chkConstraint.setSelected(false);
chkTime.setSelected(false);
chkItermax.setSelected(true);
txtReference.setText("");
txtResidu.setText("0.01");
txtTime.setText("3600");
cmbConstraint.setSelectedIndex(0);
chkResidu.addChangeListener(this);
chkReference.addChangeListener(this);
chkConstraint.addChangeListener(this);
chkTime.addChangeListener(this);
chkItermax.addChangeListener(this);
}
update();
}
@Override
public void stateChanged(ChangeEvent e) {
update();
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
update();
}
@Override
public void close() {
bnBrowse.removeActionListener(this);
chkReference.removeChangeListener(this);
chkResidu.removeChangeListener(this);
chkConstraint.removeChangeListener(this);
chkItermax.removeChangeListener(this);
chkTime.removeChangeListener(this);
getAction1Button().removeChangeListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
index 09b5d25..34fe784 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
@@ -1,354 +1,353 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
-import bilib.component.CustomizedColumn;
-import bilib.component.CustomizedTable;
+import bilib.table.CustomizedColumn;
+import bilib.table.CustomizedTable;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
-import deconvolution.modules.ImageDModule;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Imaging;
import deconvolutionlab.Lab;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
import signal.RealSignal;
import signal.factory.SignalFactory;
public class ImageModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnFile;
private JButton bnDirectory;
private JButton bnSynthetic;
private JButton bnPlatform;
public ImageModule(boolean expanded) {
super("Image", "-image", (Lab.getPlatform() == Imaging.Platform.IMAGEJ ? "Active" : ""), "Check", expanded);
}
@Override
public String getCommand() {
int row = table.getSelectedRow();
if (row < 0)
return "";
return "-image " + table.getCell(row, 1) + " " + table.getCell(row, 2);
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 100, false));
columns.add(new CustomizedColumn("Source", String.class, 100, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI - 200, true));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this image source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(3).setMaxWidth(30);
table.getColumnModel().getColumn(3).setMinWidth(30);
table.addMouseListener(this);
bnFile = new JButton("\u2295 file");
bnDirectory = new JButton("\u2295 directory");
bnSynthetic = new JButton("\u2295 synthetic");
bnPlatform = new JButton("\u2295 platform");
JToolBar pn = new JToolBar("Controls Image");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 4));
pn.setFloatable(false);
pn.add(bnFile);
pn.add(bnDirectory);
pn.add(bnSynthetic);
if (Lab.getPlatform() == Imaging.Platform.IMAGEJ)
pn.add(bnPlatform);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
table.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
bnFile.addActionListener(this);
bnDirectory.addActionListener(this);
bnSynthetic.addActionListener(this);
bnPlatform.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
getAction2Button().setToolTipText("Click to have a preview, Shift-click or Ctrl-click to show the complete stack");
getAction1Button().setToolTipText("Select the active window");
Config.registerTable(getName(), "image", table);
return panel;
}
public void update() {
int row = table.getSelectedRow();
if (row >= 0) {
setCommand(getCommand());
setSynopsis(table.getCell(row, 0));
Command.command();
}
else {
setSynopsis("");
setCommand("Drag your image file, here");
}
getAction2Button().setEnabled(table.getRowCount() > 0);
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnFile)
file(Command.getPath());
else if (e.getSource() == bnDirectory)
dir(Command.getPath());
else if (e.getSource() == bnSynthetic)
synthetic(false);
else if (e.getSource() == bnPlatform)
platform();
else if (e.getSource() == getAction1Button()) {
int row = -1;
for(int i=0; i<table.getRowCount(); i++) {
if (table.getCell(i, 0).equalsIgnoreCase("active"))
if (table.getCell(i, 1).equalsIgnoreCase("platform"))
if (table.getCell(i, 2).equalsIgnoreCase("active"))
row = i;
}
if (row < 0)
table.insert(new String[] { "active", "platform", "active", "\u232B" });
else
table.setRowSelectionInterval(row, row);
}
else if (e.getSource() == getAction2Button()) {
boolean s = (e.getModifiers() & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK;
boolean c = (e.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK;
display(s | c);
}
update();
}
public void platform() {
String name = Lab.getActiveImage();
if (name != "")
table.insert(new String[] { name, "platform", name, "\u232B" });
}
private void file(String path) {
File file = Files.browseFile(path);
if (file == null)
return;
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "\u232B" });
}
private void dir(String path) {
File file = Files.browseDirectory(path);
if (file == null)
return;
PatternDialog dlg = new PatternDialog(file);
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
table.insert(new String[] { dlg.getDirName(), "directory", dlg.getCommand(), "\u232B" });
}
private void synthetic(boolean edit) {
ArrayList<SignalFactory> list = SignalFactory.getImages();
SyntheticDialog dlg = new SyntheticDialog(list);
if (edit) {
int row = table.getSelectedRow();
if (row >= 0) {
dlg.setParameters(table.getCell(row, 0), table.getCell(row, 1));
}
}
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
if (edit) {
int row = table.getSelectedRow();
if (row <= 0)
table.removeRow(row);
}
table.insert(new String[] { dlg.getShapeName(), "synthetic", dlg.getCommand(), "\u232B" });
}
private void edit() {
int row = table.getSelectedRow();
if (row < 0)
return;
String name = table.getCell(row, 0).trim();
for (SignalFactory factory : SignalFactory.getAll()) {
if (name.equals(factory.getName().trim()))
synthetic(true);
return;
}
String filename = table.getCell(row, 1).trim();
File file = new File(filename);
if (!file.exists())
return;
if (file.isFile())
file(table.getCell(row, 21));
else
dir(table.getCell(row, 1));
}
private void display(boolean stack) {
int row = table.getSelectedRow();
if (row < 0)
return;
Deconvolution deconvolution = new Deconvolution("Check Image", Command.command());
deconvolution.openImage();
if (stack) {
RealSignal x = deconvolution.getImage();
if (x != null)
Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
}
else {
DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.IMAGE, deconvolution, null, null);
Lab.setVisible(d, false);
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 3) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
if (e.getClickCount() == 2) {
edit();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnFile.removeActionListener(this);
bnDirectory.removeActionListener(this);
bnSynthetic.removeActionListener(this);
bnPlatform.removeActionListener(this);
}
public class LocalDropTarget extends DropTarget {
@Override
public void drop(DropTargetDropEvent e) {
e.acceptDrop(DnDConstants.ACTION_COPY);
e.getTransferable().getTransferDataFlavors();
Transferable transferable = e.getTransferable();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
if (flavor.isFlavorJavaFileListType()) {
try {
List<File> files = (List<File>) transferable.getTransferData(flavor);
for (File file : files) {
if (file.isDirectory()) {
table.insert(new String[] { file.getName(), "directory", file.getAbsolutePath(), "" });
table.setRowSelectionInterval(0, 0);
update();
}
if (file.isFile()) {
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "" });
update();
}
}
}
catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
e.dropComplete(true);
super.drop(e);
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/OutputModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/OutputModule.java
index a877d5e..105dd9c 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/OutputModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/OutputModule.java
@@ -1,236 +1,236 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
-import bilib.component.CustomizedColumn;
-import bilib.component.CustomizedTable;
+import bilib.table.CustomizedColumn;
+import bilib.table.CustomizedTable;
import deconvolution.Command;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import deconvolutionlab.Output;
import deconvolutionlab.Output.View;
import deconvolutionlab.dialog.OutputDialog;
public class OutputModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnStack;
private JButton bnSeries;
private JButton bnMIP;
private JButton bnOrtho;
private JButton bnPlanar;
private JButton bnFigure;
public OutputModule(boolean expanded) {
super("Output", "", "", "Default", expanded);
}
@Override
public String getCommand() {
String cmd = " ";
if (table == null)
return cmd;
for (int i = 0; i < table.getRowCount(); i++) {
String[] values = new String[table.getColumnCount()];
for(int c=0; c<table.getColumnCount(); c++)
values[c] = table.getCell(i, c) == null ? "" : table.getCell(i, c).trim();
cmd += " -out " + values[0] + " " + values[1] + " " + values[2] + " " + values[3] + " " + values[4];
if (values[5].equals(""))
cmd += " noshow";
if (values[6].equals(""))
cmd += " nosave";
}
return cmd;
}
public void update() {
setCommand(getCommand());
setSynopsis(table.getRowCount() + " output" + (table.getRowCount() > 1 ? "s" : ""));
Command.command();
getAction1Button().setEnabled(table.getRowCount() > 0);
}
@Override
public JPanel buildExpandedPanel() {
String[] dynamics = { "intact", "rescaled", "normalized", "clipped" };
String[] types = { "float", "short", "byte" };
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Mode", String.class, 80, false));
columns.add(new CustomizedColumn("Name", String.class, Constants.widthGUI, true));
columns.add(new CustomizedColumn("Dynamic", String.class, 100, dynamics, "Select the dynamic range"));
columns.add(new CustomizedColumn("Type", String.class, 100, types, "Select the type"));
columns.add(new CustomizedColumn("Keypoint", String.class, 120, false));
columns.add(new CustomizedColumn("Show", String.class, 50, false));
columns.add(new CustomizedColumn("Save", String.class, 50, false));
columns.add(new CustomizedColumn("Del", String.class, 30, "\u232B", "Delete this image source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(5).setMaxWidth(50);
table.getColumnModel().getColumn(6).setMaxWidth(50);
table.getColumnModel().getColumn(7).setMaxWidth(30);
table.getColumnModel().getColumn(0).setMaxWidth(100);
table.getColumnModel().getColumn(2).setMaxWidth(100);
table.getColumnModel().getColumn(3).setMaxWidth(100);
table.addMouseListener(this);
bnStack = new JButton("\u2295 stack");
bnSeries = new JButton("\u2295 series");
bnMIP = new JButton("\u2295 mip");
bnOrtho = new JButton("\u2295 ortho");
bnPlanar = new JButton("\u2295 planar");
bnFigure = new JButton("\u2295 figure");
JToolBar pn = new JToolBar("Controls Image");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 6));
pn.setFloatable(false);
pn.add(bnStack);
pn.add(bnSeries);
pn.add(bnMIP);
pn.add(bnOrtho);
pn.add(bnPlanar);
pn.add(bnFigure);
JToolBar tool = new JToolBar("Path");
tool.setBorder(BorderFactory.createEmptyBorder());
tool.setLayout(new BorderLayout());
tool.setFloatable(false);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(tool, BorderLayout.NORTH);
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
bnStack.addActionListener(this);
bnSeries.addActionListener(this);
bnMIP.addActionListener(this);
bnOrtho.addActionListener(this);
bnPlanar.addActionListener(this);
bnFigure.addActionListener(this);
getAction1Button().addActionListener(this);
Config.registerTable(getName(), "output", table);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
View view = null;
if (e.getSource() == bnStack)
view = View.STACK;
else if (e.getSource() == bnSeries)
view = View.SERIES;
else if (e.getSource() == bnMIP)
view = View.MIP;
else if (e.getSource() == bnOrtho)
view = View.ORTHO;
else if (e.getSource() == bnPlanar)
view = View.PLANAR;
else if (e.getSource() == bnFigure)
view = View.FIGURE;
if (view != null) {
OutputDialog dlg = new OutputDialog(view);
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
Output out = dlg.getOut();
if (out != null)
table.insert(out.getAsString());
//Lab.setVisible(new OutputPanel(view), "panel", 30, 30);
update();
}
if (e.getSource() == getAction1Button()) {
table.removeRows();
}
}
@Override
public void mouseClicked(MouseEvent e) {
int row = table.getSelectedRow();
if (table.getSelectedColumn() == 7) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
Command.command();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnStack.removeActionListener(this);
bnSeries.removeActionListener(this);
bnMIP.removeActionListener(this);
bnOrtho.removeActionListener(this);
bnPlanar.removeActionListener(this);
bnFigure.removeActionListener(this);
getAction1Button().removeActionListener(this);
getAction2Button().removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java
index 8ef6d7d..18594ca 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java
@@ -1,342 +1,341 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
-import bilib.component.CustomizedColumn;
-import bilib.component.CustomizedTable;
+import bilib.table.CustomizedColumn;
+import bilib.table.CustomizedTable;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
-import deconvolution.modules.PSFDModule;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Imaging;
import deconvolutionlab.Lab;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
import signal.RealSignal;
import signal.factory.SignalFactory;
public class PSFModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnFile;
private JButton bnDirectory;
private JButton bnSynthetic;
private JButton bnPlatform;
public PSFModule(boolean expanded) {
super("PSF", "-psf", "", "Check", expanded);
}
@Override
public String getCommand() {
int row = table.getSelectedRow();
if (row < 0)
return "";
return "-psf " + table.getCell(row, 1) + " " + table.getCell(row, 2);
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 100, false));
columns.add(new CustomizedColumn("Source", String.class, 100, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI - 200, true));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this PSF source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(3).setMaxWidth(30);
table.getColumnModel().getColumn(3).setMinWidth(30);
table.addMouseListener(this);
bnFile = new JButton("\u2295 file");
bnDirectory = new JButton("\u2295 directory");
bnSynthetic = new JButton("\u2295 synthetic");
bnPlatform = new JButton("\u2295 platform");
JToolBar pn = new JToolBar("Controls PSF");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 5));
pn.setFloatable(false);
pn.add(bnFile);
pn.add(bnDirectory);
pn.add(bnSynthetic);
if (Lab.getPlatform() == Imaging.Platform.IMAGEJ)
pn.add(bnPlatform);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
table.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
bnFile.addActionListener(this);
bnDirectory.addActionListener(this);
bnSynthetic.addActionListener(this);
if (Lab.getPlatform() == Imaging.Platform.IMAGEJ)
bnPlatform.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
getAction2Button().setToolTipText("Click to have a preview, Shift-click or Ctrl-click to show the complete stack");
getAction1Button().setToolTipText("Select the active window");
Config.registerTable(getName(), "psf", table);
return panel;
}
public void update() {
int row = table.getSelectedRow();
if (row >= 0) {
setCommand(getCommand());
setSynopsis(table.getCell(row, 0));
Command.command();
}
else {
setSynopsis("");
setCommand("Drag your image file, here");
}
getAction2Button().setEnabled(table.getRowCount() > 0);
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnFile)
file(Command.getPath());
else if (e.getSource() == bnDirectory)
dir(Command.getPath());
else if (e.getSource() == bnSynthetic)
synthetic(false);
else if (e.getSource() == bnPlatform)
platform();
else if (e.getSource() == getAction1Button())
platform();
else if (e.getSource() == getAction2Button()) {
boolean s = (e.getModifiers() & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK;
boolean c = (e.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK;
display(s | c);
}
update();
}
public void platform() {
String name = Lab.getActiveImage();
if (name != "")
table.insert(new String[] {name, "platform", name, "\u232B" });
}
private void file(String path) {
File file = Files.browseFile(path);
if (file == null)
return;
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "\u232B" });
}
private void dir(String path) {
File file = Files.browseDirectory(path);
if (file == null)
return;
PatternDialog dlg = new PatternDialog(file);
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
table.insert(new String[] { dlg.getDirName(), "directory", dlg.getCommand(), "\u232B" });
}
private void synthetic(boolean edit) {
ArrayList<SignalFactory> list = SignalFactory.getPSF();
SyntheticDialog dlg = new SyntheticDialog(list);
if (edit) {
int row = table.getSelectedRow();
if (row >= 0) {
dlg.setParameters(table.getCell(row, 0), table.getCell(row, 1));
}
}
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
if (edit) {
int row = table.getSelectedRow();
if (row <= 0)
table.removeRow(row);
}
table.insert(new String[] { dlg.getShapeName(), "synthetic", dlg.getCommand(), "" });
}
private void edit() {
int row = table.getSelectedRow();
if (row < 0)
return;
String name = table.getCell(row, 0).trim();
for(SignalFactory factory : SignalFactory.getAll()) {
if (name.equals(factory.getName().trim()))
synthetic(true);
return;
}
String filename = table.getCell(row, 1).trim();
File file = new File(filename);
if (!file.exists())
return;
if (file.isFile())
file(table.getCell(row, 21));
else
dir(table.getCell(row, 1));
}
private void display(boolean stack) {
int row = table.getSelectedRow();
if (row < 0)
return;
Deconvolution deconvolution = new Deconvolution("Check PSF", Command.command());
deconvolution.openPSF();
if (stack) {
RealSignal x = deconvolution.getPSF();
if (x != null)
Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
}
else {
DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.PSF, deconvolution, null, null);
Lab.setVisible(d, false);
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 3) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
if (e.getClickCount() == 2) {
edit();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnFile.removeActionListener(this);
bnDirectory.removeActionListener(this);
bnSynthetic.removeActionListener(this);
bnPlatform.removeActionListener(this);
}
public class LocalDropTarget extends DropTarget {
@Override
public void drop(DropTargetDropEvent e) {
e.acceptDrop(DnDConstants.ACTION_COPY);
e.getTransferable().getTransferDataFlavors();
Transferable transferable = e.getTransferable();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
if (flavor.isFlavorJavaFileListType()) {
try {
List<File> files = (List<File>) transferable.getTransferData(flavor);
for (File file : files) {
if (file.isDirectory()) {
table.insert(new String[] { file.getName(), "directory", file.getAbsolutePath(), "" });
table.setRowSelectionInterval(0, 0);
update();
}
if (file.isFile()) {
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "" });
update();
}
}
}
catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
e.dropComplete(true);
super.drop(e);
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/RunningModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/RunningModule.java
index a4c285c..89baf47 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/RunningModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/RunningModule.java
@@ -1,264 +1,264 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.util.ArrayList;
import javax.swing.JPanel;
import javax.swing.JTextField;
-import bilib.component.CustomizedColumn;
-import bilib.component.CustomizedTable;
+import bilib.table.CustomizedColumn;
+import bilib.table.CustomizedTable;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
public class RunningModule extends AbstractModule implements MouseListener {
private CustomizedTable table;
private String[] valuesMonitor;
private String[] valuesVerbose;
private String[] valuesSystem;
private String[] valuesMultithreading;
private String[] valuesDisplay;
private String[] valuesStats;
private String[] valuesPath;
private JTextField txtMonitor;
private JTextField txtVerbose;
private JTextField txtSystem;
private JTextField txtMultithreading;
private JTextField txtDisplay;
private JTextField txtStats;
private JTextField txtPath;
private JTextField txtDirectory;
public RunningModule(boolean expanded) {
super("Running", "", "Default", "Browse", expanded);
}
@Override
public String getCommand() {
String cmd = "";
String p = txtPath.getText();
if (!p.equalsIgnoreCase(valuesPath[0]))
cmd += " -path " + txtDirectory.getText().toLowerCase();
if (!txtMonitor.getText().equalsIgnoreCase(valuesMonitor[0]))
cmd += " -monitor " + txtMonitor.getText().toLowerCase();
if (!txtVerbose.getText().equalsIgnoreCase(valuesVerbose[0]))
cmd += " -verbose " + txtVerbose.getText().toLowerCase();
if (!txtSystem.getText().equalsIgnoreCase(valuesSystem[0]))
cmd += " -system " + txtSystem.getText().toLowerCase();
if (!txtDisplay.getText().equalsIgnoreCase(valuesDisplay[0]))
cmd += " -display " + txtDisplay.getText().toLowerCase();
if (!txtStats.getText().equalsIgnoreCase(valuesStats[0]))
cmd += " -stats " + txtStats.getText().toLowerCase();
if (!txtMultithreading.getText().equalsIgnoreCase(valuesMultithreading[0]))
cmd += " -multithreading " + txtMultithreading.getText().toLowerCase();
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
valuesPath = new String[] { "current", "specify" };
valuesMonitor = new String[] { "console table", "console", "table", "no" };
valuesStats = new String[] { "no", "show", "save", "show save" };
valuesVerbose = new String[] { "log", "quiet", "mute", "prolix" };
valuesSystem = new String[] { "yes", "no" };
valuesMultithreading = new String[] { "yes", "no" };
valuesDisplay = new String[] { "yes", "no" };
txtDirectory = new JTextField(System.getProperty("user.dir"));
txtPath = new JTextField(valuesPath[0]);
txtMonitor = new JTextField(valuesMonitor[0]);
txtStats = new JTextField(valuesStats[0]);
txtVerbose = new JTextField(valuesVerbose[0]);
txtSystem = new JTextField(valuesSystem[0]);
txtMultithreading = new JTextField(valuesMultithreading[0]);
txtDisplay = new JTextField(valuesDisplay[0]);
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Settings", String.class, 150, false));
columns.add(new CustomizedColumn("State", String.class, 100, false));
columns.add(new CustomizedColumn("Information", String.class, Constants.widthGUI - 250, true));
columns.add(new CustomizedColumn("", String.class, 100, "Change", "Change this setting"));
table = new CustomizedTable(columns, false);
table.getColumnModel().getColumn(3).setMaxWidth(140);
table.getColumnModel().getColumn(3).setMaxWidth(140);
JPanel panel = new JPanel(new BorderLayout());
panel.add(table.getPane(100, 100), BorderLayout.CENTER);
Config.register(getName(), "Path", txtPath, valuesPath[0]);
Config.register(getName(), "Monitor", txtMonitor, valuesMonitor[0]);
Config.register(getName(), "Stats", txtStats, valuesStats[0]);
Config.register(getName(), "Verbose", txtVerbose, valuesVerbose[0]);
Config.register(getName(), "System", txtSystem, valuesSystem[0]);
Config.register(getName(), "Multithreading", txtMultithreading, valuesMultithreading[0]);
Config.register(getName(), "Display", txtDisplay, valuesDisplay[0]);
Config.register(getName(), "Directory", txtDirectory, System.getProperty("user.dir"));
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
table.addMouseListener(this);
return panel;
}
public void init() {
table.append(new String[] { "Path", txtPath.getText(), txtDirectory.getText(), "Change" });
table.append(new String[] { "Monitor", txtMonitor.getText(), "Monitor in table and in console", "Change" });
table.append(new String[] { "Stats", txtStats.getText(), "Compute stats (slow down)", "Change" });
table.append(new String[] { "Verbose", txtVerbose.getText(), "Level of messages in monitor", "Change" });
table.append(new String[] { "System", txtSystem.getText(), "Open the system window", "Change" });
table.append(new String[] { "Multithreading", txtMultithreading.getText(), "Activation of the multithreading", "Change" });
table.append(new String[] { "Display", txtDisplay.getText(), "Display result at the end", "Change" });
update();
}
public void update() {
setCommand(getCommand());
setSynopsis(txtDirectory.getText());
Command.command();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == getAction1Button()) {
for (int row = 0; row < table.getRowCount(); row++) {
if (table.getCell(row, 0).equalsIgnoreCase("path")) {
setDefault(row, valuesPath, txtPath);
txtDirectory.setText(System.getProperty("user.dir"));
table.setCell(0, 2, System.getProperty("user.dir"));
}
if (table.getCell(row, 0).equalsIgnoreCase("monitor"))
setDefault(row, valuesMonitor, txtMonitor);
if (table.getCell(row, 0).equalsIgnoreCase("stats"))
setDefault(row, valuesStats, txtStats);
if (table.getCell(row, 0).equalsIgnoreCase("verbose"))
setDefault(row, valuesVerbose, txtVerbose);
if (table.getCell(row, 0).equalsIgnoreCase("system"))
setDefault(row, valuesSystem, txtSystem);
if (table.getCell(row, 0).equalsIgnoreCase("multithreading"))
setDefault(row, valuesMultithreading, txtMultithreading);
if (table.getCell(row, 0).equalsIgnoreCase("display"))
setDefault(row, valuesDisplay, txtDisplay);
}
}
if (e.getSource() == getAction2Button()) {
File f = Files.browseDirectory(txtPath.getText());
if (f != null) {
txtDirectory.setText(f.getAbsolutePath());
txtPath.setText(valuesPath[1]);
table.setCell(0, 1, txtPath.getText());
table.setCell(0, 2, txtDirectory.getText());
}
}
update();
}
@Override
public void close() {
}
@Override
public void mouseClicked(MouseEvent e) {
int row = table.getSelectedRow();
if (table.getSelectedColumn() == 3) {
if (table.getCell(row, 0).equalsIgnoreCase("path")) {
toggle(row, valuesPath, txtPath);
txtDirectory.setText(System.getProperty("user.dir"));
table.setCell(0, 2, System.getProperty("user.dir"));
}
if (table.getCell(row, 0).equalsIgnoreCase("monitor"))
toggle(row, valuesMonitor, txtMonitor);
if (table.getCell(row, 0).equalsIgnoreCase("stats"))
toggle(row, valuesStats, txtStats);
if (table.getCell(row, 0).equalsIgnoreCase("verbose"))
toggle(row, valuesVerbose, txtVerbose);
if (table.getCell(row, 0).equalsIgnoreCase("system"))
toggle(row, valuesSystem, txtSystem);
if (table.getCell(row, 0).equalsIgnoreCase("multithreading"))
toggle(row, valuesMultithreading, txtMultithreading);
if (table.getCell(row, 0).equalsIgnoreCase("display"))
toggle(row, valuesDisplay, txtDisplay);
}
update();
Command.command();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
private void toggle(int row, String values[], JTextField txt) {
for (int i = 0; i < values.length; i++) {
if (table.getCell(row, 1).equalsIgnoreCase(values[i])) {
int k = i == values.length - 1 ? 0 : i + 1;
table.setCell(row, 1, values[k]);
txt.setText(values[k]);
return;
}
}
setDefault(row, values, txt);
}
private void setDefault(int row, String values[], JTextField txt) {
table.setCell(row, 1, values[0]);
txt.setText(values[0]);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/monitor/RunningMonitor.java b/DeconvolutionLab2/src/deconvolutionlab/monitor/RunningMonitor.java
index 69b6b5c..b51f0d1 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/monitor/RunningMonitor.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/monitor/RunningMonitor.java
@@ -1,133 +1,133 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.monitor;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JToolBar;
import javax.swing.table.DefaultTableModel;
-import bilib.component.CustomizedColumn;
-import bilib.component.CustomizedTable;
+import bilib.table.CustomizedColumn;
+import bilib.table.CustomizedTable;
import bilib.tools.NumFormat;
import deconvolutionlab.system.SystemUsage;
public class RunningMonitor implements AbstractMonitor {
private CustomizedTable table;
private JPanel panel;
private double chrono = System.nanoTime();
private double peak = 0;
public RunningMonitor(int width, int height) {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Time", String.class, 100, false));
columns.add(new CustomizedColumn("Memory", String.class, 100, false));
columns.add(new CustomizedColumn("Iteration", String.class, 60, false));
columns.add(new CustomizedColumn("Message", String.class, Math.max(60, width - 4*100), false));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(0).setMinWidth(40);
table.getColumnModel().getColumn(0).setMaxWidth(80);
table.getColumnModel().getColumn(1).setMinWidth(40);
table.getColumnModel().getColumn(1).setMaxWidth(80);
table.getColumnModel().getColumn(2).setMinWidth(40);
table.getColumnModel().getColumn(2).setMaxWidth(80);
JScrollPane scroll = new JScrollPane(table);
scroll.setPreferredSize(new Dimension(width, height));
JToolBar main = new JToolBar();
main.setFloatable(true);
main.setLayout(new BorderLayout());
main.add(scroll, BorderLayout.CENTER);
panel = new JPanel(new BorderLayout());
panel.add(main);
panel.setBorder(BorderFactory.createEtchedBorder());
}
public void reset() {
chrono = System.nanoTime();
peak = 0;
}
public JPanel getPanel() {
return panel;
}
public void show(String title) {
JFrame frame = new JFrame(title);
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}
@Override
public void add(Message message) {
String msg = message.getMessage();
String iteration = "";
if (msg.startsWith("@")) {
String parts[] = msg.split(" ");
if (parts.length >= 1)
iteration = parts[0];
msg = msg.substring(parts[0].length(), msg.length()).trim();
}
String time = NumFormat.seconds(System.nanoTime()-chrono);
peak = Math.max(peak, SystemUsage.getHeapUsed());
String mem = NumFormat.bytes(peak);
String[] row = new String[] {time, mem, iteration, msg};
table.append(row);
}
@Override
public void clear() {
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.setRowCount(0);
}
@Override
public String getName() {
return "running";
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/monitor/TableMonitor.java b/DeconvolutionLab2/src/deconvolutionlab/monitor/TableMonitor.java
index 750716e..07eb775 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/monitor/TableMonitor.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/monitor/TableMonitor.java
@@ -1,150 +1,149 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.monitor;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.BorderFactory;
import javax.swing.JButton;
-import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
-import bilib.component.CustomizedColumn;
-import bilib.component.CustomizedTable;
+import bilib.table.CustomizedColumn;
+import bilib.table.CustomizedTable;
public class TableMonitor implements AbstractMonitor, ActionListener {
private CustomizedTable table;
private JButton bnClear = new JButton("Clear");
private HashMap<Long, Color> colors = new HashMap<Long, Color>();
private JPanel panel;
private String name;
public TableMonitor(String name, int width, int height) {
this.name = name;
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("#", Long.class, 60, false));
columns.add(new CustomizedColumn("Time", String.class, 100, false));
columns.add(new CustomizedColumn("Memory", String.class, 100, false));
columns.add(new CustomizedColumn("Message", String.class, Math.max(60, width - 3 * 60), false));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(0).setMinWidth(60);
table.getColumnModel().getColumn(0).setMaxWidth(60);
table.getColumnModel().getColumn(1).setMaxWidth(100);
table.getColumnModel().getColumn(1).setMinWidth(100);
table.getColumnModel().getColumn(2).setMaxWidth(100);
table.getColumnModel().getColumn(2).setMinWidth(100);
RowRenderer renderer = new RowRenderer();
for (int i = 0; i < 4; i++)
table.getColumnModel().getColumn(i).setCellRenderer(renderer);
JScrollPane scroll = new JScrollPane(table);
scroll.setPreferredSize(new Dimension(width, height));
JPanel main = new JPanel(new BorderLayout());
main.add(scroll, BorderLayout.CENTER);
bnClear.addActionListener(this);
panel = new JPanel(new BorderLayout());
panel.add(main);
panel.setBorder(BorderFactory.createEtchedBorder());
}
public JPanel getPanel() {
return panel;
}
@Override
public void clear() {
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.setRowCount(0);
}
@Override
public void add(Message message) {
String msg[] = message.formatArray();
int n = msg.length;
Object[] row = new Object[n + 1];
row[0] = message.getID();
for (int i = 0; i < n; i++)
row[i + 1] = msg[i];
table.append(row);
Verbose level = message.getLevel();
Color c = new Color(0, 0, 0);
if (level == Verbose.Prolix)
c = new Color(255, 0, 0);
else if (level == Verbose.Quiet)
c = new Color(200, 200, 0);
colors.put(new Long(message.getID()), c);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnClear) {
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.setRowCount(0);
}
}
@Override
public String getName() {
return name;
}
class RowRenderer extends DefaultTableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
DefaultTableModel model = (DefaultTableModel) table.getModel();
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (row >= 0) {
Long id = (Long) model.getValueAt(row, 0);
Color color = colors.get(id);
c.setForeground(color);
}
return c;
}
}
}
diff --git a/DeconvolutionLab2/src/bilib/component/ImageLoader.java b/DeconvolutionLab2/src/deconvolutionlab/splash/ImageLoader.java
similarity index 97%
rename from DeconvolutionLab2/src/bilib/component/ImageLoader.java
rename to DeconvolutionLab2/src/deconvolutionlab/splash/ImageLoader.java
index c6a3cef..53f3827 100644
--- a/DeconvolutionLab2/src/bilib/component/ImageLoader.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/splash/ImageLoader.java
@@ -1,50 +1,50 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package bilib.component;
+package deconvolutionlab.splash;
import java.awt.Image;
import java.net.URL;
import javax.swing.ImageIcon;
public class ImageLoader {
public static Image get(String filename) {
URL url = ImageLoader.class.getResource(filename);
if (url != null) {
ImageIcon img = new ImageIcon(url, "") ;
return img.getImage();
}
return null;
}
}
diff --git a/DeconvolutionLab2/src/bilib/component/celegans.jpg b/DeconvolutionLab2/src/deconvolutionlab/splash/celegans.jpg
similarity index 100%
rename from DeconvolutionLab2/src/bilib/component/celegans.jpg
rename to DeconvolutionLab2/src/deconvolutionlab/splash/celegans.jpg
diff --git a/DeconvolutionLab2/src/deconvolutionlab/system/AbstractMeter.java b/DeconvolutionLab2/src/deconvolutionlab/system/AbstractMeter.java
index 57abb74..b783253 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/AbstractMeter.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/AbstractMeter.java
@@ -1,119 +1,119 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.system;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.util.HashMap;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
-import bilib.component.CustomizedTable;
+import bilib.table.CustomizedTable;
import deconvolutionlab.Constants;
public abstract class AbstractMeter extends JButton {
protected Color colorBackground = new Color(10, 10, 10, 30);
protected Color colorText = new Color(10, 10, 10);
protected Color colorHot = new Color(10, 10, 160, 30);
protected CustomizedTable table;
protected HashMap<String, Integer> features = new HashMap<String, Integer>();
protected boolean initialized = false;
protected String prefix = "\u25BA ";
protected boolean collapse = true;
public AbstractMeter() {
super("");
int w = (int)(Constants.widthGUI/3.2);
int h = 25;
setBorder(BorderFactory.createEtchedBorder());
setPreferredSize(new Dimension(w, h));
setMinimumSize(new Dimension(w, h));
table = new CustomizedTable(new String[] {"Tool", "Feature", "Value"}, false);
}
public boolean isExpanded() {
return !collapse;
}
public void collapse() {
collapse = true;
prefix = " \u25BA ";
}
public void expand() {
collapse = false;
prefix = " \u25BC ";
}
public JPanel getPanel(int width, int height) {
JPanel panel = new JPanel(new BorderLayout());
panel.add(table.getPane(width, height), BorderLayout.CENTER);
setDetail();
initialized = true;
return panel;
}
public abstract String getName();
public abstract void setDetail();
public void update() {
if (table == null)
return;
setDetail();
}
protected void add(int i, String row[]) {
if (initialized) {
int r = features.get(row[0]);
if (i>=0 && i<table.getRowCount())
table.setCell(r, 1, row[1]);
}
else {
table.append(row);
features.put(row[0], i);
}
}
protected String split(String name) {
String func = name.substring(3);
return func.replaceAll("(\\p{Ll})(\\p{Lu})", "$1 $2");
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/system/FFTMeter.java b/DeconvolutionLab2/src/deconvolutionlab/system/FFTMeter.java
index 0f00ac9..a057252 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/FFTMeter.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/FFTMeter.java
@@ -1,64 +1,59 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.system;
import java.awt.Graphics;
-import java.io.File;
-import java.lang.management.ClassLoadingMXBean;
-import java.lang.management.ManagementFactory;
-
-import bilib.tools.NumFormat;
import fft.FFT;
public class FFTMeter extends AbstractMeter {
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(colorText);
g.drawString(prefix + FFT.getFastestFFT().getLibraryName(), 10, 17);
}
@Override
public void update() {
repaint();
}
@Override
public String getName() {
return "FFT";
}
@Override
public void setDetail() {
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/fft/FFTPanel.java b/DeconvolutionLab2/src/fft/FFTPanel.java
index 9694991..377962d 100644
--- a/DeconvolutionLab2/src/fft/FFTPanel.java
+++ b/DeconvolutionLab2/src/fft/FFTPanel.java
@@ -1,86 +1,86 @@
package fft;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
-import bilib.component.CustomizedColumn;
-import bilib.component.CustomizedTable;
import bilib.component.HTMLPane;
+import bilib.table.CustomizedColumn;
+import bilib.table.CustomizedTable;
import bilib.tools.NumFormat;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import signal.Operations;
public class FFTPanel extends JPanel implements MouseListener {
private HTMLPane info;
private CustomizedTable table;
private ArrayList<AbstractFFTLibrary> libs;
public FFTPanel(int w, int h) {
super(new BorderLayout());
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 120, false));
columns.add(new CustomizedColumn("Installed", String.class, 120, false));
columns.add(new CustomizedColumn("Multithreadable", String.class, 120, false));
columns.add(new CustomizedColumn("Location", String.class, Constants.widthGUI, false));
table = new CustomizedTable(columns, true);
table.setRowSelectionAllowed(true);
table.addMouseListener(this);
libs = FFT.getRegisteredLibraries();
for (AbstractFFTLibrary lib : libs) {
String name = lib.getLibraryName();
String installed = lib.isInstalled() ? "Yes" : "No";
String multit = lib.isMultithreadable() ? "Yes" : "No";
String location = lib.getLocation();
table.append(new String[] { name, installed, multit, location });
}
info = new HTMLPane(w, h-100);
JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, table.getPane(w, 100), info.getPane());
split.setDividerLocation(0.5);
add(split, BorderLayout.CENTER);
table.setRowSelectionInterval(0, 0);
info.clear();
info.append("p", libs.get(0).getLicence());
}
@Override
public void mouseClicked(MouseEvent e) {
int i = table.getSelectedRow();
if (i<0)
return;
if (i>=libs.size())
return;
info.clear();
info.append("p", libs.get(i).getLicence());
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
}
diff --git a/DeconvolutionLab2/src/signal/SignalCollector.java b/DeconvolutionLab2/src/signal/SignalCollector.java
index e370fe5..f15ac42 100644
--- a/DeconvolutionLab2/src/signal/SignalCollector.java
+++ b/DeconvolutionLab2/src/signal/SignalCollector.java
@@ -1,157 +1,157 @@
package signal;
import java.util.ArrayList;
import javax.swing.JScrollPane;
-import bilib.component.CustomizedColumn;
-import bilib.component.CustomizedTable;
+import bilib.table.CustomizedColumn;
+import bilib.table.CustomizedTable;
import bilib.tools.NumFormat;
import deconvolutionlab.system.SystemUsage;
public class SignalCollector {
private static long bytesReal = 0;
private static int countReal = 0;
private static long bytesComplex = 0;
private static int countComplex = 0;
private static double chrono = 0;
private static CustomizedTable table;
private static double progress = 0;
private static int countPeakComplex = 0;
private static int countPeakReal = 0;
private static long bytesPeakComplex = 0;
private static long bytesPeakReal = 0;
private static ArrayList<Signal> signals;
protected final static int NOTIFICATION_RATE = 25;
static {
bytesReal = 0;
countReal = 0;
bytesComplex = 0;
countComplex = 0;
signals = new ArrayList<Signal>();
chrono = System.nanoTime();
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Time", String.class, 100, false));
columns.add(new CustomizedColumn("Name", String.class, 600, false));
columns.add(new CustomizedColumn("Dimension", String.class, 60, false));
columns.add(new CustomizedColumn("Count", String.class, 100, false));
columns.add(new CustomizedColumn("Total", String.class, 100, false));
columns.add(new CustomizedColumn("Memory", String.class, 100, false));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(4).setMaxWidth(100);
table.getColumnModel().getColumn(4).setMinWidth(100);
}
public static JScrollPane getPanel(int w, int h) {
return table.getPane(w, h);
}
public static String sumarize() {
String r = "Signals: " + NumFormat.bytes(bytesReal + bytesComplex);
return r;
}
public static void clear() {
for(Signal signal : signals) {
for (int z = 0; z < signal.nz; z++)
signal.data[z] = new float[1];
}
signals.clear();
table.removeRows();
}
public static double getProgress() {
return progress;
}
public static void setProgress(double p) {
progress = p;
}
public static void marker(String msg) {
String row[] = { "", msg, "", "", "", "" };
table.append(row);
}
public static void alloc(Signal signal) {
if (signal == null) {
marker("error in allocating");
return;
}
signals.add(signal);
addTable(signal, 1);
}
public static void free(Signal signal) {
if (signal == null) {
marker("error in freeing");
return;
}
for (int z = 0; z < signal.nz; z++)
signal.data[z] = new float[1];
signals.remove(signal);
addTable(signal, -1);
signal = null;
}
public static void addTable(Signal signal, int sign) {
boolean complex = signal instanceof ComplexSignal;
int nx = signal.nx;
int ny = signal.ny;
int nz = signal.nz;
long b = sign * (nx * ny * nz * 4 * (complex ? 2 : 1));
if (complex) {
bytesComplex += b;
countComplex += sign;
}
else {
bytesReal += b;
countReal += sign;
}
bytesPeakComplex = Math.max(bytesPeakComplex, bytesComplex);
bytesPeakReal = Math.max(bytesPeakReal, bytesReal);
countPeakComplex = Math.max(countPeakComplex, countComplex);
countPeakReal = Math.max(countPeakReal, countReal);
String m = NumFormat.bytes(SystemUsage.getHeapUsed());
String t = NumFormat.time(System.nanoTime() - chrono);
String dim = "" + nx + "x" + ny + "x" + nz;
String c = "" + (countReal + countComplex);
String a = NumFormat.bytes(bytesReal + bytesComplex);
String row[] = { t, (sign > 0 ? "+" : "-") + signal.name, dim, c, a, m };
table.append(row);
}
public static int getCountSignals() {
return countComplex + countReal;
}
public static long getBytesSignals() {
return bytesComplex + bytesReal;
}
public static long getBytesPeakSignals() {
return bytesPeakComplex + bytesPeakReal;
}
public static int getCountPeakSignals() {
return countPeakComplex + countPeakReal;
}
public static void resetSignals() {
countPeakComplex = 0;
countPeakReal = 0;
bytesPeakComplex = 0;
bytesPeakReal = 0;
countComplex = 0;
countReal = 0;
bytesComplex = 0;
bytesReal = 0;
}
}

Event Timeline