diff --git a/Images/EqFit1.png b/Images/EqFit1.png deleted file mode 100644 index 570dd62..0000000 Binary files a/Images/EqFit1.png and /dev/null differ diff --git a/Images/Fit2-Equations.PNG b/Images/Fit2-Equations.PNG deleted file mode 100644 index ae128f7..0000000 Binary files a/Images/Fit2-Equations.PNG and /dev/null differ diff --git a/Images/Fit2.PNG b/Images/Fit2.PNG deleted file mode 100644 index effccdc..0000000 Binary files a/Images/Fit2.PNG and /dev/null differ diff --git a/Images/MATLAB-logo.png b/Images/MATLAB-logo.png deleted file mode 100644 index 214aa86..0000000 Binary files a/Images/MATLAB-logo.png and /dev/null differ diff --git a/Images/logoFCUL.jpg b/Images/logoFCUL.jpg deleted file mode 100644 index dc3d42f..0000000 Binary files a/Images/logoFCUL.jpg and /dev/null differ diff --git a/Interface/FitModel/AddFileIcon.png b/Interface/AddFileIcon.png similarity index 100% rename from Interface/FitModel/AddFileIcon.png rename to Interface/AddFileIcon.png diff --git a/Interface/FitModel/BED.m b/Interface/BED.m similarity index 100% rename from Interface/FitModel/BED.m rename to Interface/BED.m diff --git a/Interface/FitModel/ClearPlotIcon.jpg b/Interface/ClearPlotIcon.jpg similarity index 100% rename from Interface/FitModel/ClearPlotIcon.jpg rename to Interface/ClearPlotIcon.jpg diff --git a/Interface/FitModel/Data1.m b/Interface/Data1.m similarity index 100% rename from Interface/FitModel/Data1.m rename to Interface/Data1.m diff --git a/Interface/FitModel/Data2.m b/Interface/Data2.m similarity index 100% rename from Interface/FitModel/Data2.m rename to Interface/Data2.m diff --git a/Interface/FitModel/Data3.m b/Interface/Data3.m similarity index 100% rename from Interface/FitModel/Data3.m rename to Interface/Data3.m diff --git a/Interface/FitModel/Data4.m b/Interface/Data4.m similarity index 100% rename from Interface/FitModel/Data4.m rename to Interface/Data4.m diff --git a/Interface/FitModel/Data5.m b/Interface/Data5.m similarity index 100% rename from Interface/FitModel/Data5.m rename to Interface/Data5.m diff --git a/Interface/FitModel/DeleteFileIcon.png b/Interface/DeleteFileIcon.png similarity index 100% rename from Interface/FitModel/DeleteFileIcon.png rename to Interface/DeleteFileIcon.png diff --git a/Interface/FitModel/RADIANCE-Guide.pdf b/Interface/RADIANCE-Guide.pdf similarity index 100% rename from Interface/FitModel/RADIANCE-Guide.pdf rename to Interface/RADIANCE-Guide.pdf diff --git a/Interface/FitModel/RoundStr2Double.m b/Interface/RoundStr2Double.m similarity index 100% rename from Interface/FitModel/RoundStr2Double.m rename to Interface/RoundStr2Double.m diff --git a/Interface/FitModel/SavePlotIcon.png b/Interface/SavePlotIcon.png similarity index 100% rename from Interface/FitModel/SavePlotIcon.png rename to Interface/SavePlotIcon.png diff --git a/Interface/FitModel/bedfunction.m b/Interface/bedfunction.m similarity index 100% rename from Interface/FitModel/bedfunction.m rename to Interface/bedfunction.m diff --git a/Interface/FitModel/calculate_n.m b/Interface/calculate_n.m similarity index 100% rename from Interface/FitModel/calculate_n.m rename to Interface/calculate_n.m diff --git a/Interface/FitModel/chi2_residuals.m b/Interface/chi2_residuals.m similarity index 100% rename from Interface/FitModel/chi2_residuals.m rename to Interface/chi2_residuals.m diff --git a/Interface/FitModel/ciencias_ul_azul_h_s-ass.png b/Interface/ciencias_ul_azul_h_s-ass.png similarity index 100% rename from Interface/FitModel/ciencias_ul_azul_h_s-ass.png rename to Interface/ciencias_ul_azul_h_s-ass.png diff --git a/Interface/dev/@olduitable/javaClasses.jar b/Interface/dev/@olduitable/javaClasses.jar deleted file mode 100644 index 03c1763..0000000 Binary files a/Interface/dev/@olduitable/javaClasses.jar and /dev/null differ diff --git a/Interface/dev/@olduitable/javaCodes/CellEditor.java b/Interface/dev/@olduitable/javaCodes/CellEditor.java deleted file mode 100644 index 20a1f95..0000000 --- a/Interface/dev/@olduitable/javaCodes/CellEditor.java +++ /dev/null @@ -1,27 +0,0 @@ -package asd.fgh.olduitable; -import java.awt.*; -import javax.swing.*; -import javax.swing.border.LineBorder; - -public class CellEditor extends DefaultCellEditor { - - public CellEditor(String columnalign) { - super(new JTextField()); - JTextField textField = (JTextField) getComponent(); - if (columnalign.equals("left")) - textField.setHorizontalAlignment(JTextField.LEFT); - else if (columnalign.equals("center")) - textField.setHorizontalAlignment(JTextField.CENTER); - else - textField.setHorizontalAlignment(JTextField.RIGHT); - //textField.setBorder(null); - textField.setBorder(new LineBorder(Color.black)); - } - - @Override - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - JTextField textField = (JTextField) super.getTableCellEditorComponent(table, value, isSelected, row, column); - textField.selectAll(); - return textField; - } -} diff --git a/Interface/dev/@olduitable/javaCodes/CellRenderer.java b/Interface/dev/@olduitable/javaCodes/CellRenderer.java deleted file mode 100644 index 95ea294..0000000 --- a/Interface/dev/@olduitable/javaCodes/CellRenderer.java +++ /dev/null @@ -1,231 +0,0 @@ -package asd.fgh.olduitable; -import java.awt.*; -import java.util.*; -import javax.swing.*; -import javax.swing.border.*; -import javax.swing.table.*; - -public class CellRenderer extends DefaultTableCellRenderer implements TableCellRenderer { - - private Color selbgcolor = new Color(236, 243, 255); - private Color selfgcolor = new Color(0, 0, 0); - private Color selbordercolor = new Color(66, 133, 244); - - private Color[] rowcolor = {Color.white, new Color(240,240,240)}; - private Color[] colcolor = {Color.white, new Color(240,240,240)}; - private boolean rowstriping = false, colstriping = false; - private double id_rowcolor, id_colcolor; - - private Color cellcolor, cellfg; - private Map cellBgInfo = new HashMap<>(); - private Map cellFgInfo = new HashMap<>(); - - private String colformat = ""; - - public CellRenderer() { - setHorizontalAlignment(CENTER); - } - - public CellRenderer(boolean row_striping, boolean col_striping, float[][] row_color, float[][] col_color, Color selbg_color, Color selborder_color, Color selfg_color) { - rowstriping = row_striping; - colstriping = col_striping; - rowcolor = triplet2color(row_color); - colcolor = triplet2color(col_color); - selbgcolor = selbg_color; - selbordercolor = selborder_color; - selfgcolor = selfg_color; - } - - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - - JComponent cell = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - JLabel text = (JLabel) cell; - - // set the format - if (value != null && !value.toString().isEmpty() && !colformat.isEmpty()) { - try { - text.setText(String.format(colformat, value)); - } - catch (java.util.IllegalFormatConversionException e) { - try { - text.setText(String.format(colformat, Double.valueOf(value.toString()))); - } - catch (Exception e2) { //java.lang.NumberFormatException - } - } - catch (Exception e3) { // incompatible format - //System.err.println("Exception in row = " + (row + 1) + ", column = " + (column + 1)); // matlab indices - //throw e; - } - } - //else if (value instanceof Double) - //text.setText(String.format("%g", value)); // "%g" doesn't work like in C or Matlab - - // set the background - cell.setBackground(table.getBackground()); // default colors - cell.setForeground(table.getForeground()); - - if (rowstriping) { // rowstriping has priority - id_rowcolor = (double)row - rowcolor.length * Math.floor(row / rowcolor.length); - cell.setBackground(rowcolor[(int)id_rowcolor]); - } - else if (colstriping) { - id_colcolor = (double)column - colcolor.length * Math.floor(column / colcolor.length); - cell.setBackground(colcolor[(int)id_colcolor]); - } - - // set the background and foreground properties for a specific cell through the "setCellBg" and "setCellFg" methods (idea taken from Yair Altman's "ColoredFieldCellRenderer" class) - int colored_row = -1, colored_col = -1; - cellcolor = cellBgInfo.get(new Vector(Arrays.asList(row,column))); - if (cellcolor != null) { - cell.setBackground(cellcolor); - colored_row = row; - colored_col = column; - } - - cellfg = cellFgInfo.get(new Vector(Arrays.asList(row,column))); - if (cellfg != null) { - cell.setForeground(cellfg); - colored_row = row; - colored_col = column; - } - - - // highlight the selection as in matlab's old uitable (with diferent border and background color, however) - if (isSelected) { - // if table is using 'rowstriping' or 'colstriping', selection only will appear with a outer border - if (!rowstriping && !colstriping && colored_row == -1 && colored_col == -1) { - if (row != table.getSelectionModel().getLeadSelectionIndex() || column != table.getColumnModel().getSelectionModel().getLeadSelectionIndex()) { // cell selected isn't the lead (lead selection will be white) - cell.setBackground(selbgcolor); - cell.setForeground(selfgcolor); - } - } - /* - else - cell.setBackground(cell.getBackground().darker());*/ - - // get the current selection - int r0 = table.getSelectedRow(); // min row index from selection - int rf = r0 + table.getSelectedRowCount() - 1; // max row index - int c0 = table.getSelectedColumn(); // min col index - int cf = c0 + table.getSelectedColumnCount() - 1; // max col index - - this.setCellBorders(cell, selbordercolor, row, column, r0, rf, c0, cf); - } - - return cell; - } - - public void setSelectionBgColor(Color color) { - selbgcolor = color; - } - - public void setSelectionFgColor(Color color) { - selfgcolor = color; - } - - public void setSelectionBorderColor(Color color) { - selbordercolor = color; - } - - public void setColumnFormat(String value) { - colformat = value; - } - - public void setRowStriping(boolean value) { - rowstriping = value; - } - - public void setColumnStriping(boolean value) { - colstriping = value; - } - - public void setRowColor(float[][] colors) { - rowstriping = true; - rowcolor = triplet2color(colors); - } - - public void setColumnColor(float[][] colors) { - colstriping = true; - colcolor = triplet2color(colors); - } - - public void setHorizontalAlignment(String align) { - if (align.equalsIgnoreCase("left")) - setHorizontalAlignment(LEFT); - else if (align.equalsIgnoreCase("center")) - setHorizontalAlignment(CENTER); - else - setHorizontalAlignment(RIGHT); - } - - public void setCellBg(Color color, int row, int column) { - cellBgInfo.put(new Vector(Arrays.asList(row, column)), color); - } - - public void setCellFg(Color color, int row, int column) { - cellFgInfo.put(new Vector(Arrays.asList(row, column)), color); - } - - public void resetCellBg() { - cellBgInfo.clear(); - } - - public void resetCellFg() { - cellBgInfo.clear(); - } - - private Color[] triplet2color(float[][] colors) { - Color[] colorArray = new Color[colors.length]; - for(int i = 0; i < colors.length; i++){ - colorArray[i] = new Color(colors[i][0], colors[i][1], colors[i][2]); - } - return colorArray; - } - - // this function is static only to recycle code and use it in the "CheckBoxRenderer" class - public static void setCellBorders(JComponent cell, Color borderColor, int row, int column, int r0, int rf, int c0, int cf) { - if (r0 == rf && c0 == cf) // one cell selection - cell.setBorder(new LineBorder(borderColor)); - else if (r0 < rf && c0 == cf) { // vertical selection - if (row == r0) - cell.setBorder(new CompoundBorder(new MatteBorder(1, 1, 0, 1, borderColor),new EmptyBorder(0, 0, 1, 0))); - else if (row < rf) - cell.setBorder(new CompoundBorder(new MatteBorder(0, 1, 0, 1, borderColor),new EmptyBorder(1,0,1,0))); - else // if (row == rf) - cell.setBorder(new CompoundBorder(new MatteBorder(0, 1, 1, 1, borderColor),new EmptyBorder(1, 0,0,0))); - } - else if (r0 == rf && c0 < cf) { // horizontal selection - if (column == c0) - cell.setBorder(new CompoundBorder(new MatteBorder(1, 1, 1, 0, borderColor),new EmptyBorder(0, 0, 0, 1))); - else if (column < cf) - cell.setBorder(new CompoundBorder(new MatteBorder(1, 0, 1, 0, borderColor),new EmptyBorder(0, 1, 0, 1))); - else // if (column == cf) - cell.setBorder(new CompoundBorder(new MatteBorder(1, 0, 1, 1, borderColor),new EmptyBorder(0, 1, 0, 0))); - } - else if (r0 < rf && c0 < cf) { // 2D selection - if (column == c0) { - if (row == r0) - cell.setBorder(new CompoundBorder(new MatteBorder(1, 1, 0, 0, borderColor),new EmptyBorder(0, 0, 1, 1))); - else if (row < rf) - cell.setBorder(new CompoundBorder(new MatteBorder(0, 1, 0, 0, borderColor),new EmptyBorder(1, 0, 1, 1))); - else // if (row == rf) - cell.setBorder(new CompoundBorder(new MatteBorder(0, 1, 1, 0, borderColor),new EmptyBorder(1, 0, 0, 1))); - } - else if (column < cf) { - if (row == r0) - cell.setBorder(new CompoundBorder(new MatteBorder(1, 0, 0, 0, borderColor),new EmptyBorder(0, 1, 1, 1))); - else if (row == rf) - cell.setBorder(new CompoundBorder(new MatteBorder(0, 0, 1, 0, borderColor),new EmptyBorder(1, 1, 0, 1))); - } - else /* if (column == cf)*/ { - if (row == r0) - cell.setBorder(new CompoundBorder(new MatteBorder(1, 0, 0, 1, borderColor),new EmptyBorder(0, 1, 1, 0))); - else if (row < rf) - cell.setBorder(new CompoundBorder(new MatteBorder(0, 0, 0, 1, borderColor),new EmptyBorder(1, 1, 1, 0))); - else // if (row == rf) - cell.setBorder(new CompoundBorder(new MatteBorder(0, 0, 1, 1, borderColor),new EmptyBorder(1, 1, 0, 0))); - } - } - } -} \ No newline at end of file diff --git a/Interface/dev/@olduitable/javaCodes/CheckBoxRenderer.java b/Interface/dev/@olduitable/javaCodes/CheckBoxRenderer.java deleted file mode 100644 index b38b668..0000000 --- a/Interface/dev/@olduitable/javaCodes/CheckBoxRenderer.java +++ /dev/null @@ -1,132 +0,0 @@ -package asd.fgh.olduitable; -import java.awt.*; -import java.util.*; -import javax.swing.*; -import javax.swing.border.*; -import javax.swing.table.*; - -public class CheckBoxRenderer extends JCheckBox implements TableCellRenderer { - - private Color selbgcolor = new Color(236, 243, 255); - private Color selbordercolor = new Color(66, 133, 244); - - private Color[] rowcolor = {Color.white, new Color(240,240,240)}; - private Color[] colcolor = {Color.white, new Color(240,240,240)}; - private boolean rowstriping = false, colstriping = false; - private double id_rowcolor, id_colcolor; - - private Color cellcolor; - private Map cellBgInfo = new HashMap<>(); - - public CheckBoxRenderer() { - setHorizontalAlignment(CENTER); - setBorderPainted(true); - } - - public CheckBoxRenderer(boolean row_striping, boolean col_striping, float[][] row_color, float[][] col_color, Color selbg_color, Color selborder_color) { - setHorizontalAlignment(CENTER); - setBorderPainted(true); - rowstriping = row_striping; - colstriping = col_striping; - rowcolor = triplet2color(row_color); - colcolor = triplet2color(col_color); - selbgcolor = selbg_color; - selbordercolor = selborder_color; - } - - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - - // set the background - setBackground(table.getBackground()); // default color - - if (rowstriping) { // rowstriping has priority - id_rowcolor = (double)row - rowcolor.length * Math.floor(row / rowcolor.length); - setBackground(rowcolor[(int)id_rowcolor]); - } - else if (colstriping) { - id_colcolor = (double)column - colcolor.length * Math.floor(column / colcolor.length); - setBackground(colcolor[(int)id_colcolor]); - } - - // set the background property for a specific cell through the "setCellBg" method (idea taken from Yair Altman's "ColoredFieldCellRenderer" class) - int colored_row = -1, colored_col = -1; - cellcolor = cellBgInfo.get(new Vector(Arrays.asList(row, column))); - if (cellcolor != null) { - setBackground(cellcolor); - colored_row = row; - colored_col = column; - } - - setBorder(new EmptyBorder(1, 1, 1, 1)); - - // highlight the selection as in matlab old uitable (with diferent border and background color, however) - if (isSelected) { - // if table is using 'rowstriping' or 'colstriping' selection only will appear with a outer border - if (!rowstriping && !colstriping && colored_row == -1 && colored_col == -1) { - if (row != table.getSelectionModel().getLeadSelectionIndex() || column != table.getColumnModel().getSelectionModel().getLeadSelectionIndex()) // cell selected isn't the lead (lead selection will be white) - setBackground(selbgcolor); - } - /* - else - setBackground(getBackground().darker());*/ - - // get the current selection - int r0 = table.getSelectedRow(); // min row index from selection - int rf = r0 + table.getSelectedRowCount() - 1; // max row index - int c0 = table.getSelectedColumn(); // min col index - int cf = c0 + table.getSelectedColumnCount() - 1; // max col index - - CellRenderer.setCellBorders(this, selbordercolor, row, column, r0, rf, c0, cf); - if (r0 == rf && c0 == cf) setBorder(new EmptyBorder(1, 1, 1, 1)); - } - - // define the status of the check box (if the assigned value is not a boolean, show an unchecked box) - if (value == null) value = false; - boolean flag = new Boolean(value.toString()); - setSelected(flag); - - return this; - } - - public void setSelectionBgColor(Color color) { - selbgcolor = color; - } - - public void setSelectionBorderColor(Color color) { - selbordercolor = color; - } - - public void setRowStriping(boolean value) { - rowstriping = value; - } - - public void setColumnStriping(boolean value) { - colstriping = value; - } - - public void setRowColor(float[][] colors) { - rowstriping = true; - rowcolor = triplet2color(colors); - } - - public void setColumnColor(float[][] colors) { - colstriping = true; - colcolor = triplet2color(colors); - } - - public void setCellBg(Color color, int row, int column) { - cellBgInfo.put(new Vector(Arrays.asList(row, column)), color); - } - - public void resetCellBg() { - cellBgInfo.clear(); - } - - private Color[] triplet2color(float[][] colors) { - Color[] colorArray = new Color[colors.length]; - for(int i = 0; i < colors.length; i++){ - colorArray[i] = new Color(colors[i][0], colors[i][1], colors[i][2]); - } - return colorArray; - } -} \ No newline at end of file diff --git a/Interface/dev/@olduitable/javaCodes/ColHeaderRenderer.java b/Interface/dev/@olduitable/javaCodes/ColHeaderRenderer.java deleted file mode 100644 index ea594a1..0000000 --- a/Interface/dev/@olduitable/javaCodes/ColHeaderRenderer.java +++ /dev/null @@ -1,99 +0,0 @@ -package asd.fgh.olduitable; -import java.awt.*; -import java.util.List; -import javax.swing.*; -import javax.swing.border.*; -import javax.swing.table.*; - -public class ColHeaderRenderer extends JLabel implements TableCellRenderer { - - private Color bgcolor = new Color(240, 240, 240); - private Color fgcolor = new Color(0, 0, 0); - private Color selbgcolor = new Color(204, 204, 204); - private Color selfgcolor = new Color(0, 0, 0); - private Color gridcolor = new Color(0.75F, 0.75F, 0.75F); - //private Color topbordercolor = new Color(66, 133, 244); - - private JLabel header = new JLabel(); - private JLabel arrow = new JLabel(); - private int left, bottom; // these are the borders' widths to try to center the texts of the previous jlabels - - public ColHeaderRenderer() { - setOpaque(true); - setLayout(new BorderLayout()); - arrow.setFont(new Font(arrow.getFont().getName(),0,9)); - header.setHorizontalAlignment(JLabel.CENTER); - add(header, BorderLayout.CENTER); - add(arrow, BorderLayout.EAST); - } - - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - - setBorder(new MatteBorder(0, 0, 1, 1, gridcolor)); - - // highlight column header according to the table selection - if (table.isColumnSelected(column)) { - setBackground(selbgcolor); - header.setForeground(selfgcolor); - //setBorder(new CompoundBorder(new MatteBorder(1, 0, 0, 0, topbordercolor),new MatteBorder(0, 0, 1, 1, new Color(0.75F, 0.75F, 0.75F)))); - } else { - setBackground(bgcolor); - header.setForeground(fgcolor); - //setBorder(new MatteBorder(1, 0, 1, 1, new Color(0.75F, 0.75F, 0.75F))); - } - - if (value != null) - header.setText(String.valueOf(value)); - else - header.setText(""); - - // put an arrow indicating if the column is sorted - bottom = 0; - left = 4; - arrow.setText(""); - List keys = table.getRowSorter().getSortKeys(); - - if (!keys.isEmpty() && column == keys.get(0).getColumn()) { - left = 12; - arrow.setForeground(selbgcolor.darker()); - if (keys.get(0).getSortOrder() == SortOrder.ASCENDING) { - bottom = 2; - arrow.setText("▲"); - } - else - arrow.setText("▼"); - } - - arrow.setBorder(new EmptyBorder(0, 0, bottom, 4)); - header.setBorder(new EmptyBorder(0, left, 0, 0)); - - return this; - } - - public void setBackgroundColor(Color bg_color) { - bgcolor = bg_color; - } - - public void setForegroundColor(Color fg_color) { - fgcolor = fg_color; - } - - public void setGridColor(Color grid_color) { - gridcolor = grid_color; - } - - public void setSelectionBgcolor(Color sel_bgcolor) { - selbgcolor = sel_bgcolor; - } - - public void setSelectionFgcolor(Color sel_fgcolor) { - selfgcolor = sel_fgcolor; - } - - /* - public void setSelectionTopBorderColor(Color sel_bordercolor) { - topbordercolor = sel_bordercolor; - } - */ -} diff --git a/Interface/dev/@olduitable/javaCodes/ColorCellEditor.java b/Interface/dev/@olduitable/javaCodes/ColorCellEditor.java deleted file mode 100644 index a9c1945..0000000 --- a/Interface/dev/@olduitable/javaCodes/ColorCellEditor.java +++ /dev/null @@ -1,35 +0,0 @@ -package asd.fgh.olduitable; -import java.awt.*; -import javax.swing.*; -import javax.swing.table.TableCellEditor; - -public class ColorCellEditor extends AbstractCellEditor implements TableCellEditor { - - private ColorComboBox button; - - public ColorCellEditor(ColorComboBox specialButton) { - button = specialButton; - } - - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - - try { - button.getJLabel().setBackground((Color)table.getValueAt(row, column)); - } - catch (Exception e) { - button.getJLabel().setBackground(Color.white); - } - - return button; - } - - public Object getCellEditorValue() { - return button.getJLabel().getBackground(); - } - - public boolean stopCellEditing() { - button.setSelected(false); - super.cancelCellEditing(); // the editor's behavior was implemented in Matlab to increase the performace in large tables (in which 'stopCellEditng' and 'getCellEditorValue' functions may last seconds!!) - return super.stopCellEditing(); - } -} diff --git a/Interface/dev/@olduitable/javaCodes/ColorCellRenderer.java b/Interface/dev/@olduitable/javaCodes/ColorCellRenderer.java deleted file mode 100644 index bdcf649..0000000 --- a/Interface/dev/@olduitable/javaCodes/ColorCellRenderer.java +++ /dev/null @@ -1,60 +0,0 @@ -package asd.fgh.olduitable; -import java.awt.*; -import java.lang.reflect.Field; -import javax.swing.*; -import javax.swing.border.*; -import javax.swing.table.*; - -public class ColorCellRenderer extends DefaultTableCellRenderer implements TableCellRenderer { - - private Color jcolor; - private CompoundBorder border = new CompoundBorder(new LineBorder(Color.white, 3), new LineBorder(new Color(51, 51, 51))); - - public ColorCellRenderer() {} - - public Component getTableCellRendererComponent(JTable table, Object color, boolean isSelected, boolean hasFocus, int row, int column) { - - JComponent cell = (JComponent) super.getTableCellRendererComponent(table, color, isSelected, hasFocus, row, column); - - try { - if (color == null) - jcolor = Color.white; - else if (color instanceof Color) - jcolor = (Color) color; - else /*if (color instanceof String)*/ { - try { - String colorName = String.valueOf(color); - if (colorName.equalsIgnoreCase("r")) - colorName = "red"; - else if (colorName.equalsIgnoreCase("g")) - colorName = "green"; - else if (colorName.equalsIgnoreCase("b")) - colorName = "blue"; - else if (colorName.equalsIgnoreCase("y")) - colorName = "yellow"; - else if (colorName.equalsIgnoreCase("m")) - colorName = "magenta"; - else if (colorName.equalsIgnoreCase("c")) - colorName = "cyan"; - else if (colorName.equalsIgnoreCase("k")) - colorName = "black"; - Field field = Color.class.getField(colorName); - jcolor = (Color) field.get(null); - table.setValueAt(jcolor, row, column); - } - catch (Exception e) { - jcolor = Color.white; - } - } - } - catch (Exception e2) { - jcolor = Color.white; - } - - setText(""); - cell.setBackground(jcolor); - cell.setBorder(border); - - return cell; - } -} \ No newline at end of file diff --git a/Interface/dev/@olduitable/javaCodes/ColorComboBox.java b/Interface/dev/@olduitable/javaCodes/ColorComboBox.java deleted file mode 100644 index ef5b7a0..0000000 --- a/Interface/dev/@olduitable/javaCodes/ColorComboBox.java +++ /dev/null @@ -1,114 +0,0 @@ -package asd.fgh.olduitable; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.border.*; -import javax.swing.event.*; -import javax.swing.BorderFactory.*; - -public class ColorComboBox extends DropDownButton { - - private JPopupMenu popup; - private Component[] colors; - //private Color pickedColor; - private int storedColor = 55; // by default, the last color in the pallete (white) - private int targetedItem = -1; // current targeted color - private CompoundBorder exitColor = new CompoundBorder(new LineBorder(new Color(240,240,240),3), new LineBorder(Color.black)); - private CompoundBorder overColor = new CompoundBorder(new CompoundBorder(new LineBorder(new Color(0,114,189)),new LineBorder(new Color(145,201,247),2)), new LineBorder(Color.black)); - - public ColorComboBox() { - super(); - - getJLabel().setBorder(new CompoundBorder(new LineBorder(Color.white,2),new LineBorder(new Color(51, 51, 51)))); - - getArrowButton().addMouseWheelListener(new MouseWheelListener() { - public void mouseWheelMoved(MouseWheelEvent e) { - setSelected(false); - } - }); - - getArrowButton().addKeyListener(new KeyListener() { - public void keyPressed(KeyEvent e) { - if (popup.isVisible() && targetedItem > -1) - ((JMenuItem)popup.getComponent(targetedItem)).setBorder(exitColor); - setSelected(false); - } - public void keyTyped(KeyEvent e) {} - public void keyReleased(KeyEvent e) {} - }); - - } - - public void highlightSavedColor() { - if (storedColor != -1) ((JMenuItem)colors[storedColor]).setBorder(exitColor); - storedColor = -1; - - for(int i = 0; i < colors.length - 2; i++) { - if (getJLabel().getBackground().equals(colors[i].getBackground())) { - ((JMenuItem)colors[i]).setBorder(overColor); - storedColor = i; - break; - } - } - } - - @Override - public void setPopupMenu(final JPopupMenu popupmenu) { - popup = popupmenu; - colors = popup.getComponents(); - - MouseListener listener = new MouseListener() { - public void mousePressed(MouseEvent evt) { - JMenuItem colorsh = (JMenuItem)evt.getSource(); - getJLabel().setBackground(colorsh.getBackground()); - popup.setVisible(false); - setSelected(false); - colorsh.setBorder(exitColor); - //pickedColor = colorsh.getBackground(); - } - - public void mouseEntered(MouseEvent evt) { - JMenuItem colorsh = (JMenuItem)evt.getSource(); - colorsh.setBorder(overColor); - targetedItem = popup.getComponentIndex(colorsh); - } - - public void mouseExited(MouseEvent evt) { - JMenuItem colorsh = (JMenuItem)evt.getSource(); - if (storedColor == -1 || !colorsh.equals(colors[storedColor])) - colorsh.setBorder(exitColor); - } - - public void mouseReleased(MouseEvent evt) { - ((JMenuItem)evt.getSource()).setBorder(exitColor); - } - - public void mouseClicked(MouseEvent evt) {} - }; - - MouseWheelListener wheellistener = new MouseWheelListener() { - public void mouseWheelMoved(MouseWheelEvent e) { - ((JMenuItem)e.getSource()).setBorder(exitColor); - setSelected(false); - } - }; - - for(int i = 0; i < colors.length - 2; i++) { - colors[i].setEnabled(false); - colors[i].addMouseListener(listener); - colors[i].addMouseWheelListener(wheellistener); - } - } - - @Override - public void showPopup() { - try { - highlightSavedColor(); - popup.show(this, getWidth() - popup.getPreferredSize().width, getHeight()); - setSelected(true); - getArrowButton().requestFocus(); - } - catch (Exception e) { // IllegalComponentStateException - } - } -} \ No newline at end of file diff --git a/Interface/dev/@olduitable/javaCodes/ColumnHeader.java b/Interface/dev/@olduitable/javaCodes/ColumnHeader.java deleted file mode 100644 index f08422c..0000000 --- a/Interface/dev/@olduitable/javaCodes/ColumnHeader.java +++ /dev/null @@ -1,70 +0,0 @@ -package asd.fgh.olduitable; -import java.awt.Component; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.table.JTableHeader; - -public class ColumnHeader extends JTableHeader { - - private int startdrag = -1; // first column selected (through the column header) that could the beginning of the drag with the mouse - private String[] columnToolTips; - private int currentIndex = -1; - - public ColumnHeader(final JTable table) { - super(table.getColumnModel()); - - // initial adjustements - setDefaultRenderer(new ColHeaderRenderer()); - setReorderingAllowed(false); - - // select the columns if the headers are right-clicked - addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - int col = columnAtPoint(e.getPoint()); - if (e.isMetaDown() && table.isEnabled() && col > -1 && getResizingColumn() == null) { - startdrag = col; - table.setColumnSelectionInterval(col,col); - table.setRowSelectionInterval(table.getRowCount() - 1,0); - } - } - }); - - addMouseMotionListener(new MouseMotionListener() { - public void mouseDragged(MouseEvent e) { - if (e.isMetaDown() && table.isEnabled() && startdrag > -1) { - int col = columnAtPoint(e.getPoint()); - if (col > -1 && getResizingColumn() == null) { - table.setColumnSelectionInterval(startdrag,col); - table.scrollRectToVisible(table.getCellRect(0,col,true)); - } - } - } - - // show a custom tooltip for column - public void mouseMoved(MouseEvent e) { - int colIndex = table.columnAtPoint(e.getPoint()); - if (columnToolTips != null) { - if (colIndex > - 1 && colIndex != currentIndex) { - currentIndex = colIndex; - if (!columnToolTips[colIndex].isEmpty()) - setToolTipText(columnToolTips[colIndex]); - else - setToolTipText(null); - } - } - else - setToolTipText(null); - } - }); - } - - @Override - public void columnSelectionChanged(ListSelectionEvent e) { - repaint(); - } - - public void setColumnToolTips(String[] tooltips) { - columnToolTips = tooltips; - } -} diff --git a/Interface/dev/@olduitable/javaCodes/DropDownButton.java b/Interface/dev/@olduitable/javaCodes/DropDownButton.java deleted file mode 100644 index bc6d526..0000000 --- a/Interface/dev/@olduitable/javaCodes/DropDownButton.java +++ /dev/null @@ -1,81 +0,0 @@ -package asd.fgh.olduitable; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.border.*; -import javax.swing.event.*; -import javax.swing.BorderFactory.*; - -public class DropDownButton extends JButton { - - private JButton arrowButton = new JButton(); //"⌵" - private JPopupMenu popup; - private JLabel label = new JLabel(""); - - public DropDownButton() { - - setFocusPainted(false); - setOpaque(true); - setBackground(Color.white); - setContentAreaFilled(false); - - label.setOpaque(true); - label.setBackground(Color.white); - //label.setBorder(new CompoundBorder(new LineBorder(Color.white,2),new LineBorder(Color.black))); - - arrowButton.setIcon(UIManager.getIcon("Table.descendingSortIcon")); - arrowButton.setOpaque(true); - arrowButton.setContentAreaFilled(false); - arrowButton.setFocusPainted(false); - arrowButton.setBorder(new EmptyBorder(0,0,0,1)); - arrowButton.setPreferredSize(new Dimension(20, 0)); - - arrowButton.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent evt) { - if (arrowButton.getModel().isPressed()) { - arrowButton.setContentAreaFilled(true); - } else if (arrowButton.getModel().isRollover()) { - arrowButton.setContentAreaFilled(true); - } else { - arrowButton.setContentAreaFilled(false); - } - } - }); - - setLayout(new BorderLayout()); - setMargin(new Insets(-1, -1,-1,-3)); - - add(label, BorderLayout.CENTER); - add(arrowButton, BorderLayout.EAST); - } - - public void setPopupMenu(final JPopupMenu popupmenu) { - popup = popupmenu; - } - - - public JButton getArrowButton() { - return arrowButton; - } - - public JLabel getJLabel() { - return label; - } - - public JPopupMenu getPopupMenu() { - return popup; - } - - public void showPopup() { - try { - popup.show(this, getWidth() - popup.getPreferredSize().width, getHeight()); - setSelected(true); - } - catch (Exception e) { // IllegalComponentStateException - } - } - - /*public void hidePopup() { - popup.setVisible(false); - }*/ -} \ No newline at end of file diff --git a/Interface/dev/@olduitable/javaCodes/EditableModel.java b/Interface/dev/@olduitable/javaCodes/EditableModel.java deleted file mode 100644 index 8d9a5c6..0000000 --- a/Interface/dev/@olduitable/javaCodes/EditableModel.java +++ /dev/null @@ -1,46 +0,0 @@ -package asd.fgh.olduitable; -import java.util.Arrays; -import javax.swing.table.*; - -public class EditableModel extends DefaultTableModel implements TableModel { - - boolean[] columnEditable = new boolean[this.getColumnCount()]; - - public EditableModel(Object[][] data, Object[] columnNames) { - super(data, columnNames); - Arrays.fill(columnEditable, false); - } - - public boolean isCellEditable(int row, int column) { - return columnEditable[column]; - } - - public boolean[] getColumnEditable() { - return columnEditable; - } - - public boolean getColumnEditable(int column) { - return columnEditable[column]; - } - - //adjust 'columnEditable' to a specific number of columns (this must be used before any method that changes the column count to avoid the 'java.lang.ArrayIndexOutOfBounds' exception) - public void resizeEditableArray(int columnCount) { - if (columnEditable.length < columnCount) { - boolean[] aux = Arrays.copyOf(columnEditable, columnCount); - Arrays.fill(aux, columnEditable.length, columnCount - 1, false) ; - columnEditable = aux; - } - else if (columnEditable.length > columnCount) { - boolean[] aux = Arrays.copyOf(columnEditable, columnCount); - columnEditable = aux; - } - } - - public void setEditable(boolean editable) { - Arrays.fill(columnEditable, editable); - } - - public void setColumnEditable(int column, boolean editable) { - columnEditable[column] = editable; - } -} diff --git a/Interface/dev/@olduitable/javaCodes/LongTextCellEditor.java b/Interface/dev/@olduitable/javaCodes/LongTextCellEditor.java deleted file mode 100644 index d97a94e..0000000 --- a/Interface/dev/@olduitable/javaCodes/LongTextCellEditor.java +++ /dev/null @@ -1,40 +0,0 @@ -package asd.fgh.olduitable; -import java.awt.*; -import javax.swing.*; -import javax.swing.table.TableCellEditor; - -public class LongTextCellEditor extends AbstractCellEditor implements TableCellEditor { - - private TextAreaComboBox button; - private String text = " "; - - public LongTextCellEditor(TextAreaComboBox specialButton) { - button = specialButton; - } - - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - - if (value != null) - text = String.valueOf(table.getValueAt(row, column)); - else - text = ""; - - button.getTextArea().setText(text); - button.getJLabel().setText(text); - - return button; - } - - public Object getCellEditorValue() { - return button.getTextArea().getText(); - } - - public boolean stopCellEditing() { - /*button.setSelected(false); - if (!button.getArrowButton().isSelected()) { - super.cancelCellEditing(); - }*/ - super.cancelCellEditing(); - return super.stopCellEditing(); - } -} \ No newline at end of file diff --git a/Interface/dev/@olduitable/javaCodes/RowHeader.java b/Interface/dev/@olduitable/javaCodes/RowHeader.java deleted file mode 100644 index ac8ee21..0000000 --- a/Interface/dev/@olduitable/javaCodes/RowHeader.java +++ /dev/null @@ -1,85 +0,0 @@ -package asd.fgh.olduitable; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.table.*; - -public class RowHeader extends JTable { - - private int startDrag = -1; // first row selected (through the row header) that could the beginning of the drag with the mouse - - public RowHeader(final JTable table) { - this(new DefaultTableModel(1,1), table); - } - - public RowHeader(TableModel model, final JTable table) { - super(model); - - // default settings - getColumnModel().getColumn(0).setPreferredWidth(30); - setRowHeight(20); - setGridColor(new Color(0.75F,0.75F,0.75F)); - setCellSelectionEnabled(true); - setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); - setDefaultRenderer(getColumnClass(0), new RowHeaderRenderer()); - setPreferredScrollableViewportSize(getPreferredSize()); // adjust viewport to rowheader size - - // add mouse listeners to highlight the table's rows according to the selection of the row headers - addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - int row = rowAtPoint(e.getPoint()); - if (table.isEnabled() && row > -1) { - startDrag = row; - table.setColumnSelectionInterval(table.getColumnCount() - 1,0); - table.setRowSelectionInterval(row,row); - } - } - public void mouseReleased(MouseEvent e) { - table.requestFocus(); // return focus to the main table - } - }); - - addMouseMotionListener(new MouseMotionListener() { - public void mouseDragged(MouseEvent e) { - if (table.isEnabled() && startDrag > -1) { - int row = rowAtPoint(e.getPoint()); - if (row > -1) { - table.setRowSelectionInterval(startDrag,row); - table.setColumnSelectionInterval(table.getColumnCount() - 1,0); - table.scrollRectToVisible(table.getCellRect(row,0,true)); - /*if (e.getX() > getWidth() || e.getX() < 0) - setRowSelectionInterval(startDrag,row);*/ - } - } - } - public void mouseMoved(MouseEvent e) {} - }); - - - // highlight the row headers according to the table's selection - table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - int firstRow = table.getSelectedRow(); - if (table.getSelectedRowCount() == getRowCount()) - selectAll(); - else if (firstRow == -1 || table.getSelectedColumnCount() == 0) - clearSelection(); - else { - int leadRow = table.getSelectionModel().getLeadSelectionIndex(); - int lastRow = firstRow + table.getSelectedRowCount() - 1; // table.getSelectionModel().getMaxSelectionIndex() - setColumnSelectionInterval(0,0); - if (leadRow > firstRow) - setRowSelectionInterval(firstRow, lastRow); - else - setRowSelectionInterval(lastRow, leadRow); - } - } - }); - } - - @Override - public boolean isCellEditable(int row, int column) { - return false; - } -} \ No newline at end of file diff --git a/Interface/dev/@olduitable/javaCodes/RowHeaderRenderer.java b/Interface/dev/@olduitable/javaCodes/RowHeaderRenderer.java deleted file mode 100644 index 4621b12..0000000 --- a/Interface/dev/@olduitable/javaCodes/RowHeaderRenderer.java +++ /dev/null @@ -1,71 +0,0 @@ -package asd.fgh.olduitable; -import java.awt.*; -import javax.swing.*; -import javax.swing.border.*; -import javax.swing.table.*; - -public class RowHeaderRenderer extends DefaultTableCellRenderer implements TableCellRenderer { - - private Color bgcolor = new Color(240, 240, 240); - private Color fgcolor = Color.black; - private Color selbgcolor = new Color(204, 204, 204); - private Color selfgcolor = Color.black; - //private Color leftbordercolor = new Color(66, 133, 244); - - public RowHeaderRenderer() { - setHorizontalAlignment(CENTER); - } - - public RowHeaderRenderer(Color bg_color) { - setHorizontalAlignment(CENTER); - bgcolor = bg_color; - } - - public RowHeaderRenderer(Color bg_color, Color fg_color) { - setHorizontalAlignment(CENTER); - bgcolor = bg_color; - fgcolor = fg_color; - } - - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - - super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - - setBorder(noFocusBorder); - - // highlight the row headers according to the selection - if (isSelected) { - setBackground(selbgcolor); - setForeground(selfgcolor); - //setBorder(new CompoundBorder(new MatteBorder(0, 1, 0, 0, leftbordercolor),new EmptyBorder(1, 0, 1, 1))); - } - else { - setBackground(bgcolor); - setForeground(fgcolor); - } - - return this; - } - - public void setBackgroundColor(Color bg_color) { - bgcolor = bg_color; - } - - public void setForegroundColor(Color fg_color) { - fgcolor = fg_color; - } - - public void setSelectionBgcolor(Color sel_bgcolor) { - selbgcolor = sel_bgcolor; - } - - public void setSelectionFgcolor(Color sel_fgcolor) { - selfgcolor = sel_fgcolor; - } - - /* - public void setSelectionLeftBorderColor(Color sel_bordercolor) { - leftbordercolor = sel_bordercolor; - } - */ -} \ No newline at end of file diff --git a/Interface/dev/@olduitable/javaCodes/Sorter.java b/Interface/dev/@olduitable/javaCodes/Sorter.java deleted file mode 100644 index 60816e6..0000000 --- a/Interface/dev/@olduitable/javaCodes/Sorter.java +++ /dev/null @@ -1,41 +0,0 @@ -package asd.fgh.olduitable; -import java.util.*; -import javax.swing.*; -import javax.swing.table.*; - -public class Sorter extends TableRowSorter{ - - private Comparator comparator = new Comparator() { - public int compare(Object o1, Object o2) { - if (o1 instanceof Double && o2 instanceof Double) - return ((Double)o1).compareTo((Double)o2); - else - return o1.toString().compareTo(o2.toString()); - } - }; - - private List sortKeys = new ArrayList<>(1); - - public Sorter(TableModel model) { - super(model); - } - - public boolean isSortable(int column) { - return false; - } - - public void setComparators() { - for (int column = 0; column < this.getModel().getColumnCount(); column++) { - this.setComparator(column, comparator); - } - } - - public void setSortKeys(int column, String sortOrder) { - sortKeys.clear(); - if (sortOrder.equalsIgnoreCase("ascend")) - sortKeys.add(new RowSorter.SortKey(column, SortOrder.ASCENDING)); - else - sortKeys.add(new RowSorter.SortKey(column, SortOrder.DESCENDING)); - super.setSortKeys(sortKeys); - } -} diff --git a/Interface/dev/@olduitable/javaCodes/Table.java b/Interface/dev/@olduitable/javaCodes/Table.java deleted file mode 100644 index afdc555..0000000 --- a/Interface/dev/@olduitable/javaCodes/Table.java +++ /dev/null @@ -1,82 +0,0 @@ -package asd.fgh.olduitable; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.table.TableCellRenderer; -import javax.swing.SwingUtilities; - -public class Table extends JTable { - - public Table(EditableModel model) { - super(model); - - // initial adjustements - setRowHeight(20); - setGridColor(new Color(0.85F,0.85F,0.85F)); - setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - setCellSelectionEnabled(true); - setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); - setDefaultRenderer(getColumnClass(0), new CellRenderer()); - setDefaultEditor(getColumnClass(0), new CellEditor("center")); - putClientProperty("terminateEditOnFocusLost", true); // Boolean.TRUE // it only works if the current focus owner is a child of the table's top level ancestor - - // this is to ensure that the popup editor appears immediately after the cell is clicked - ListSelectionListener startEditing = new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - if (isEditing() && !e.getValueIsAdjusting()) { - Component editor = getEditorComponent(); - if (editor instanceof JComboBox) - ((JComboBox)editor).showPopup(); - else if (editor instanceof ColorComboBox) { - ((ColorComboBox)editor).showPopup(); - } - else if (editor instanceof TextAreaComboBox) { - ((TextAreaComboBox)editor).showPopup(); - } - } - } - }; - - getSelectionModel().addListSelectionListener(startEditing); - getColumnModel().getSelectionModel().addListSelectionListener(startEditing); - - } - - public void stopEditingWhenOtherComponentIsClicked() { - MouseAdapter stopEditing = new MouseAdapter() { - public void mousePressed(MouseEvent e) { - Component editor = getEditorComponent(); - if (editor != null) { - if (editor instanceof TextAreaComboBox) ((TextAreaComboBox)editor).setSelected(false); - getCellEditor().stopCellEditing(); - } - } - }; - - JScrollPane scrollpane = (JScrollPane)getParent().getParent(); - JScrollBar hscrollbar = scrollpane.getHorizontalScrollBar(); - JScrollBar vscrollbar = scrollpane.getVerticalScrollBar(); - - getTableHeader().addMouseListener(stopEditing); // click on the column headers - scrollpane.addMouseListener(stopEditing); // click on the empty corners - getParent().addMouseListener(stopEditing); // click on the empty panel area - hscrollbar.addMouseListener(stopEditing); // click on the scroll bars - vscrollbar.addMouseListener(stopEditing); - hscrollbar.getComponent(0).addMouseListener(stopEditing); // click on the arrows - hscrollbar.getComponent(1).addMouseListener(stopEditing); - vscrollbar.getComponent(0).addMouseListener(stopEditing); - vscrollbar.getComponent(1).addMouseListener(stopEditing); - } - - public int getOptimalColumnWidth(int column) { - int width = 0; - TableCellRenderer renderer = getColumnModel().getColumn(column).getCellRenderer(); - FontMetrics fontMetrics = getFontMetrics(getFont()); - for(int row = 0; row < getRowCount(); row++) { - CellRenderer cellRenderer = (CellRenderer)prepareRenderer(renderer, row, column); - width = Math.max(width, SwingUtilities.computeStringWidth(fontMetrics, cellRenderer.getText())); - } - return width; - } -} diff --git a/Interface/dev/@olduitable/javaCodes/TextAreaComboBox.java b/Interface/dev/@olduitable/javaCodes/TextAreaComboBox.java deleted file mode 100644 index dce75ee..0000000 --- a/Interface/dev/@olduitable/javaCodes/TextAreaComboBox.java +++ /dev/null @@ -1,16 +0,0 @@ -package asd.fgh.olduitable; -import javax.swing.JTextArea; - -public class TextAreaComboBox extends DropDownButton{ - - private JTextArea textArea; - - public TextAreaComboBox(JTextArea text_Area) { - super(); - textArea = text_Area; - } - - public JTextArea getTextArea() { - return textArea; - } -} diff --git a/Interface/dev/@olduitable/olduitable.m b/Interface/dev/@olduitable/olduitable.m deleted file mode 100644 index cd607d7..0000000 --- a/Interface/dev/@olduitable/olduitable.m +++ /dev/null @@ -1,3164 +0,0 @@ -classdef olduitable < matlab.mixin.SetGet - % OLDUITABLE is a Matlab class that implements a Java-based table. - % It includes many of the properties of the Matlab uitable, with an interface - % similar to its undocumented version (v0). Besides this class incorporates - % new properties such as ColumnAlign, ColumnColor, ColumnToolTip, GridColor, - % HeaderBackground, SelectionBackground, among others, and methods to insert - % or delete rows and columns and paste blocks of cells as a typical spreadsheet. - % - % For more details go to online documentation
- - % Licensed under the terms of the MIT License - % Copyright (c) 2018 Pablo Baez R. - - %% Properties - properties % callbacks (3/5) - ButtonDownFcn = '' % Function that is executed when a button mouse is clicked.
  • Valid Inputs: function handle | cell array | char vector - CellEditCallback = '' % Function that is executed when the contents of table change.
  • Valid Inputs: function handle | cell array | char vector - CellSelectionCallback = '' % Function that is executed when the table selection changes.
  • Valid Inputs: function handle | cell array | char vector - end - - properties (Dependent) - ColumnAlign % Indicates the alignment of the columns.
  • Valid Inputs: 'letf' | 'center' | 'right' | cell array of char vectors - ColumnColor % Indicates the pattern for the columns' background colors.
  • Valid Inputs: matrix of RGB triplets - ColumnEditable % Indicates the ability to edit the column cells.
  • Valid Inputs: logical scalar or array | numeric scalar or array with binary values - ColumnFormat % Indicates the column displays.
  • Valid Inputs: '' | 'bank' | 'char' | 'color' | 'logical' | 'longchar' | 'popup' | char vector with a formatting operator | cell array of char vectors - ColumnFormatData % Indicates the list of options for the columns with a 'popup' ColumnFormat value.
  • Valid Inputs: cell array with empty values or cellstr arrays - ColumnName % Indicates the names of the column headers.
  • Valid Inputs: 'numbered' | empty array | cell array of char vectors - ColumnResizable % Indicates the ability to resize the column widths.
  • Valid Inputs: logical scalar or array | numeric scalar or array with binary values - ColumnSortable % Indicates the ability to sort the column.
  • Valid Inputs: logical scalar or array | numeric scalar or array with binary values - ColumnStriping % Indicates if columns have a shading pattern.
  • Valid Inputs: 'on' | 'off' - ColumnToolTip % Indicates the tooltips for the column headers.
  • Valid Inputs: '' | cell array of char vectors - ColumnWidth % Indicates the width of the columns.
  • Valid Inputs: positive number | cell array with positive numbers - Data % Indicates the contents of the table.
  • Valid Inputs: numeric, logical or cell array - Enable % Indicates the ability to interact with the mouse and keyborad in the table.
  • Valid Inputs: 'on' | 'off' - FontName % Indicates the font for the cell content.
  • Valid Inputs: see List system fonts) - FontSize % Indicates the font size for the table.
  • Valid Inputs: positive number whose value is in pixel units) - FontStyle % Indicates the font style for the table.
  • Valid Inputs: 'normal' (0) | 'bold' (1) | 'italic' (2) - ForegroundColor % Indicates the cell text color.
  • Valid Inputs: short or long name of the color | RGB triplet - GridColor % Indicates the color of the grid in the table.
  • Valid Inputs: short or long name of the color | RGB triplet - HeaderBackground % Indicates the background color of row and column headers.
  • Valid Inputs: short or long name of the color | RGB triplet - HeaderForeground % Indicates the foreground color of row and column headers.
  • Valid Inputs: short or long name of the color | RGB triplet - HeaderGridColor % Indicates the color of the grid in the row and column headers.
  • Valid Inputs: short or long name of the color | RGB triplet - HeaderSelectionBg % Indicates the selection background color of row and column headers.
  • Valid Inputs: short or long name of the color | RGB triplet - HeaderSelectionFg % Indicates the selection foreground color of row and column headers.
  • Valid Inputs: short or long name of the color | RGB triplet - end - - properties % callbacks (5/5) - KeyPressFcn = '' % Function that is executed when a key is pressed.
  • Valid Inputs: function handle | cell array | char vector - KeyReleaseFcn = '' % Function that is executed when a key is released.
  • Valid Inputs: function handle | cell array | char vector - end - - properties (Dependent) - Parent % Indicates the parent object of the table.
  • Valid Inputs: Figure | Panel | ButtonGroup | Tab - Position % Indicates the location and size of the table with respect to its parent.
  • Valid Inputs: numeric array [left bottom width height] - RowColor % Indicates the pattern for the rows' background colors.
  • Valid Inputs: matrix of RGB triplets - RowHeight % Indicates the height of the rows.
  • Valid Inputs: 'auto' | positive number whose value is in pixel units - RowName % Indicates the names of the column headers.
  • Valid Inputs: 'numbered' | empty array | cell arry of char vectors - RowStriping % Indicates if rows have a shading pattern.
  • Valid Inputs: 'on' | 'off' - SelectionBackground % Indicates the selection background color of cells.
  • Valid Inputs: short or long name of the color | RGB triplet - SelectionForeground % Indicates the selection foreground color of cells.
  • Valid Inputs: short or long name of the color | RGB triplet - SelectionBorderColor % Indicates the color of the external selection border.
  • Valid Inputs: short or long name of the color | RGB triplet - Tag % Assigns the table identifier.
  • Valid Inputs: char vector - UIContextMenu % Indicates the context menu for table.
  • Valid Inputs: empty array | 'default' | a Java component of type javax.swing.JPopupMenu - Units % Indicates the units of measure in which the Position vector is expressed.
  • Valid Inputs: 'pixels' | 'normalized' | 'inches' | 'centimeters' | 'points' | 'characters' - UserData % Indicates the user data associated with the 'olduitable' object.
  • Valid Inputs: any Matlab array - Visible % Indicates the table visibility.
  • Valid Inputs: 'on' | 'off' - end - - % read-only properties - properties (SetAccess = private) - Extent % Read-only property that indicates the width and height of the rectangle containing the table in pixels (1x2 numeric array) - RowSortIndices % Read-only property that indicates the row indices for the current sort mode according to the unsorted state (= [] if columns are unsorted) - SortDirection % Read-only property that indicates the current sort direction.
  • Values: 0 (unsorted), 1 (ascend) or -1 (descend) - SortedColumn % Read-only property that indicates the current sorted column index (= 0 if columns are unsorted) - end - - %% Internal properties - properties (Access = protected, Hidden) - editing % parameter that prevents the 'TableChangedCallback' re-entrancy - editingRow = -1 % index for the last row that was in an edit mode - editingCol = -1 % index for the last column that was in an edit mode - editType % parameter that indicates the type of edition in the table ('CellEdit','ColumnsInsertion','RowsInsertion','ColumnsDelete', etc.) - fontMetrics % parameter to measure the strings according to the font used in the table - fontMetricsHeaders % idem for the row and column headers - inConstruction = false % parameter that indicates whether table is still in construction - info % variable that works as a backup that store all the settable properties (except for callback functions, Data, Parent and UserData) - isDataModified = false % parameter that indicates whether a cell was modified - oldValue % previous value for the last cell edited - rheaderWidth = 0 % width of the row headers - rownames % cell array of chars vectors that contains the row heading names - theaderHeight = 0 % height of the column headers - end - - properties (Access = protected, Hidden) % java objects - columnHeader % the column header (a 'asd.fgh.olduitable.ColumnHeader' object that extends the JTableHeader class) - columnModel % the column model (a 'javax.swing.table.DefaultTableColumnModel' object) - cont % the table's container (a 'matlab.ui.container.Panel' object) - corner % upper left corner of table (a 'javax.swing.JLabel' object) - jtable % the main table (a 'asd.fgh.olduitable.Table' object that extends the JTable class) - jscrollpane % the scroll pane (a 'javax.swing.JScrollPane' object) - rowheader % the row header (a 'asd.fgh.olduitable.RowHeader' object that extends the JTable class) - sorter % the object that provides the sorting ('asd.fgh.olduitable.Sorter' object that extends the TableRowSorter class) - tableModel % the table model (a 'asd.fgh.olduitable.EditableModel' object that extends the DefaultTableModel class) - defaultContextMenu % the context menu by default (a 'javax.swing.JPopupMenu' object) - end - - properties (Access = protected, Hidden) % auxiliary variables that indicate the selection changes in table - ColumnsSelectionRange = {0,0} % {FirstColumnSelected,LastColumnSelected} ---> selection sequence (not ordered by the indices) - RowsSelectionRange = {0,0} % idem for the rows - end - - properties (Access = protected, Hidden) - colorEditor = struct('cellbutton',[],'dropdownMenu',[]) % structure that stores the color picker (a javax.swing.JPopupMenu object) - colorFormat % parameter that indicate if the column has a 'color' value for the 'columnformat' property - longcharEditor = struct('cellbutton',[],'dropdownMenu',[],'area',[]) % structure that stores the ... (a javax.swing.JPopupMenu object) - end - - properties (Constant, Hidden) - listfonts = [listfonts;'MS Sans Serif'] % list of available fonts (at least in MS Windows) - propertyList = {'ButtonDownFcn','CellEditCallback','CellSelectionCallback','ColumnAlign','ColumnColor','ColumnEditable',... - 'ColumnFormat','ColumnFormatData','ColumnName','ColumnResizable','ColumnSortable','ColumnStriping','ColumnToolTip',... - 'ColumnWidth','Data','Enable','FontName','FontSize','FontStyle','ForegroundColor','GridColor','HeaderBackground',... - 'HeaderForeground','HeaderGridColor','HeaderSelectionBg','HeaderSelectionFg','KeyPressFcn','KeyReleaseFcn','Parent',... - 'Position','RowColor','RowHeight','RowName','RowStriping','SelectionBackground','SelectionForeground','SelectionBorderColor',... - 'Tag','UIContextMenu','Units','UserData','Visible'}' - validParent = {'matlab.ui.Figure','matlab.ui.container.Tab','matlab.ui.container.Panel','matlab.ui.container.ButtonGroup'}' - end - - %% Constructor - methods - function obj = olduitable(varargin) - %Creates a new olduitable object.
  • t = olduitable;
  • t = olduitable('PropertyName',value,...);
  • t = olduitable(parent,'PropertyName',value,...); - - % create input parser scheme to validate the arguments - scheme = inputParser; - - if verLessThan('matlab','8.2') % --> versions earlier than R2013b - addParamFcn = 'addParamValue'; - else - addParamFcn = 'addParameter'; - end - - scheme.(addParamFcn)('ButtonDownFcn','',@(x)obj.callbackValidation(x)); - scheme.(addParamFcn)('CellEditCallback','',@(x)obj.callbackValidation(x)); - scheme.(addParamFcn)('CellSelectionCallback','',@(x)obj.callbackValidation(x)); - scheme.(addParamFcn)('ColumnAlign','center',@(x)obj.columnalignValidation(x)); - scheme.(addParamFcn)('ColumnColor',[1 1 1;16/17*ones(1,3)],@(x)obj.rgbValidation(x)); - scheme.(addParamFcn)('ColumnEditable',false,@(x)obj.binaryValidation(x)); - scheme.(addParamFcn)('ColumnFormat','',@(x)obj.columnformatValidation(x)); - scheme.(addParamFcn)('ColumnFormatData',{},@(x)obj.colformatdataValidation(x)); - scheme.(addParamFcn)('ColumnName','numbered',@(x)obj.headerNamesValidation(x)); - scheme.(addParamFcn)('ColumnResizable',true,@(x)obj.binaryValidation(x)); - scheme.(addParamFcn)('ColumnSortable',true,@(x)obj.binaryValidation(x)); - scheme.(addParamFcn)('ColumnStriping','off',@(x)obj.onoffValidation(x)); - scheme.(addParamFcn)('ColumnToolTip','',@(x)obj.tooltipsValidation(x)); - scheme.(addParamFcn)('ColumnWidth',75,@(x)obj.columnwidthValidation(x)); - scheme.(addParamFcn)('Data',cell(1,1),@(x)obj.dataValidation(x)); - scheme.(addParamFcn)('Enable','on',@(x)obj.onoffValidation(x)); - scheme.(addParamFcn)('FontName','',@(x)obj.fontnameValidation(x)); - scheme.(addParamFcn)('FontSize',12,@(x)obj.fontsizeValidation(x)); - scheme.(addParamFcn)('FontStyle',0,@(x)obj.fontstyleValidation(x)); - scheme.(addParamFcn)('ForegroundColor',[0 0 0],@(x)obj.colorValidation(x)); - scheme.(addParamFcn)('GridColor',0.85*[1 1 1],@(x)obj.colorValidation(x)); - scheme.(addParamFcn)('HeaderBackground',16/17*[1 1 1],@(x)obj.colorValidation(x)); - scheme.(addParamFcn)('HeaderForeground',[0 0 0],@(x)obj.colorValidation(x)); - scheme.(addParamFcn)('HeaderGridColor',0.75*[1 1 1],@(x)obj.colorValidation(x)); - scheme.(addParamFcn)('HeaderSelectionBg',0.8*[1 1 1],@(x)obj.colorValidation(x)); - scheme.(addParamFcn)('HeaderSelectionFg',[0 0 0],@(x)obj.colorValidation(x)); - scheme.(addParamFcn)('KeyPressFcn','',@(x)obj.callbackValidation(x)); - scheme.(addParamFcn)('KeyReleaseFcn','',@(x)obj.callbackValidation(x)); - scheme.(addParamFcn)('Parent',[],@(x)obj.parentValidation(x)); - scheme.(addParamFcn)('Position',[1 1 350 300],@(x)obj.positionValidation(x)); - scheme.(addParamFcn)('RowColor',[1 1 1;16/17*ones(1,3)],@(x)obj.rgbValidation(x)); - scheme.(addParamFcn)('RowHeight','auto',@(x)obj.rowheightValidation(x)); - scheme.(addParamFcn)('RowName','numbered',@(x)obj.headerNamesValidation(x)); - scheme.(addParamFcn)('RowStriping','off',@(x)obj.onoffValidation(x)); - scheme.(addParamFcn)('SelectionBackground',[236 243 255]./255,@(x)obj.colorValidation(x)); - scheme.(addParamFcn)('SelectionForeground',[0 0 0],@(x)obj.colorValidation(x)); - scheme.(addParamFcn)('SelectionBorderColor',[66 133 244]./255,@(x)obj.colorValidation(x)); - scheme.(addParamFcn)('Tag','',@(x)obj.tagValidation(x)); - scheme.(addParamFcn)('UIContextMenu','auto',@(x)obj.jpopupValidation(x)); - scheme.(addParamFcn)('Units','pixels',@(x)obj.unitsValidation(x)); - scheme.(addParamFcn)('UserData',[]); - scheme.(addParamFcn)('Visible','on',@(x)obj.onoffValidation(x)); - - %ind0 = 1; - if isempty(varargin) - ind0 = []; % t = olduitable - elseif ischar(varargin{1}) - ind0 = 1; % t = olduitable('PropertyName1',value1,'PropertyName2',value2,...) - elseif ismember(class(varargin{1}),obj.validParent) && isvalid(varargin{1}) - ind0 = 2; % t = olduitable(Parent,'PropertyName1',value1,...) - end - - parse(scheme,varargin{ind0:end}); - params = scheme.Results; - - % initial construction ----------------------------------------------------------------------------------------------- - obj.inConstruction = true; % notify start of construction - - % add the java classes to the dynamic path - folder = fullfile(fileparts(which('olduitable')),'javaClasses.jar'); - if ~ismember(folder,javaclasspath('-all')) - if ~isempty(javaclasspath('-dynamic')) - warning(['Clear the classes or create a custom classpath including the filename ',folder]); - return; - else - javaaddpath(folder); - end - end - - % if local region doesn't have the dot(.) as the decimal separator, change the region to one that has it - formatSymbols = java.text.DecimalFormatSymbols(java.util.Locale.getDefault); % default symbols according to regional settings - if ~strcmp(formatSymbols.getDecimalSeparator,'.') && ... - ~strcmp(java.util.Locale.getDefault.toString,'en_US') - java.util.Locale.setDefault(java.util.Locale.US); % Locale.ENGLISH - end - - % define parent - if isempty(params.Parent) && ~isempty(ind0) && ind0 == 2 - params.Parent = varargin{1}; % parent will be the first argument - elseif isempty(params.Parent) - params.Parent = gcf; % table will be assigned to the current figure (or a new if doesn't exist) - end - - % define the java components - - % custom table model that implements the 'ColumnEditable' property - model = javaObjectEDT('asd.fgh.olduitable.EditableModel',cell(1,1),' '); - obj.tableModel = handle(model,'CallbackProperties'); - - % jtable - table = javaObjectEDT('asd.fgh.olduitable.Table',obj.tableModel); - obj.jtable = handle(table,'CallbackProperties'); - defaultFont = obj.jtable.getFont; - obj.fontMetrics = obj.jtable.getFontMetrics(defaultFont); - obj.fontMetricsHeaders = obj.fontMetrics; - - % column model - obj.columnModel = handle(obj.jtable.getColumnModel,'CallbackProperties'); - - % sorter - obj.sorter = asd.fgh.olduitable.Sorter(obj.tableModel); - %obj.sorter.setSortsOnUpdates(true); - obj.jtable.setRowSorter(obj.sorter); - - % jscrollpane - obj.cont = uipanel(params.Parent,'BorderType','beveledout','DeleteFcn',@(~,~)obj.delete); - obj.jscrollpane = javaObjectEDT('javax.swing.JScrollPane',obj.jtable); - [obj.jscrollpane,wrapper] = javacomponent(obj.jscrollpane,[],obj.cont); - wrapper.Units = 'normalized'; - wrapper.Position = [0 0 1 1]; - - % column header - columnheader = javaObjectEDT('asd.fgh.olduitable.ColumnHeader',obj.jtable); - obj.columnHeader = handle(columnheader,'CallbackProperties'); - obj.jtable.setTableHeader(obj.columnHeader); - obj.jscrollpane.setColumnHeaderView(obj.columnHeader); - d = obj.columnHeader.getPreferredSize; d.height = 24; - obj.columnHeader.getParent.setPreferredSize(d); - - % row header - %rheader = javaObjectEDT('asd.fgh.olduitable.RowHeader',obj.jtable); - rheaderModel = javaObjectEDT('javax.swing.table.DefaultTableModel',cell(1,1),' '); - rheader = javaObjectEDT('asd.fgh.olduitable.RowHeader',rheaderModel,obj.jtable); - obj.rowheader = handle(rheader,'CallbackProperties'); - obj.jscrollpane.setRowHeaderView(obj.rowheader); - - % upper left corner - corner = javaObjectEDT('javax.swing.JLabel','◢'); - obj.corner = handle(corner,'CallbackProperties'); - obj.jscrollpane.setCorner(javax.swing.ScrollPaneConstants.UPPER_LEFT_CORNER,obj.corner); - obj.corner.setOpaque(true); - border = javax.swing.border.CompoundBorder(... - javax.swing.border.MatteBorder(0,0,1,1,java.awt.Color(0.75,0.75,0.75)),javax.swing.border.EmptyBorder(0,0,-1,2)); - obj.corner.setBorder(border); - obj.corner.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); - obj.corner.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM); - obj.corner.setFont(java.awt.Font(defaultFont.getName,0,16)); - obj.corner.setForeground(java.awt.Color(0.8,0.8,0.8)); - - % Set property values ----------------------------------------------------------------------------------------------- - - % resize values for the properties that could vary in each column - n = size(params.Data,2); - colProperties = {'ColumnAlign','ColumnEditable','ColumnFormat','ColumnFormatData','ColumnResizable','ColumnSortable','ColumnToolTip','ColumnWidth'}; - defaultvalues = {'center',false,'',{},true,true,'',75}; - for i = [1 3 4 7 8] - params.(colProperties{i}) = obj.resize2columncount(n,defaultvalues{i},params.(colProperties{i})); - end - for i = [2 5 6] - params.(colProperties{i}) = obj.resizelogical2columns(n,defaultvalues{i},params.(colProperties{i})); - end - - % store user-defined or default values in backup - obj.info = params; - obj.info.Data = []; % store the data is not necessary (and could take much memory space) - obj.info.Parent = []; - obj.info.UserData = []; - - % assign essential properties (with user-defined or default values) - % ('Parent' has already been assigned) - properties1 = {'Visible','Units','Position','Data','ColumnName','RowName','UIContextMenu','RowStriping'}; - for i = 1:length(properties1) - obj.(properties1{i}) = params.(properties1{i}); - end - - % assign additional properties if those were defined by the user, except for 'ColumnFormatData' that has already assigned internally) - % (with certain order according to their interdependence) - if ~isempty(ind0) - index = 1:length(obj.propertyList); - if ~isstruct(varargin{ind0}) - [verify,~] = ismember(lower(obj.propertyList),lower(varargin(ind0:2:end-1))); - else % that case is for when 'olduitable.loadinfo' function is used - [verify,~] = ismember(lower(obj.propertyList),lower(fieldnames(varargin{ind0}))); - end - for k = index(verify), toSet.(obj.propertyList{k}) = true; end - for k = index(~verify), toSet.(obj.propertyList{k}) = false; end - properties2 = {'FontName','FontStyle','FontSize','RowHeight','Tag','UserData',... - 'RowColor','ColumnStriping','ColumnColor','ForegroundColor','GridColor',... - 'HeaderBackground','HeaderForeground','HeaderGridColor','HeaderSelectionBg','HeaderSelectionFg',... - 'SelectionBackground','SelectionForeground','SelectionBorderColor',... - 'ColumnAlign','ColumnFormat','ColumnEditable','ColumnResizable','ColumnSortable','ColumnToolTip','ColumnWidth','Enable',... - 'ButtonDownFcn','CellEditCallback','CellSelectionCallback','KeyPressFcn','KeyReleaseFcn'}; - for i = 1:length(properties2) - if toSet.(properties2{i}), obj.(properties2{i}) = params.(properties2{i}); end - end - end - - % callbacks assignments ----------------------------------------------------------------------------------------------- - obj.jtable.stopEditingWhenOtherComponentIsClicked; - obj.jtable.ComponentResizedCallback = @obj.columnResize; - obj.tableModel.TableChangedCallback = @obj.cellEdit; - - % add listeners to the selection models - rowSelectionHandle = handle(obj.jtable.getSelectionModel,'CallbackProperties'); - colSelectionHandle = handle(obj.jtable.getColumnModel.getSelectionModel,'CallbackProperties'); - rowSelectionHandle.ValueChangedCallback = {@obj.selectionChanged,'Rows'}; - colSelectionHandle.ValueChangedCallback = {@obj.selectionChanged,'Columns'}; - - % add mouse and keyboard listeners to the jscrollpane's components that trigger the user's callbacks - obj.jtable.MousePressedCallback = @obj.jtableSelection; - obj.jtable.KeyPressedCallback = @obj.keyfunction; - obj.jtable.KeyReleasedCallback = {@obj.callKeyFcn,'KeyReleaseFcn'}; - obj.corner.MousePressedCallback = @obj.cornerSelection; - obj.rowheader.MousePressedCallback = @(~,evt)obj.callButtonDownFcn(evt,'RowHeader'); - obj.columnHeader.MousePressedCallback = @obj.colheaderSelection; - set(handle(obj.jscrollpane.getViewport,'CallbackProperties'),... - 'MousePressedCallback',@(~,evt)obj.callButtonDownFcn(evt,'EmptyPanel')); - obj.jscrollpane.MousePressedCallback = @(~,evt)obj.callButtonDownFcn(evt,'OtherCorners'); - - % finally -------------------------------------------------------------------------------------------------- - obj.jtable.repaint; - obj.jtable.changeSelection(0,0,false,false); - obj.rowheader.changeSelection(0,0,false,false); - obj.inConstruction = false; - end - end - - %% User methods - % Syntax: - % methodName(obj,arg1,arg2,...) - % obj.methodName(arg1,arg2,...) - methods - - % Destructor - function delete(obj) - % olduitable object destructor (this function runs automatically if the parent is destroyed)
    t.delete - if ~isempty(obj.cont) && strcmp(obj.cont.BeingDeleted,'off') - delete(obj.cont); % necessary if manual removal is performed - end - end - - % Recoverer - function saveInfo(obj,varargin) - % This function saves the property values in a *.mat file.
    t.saveInfo
    t.saveInfo('filename') - - % define the filename - if isempty(varargin) - filename = inputname(1); % use object's name if filename isn't specified - elseif nargin == 2 && ischar(varargin{1}) && isrow(varargin{1}) && ... - regexp(varargin{1},['^(?!^(PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\..*)','(\..+)?$)[^\x00-\x1f\\?*:\"><|/]+$'],'once') - % taken from https://www.mathworks.com/matlabcentral/answers/44165-check-if-filename-is-valid#answer_54287 - filename = varargin{1}; - else - error('Input must be a character vector that contains a valid file name'); - end - - % store values in a structure named 'properties' (except for the 'Parent' and for a custom 'UIContextMenu') - properties = obj.info; - properties.Data = obj.Data; - properties.Parent = []; - properties.UserData = obj.cont.UserData; - if ~ischar(properties.UIContextMenu), properties.UIContextMenu = []; end - - % store callback functions - callbacks = {'ButtonDownFcn','CellEditCallback','CellSelectionCallback','KeyPressFcn','KeyReleaseFcn'}; - for i = 1:5 - properties.(callbacks{i}) = obj.(callbacks{i}); - end - - % save the structure in the filename.mat file - save(filename,'properties') - end - - function fitAllColumns2Panel(obj) - % Function to adjust the column widths to the visible area of the scroll pane.
    t.fitAllColumns2Panel - obj.jtable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS); - end - - function fitColumn2Data(obj,columnIndex,varargin) - % Function to adjust the column width depending on its content.
    t.fitColumn2Data(columnIndex)
    t.fitColumn2Data(columnIndex,considerHeader) % considerHeader is a logical scalar (false by default) - - % ensure that the column widths are adjustable - if obj.jtable.getAutoResizeMode ~= 0 - obj.jtable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); - end - - % validate inputs - validateattributes(columnIndex,{'numeric'},{'scalar','integer','>',0,'<=',obj.jtable.getColumnCount}); - if ~isempty(varargin) - if nargin == 3 - validateattributes(varargin{1},{'logical'},{'scalar'}); - else - error('Input must be a logical scalar'); - end - considerHeader = varargin{1}; - else - considerHeader = false; - end - - % get width according to the column format - column = obj.columnModel.getColumn(columnIndex-1); - format = obj.info.ColumnFormat{columnIndex}; - if strcmpi(format,'color') - width = 40; - elseif strcmpi(format,'logical') - width = 20; - elseif strcmpi(format,'longchar') - width = column.getPreferredWidth; % maintain previous width - else -% % this loop in Matlab has a poor performace (specially in large tables), for this reason the same code is -% % implemented in the 'getOptimalColumnWidth' method for the 'asd.fgh.olduitable.Table' java class -% width = 0; -% renderer = column.getCellRenderer; -% for row = 1:obj.jtable.getRowCount -% cr = obj.jtable.prepareRenderer(renderer,row-1,columnIndex-1); -% width = max(width,javax.swing.SwingUtilities.computeStringWidth(obj.fontMetrics,cr.getText)); -% end - width = obj.jtable.getOptimalColumnWidth(columnIndex-1); - - if strcmpi(format,'popup') % give additional space for the scrollbar (if it exists) - editor = obj.jtable.getCellEditor(0,columnIndex-1).getComponent; - if editor.getMaximumRowCount < editor.getItemCount, width = 15 + width; end - else - width = 10 + width; - end - end - - % recalculate the width if the column header is considered - if considerHeader - if ischar(obj.info.ColumnName) - width = max(width,10+javax.swing.SwingUtilities.computeStringWidth(obj.fontMetricsHeaders,column.getHeaderValue)); - else - % split the column header if it has more than one line and calculate for the maximum string width - headerName4line = strsplit(obj.info.ColumnName{columnIndex},'|'); - width = max(width,10+max(cellfun(@(x)javax.swing.SwingUtilities.computeStringWidth(obj.fontMetricsHeaders,x),headerName4line))); - end - end - - % set the new column width - column.setPreferredWidth(width); - - % store value in backup - obj.info.ColumnWidth{columnIndex} = width; - end - - function setSelection(obj,firstCell,lastCell) - % Function to select a range of cells.
    t.setSelection(firstCell,lastCell); % where firstCell = [firstRowIndex, firstColumnIndex] and lastCell = [lastRowIndex, lastColumnIndex] - - % validate inputs - cells = {firstCell,lastCell}; - for i = 1:2 - cell = cells{i}; - validateattributes(cell,{'numeric'},{'row','size',[1,2]}); - validateattributes(cell(1),{'numeric'},{'scalar','integer','>',0,'<=',obj.jtable.getRowCount}); - validateattributes(cell(2),{'numeric'},{'scalar','integer','>',0,'<=',obj.jtable.getColumnCount}); - end - - % change the selection - obj.jtable.setRowSelectionInterval(firstCell(1)-1,lastCell(1)-1); - obj.jtable.setColumnSelectionInterval(firstCell(2)-1,lastCell(2)-1); - - % scroll to first cell - obj.jtable.scrollRectToVisible(obj.jtable.getCellRect(firstCell(1)-1,firstCell(2)-1,true)); - end - - function val = getValue(obj,row,column) - % Function to get the content of a specific cell.
    value = t.getValue(rowIndex,columnIndex); - - % validate inputs - validateattributes(row,{'numeric'},{'scalar','integer','>',0,'<=',obj.jtable.getRowCount}); - validateattributes(column,{'numeric'},{'scalar','integer','>',0,'<=',obj.jtable.getColumnCount}); - - % get the cell value - val = obj.jtable.getValueAt(row-1,column-1); - end - - function setValue(obj,val,row,column) - % Function to set the content of a specific cell.
    t.setValue(value,rowIndex,columnIndex); - - % validate inputs - if (~isscalar(val) && ~ischar(val)) || iscell(val) - error('Value must be a scalar or char vector that is not contained in a cell array'); - end - validateattributes(row,{'numeric'},{'scalar','integer','>',0,'<=',obj.jtable.getRowCount}); - validateattributes(column,{'numeric'},{'scalar','integer','>',0,'<=',obj.jtable.getColumnCount}); - - % set the cell value - obj.jtable.setValueAt(val,row-1,column-1); % according to the current view - end - - function setCellBg(obj,val,row,column) - % Function to set the background of a specific cell.
    t.setCellBg(color,rowIndex,columnIndex); % the color value is a RGB triplet or the short or long name of a basic color - - % validate inputs - obj.colorValidation(val,'Color'); - validateattributes(row,{'numeric'},{'scalar','integer','>',0,'<=',obj.jtable.getRowCount}); - validateattributes(column,{'numeric'},{'scalar','integer','>',0,'<=',obj.jtable.getColumnCount}); - - % convert the value to a java color - val = obj.rgb2java(obj.char2rgb(val)); - - % paint the cell foreground - if ~obj.colorFormat(column) - obj.columnModel.getColumn(column-1).getCellRenderer.setCellBg(val,row-1,column-1); - obj.jtable.repaint; - end - end - - function setCellFg(obj,val,row,column) - % Function to set the foreground of a specific cell.
    t.setCellFg(color,rowIndex,columnIndex); % the color value is a RGB triplet or the short or long name of a basic color - - % validate inputs - obj.colorValidation(val,'Color'); - validateattributes(row,{'numeric'},{'scalar','integer','>',0,'<=',obj.jtable.getRowCount}); - validateattributes(column,{'numeric'},{'scalar','integer','>',0,'<=',obj.jtable.getColumnCount}); - - % convert the value to a java color - val = obj.rgb2java(obj.char2rgb(val)); - - % paint the cell background - if ~obj.colorFormat(column) && ~strcmpi(obj.info.ColumnFormat{column},'logical') - obj.columnModel.getColumn(column-1).getCellRenderer.setCellFg(val,row-1,column-1); - obj.jtable.repaint; - end - end - - function resetCellBg(obj,column) - % Function to return to the previous background (for a single column) defined by the RowColor or ColumnColor properties.
    t.resetCellBg(columnIndex) - validateattributes(column,{'numeric'},{'scalar','integer','>',0,'<=',obj.jtable.getColumnCount}); - obj.columnModel.getColumn(column-1).getCellRenderer.resetCellBg; - end - - function resetCellFg(obj,column) - % Function to return to the previous foreground (for a single column) defined by the ForegroundColor property.
    t.resetCellFg(columnIndex) - validateattributes(column,{'numeric'},{'scalar','integer','>',0,'<=',obj.jtable.getColumnCount}); - obj.columnModel.getColumn(column-1).getCellRenderer.resetCellFg; - end - - function sortColumn(obj,column,direction,varargin) - % Function to sort the rows of a column.
    t.sortColumn(columnIndex,direction) % direction is the char vector 'ascend' or 'descend' - - % validate inputs (varargin is used only to denote an internal use of this function, so the validation in that case is not necessary) - if isempty(varargin) - validateattributes(column,{'numeric'},{'scalar','integer','>',0,'<=',obj.jtable.getColumnCount}); - direction = validatestring(direction,{'ascend','descend'}); - end - - % if function was internally called... - if isnumeric(direction) - if direction == 1 - direction = 'ascend'; - else - direction = 'descend'; - end - end - - previousSelectedRowCount = obj.jtable.getSelectedRowCount; - - % sort column - sortKeys = obj.sorter.getSortKeys; - if obj.isDataModified - obj.unsort; - obj.sorter.setSortKeys(column-1,direction); - obj.isDataModified = false; - elseif sortKeys.isEmpty || column ~= obj.SortedColumn || ... - ~strcmpi([direction,'ing'],char(sortKeys.get(0).getSortOrder)) - obj.sorter.setSortKeys(column-1,direction); - else - return; - end - - % get reordered row indices (according to the underlying model) - m = obj.jtable.getRowCount; - sortedInd = zeros(1,m); - for i = 1:m - sortedInd(i) = 1 + obj.jtable.convertRowIndexToModel(i-1); - end - - % reorder the row heading names - %javaMethodEDT('getModel',obj.rowheader); - if m < length(obj.rownames) - rowheaders = obj.getDataInModel(obj.rowheader.getModel); - [~,ind] = ismember(obj.rownames,rowheaders); - rnames = obj.rownames(ind>0); - obj.rowheader.getModel.setDataVector(rnames(sortedInd),' '); - elseif ~isempty(obj.rownames) - obj.rowheader.getModel.setDataVector(obj.rownames(sortedInd),' '); - end - - % store the new sort parameters - obj.RowSortIndices = sortedInd; - obj.SortedColumn = column; - if strcmpi(direction,'ascend') - obj.SortDirection = 1; - else%if strcmpi(direction,'descend') - obj.SortDirection = -1; - end - - % try to restore the previous selection - % if it wasn't consecutive with respect to the current view, deselect - if obj.jtable.getSelectedRowCount ~= previousSelectedRowCount - obj.jtable.clearSelection; - else - obj.highlightRowHeaders; - end - end - - function unsort(obj) - % Function to unsort the table.
    t.unsort - - % verify that there is a sort state, if not return - if obj.SortDirection == 0, return; end - - % update the parameters - obj.SortedColumn = 0; - obj.SortDirection = 0; - obj.RowSortIndices = []; - obj.sorter.setSortKeys([]); - - % restore the row heading names - %javaMethodEDT('getModel',obj.rowheader); - if obj.jtable.getRowCount < length(obj.rownames) % ---> some rows were removed - rowheaders = obj.getDataInModel(obj.rowheader.getModel); - [~,ind] = ismember(obj.rownames,rowheaders); - obj.rowheader.getModel.setDataVector(obj.rownames(ind>0),' '); - else - obj.RowName = obj.info.RowName; - end - end - - function paste(obj,varargin) - % Function to paste a block of cells (copied from excel, for example) in the table.
    t.paste - - % get the reference cell from which to start - row0 = obj.jtable.getSelectedRow; - col0 = obj.jtable.getSelectedColumn; - - % return if there are no selected cells - if row0 == -1 || col0 == -1, return; end - - obj.stopEditing; - - % get the system clipboard content or a value to replicate in each selected cell - % (this last option is used to delete the cells' contents) - if isempty(varargin) - obj.editType = 'ContentsReplacement'; - editData = obj.getclipdata; - else - obj.editType = 'ContentsRemoval'; - editData = varargin{:}; - end - - % define number of rows and columns to edit and resize 'editData' according to this - if isscalar(editData) - numRows = obj.jtable.getSelectedRowCount; - numCols = obj.jtable.getSelectedColumnCount; - editData = repmat(editData,numRows,numCols); % replicate in each selected cell the unique value - else - numRows = min(size(editData,1),obj.jtable.getRowCount - row0); - numCols = min(size(editData,2),obj.jtable.getColumnCount - col0); - editData = editData(1:numRows,1:numCols); - end - - % if any column in the selection interval is not editable, return - colEditable = obj.tableModel.getColumnEditable; - if any(~colEditable((1+col0:col0+numCols))) - obj.editType = ''; - return - end - - % disable default callback - obj.tableModel.TableChangedCallback = []; - -% % this discarded code is to allow a partial edition at intervals -% % in which at least the first selected column is editable -% ind = 1:obj.jtable.getColumnCount; -% NotEditableInd=ind(~colEditable) - 1; % java index -% firstNonColEdit = min(NotEditableInd(NotEditableInd >= col0)); -% if ~isempty(firstNonColEdit) && firstNonColEdit >= col0 && firstNonColEdit < col0 + numCols -% numCols = firstNonColEdit - col0; -% editData = editData(:,1:numCols); -% warning(['The edition was interrupted in column index = ',... -% num2str(firstNonColEdit + 1),' because this column is not editable.']); -% end - - % store old data - oldData = obj.Data; - - % define the indices where to paste the new contents - editedRows = 1 + row0 : row0 + numRows; % matlab indices - editedColumns = 1 + col0 : col0 + numCols; % matlab indices - - % edit in jtable (it could take a few seconds in large tables (> 1000 x 1000 cells)) - if numRows * numCols < 40000 % && numCols > 0 - % reasonable number of edited cells in which double loop is the fastest procedure - for j = 0:numCols-1 - for i = 0:numRows-1 - obj.jtable.setValueAt(editData{i+1,j+1}, i + row0, j + col0); - end - end - obj.isDataModified = true; - % call user callback function - obj.callCellEditCallback(editedRows',editedColumns',oldData,editData,obj.editType); - else % re-set the complete data could be faster than double loop in large tables - % verify that there is no a sort mode, if not return - if (obj.isSortModeActive('paste')) - obj.editType = ''; - obj.tableModel.TableChangedCallback = @obj.cellEdit; % enable default callback - return; - end - newData = oldData; - newData(editedRows,editedColumns) = editData; - obj.Data = newData; - end - - % select edited cells - if numCols > 0 - obj.jtable.setRowSelectionInterval(row0,row0+numRows-1); - obj.jtable.setColumnSelectionInterval(col0,col0+numCols-1); - if numRows * numCols >= 40000, obj.highlightRowHeaders; end - end - - % enable default callback - obj.tableModel.TableChangedCallback = @obj.cellEdit; - - end - - function cut(obj) - % Function to cut the contents of the selected cells in the table.
    t.cut - obj.keyRobot('control','c'); - obj.paste({''}); - end - - function insertRows(obj,direction,varargin) - % Function to insert rows according to the current selection.
    t.insertRows(direction) % where direction is 'above' or 'below' - - % validate inputs (varargin is used only to denote an internal use of this function, - % so the validation in that case is not necessary) - if isempty(varargin), direction = validatestring(direction,{'above','below'}); end - - % verify that all columns are editable and at least one cell is selected - if any(~obj.ColumnEditable) || obj.jtable.getSelectedRow == -1, return; end - - % verify that there is no a sort mode, if not return - if (obj.isSortModeActive('insertRows')), return; end - - % disable default callback (this works in single cell editions) - obj.tableModel.TableChangedCallback = []; - - obj.stopEditing; - - % get the reference where begin the insertion - selectedRows = obj.jtable.getSelectedRows; - if strcmp(direction,'above') - ind = selectedRows(1) - 1; - else%if strcmp('below') - if length(selectedRows) > 1 - ind = selectedRows(end); - else - ind = selectedRows; - end - end - - % store old data - oldData = obj.Data; - - % add empty rows (in the main table as also in the row headers) - n = obj.jtable.getColumnCount; - numAddedRows = length(selectedRows); - for i =1:numAddedRows - obj.rowheader.getModel.insertRow(ind+i,cell(1,1)); - obj.tableModel.insertRow(ind+i,cell(1,n)); - end - - % re-assign the row names if these are numbers, otherwise it is only necessary to store the new empty values - if ischar(obj.info.RowName) %&& strcmpi(obj.info.RowName,'numbered') - obj.RowName = 'numbered'; - else - obj.info.RowName = [obj.info.RowName(1:ind+1);cell(numAddedRows,1);obj.info.RowName(ind+2:end)]; - end - - % select the added rows - obj.jtable.setColumnSelectionInterval(n-1,0); - interval = [selectedRows(1),selectedRows(end)]; - if strcmp(direction,'below'), interval = interval + numAddedRows; end - obj.jtable.setRowSelectionInterval(interval(1),interval(2)); - obj.jtable.scrollRectToVisible(obj.jtable.getCellRect(interval(2),0,true)); - - % call user's callback function - obj.callCellEditCallback(selectedRows+1,[],oldData,{},'RowsInsertion') - - % enable default callback - obj.tableModel.TableChangedCallback = @obj.cellEdit; - end - - function insertColumns(obj,direction,varargin) - % Function to insert columns according to the current selection.
    t.insertColumns(direction) % where direction is 'left' or 'right' - - % validate inputs (varargin is used only to denote an internal use of this function, - % so the validation in that case is not necessary) - if isempty(varargin), direction = validatestring(direction,{'left','right'}); end - - % verify that all columns are editable and at least one cell is selected - if any(~obj.ColumnEditable) || obj.jtable.getSelectedRow == -1, return; end - - obj.editType = 'ColumnsInsertion'; - - % store previous sort mode and unsort if required - %if (obj.isSortModeActive('insertColumns')), return; end - sortMode = obj.SortDirection; - if sortMode ~= 0 - sortedColumn = obj.SortedColumn; - sortedData = obj.Data; - obj.unsort; - end - - % get the reference where begin the insertion - selectedCols = obj.jtable.getSelectedColumns; - if strcmp(direction,'left') - ind = selectedCols(1) - 1; - else%if strcmp('right') - if length(selectedCols) > 1 - ind = selectedCols(end); - else - ind = selectedCols; - end - end - - % store previous data - oldData = obj.Data; - - % update property values (in backup) that depend of the number of columns - numAddedCols = length(selectedCols); - m = obj.jtable.getRowCount; - n = obj.jtable.getColumnCount; - prop = {'ColumnAlign','ColumnFormat','ColumnFormatData','ColumnToolTip','ColumnWidth'}; - val0 = {'center','',{},'',75}; - for k = 1:length(prop) - oldValues = obj.info.(prop{k}); -% % this is to get the vector for all the columns and not a single value -% if ~iscell(oldValues), oldValues = repmat({oldValues},1,n); end - obj.info.(prop{k}) = [oldValues(1:ind+1),repmat(val0(k),1,numAddedCols),oldValues(ind+2:end)]; - end - if ~ischar(obj.info.ColumnName) % && ~strcmpi(obj.info.ColumnName,'numbered') - obj.info.ColumnName = [obj.info.ColumnName(1:ind+1),repmat({''},1,numAddedCols),obj.info.ColumnName(ind+2:end)]; - end - obj.info.ColumnEditable = true(1,n+numAddedCols); - obj.info.ColumnResizable = [obj.info.ColumnResizable(1:ind+1),true(1,numAddedCols),obj.info.ColumnResizable(ind+2:end)]; - obj.info.ColumnSortable = [obj.info.ColumnSortable(1:ind+1),true(1,numAddedCols),obj.info.ColumnSortable(ind+2:end)]; - - % re-assign the data to include the "added columns" (and with it: the renderers, editors, column names, etc.) - % The methods 'addColumn' and 'moveColumn' aren't used because the column indices in the model don't match with the "view indices" - % what could cause a great confusion (the added columns would have the last indices in terms of the model...). In this sense, - % the methods 'convertColumnIndexToView' and 'convertColumnIndexToModel' could help. But, the main reason for not using the - % 'moveColumn' method is because the old column is shifted left or right (randomly?), so we would have to reorder a lot of columns... - obj.Data = [oldData(:,1:ind+1),cell(m,numAddedCols),oldData(:,ind+2:end)]; - - % restore the previous sort mode - if sortMode ~= 0 - if ind + 2 <= sortedColumn, sortedColumn = sortedColumn + numAddedCols; end - obj.sortColumn(sortedColumn,sortMode,'InternalUse'); - oldData = sortedData; - end - - % select the added columns - obj.jtable.setRowSelectionInterval(m-1,0); - interval = [selectedCols(1),selectedCols(end)]; - if strcmp(direction,'right'), interval = interval + numAddedCols; end - obj.jtable.setColumnSelectionInterval(interval(1),interval(2)); - obj.jtable.scrollRectToVisible(obj.jtable.getCellRect(0,interval(2),true)); - obj.rowheader.selectAll; - - % call user's callback function - obj.callCellEditCallback([],selectedCols+1,oldData,{},'ColumnsInsertion'); - end - - function deleteRows(obj) - % Function to delete the selected rows
    t.deleteRows - - % verify that all columns are editable and at least one cell is selected - if any(~obj.ColumnEditable) || obj.jtable.getSelectedRow == -1, return; end - - % disable default callback - obj.tableModel.TableChangedCallback = []; - - obj.stopEditing; - - % get the selected rows (that will be removed) - selectedRows = obj.jtable.getSelectedRows; - numDeletedRows = length(selectedRows); - - % clear selection (this is to avoid conflicts with the selection listeners) - obj.jtable.clearSelection; - - % store old data - oldData = obj.Data; - - % delete the selected rows (in the main table as also in the row headers) - for i = 1:numDeletedRows - indice=obj.jtable.convertRowIndexToModel(selectedRows(1)); - obj.tableModel.removeRow(indice); - obj.rowheader.getModel.removeRow(selectedRows(1)); - end - - % all rows were deleted? let an empty one - if numDeletedRows == size(oldData,1) - obj.rowheader.getModel.insertRow(0,'1'); - obj.tableModel.insertRow(0,cell(1,obj.jtable.getColumnCount)); - end - - % update the 'RowSortIndices' if sort mode is active - if obj.SortedColumn > 0 - m = obj.jtable.getRowCount; - sortedInd = zeros(1,m); - for i = 1:m - sortedInd(i) = 1 + obj.jtable.convertRowIndexToModel(i-1); - end - obj.RowSortIndices = sortedInd; - end - - % call user's callback function - obj.callCellEditCallback(selectedRows+1,[],oldData,{},'RowsDelete'); - - % enable default callback - obj.tableModel.TableChangedCallback = @obj.cellEdit; - end - - function deleteColumns(obj) - % Function to delete the selected columns
    t.deleteColumns - - % verify that all columns are editable and at least one cell is selected - if any(~obj.ColumnEditable) || obj.jtable.getSelectedRow == -1, return; end - - obj.editType = 'ColumnsDelete'; - - % get the selected columns (that will be "removed") - selectedCols = obj.jtable.getSelectedColumns; - numDeletedCols = length(selectedCols); - - % store previous sort mode and unsort if required - %if (obj.isSortModeActive('deleteColumns')), return; end - sortMode = obj.SortDirection; - if sortMode ~= 0 - sortedColumn = obj.SortedColumn; - sortedData = obj.Data; - obj.unsort; - end - - % store previous (unsorted) data - oldData = obj.Data; - -% for i =1:numDeletedCols -% obj.jtable.removeColumn(obj.columnModel.getColumn(selectedCols(1))); -% end - - % update values of the properties (in backup) that can vary from column to column - n = obj.jtable.getColumnCount; - prop = {'ColumnAlign','ColumnFormat','ColumnFormatData','ColumnToolTip','ColumnWidth'}; - val0 = {'center','',{},'',75}; - if numDeletedCols < n - for k = 1:length(prop) - oldValues = obj.info.(prop{k}); -% % this is to get the vector for all the columns and not a single value -% if ~iscell(oldValues), oldValues = repmat({oldValues},1,n); end - obj.info.(prop{k}) = oldValues([1:selectedCols(1),selectedCols(end)+2:end]); - end - - if ~ischar(obj.info.ColumnName) % && ~strcmpi(obj.info.ColumnName,'numbered') - obj.info.ColumnName = obj.info.ColumnName([1:selectedCols(1),selectedCols(end)+2:end]); - end - obj.info.ColumnEditable = true(1,n-numDeletedCols); - obj.info.ColumnResizable = obj.info.ColumnResizable([1:selectedCols(1),selectedCols(end)+2:end]); - obj.info.ColumnSortable = obj.info.ColumnSortable([1:selectedCols(1),selectedCols(end)+2:end]); - - updatedData = oldData(:,[1:selectedCols(1),selectedCols(end)+2:end]); - else % delete all columns ? Nope, let an empty column - for k = 1:length(prop) - obj.info.(prop{k}) = val0{k}; - end - obj.colorFormat = []; - obj.info.ColumnName = 'numbered'; - obj.info.ColumnResizable = true; - obj.info.ColumnSortable = true; - updatedData = cell(obj.jtable.getRowCount,1); - end - - % re-assign the data - obj.Data = updatedData; - - % restore the previous sort mode if it exists provide that the sorted column had not been deleted - % if not, display the unsorted data - if sortMode ~= 0 - if ~ismember(sortedColumn,selectedCols+1) - if sortedColumn >= selectedCols(end)+1 - sortedColumn = sortedColumn - numDeletedCols; - end - obj.sortColumn(sortedColumn,sortMode,'InternalUse'); - oldData = sortedData; - end - end - - % clear selection - obj.rowheader.clearSelection; - - % call user's callback function - obj.callCellEditCallback([],selectedCols+1,oldData,{},'ColumnsDelete'); - end - - end - - % Deconstructor - methods (Static) - function obj = loadInfo(filename) - % Function to redraw the table whose properties were stored in the filename.mat file through the saveInfo function
    t2 = olduitable.loadInfo('filename'); - properties = []; - load(filename,'properties'); % load property values - obj = olduitable(figure,properties(:)); % redraw table in a new figure - end - end - - %% Get/Set methods - methods - % ButtonDownFcn ---------------------------------------------------------------------- - function set.ButtonDownFcn(obj,val) - obj.callbackValidation(val,'ButtonDownFcn'); - obj.ButtonDownFcn = val; - end % get method is not necessary for callbacks properties because these aren't 'Dependent' - - % CellEditCallback ------------------------------------------------------------------- - function set.CellEditCallback(obj,val) - obj.callbackValidation(val,'CellEditCallback'); - obj.CellEditCallback = val; - end - - % CellSelectionCallback ------------------------------------------------------------------- - function set.CellSelectionCallback(obj,val) - obj.callbackValidation(val,'CellSelectionCallback'); - obj.CellSelectionCallback = val; - end - - % ColumnAlign ------------------------------------------------------------------- - function val = get.ColumnAlign(obj) - val = obj.info.ColumnAlign; - end % get.ColumnAlign - - function set.ColumnAlign(obj,val) - % validate input (if table is being built the validation already was done) - if ~obj.inConstruction - obj.columnalignValidation(val,'ColumnAlign'); - val = obj.resize2columncount(obj.jtable.getColumnCount,'center',val); - %[colalign,obj.info.ColumnAlign] = obj.resize2columncount(obj.jtable.getColumnCount,'center',val); - end - - % modify renderer to include the new value - obj.modifyRenderer('setHorizontalAlignment',val); - - % store value in backup - obj.info.ColumnAlign = val; - end % set.ColumnAlign - - % ColumnColor ------------------------------------------------------------------- - function val = get.ColumnColor(obj) - val = obj.info.ColumnColor; - end % get.ColumnColor - - function set.ColumnColor(obj,val) - % validate input - if ~obj.inConstruction, obj.rgbValidation(val,'ColumnColor'); end - - % modify renderer to include the new value - colcolors = single(val); - if strcmpi(obj.info.ColumnStriping,'off') && strcmpi(obj.info.RowStriping,'off') - obj.modifyRenderer('setColumnStriping',false); - elseif strcmpi(obj.info.ColumnStriping,'on') - obj.modifyRenderer('setColumnColor',colcolors); - end - - % store value in backup - obj.info.ColumnColor = val; - end % set.ColumnColor - - % ColumnEditable ------------------------------------------------------------------- - function val = get.ColumnEditable(obj) - val = obj.info.ColumnEditable; - if ~islogical(val), val = logical(val); end - end % get.ColumnEditable - - function set.ColumnEditable(obj,val) - % validate input - if ~obj.inConstruction - obj.binaryValidation(val,'ColumnEditable'); - if isscalar(obj.uniqueValue(val)) - val = repmat(val(1),1,obj.jtable.getColumnCount); - else - val = obj.resizelogical2columns(obj.jtable.getColumnCount,false,val); - end - %[coleditable,obj.info.ColumnEditable] = obj.resizelogical2columns(n,false,val); - end - - % assign the column editable property value - for j = 1:obj.jtable.getColumnCount - obj.tableModel.setColumnEditable(j-1,val(j)); - end - - % enable/disable items of the default context menu if it is assigned - if strcmpi(obj.UIContextMenu,'auto') - items = obj.defaultContextMenu.getComponents; - if all(logical(val)) - for i = 1:length(items), items(i).setEnabled(true); end - else - for i = 5:length(items), items(i).setEnabled(false); end - end - end - - % store value in backup - obj.info.ColumnEditable = val; - end % set.ColumnEditable - - % ColumnFormat ------------------------------------------------------------------- - function val = get.ColumnFormat(obj) - val = obj.info.ColumnFormat; - end % get.ColumnFormat - - function set.ColumnFormat(obj,val) - % validate input - n = obj.jtable.getColumnCount; - if ~obj.inConstruction - obj.columnformatValidation(val,'ColumnFormat'); - val = obj.resize2columncount(n,'',val); - %[colformat,obj.info.ColumnFormat] = obj.resize2columncount(n,'',val); - end - columnformat = val; - - % reset colorFormat parameter - obj.colorFormat = false(1,n); - - % retrive property values if required (in case that column renderer is not suitable for the assigned format) - colalign = obj.info.ColumnAlign; - colformatdata = obj.info.ColumnFormatData; - data = obj.Data; - args = {strcmpi(obj.info.RowStriping,'on'),strcmpi(obj.info.ColumnStriping,'on'),... - single(obj.info.RowColor),single(obj.info.ColumnColor),... - obj.rgb2java(obj.char2rgb(obj.info.SelectionBackground)),... - obj.rgb2java(obj.char2rgb(obj.info.SelectionBorderColor)),... - obj.rgb2java(obj.char2rgb(obj.info.SelectionForeground))}; - - % loop in all columns - for j = 1:n - column = obj.columnModel.getColumn(j-1); - cr = column.getCellRenderer; - if strcmpi(columnformat{j},'color') - obj.colorFormat(j) = true; - if isa(cr,'asd.fgh.olduitable.ColorCellRenderer'), continue; end - if isempty(obj.colorEditor.cellbutton), loadColorPicker(obj); end - column.setCellEditor(asd.fgh.olduitable.ColorCellEditor(obj.colorEditor.cellbutton)); - column.setCellRenderer(asd.fgh.olduitable.ColorCellRenderer); - elseif strcmpi(columnformat{j},'logical') - if ~isa(cr,'asd.fgh.olduitable.CheckBoxRenderer') - column.setCellRenderer(asd.fgh.olduitable.CheckBoxRenderer(args{1:end-1})); - end - column.setCellEditor(javax.swing.DefaultCellEditor(asd.fgh.olduitable.CheckBoxRenderer)); - else - % verify renderer's assignment - if ~isa(cr,'asd.fgh.olduitable.CellRenderer') - cr = asd.fgh.olduitable.CellRenderer(args{:}); - cr.setHorizontalAlignment(colalign{j}); - end - - % verify editor's assignment - if strcmpi(columnformat{j},'longchar') - if ~isa(column.getCellEditor,'asd.fgh.olduitable.LongTextCellEditor') - if isempty(obj.longcharEditor.cellbutton), loadTextArea(obj); end - column.setCellEditor(asd.fgh.olduitable.LongTextCellEditor(obj.longcharEditor.cellbutton)); - end - elseif strcmpi(columnformat{j},'popup') - if isempty(colformatdata{j}) - if iscellstr(data(:,j)) - colformatdata{j} = data(:,j); - elseif all(cellfun(@(x)isnumeric(x) || ischar(x),data(:,j))) - colformatdata{j} = cellfun(@num2str,data(:,j),'UniformOutput',false); - end - obj.info.ColumnFormatData{j} = colformatdata{j}; - end - obj.assignPopupList(j,colformatdata{j}); - else - if strcmpi(columnformat{j},'bank') - columnformat{j} = '%.2f'; - elseif strcmpi(columnformat{j},'char') - columnformat{j} = '%s'; - end - cr.setColumnFormat(columnformat{j}); - column.setCellEditor(asd.fgh.olduitable.CellEditor(colalign{j})); - end - - % update the renderer - column.setCellRenderer(cr); - end - end - - % repaint the table to include the changes - obj.jtable.repaint; - - % store value in backup - obj.info.ColumnFormat = val; - end % set.ColumnFormat - - % ColumnFormatData ------------------------------------------------------------------- - function val = get.ColumnFormatData(obj) - val = obj.info.ColumnFormatData; - end % get.ColumnFormat - - function set.ColumnFormatData(obj,val) - % validate input - n = obj.jtable.getColumnCount; - if ~obj.inConstruction - obj.colformatdataValidation(val,'ColumnFormatData'); - val = obj.resize2columncount(n,{},val); - end - - % assign the popup list (if ColumnFormat corresponds to 'popup') - ind = 1:n; - ind = ind(~cellfun(@isempty,val)); - columnformat = obj.info.ColumnFormat; - for j = ind - if strcmpi(columnformat{j},'popup') - %if ~isequal(sort(obj.info.ColumnFormatData{j}),sort(val{j})) - obj.assignPopupList(j,val{j}); - %end - else - warning('%s\n',['The format of the column in the index = ',num2str(j),' is not equal to ''popup''.'],... - 'Change the ''Columnformat'' for this column so that ''ColumnFormatData'' takes effect.'); - end - end - - % store value in backup - obj.info.ColumnFormatData = val; - end % set.ColumnFormat - - % ColumnName ------------------------------------------------------------------- - function val = get.ColumnName(obj) - val = obj.info.ColumnName; - end % get.ColumnName - - function set.ColumnName(obj,val) - % validate input - if ~obj.inConstruction, obj.headerNamesValidation(val,'ColumnName'); end - if ~ischar(val) && iscolumn(val), val = val'; end - - n = obj.jtable.getColumnCount; - d = obj.columnHeader.getPreferredSize; - - % assign the new column headers - if isempty(val) - d.height = 0; - else - newlines = 0; - if ischar(val) %&& strcmpi(val,'numbered') - colnames = obj.num2cellstr(1:n); - for j = 1:n - obj.columnModel.getColumn(j-1).setHeaderValue(colnames{j}); %num2str(j) - end - else - val = obj.resize2columncount(n,'',val); - colnames = val; - - % define a multiline column name if the vertical slash (|) is included - %ind = cellfun(@(x)~isempty(x),strfind(lower(colnames),'|')); - %colnames = cellfun(@(x)strrep(x,'|','
    '),colnames,'UniformOutput',false); - for j = 1:n - ind = strfind(colnames{j},'|'); - if ~isempty(ind) - colnames{j} = ['
    ',strrep(colnames{j},'|','
    ')]; - newlines = max(newlines,length(ind)); -% else -% ind = strfind(lower(colnames{j}),' or
    instead
    - end - - % update the column header's height according to the line count - if newlines == 0 - d.height = 24; - else - %d.height = 1.2*obj.fontMetrics.getHeight*(1+newlines); % line-height~1.2xfontHeight - d.height = 1.2*16*(1+newlines); - end - end - - % change the column header's height if necessary - if ~isequal(d.height,obj.theaderHeight) - obj.theaderHeight = d.height; - obj.columnHeader.getParent.setPreferredSize(d); - obj.columnHeader.revalidate; - end - - % update current view - obj.columnHeader.repaint; - - % store new value in backup - obj.info.ColumnName = val; - end % set.ColumnName - - % ColumnResizable ------------------------------------------------------------------- - function val = get.ColumnResizable(obj) - val = obj.info.ColumnResizable; - if ~islogical(val), val = logical(val); end - end % get.ColumnResizable - - function set.ColumnResizable(obj,val) - % validate input - if ~obj.inConstruction - obj.binaryValidation(val,'ColumnResizable'); - val = obj.resizelogical2columns(obj.jtable.getColumnCount,true,val); - %[colresizable,obj.info.ColumnResizable] = obj.resizelogical2columns(obj.jtable.getColumnCount,true,val); - end - - % assign the new value - for j = 1:obj.jtable.getColumnCount - column = obj.columnModel.getColumn(j-1); - column.setResizable(val(j)); - end - - % store new value in backup - obj.info.ColumnResizable = val; - end % set.ColumnResizable - - % ColumnSortable ------------------------------------------------------------------- - function val = get.ColumnSortable(obj) - val = obj.info.ColumnSortable; - if ~islogical(val), val = logical(val); end - end % get.ColumnSortable - - function set.ColumnSortable(obj,val) - % validate input and store in backup - if ~obj.inConstruction - obj.binaryValidation(val,'ColumnSortable'); - obj.info.ColumnSortable = obj.resizelogical2columns(obj.jtable.getColumnCount,true,val); - %[colsortable,obj.info.ColumnSortable] = obj.resizelogical2columns(obj.jtable.getColumnCount,true,val); - end - end % set.ColumnSortable - - % ColumnStriping ------------------------------------------------------------------- - function val = get.ColumnStriping(obj) - val = obj.info.ColumnStriping; - end % get.ColumnStriping - - function set.ColumnStriping(obj,val) - % validate input - if ~obj.inConstruction, obj.onoffValidation(val,'ColumnStriping'); end - - % store value in backup - obj.info.ColumnStriping = val; - - % modify renderer to include the new value - obj.modifyRenderer('setColumnStriping',strcmpi(val,'on')); - - % reassign the 'ColumnColor' property (really, it's only necessary if value is 'on') - if ~obj.inConstruction, obj.ColumnColor = obj.info.ColumnColor; end - end % set.ColumnStriping - - % ColumnToolTip ------------------------------------------------------------------- - function val = get.ColumnToolTip(obj) - val = obj.info.ColumnToolTip; - end % get.ColumnToolTip - - function set.ColumnToolTip(obj,val) - % validate input - if ~obj.inConstruction - obj.tooltipsValidation(val,'ColumnToolTip'); - val = obj.resize2columncount(obj.jtable.getColumnCount,'',val); - end - - % define a multiline column tooltip if the vertical slash (|) is included - for j = 1:obj.jtable.getColumnCount - ind = strfind(val{j},'|'); - if ~isempty(ind) - val{j} = ['',strrep(val{j},'|','
    ')]; - end - end - - % update the column tooltips - obj.columnHeader.setColumnToolTips(val); - - % store value in backup - obj.info.ColumnToolTip = val; - end % set.ColumnStriping - - % ColumnWidth ------------------------------------------------------------------- - function val = get.ColumnWidth(obj) - if obj.jtable.getAutoResizeMode == 0 - val = obj.info.ColumnWidth; - else%if obj.jtable.getAutoResizeMode == 4 % ('AUTO_RESIZE_ALL_COLUMNS') - val = cell(1,obj.jtable.getColumnCount); - for j = 1:obj.jtable.getColumnCount - column = obj.columnModel.getColumn(j-1); - val{j}=column.getWidth; - end - end - %val = obj.uniqueValue(val); % display the unique value if it exists and not the cell array - end % get.ColumnWidth - - function set.ColumnWidth(obj,val) - % validate input - if ~obj.inConstruction - obj.columnwidthValidation(val,'ColumnWidth'); - val = obj.resize2columncount(obj.jtable.getColumnCount,75,val); - %[colwidth,obj.info.ColumnWidth] = obj.resize2columncount(obj.jtable.getColumnCount,75,val); - end - - % assign column widths - obj.jtable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); - for j = 1:obj.jtable.getColumnCount - column = obj.columnModel.getColumn(j-1); - column.setPreferredWidth(val{j}); - end - - % store value in backup - obj.info.ColumnWidth = val; - end % set.ColumnWidth - - % Data ------------------------------------------------------------------- - function val = get.Data(obj) - val = obj.getDataInModel(obj.tableModel); - if ~isempty(obj.RowSortIndices), val = val(obj.RowSortIndices,:); end - end % get.Data - - function set.Data(obj,val) - % validate input - if ~obj.inConstruction, obj.dataValidation(val,'Data'); end - - % convert value to a cell array - if isnumeric(val) || islogical(val), val = num2cell(val); end - - % reset the sort status - obj.SortDirection = 0; - obj.SortedColumn = 0; - obj.RowSortIndices = []; - - % disable 'TableChangedCallback' - obj.tableModel.TableChangedCallback = []; - - % set the new data in the table and update the row header - m = size(val,1); - n = size(val,2); - if n ~= obj.jtable.getColumnCount, obj.tableModel.resizeEditableArray(n); end - obj.tableModel.setDataVector(val,repmat({' '},1,n)); drawnow; - if m ~= obj.rowheader.getRowCount, obj.rowheader.getModel.setRowCount(m); end; drawnow - - % reassign comparators for the sorter - obj.sorter.setComparators; - - % update properties that can depend of the table size (really, if we use - % 'setRowCount' + 'setValueAt' methods and the column count doesn't change, - % the custom renderers and editors (in columns) won't be deleted, but 'setDataVector' - % is a more direct and often faster method, even with these reassignments, so ....) - if ~obj.inConstruction - if m ~= length(obj.rownames), obj.RowName = obj.info.RowName; end - obj.ColumnName = obj.info.ColumnName; - reAssignRenderers_Editors(obj); - obj.ColumnEditable = obj.info.ColumnEditable; - obj.ColumnResizable = obj.info.ColumnResizable; - obj.ColumnSortable = obj.info.ColumnSortable; - obj.ColumnToolTip = obj.info.ColumnToolTip; - if obj.jtable.getAutoResizeMode ~= 4, obj.ColumnWidth = obj.info.ColumnWidth; end - - % check if method wasn't called from another (such as insertColumns, deleteColumns, etc.) - if isempty(obj.editType) - obj.rememberSelection; % restore previous selection - else - obj.editType = ''; - end - end - - % enable 'TableChangedCallback' - obj.tableModel.TableChangedCallback = @obj.cellEdit; - end % set.Data - - % Enable ------------------------------------------------------------------- - function val = get.Enable(obj) - val = obj.info.Enable; - end % get.Enable - - function set.Enable(obj,val) - % validate input - if ~obj.inConstruction, obj.onoffValidation(val,'Enable'); end - flag = strcmpi(val,'on'); - - % enable or disable the java components - obj.stopEditing; - obj.jtable.setEnabled(flag); - obj.rowheader.setEnabled(flag); - obj.columnHeader.setEnabled(flag); - obj.jscrollpane.getVerticalScrollBar.setEnabled(flag); - obj.jscrollpane.getHorizontalScrollBar.setEnabled(flag); - - % enable or disable the 'ColumnToolTip' and 'UIContextMenu' properties - if flag - if ~obj.inConstruction - obj.ColumnToolTip = obj.info.ColumnToolTip; - obj.UIContextMenu = obj.info.UIContextMenu; - end - else - obj.columnHeader.setColumnToolTips({}); - obj.jtable.setComponentPopupMenu([]); - end - - % store value in backup - obj.info.Enable = val; - end % set.Enable - - % FontName ------------------------------------------------------------------- - function val = get.FontName(obj) - % val = obj.info.FontName; - val = char(obj.jtable.getFont.getFontName); - end % get.FontName - - function set.FontName(obj,val) - % validate input - if ~obj.inConstruction, obj.fontnameValidation(val,'FontName'); end - - % get the currrent font in jtable and update value - font = obj.jtable.getFont; - font = java.awt.Font(val,font.getStyle,font.getSize); - - % set value in the body - obj.jtable.setFont(font); - %obj.rowheader.setFont(font); - - % store value in backup - obj.info.FontName = val; - - % update rowheight if the 'auto' value is assigned - obj.fontMetrics = obj.jtable.getFontMetrics(font); - if ischar(obj.info.RowHeight), obj.RowHeight = obj.info.RowHeight; end - end % set.FontName - - % FontSize ------------------------------------------------------------------- - function val = get.FontSize(obj) - val = obj.info.FontSize; - end % get.FontSize - - function set.FontSize(obj,val) - % validate input - if ~obj.inConstruction, obj.fontsizeValidation(val,'FontSize'); end - val = round(val); % round val to the nearest integer - - % get the currrent font in jtable and update value - font = obj.jtable.getFont; - font = java.awt.Font(font.getName,font.getStyle,val); - - % set value in the body - obj.jtable.setFont(font); - %obj.rowheader.setFont(font); - - % store value in backup - obj.info.FontSize = val; - - % update rowheight if the 'auto' value is assigned - obj.fontMetrics = obj.jtable.getFontMetrics(font); - if ischar(obj.info.RowHeight), obj.RowHeight = obj.info.RowHeight; end - end % set.FontSize - - % FontStyle ------------------------------------------------------------------- - function val = get.FontStyle(obj) - val = obj.info.FontStyle; - if isnumeric(val) - if val == 0 - val = 'normal'; - elseif val == 1 - val = 'bold'; - elseif val == 2 - val = 'italic'; - else%if val == 3 - val = 'bold italic'; - end - end - end % get.FontStyle - - function set.FontStyle(obj,val) - % validate input - if ~obj.inConstruction, obj.fontstyleValidation(val,'FontStyle'); end - if ischar(val) - if strcmpi(val,'normal') - val = 0; - elseif strcmpi(val,'bold') - val = 1; - elseif strcmpi(val,'italic') - val = 2; - else%if strcmpi(val,'bold italic') - val = 3;% java.awt.Font.BOLD + java.awt.Font.ITALIC - end - end - - % get the currrent font in jtable and update value - font = obj.jtable.getFont; - font = java.awt.Font(font.getName,val,font.getSize); - - % set value in the body - obj.jtable.setFont(font); - %obj.rowheader.setFont(font); - - % store value in backup - obj.info.FontStyle = val; - end % set.FontStyle - - % ForegroundColor ------------------------------------------------------------------- - function val = get.ForegroundColor(obj) - val = obj.info.ForegroundColor; - end % get.ForegroundColor - - function set.ForegroundColor(obj,val) - % validate input - if ~obj.inConstruction, obj.colorValidation(val,'ForegroundColor'); end - rgbColor = obj.char2rgb(val); - - % assign value in the table - obj.jtable.setForeground(obj.rgb2java(rgbColor)); - - % store value in backup - obj.info.ForegroundColor = rgbColor; - end % set.ForegroundColor - - % GridColor ------------------------------------------------------------------- - function val = get.GridColor(obj) - val = obj.info.GridColor; - end % get.GridColor - - function set.GridColor(obj,val) - % validate input - if ~obj.inConstruction, obj.colorValidation(val,'GridColor'); end - rgbColor = obj.char2rgb(val); - - % assign value in the table - obj.jtable.setGridColor(obj.rgb2java(rgbColor)); - - % store value in backup - obj.info.GridColor = rgbColor; - end % set.GridColor - - % HeaderBackground ------------------------------------------------------------------- - function val = get.HeaderBackground(obj) - val = obj.info.HeaderBackground; - end % get.HeaderBackground - - function set.HeaderBackground(obj,val) - % validate input - if ~obj.inConstruction, obj.colorValidation(val,'HeaderBackground'); end - rgbColor = obj.char2rgb(val); - javaColor = obj.rgb2java(rgbColor); - - % modify headers' renderers and corner background - obj.modifyHeadersRenderer('setBackgroundColor',javaColor); - obj.corner.setBackground(javaColor); - - % store value in backup - obj.info.HeaderBackground = rgbColor; - end % set.HeaderBackground - - % HeaderForeground ------------------------------------------------------------------- - function val = get.HeaderForeground(obj) - val = obj.info.HeaderForeground; - end % get.HeaderForeground - - function set.HeaderForeground(obj,val) - % validate input - if ~obj.inConstruction, obj.colorValidation(val,'HeaderForeground'); end - rgbColor = obj.char2rgb(val); - - % modify headers' renderers to include the new value - obj.modifyHeadersRenderer('setForegroundColor',obj.rgb2java(rgbColor)); - - % store value in backup - obj.info.HeaderForeground = rgbColor; - end % set.HeaderForeground - - % HeaderGridColor ------------------------------------------------------------------- - function val = get.HeaderGridColor(obj) - val = obj.info.HeaderGridColor; - end % get.HeaderGridColor - - function set.HeaderGridColor(obj,val) - % validate input - if ~obj.inConstruction, obj.colorValidation(val,'HeaderGridColor'); end - rgbColor = obj.char2rgb(val); - javaColor = obj.rgb2java(rgbColor); - - % set value for the row headers - obj.rowheader.setGridColor(javaColor); - - % set value for the column headers - columnheaderRenderer = obj.columnHeader.getDefaultRenderer; - columnheaderRenderer.setGridColor(javaColor); - obj.columnHeader.setDefaultRenderer(columnheaderRenderer); - obj.columnHeader.repaint; - - % set value for the corner - border = javax.swing.border.CompoundBorder(... - javax.swing.border.MatteBorder(0,0,1,1,javaColor),javax.swing.border.EmptyBorder(0,0,-1,2)); - obj.corner.setBorder(border); - - % store value in backup - obj.info.HeaderGridColor = rgbColor; - end % set.HeaderGridColor - - % HeaderSelectionBg ------------------------------------------------------------------- - function val = get.HeaderSelectionBg(obj) - val = obj.info.HeaderSelectionBg; - end % get.HeaderSelectionBg - - function set.HeaderSelectionBg(obj,val) - % validate input - if ~obj.inConstruction, obj.colorValidation(val,'HeaderSelectionBg'); end - rgbColor = obj.char2rgb(val); - javaColor = obj.rgb2java(rgbColor); - - % modify headers' renderers and corner to include the new value - obj.modifyHeadersRenderer('setSelectionBgcolor',javaColor); - obj.corner.setForeground(javaColor); - - % store value in backup - obj.info.HeaderSelectionBg = rgbColor; - end % set.HeaderSelectionBg - - % HeaderSelectionFg ------------------------------------------------------------------- - function val = get.HeaderSelectionFg(obj) - val = obj.info.HeaderSelectionFg; - end % get.HeaderSelectionFg - - function set.HeaderSelectionFg(obj,val) - % validate input - if ~obj.inConstruction, obj.colorValidation(val,'HeaderSelectionFg'); end - rgbColor = obj.char2rgb(val); - - % modify headers' renderers to include the new value - obj.modifyHeadersRenderer('setSelectionFgcolor',obj.rgb2java(rgbColor)); - - % store value in backup - obj.info.HeaderSelectionFg = rgbColor; - end % set.HeaderSelectionFg - - % KeyPressFcn ------------------------------------------------------------------- - function set.KeyPressFcn(obj,val) - obj.callbackValidation(val,'KeyPressFcn'); - obj.KeyPressFcn = val; - end - - % KeyReleaseFcn ------------------------------------------------------------------- - function set.KeyReleaseFcn(obj,val) - obj.callbackValidation(val,'KeyReleaseFcn'); - obj.KeyReleaseFcn = val; - end - - % Parent ------------------------------------------------------------------- - function val = get.Parent(obj) - val = obj.cont.Parent; - end % get.Parent - - function set.Parent(obj,val) - if ~obj.inConstruction, obj.parentValidation(val,'Parent'); end - obj.cont.Parent = val; - end % set.Parent - - % Position ------------------------------------------------------------------- - function val = get.Position(obj) - val = obj.cont.Position; - end % get.Position - - function set.Position(obj,val) - if ~obj.inConstruction, obj.positionValidation(val,'Position'); end - obj.cont.Position = val; - obj.info.Position = val; - end % set.Position - - % RowColor ------------------------------------------------------------------- - function val = get.RowColor(obj) - val = obj.info.RowColor; - end % get.RowColor - - function set.RowColor(obj,val) - % validate input - if ~obj.inConstruction, obj.rgbValidation(val,'RowColor'); end - rowcolors = single(val); - - % modify renderer to include the new value - if strcmpi(obj.info.RowStriping,'on') - obj.modifyRenderer('setRowColor',rowcolors); - else - if ~isequal(rowcolors(1,:),[1 1 1]) - obj.modifyRenderer('setRowColor',rowcolors(1,:)); - end - end - - % store value in backup - obj.info.RowColor = val; - end % set.RowColor - - % RowHeight ------------------------------------------------------------------- - function val = get.RowHeight(obj) - val = obj.info.RowHeight; - end % get.RowHeight - - function set.RowHeight(obj,val) - % validate input - if ~obj.inConstruction, obj.rowheightValidation(val,'RowHeight'); end - - % define row height and round to the nearest integer - if strcmpi(val,'auto') - %rowHeight = round(obj.info.FontSize*20/12); - rowHeight = round(1.25*obj.fontMetrics.getHeight); - else - val = round(val); - rowHeight = val; - end - - % assign value in main table and row headers - obj.jtable.setRowHeight(rowHeight); - obj.rowheader.setRowHeight(rowHeight); - - % store value in backup - obj.info.RowHeight = val; - end % set.RowHeight - - % RowName ------------------------------------------------------------------- - function val = get.RowName(obj) - if ~isempty(obj.rownames) && (obj.SortDirection ~= 0 || obj.jtable.getRowCount < length(obj.rownames)) - val = obj.getDataInModel(obj.rowheader.getModel); - else - val = obj.info.RowName; - end - end % get.RowName - - function set.RowName(obj,val) - % validate input - if ~obj.inConstruction, obj.headerNamesValidation(val,'RowName'); end - m = obj.jtable.getRowCount; - if ~ischar(val) && isrow(val), val = val'; end - - % define row headers and their widths - if isempty(val) - obj.rownames = {}; - rnames = repmat({''},m,1); - width = 0; - else - if ischar(val) && strcmpi(val,'numbered') - rnames = obj.num2cellstr(1:m)'; - % define the width that fits the content of the row header (this implies getting the string width of the largest number) - width = 10 + javax.swing.SwingUtilities.computeStringWidth(obj.fontMetricsHeaders,rnames{m}); - else - val = obj.resize2columncount(m,'',val')'; - rnames = val; - width = max(15,10 + max(cellfun(@(x)javax.swing.SwingUtilities.computeStringWidth(obj.fontMetricsHeaders,x),rnames))); - end - obj.rownames = rnames; % store values shown on the screen - end - - % assign row headers - obj.rowheader.getModel.setDataVector(rnames,' '); - - % assign row header width - if ~isequal(width,obj.rheaderWidth) - obj.rheaderWidth = width; - d2 = obj.rowheader.getPreferredSize; - d2.width = width; - obj.rowheader.setPreferredScrollableViewportSize(d2); - end - - % update view - obj.rowheader.getModel.fireTableDataChanged; - obj.highlightRowHeaders; - - % store value in backup - obj.info.RowName = val; - end % set.RowName - - % RowStriping ------------------------------------------------------------------- - function val = get.RowStriping(obj) - val = obj.info.RowStriping; - end % get.RowStriping - - function set.RowStriping(obj,val) - % validate input - if ~obj.inConstruction, obj.onoffValidation(val,'RowStriping'); end - - % store value in backup - obj.info.RowStriping = val; - - % modify renderer to include the new value - obj.modifyRenderer('setRowStriping',strcmpi(val,'on')); - - % re-assign the row colors if required - if ~obj.inConstruction - if strcmpi(val,'on'), obj.RowColor = obj.info.RowColor; end - end - end % set.RowStriping - - % SelectionBackground ------------------------------------------------------------------- - function val = get.SelectionBackground(obj) - val = obj.info.SelectionBackground; - end % get.SelectionBackground - - function set.SelectionBackground(obj,val) - % validate input - if ~obj.inConstruction, obj.colorValidation(val,'SelectionBackground'); end - rgbColor = obj.char2rgb(val); - - % modify renderer to include the new value - obj.modifyRenderer('setSelectionBgColor',obj.rgb2java(rgbColor)); - - % store value in backup - obj.info.SelectionBackground = rgbColor; - end % set.SelectionBackground - - % SelectionForeground ------------------------------------------------------------------- - function val = get.SelectionForeground(obj) - val = obj.info.SelectionForeground; - end % get.SelectionForeground - - function set.SelectionForeground(obj,val) - % validate input - if ~obj.inConstruction, obj.colorValidation(val,'SelectionForeground'); end - rgbColor = obj.char2rgb(val); - - % modify renderer to include the new value - obj.modifyRenderer('setSelectionFgColor',obj.rgb2java(rgbColor)); - - % store value in backup - obj.info.SelectionForeground = rgbColor; - end % set.SelectionForeground - - % SelectionBorderColor ------------------------------------------------------------------- - function val = get.SelectionBorderColor(obj) - val = obj.info.SelectionBorderColor; - end % get.SelectionBorderColor - - function set.SelectionBorderColor(obj,val) - % validate input - if ~obj.inConstruction, obj.colorValidation(val,'SelectionBorderColor'); end - rgbColor = obj.char2rgb(val); - - % modify renderer to include the new value - obj.modifyRenderer('setSelectionBorderColor',obj.rgb2java(rgbColor)); - - % store value in backup - obj.info.SelectionBorderColor = rgbColor; - end % set.SelectionBorderColor - - % Tag ------------------------------------------------------------------- - function val = get.Tag(obj) - val = obj.cont.Tag; - end % get.Tag - - function set.Tag(obj,val) - if ~obj.inConstruction, obj.tagValidation(val,'Visible'); end - obj.cont.Tag = val; - obj.info.Tag = val; - end % set.Tag - - % UIContextMenu ------------------------------------------------------------------- - function val = get.UIContextMenu(obj) - val = obj.info.UIContextMenu; - end % get.UIContextMenu - - function set.UIContextMenu(obj,val) - % validate input - if ~obj.inConstruction, obj.jpopupValidation(val,'UIContextMenu'); end - - % assign context menu - if ischar(val) && strcmpi(val,'auto') - if isempty(obj.defaultContextMenu), loadDefaultContextMenu(obj); end - obj.jtable.setComponentPopupMenu(obj.defaultContextMenu); - else - obj.jtable.setComponentPopupMenu(val); - end - - % store value in backup - obj.info.UIContextMenu = val; - end % set.UIContextMenu - - % Units ------------------------------------------------------------------- - function val = get.Units(obj) - val = obj.cont.Units; - end % get.Units - - function set.Units(obj,val) - if ~obj.inConstruction, obj.unitsValidation(val,'Units'); end - obj.cont.Units = val; - obj.info.Units = val; - obj.info.Position = obj.cont.Position; % update position according to new units - end % set.Units - - % UserData ------------------------------------------------------------------- - function val = get.UserData(obj) - val = obj.cont.UserData; - end % get.UserData - - function set.UserData(obj,val) - obj.cont.UserData = val; - end % set.UserData - - % Visible ------------------------------------------------------------------- - function val = get.Visible(obj) - val = obj.cont.Visible; - end % get.Visible - - function set.Visible(obj,val) - if ~obj.inConstruction, obj.onoffValidation(val,'Visible'); end - obj.cont.Visible = val; - obj.info.Visible = val; - end % set.Visible - - % Extent ------------------------------------------------------------------- - function val = get.Extent(obj) - tableSize = obj.jtable.getPreferredSize; - val = [tableSize.width+obj.rowheader.getPreferredScrollableViewportSize.width+4,... - tableSize.height+obj.columnHeader.getParent.getPreferredSize.height+4]; - end % get.Extent - end - - % utility functions to facilitate the update of the renderers - methods (Access = private, Hidden) - % this function modifies the renderers according to the new user assignments - function modifyRenderer(obj,method,value) - % exclude the columns with a 'color' format (these have a non-editable renderer) - ind = 1:obj.jtable.getColumnCount; - if ~isempty(obj.colorFormat), ind = ind(~obj.colorFormat); end - columnFormat = obj.info.ColumnFormat; - - % loop in the columns with a customizable renderer - for j = ind - % verify renderer and validity of method - column = obj.columnModel.getColumn(j-1); - cr = column.getCellRenderer; - if strcmp(columnFormat{j},'logical') - if ismember(method,{'setHorizontalAlignment','setSelectionFgColor'}) - continue; % these properties don't apply for the 'logical' format - elseif ~isa(cr,'asd.fgh.olduitable.CheckBoxRenderer') - cr = asd.fgh.olduitable.CheckBoxRenderer; - end - elseif isempty(cr) % assign a renderer if the column doesn't have - cr = asd.fgh.olduitable.CellRenderer; - end - - % modify renderer - if ~iscell(value) % is the value the same for all columns? - cr.(method)(value); - else - cr.(method)(value{j}); - end - - % assign modified renderer - column.setCellRenderer(cr); - end - - % update the current view - obj.jtable.repaint; - end - - % this function reassigns the renderers and editors. - % It applies when new data is established (and editors and renderers are removed) - function reAssignRenderers_Editors(obj) - % retrieve property values for renderers - n = obj.jtable.getColumnCount; - %if ~iscell(colalign), colalign = repmat({colalign},1,n); end - colalign = obj.resize2columncount(n,'center',obj.info.ColumnAlign); - columnformat = obj.resize2columncount(n,'',obj.info.ColumnFormat); - args = {strcmpi(obj.info.RowStriping,'on'),strcmpi(obj.info.ColumnStriping,'on'),... - single(obj.info.RowColor),single(obj.info.ColumnColor),... - obj.rgb2java(obj.char2rgb(obj.info.SelectionBackground)),... - obj.rgb2java(obj.char2rgb(obj.info.SelectionBorderColor)),... - obj.rgb2java(obj.char2rgb(obj.info.SelectionForeground))}; - - % exclude the columns with a 'color' format - ind = 1:n; - if ~isempty(obj.colorFormat) - obj.colorFormat = obj.resizelogical2columns(n,false,obj.colorFormat); - ind = ind(~obj.colorFormat); - end - - % loop in the columns to reassign the renderers - for j = ind - column = obj.columnModel.getColumn(j-1); - if ~strcmpi(columnformat{j},'logical') - cr = asd.fgh.olduitable.CellRenderer(args{:}); - cr.setHorizontalAlignment(colalign{j}); - else - cr = asd.fgh.olduitable.CheckBoxRenderer(args{1:end-1}); - end - column.setCellRenderer(cr); - end - - % store - obj.info.ColumnAlign = colalign; - - % reassign special renderers and all editors - obj.ColumnFormat = columnformat; - end - - % this function modifies the headers renderer (for columns and rows) according to the new user assignments - function modifyHeadersRenderer(obj,method,value) - % retrive the current renderers - objectClass = obj.rowheader.getColumnClass(0); - rowheaderRenderer = obj.rowheader.getDefaultRenderer(objectClass); - columnheaderRenderer = obj.columnHeader.getDefaultRenderer; - - % modify renderer - rowheaderRenderer.(method)(value); - columnheaderRenderer.(method)(value); - - % assign modified renderer - obj.rowheader.setDefaultRenderer(objectClass,rowheaderRenderer); - obj.columnHeader.setDefaultRenderer(columnheaderRenderer); - - % update the current view - obj.columnHeader.repaint; - obj.rowheader.repaint; - end - - function assignPopupList(obj,columnIndex,list) - cb = javax.swing.JComboBox(unique(list)); - obj.columnModel.getColumn(columnIndex-1).setCellEditor(javax.swing.DefaultCellEditor(cb)); - end - end - - %% Default context menu, color picker and longchar editor - methods (Access = private, Hidden) - % Default context menu ----------------------------------------------------------------------------------- - - % function that creates the default context menu associated to the table - function loadDefaultContextMenu(obj) - % create a 'javax.swing.JPopupMenu' component - contextMenu = javaObjectEDT('javax.swing.JPopupMenu'); - obj.defaultContextMenu = handle(contextMenu,'CallbackProperties'); - - % define labels for the items - labels = {'Cut','Copy','Paste','Clear Contents','Insert Row(s) Above','Insert Row(s) Below',... - 'Insert Column(s) to the Left','Insert Column(s) to the Right','Delete Row(s)','Delete Column(s)'}; - - % define callbacks - actions = {@(~,~)obj.cut,@(~,~)obj.keyRobot('control','c'),@(~,~)obj.paste,@(~,~)obj.paste({''}),... - @(~,~)obj.insertRows('above','InternalUse'),@(~,~)obj.insertRows('below','InternalUse'),... - @(~,~)obj.insertColumns('left','InternalUse'),@(~,~)obj.insertColumns('right','InternalUse'),... - @(~,~)obj.deleteRows,@(~,~)obj.deleteColumns}; - - % define keyboard shortcuts - keyCode = [88,67,86,127,38,40,37,39,45,8]; - modifier = [2,2,2,0,8,8,8,8,2,2]; - - % create items and assign properties - for i = 1:length(labels) - item = handle(javax.swing.JMenuItem(labels{i}),'CallbackProperties'); - item.setAccelerator(javax.swing.KeyStroke.getKeyStroke(keyCode(i),modifier(i))); - if i == 5; obj.defaultContextMenu.addSeparator; end - if i >= 5, item.setEnabled(false); end % at the beginning, by default, the table isn't editable - item.ActionPerformedCallback = actions{i}; - obj.defaultContextMenu.add(item); - end - - % associate popup-menu to table (only its body, excluding so the row and column headers) - obj.jtable.setComponentPopupMenu(obj.defaultContextMenu); - end - - % Color picker --------------------------------------------------------------------------------------------- - % The folow functions complement the color cell editor. Without question - % the JIDE class "com.jidesoft.combobox.ColorComboBox" (available in Matlab) - % is a much better choise, but to avoid any legal problem it won't be used. - - % function that preloads the color picker immediately user sets the - % property 'ColumnFormat' for any column with a 'color' value - function loadColorPicker(obj) - % define palette of colors (many of them are the same that use JIDE's ColorComboBox) - rgbColors = 1/255*[0 0 0; 82 48 48; 51 51 0; 0 51 0; 0 51 102; 0 0 128; 39 58 95; 51 51 51; - 128 0 0; 135 81 81; 128 128 0; 27 79 53; 0 128 128; 0 0 255; 51 51 153; 80 80 80; - 162 20 47; 153 51 0; 119 172 48; 59 113 86; 51 204 204; 78 101 148; 102 102 153; 128 128 128; - 255 0 0; 255 102 0; 153 204 0; 0 128 0; 0 255 255; 51 102 255; 128 0 128; 153 153 153; - 255 0 255; 255 153 0; 191 191 0; 51 153 102; 204 255 255; 0 114 189; 153 51 102; 192 192 192; - 255 153 204; 255 204 0; 255 255 0; 0 255 0; 205 224 247; 0 204 255; 131 97 123; 220 220 220; - 236 214 214; 255 204 153; 255 255 153; 204 255 204; 222 235 250; 153 204 255; 204 153 255; 255 255 255]; - - % define tooltip texts for the basic colors - colorNames = cell(1,size(rgbColors,1)); - colorNames([1,14,25,29,33,43,44,56]) = {'black','blue','red','cyan','magenta','yellow','green','white'}; - - % create a 'javax.swing.JPopupMenu' component - n = 8; % number of colors per row - popup = javaObjectEDT('javax.swing.JPopupMenu'); - popup = handle(popup,'CallbackProperties'); - popup.setPreferredSize(java.awt.Dimension(164,172)); - - % define the grid to place the colors - popup.setLayout(java.awt.GridBagLayout); - grid = java.awt.GridBagConstraints; - - % define border for the menu items (to create empty spaces between colors) - customBorder = javax.swing.border.CompoundBorder(... - javax.swing.border.LineBorder(java.awt.Color(0.94,0.94,0.94),3),... - javax.swing.border.LineBorder(java.awt.Color.black)); - - % create a 'javax.swing.JMenuItem' for each color and assign properties - dim = java.awt.Dimension(19,19); - for i=1:size(rgbColors,1) - % define the place in the grid for the color - grid.gridy = floor((i-0.1)/n); - - % paint the item according to the color - color = handle(javax.swing.JMenuItem(''),'CallbackProperties'); - color.setPreferredSize(dim); - color.setOpaque(true); - color.setBackground(java.awt.Color(rgbColors(i,1),rgbColors(i,2),rgbColors(i,3))); - color.setBorderPainted(true); - color.setBorder(customBorder); - - % set the tooltip (for the non-basic colors show the RGB triplet) - if isempty(colorNames{i}) - color.setToolTipText(mat2str(rgbColors(i,:),2)); - else - color.setToolTipText(colorNames{i}); - end - - color.MousePressedCallback = @(~,~)obj.jtable.setValueAt(color.getBackground,obj.editingRow,obj.editingCol); - - % add item to the popup menu - popup.add(color,grid); - end - - % define the buttons 'More Colors' and 'None' for the color picker - buttonsNames={'More Colors','None'}; - grid.gridwidth=4; - grid.gridy=grid.gridy+1; - grid.insets = java.awt.Insets(5,3,4,3); - buttonBorder(1)=javax.swing.border.CompoundBorder(... - javax.swing.border.LineBorder(java.awt.Color(0.5,0.5,0.5)),javax.swing.border.EmptyBorder(-2,-30,0,0)); - buttonBorder(2)=javax.swing.border.CompoundBorder(... - javax.swing.border.LineBorder(java.awt.Color(0.5,0.5,0.5)),javax.swing.border.EmptyBorder(-2,-11,0,0)); - action{1} = @obj.moreColorsButton; - action{2} = @obj.noneButton; - - for i=1:2 - grid.gridx = 4*(i-1); - button = handle(javax.swing.JMenuItem(buttonsNames{i}),'CallbackProperties'); - button.setOpaque(true); - button.setBackground(java.awt.Color(0.88,0.88,0.88)); - button.setPreferredSize(java.awt.Dimension(70,20)); - button.setBorderPainted(true); - button.setBorder(buttonBorder(i)); - button.MousePressedCallback = action{i}; - button.MouseEnteredCallback = @(~,~)button.setBackground(java.awt.Color(0.9,0.95,0.98)); - button.MouseExitedCallback = @(~,~)button.setBackground(java.awt.Color(0.88,0.88,0.88)); - popup.add(button,grid); - end - - % create a custom dropdown button which will be displayed when the edit mode is active - ddbutton = javaObjectEDT('asd.fgh.olduitable.ColorComboBox'); - ddbutton = handle(ddbutton,'CallbackProperties'); - arrowButton = handle(ddbutton.getArrowButton,'CallbackProperties'); - label = handle(ddbutton.getJLabel,'CallbackProperties'); - ddbutton.setPopupMenu(popup); - - % assign callbacks to show or hide the color picker if the cell, whose column has a 'color' format, is clicked - clickOnCell = @(~,~)obj.displayPopupEditor('colorEditor'); - ddbutton.MousePressedCallback = clickOnCell; - arrowButton.MousePressedCallback = clickOnCell; - label.MousePressedCallback = clickOnCell; - - % assign miscellaneous callbacks to avoid the occurrence of unwanted behaviors - arrowButton.MouseWheelMovedCallback = @(~,~)obj.jtable.requestFocus; - arrowButton.KeyPressedCallback = @(~,~)popup.setVisible(false); - arrowButton.FocusLostCallback = @(~,~)obj.colorEditorLostFocus; - obj.jtable.AncestorMovedCallback = @(~,~)obj.stopEditing; - - % store objects - obj.colorEditor.cellbutton = ddbutton; - obj.colorEditor.dropdownMenu = popup; - end - - % function that runs when the color picker loses the focus - function colorEditorLostFocus(obj) - focusOwner = java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager.getFocusOwner; - if isempty(focusOwner) || isa(focusOwner,'asd.fgh.olduitable.RowHeader') - if isvalid(obj) - obj.colorEditor.dropdownMenu.setVisible(false); - obj.colorEditor.cellbutton.setSelected(false); - end - end - end - - % function that runs when the 'More Colors' button is pressed - function moreColorsButton(obj,button,~) - button.setBackground(java.awt.Color(0.88,0.88,0.88)); - label = obj.colorEditor.cellbutton.getJLabel; - color = javax.swing.JColorChooser.showDialog(javax.swing.JButton,'Select Color',label.getBackground); - if ~isempty(color) - label.setBackground(color); - obj.jtable.setValueAt(color,obj.editingRow,obj.editingCol); - end - obj.colorEditor.cellbutton.setSelected(false); - end - - % function that runs when the 'None' button is pressed - function noneButton(obj,button,~) - button.setBackground(java.awt.Color(0.88,0.88,0.88)); - white = java.awt.Color.white; - obj.jtable.setValueAt(white,obj.editingRow,obj.editingCol); - obj.colorEditor.cellbutton.getJLabel.setBackground(white); - obj.colorEditor.cellbutton.setSelected(false); - end - - % function that shows or hides the popup editor (for columns with the 'color' or 'longchar' format) - function displayPopupEditor(obj,editor) - % retrieve editor parameters - cellButton = obj.(editor).cellbutton; - editArea = obj.(editor).dropdownMenu; - - % get the selected cell - editRow = obj.jtable.getSelectedRow; - editCol = obj.jtable.getSelectedColumn; - - % start the edit mode if necessary - if isempty(obj.jtable.getCellEditor), obj.jtable.editCellAt(editRow,editCol); end - - % The popup editors will be displayed each time the selection changes to a column with the proper format. - % This was implemented in the 'asd.fgh.olduitable.Table' class through a selection listener, so this function - % will only work when the same cell is clicked or when the edition was interrupted by a sort action. - if ~editArea.isVisible && obj.editingRow == editRow && obj.editingCol == editCol - cellButton.setSelected(~cellButton.isSelected); - if cellButton.isSelected, cellButton.showPopup; end - elseif obj.editingRow == -1 - obj.editingRow = editRow; - obj.editingCol = editCol; - cellButton.showPopup; - end - end - - % longchar ------------------------------------------------------------------------------------------------------------- - % function that preloads the long char editor - function loadTextArea(obj) - % create the dropdown menu - popup = javaObjectEDT('javax.swing.JPopupMenu'); - popup = handle(popup,'CallbackProperties'); - popup.setPreferredSize(java.awt.Dimension(164,172)); - popup.setLayout(java.awt.GridBagLayout); - - % define the text area - textarea = handle(javax.swing.JTextArea(7,1),'CallbackProperties'); - panel = javax.swing.JScrollPane(textarea,javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,... - javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - - % define grid and add panel (and with it the text area) to popup - grid = java.awt.GridBagConstraints; - grid.gridwidth = 2; - grid.fill = java.awt.GridBagConstraints.HORIZONTAL; - grid.insets = java.awt.Insets(2,2,2,2); - grid.weightx = 1; - popup.add(panel,grid); - - % define the buttons 'Ok' and 'Cancel' - buttonsNames={'Ok','Cancel'}; - grid.gridy = 1; % second row (java indices) - grid.gridwidth = 1; - grid.insets = java.awt.Insets(3,2,1,2); - % define borders to try to center the label of menu items - buttonBorder(1)=javax.swing.border.CompoundBorder(... - javax.swing.border.LineBorder(java.awt.Color(0.5,0.5,0.5)),javax.swing.border.EmptyBorder(-2,-3,0,0)); - buttonBorder(2)=javax.swing.border.CompoundBorder(... - javax.swing.border.LineBorder(java.awt.Color(0.5,0.5,0.5)),javax.swing.border.EmptyBorder(-2,-13,0,0)); - action{1} = @obj.okButton; - action{2} = @obj.cancelButton; - - for i=1:2 - button = handle(javax.swing.JMenuItem(buttonsNames{i}),'CallbackProperties'); - button.setOpaque(true); - button.setBackground(java.awt.Color(0.88,0.88,0.88)); - button.setPreferredSize(java.awt.Dimension(40,20)); - button.setBorderPainted(true); - button.setBorder(buttonBorder(i)); - button.MousePressedCallback = action{i}; - button.MouseEnteredCallback = @(~,~)button.setBackground(java.awt.Color(0.9,0.95,0.98)); - button.MouseExitedCallback = @(~,~)button.setBackground(java.awt.Color(0.88,0.88,0.88)); - popup.add(button,grid); - end - - % create a custom dropdown button which will be displayed when the edit mode is active - ddbutton = javaObjectEDT('asd.fgh.olduitable.TextAreaComboBox',textarea); - ddbutton = handle(ddbutton,'CallbackProperties'); - ddbutton.setPopupMenu(popup); - arrowButton = handle(ddbutton.getArrowButton,'CallbackProperties'); - label = handle(ddbutton.getJLabel,'CallbackProperties'); - - % display the text area if the cell, whose column has a 'longchar' format, is clicked - ddbutton.MousePressedCallback = @(~,~)obj.displayPopupEditor('longcharEditor'); - arrowButton.MousePressedCallback = @(~,~)obj.displayPopupEditor('longcharEditor'); - label.MousePressedCallback = @(~,~)obj.displayPopupEditor('longcharEditor'); - - % fix behavior if the editor lost the focus - textarea.FocusLostCallback = @(~,~)obj.textAreaLostFocus; - obj.jtable.AncestorMovedCallback = @(~,~)obj.stopEditing; - - % store objects - obj.longcharEditor.area = textarea; - obj.longcharEditor.cellbutton = ddbutton; - obj.longcharEditor.dropdownMenu = popup; - end - - % function that is executed when the 'longchar' editor loses the focus - function textAreaLostFocus(obj) - row = obj.jtable.getSelectedRow; - col = obj.jtable.getSelectedColumn; - if obj.jtable.getSelectedRowCount == 1 && obj.jtable.getSelectedColumnCount == 1 && obj.tableModel.getColumnEditable(col) - if ismember(obj.info.ColumnFormat{col+1},{'color','popup'}) - obj.jtable.editCellAt(row,col); - obj.jtable.getEditorComponent.showPopup; - elseif strcmpi(obj.info.ColumnFormat{col+1},'logical') - obj.jtable.editCellAt(row,col); - else - obj.longcharEditor.cellbutton.requestFocus; - end - else - obj.longcharEditor.dropdownMenu.setVisible(false); - end - end - - % function that runs when the 'Ok' button is pressed - function okButton(obj,button,~) - button.setBackground(java.awt.Color(0.88,0.88,0.88)); - obj.jtable.setValueAt(obj.longcharEditor.area.getText,obj.editingRow,obj.editingCol); - obj.longcharEditor.cellbutton.setSelected(false); - %obj.longcharEditor.cellbutton.getArrowButton.setSelected(true); - end - - % function that runs when the 'Cancel' button is pressed - function cancelButton(obj,button,~) - button.setBackground(java.awt.Color(0.88,0.88,0.88)); - obj.longcharEditor.cellbutton.setSelected(false); - %obj.longcharEditor.cellbutton.getArrowButton.setSelected(false); - end - - end - - %% Callbacks associated with mouse and keyboard actions - methods (Access = private, Hidden) - % Mouse functions ------------------------------------------------------------------------------ - - % actions when the upper left corner is selected - function cornerSelection(obj,~,evt) - if obj.jtable.isEnabled - obj.stopEditing; - obj.jtable.selectAll; - obj.jtable.requestFocus; % return focus to table's body - end - obj.callButtonDownFcn(evt,'Corner'); % call user's callback - end - - % actions when the table's body is selected - function jtableSelection(obj,jtable,evt) - % store cell value prior to editing - if jtable.isEditing - obj.oldValue = jtable.getValueAt(jtable.getEditingRow,jtable.getEditingColumn); - end - - % right click ----> context menu - if evt.isMetaDown && jtable.isEnabled - obj.stopEditing; - - % select cell when the right click occurs outside the current selected interval - point = evt.getPoint; - row = jtable.rowAtPoint(point); - col = jtable.columnAtPoint(point); - if ~ismember(row,jtable.getSelectedRows) || ~ismember(col,jtable.getSelectedColumns) - jtable.changeSelection(row,col,false,false); - end - - % if the default context menu is present, enable/disable the - % 'cut', 'paste' & 'clear' items according to the column editable property - if ischar(obj.UIContextMenu) && strcmpi(obj.UIContextMenu,'auto') - editable = obj.tableModel.getColumnEditable; - items = obj.defaultContextMenu.getComponents; - flag = all(editable((jtable.getSelectedColumns + 1))); - for i = [1 3 4] - items(i).setEnabled(flag); - end - end - end - - % call user's callback ('CellSelectionCallback' is triggered in the 'selectionChanged' function) - obj.callButtonDownFcn(evt,'Body'); - end - - % actions when the column headers are selected - function colheaderSelection(obj,colheader,evt) - % fix problem with popup editors when the column headers are clicked - if ~isempty(obj.colorEditor.dropdownMenu), obj.colorEditor.dropdownMenu.setVisible(false); end - if ~isempty(obj.longcharEditor.dropdownMenu), obj.longcharEditor.dropdownMenu.setVisible(false); end - - % (un)sort the column when its header is left-clicked - column = 1 + colheader.columnAtPoint(evt.getPoint); - if obj.jtable.isEnabled && column > 0 && ~evt.isMetaDown && isempty(colheader.getResizingColumn) && obj.info.ColumnSortable(column) - if column == obj.SortedColumn && ~obj.isDataModified - if obj.SortDirection == 1 - obj.sortColumn(column,'descend','InternalUse'); - else%if obj.SortDirection == -1 - obj.unsort; - end - else - obj.sortColumn(column,'ascend','InternalUse'); - end - end - - % call user's callback - obj.callButtonDownFcn(evt,'ColumnHeader'); - end - - % function to update the width of a resized column - function columnResize(obj,~,~) - resizedColumn = obj.columnHeader.getResizingColumn; - if ~isempty(resizedColumn) - obj.info.ColumnWidth{resizedColumn.getModelIndex + 1} = resizedColumn.getWidth; - end - end - - % function that creates the 'eventdata' for the 'ButtonDownFcn' property and executes this callback - function callButtonDownFcn(obj,evt,areaName) - % areaName = 'Body' (main table), 'ColumnHeader', 'RowHeader', 'EmptyPanel' or 'Corner' (top-left of pane) - if ~isempty(obj.ButtonDownFcn) - % create 'eventdata' structure - click = {'left','middle','right'}; - eventdata.ClickedArea = areaName; - eventdata.Button = click{ismember([1 2 3],evt.getButton)}; - eventdata.ClickCount = evt.getClickCount; - eventdata.ClickPosition = [evt.getPoint.x,evt.getPoint.y]; % [0,0] -> top-left of area (in relative pixels units) - - % evalue user's callback function - obj.evalFcn(obj.ButtonDownFcn,eventdata); - end - end - - % function that evalues the user's callback depending on whether it is a 'function handle', a cell array or a char - function evalFcn(obj,fcn,eventdata) - if isa(fcn,'function_handle') - feval(fcn,obj,eventdata); - elseif iscell(fcn) - feval(fcn{1},obj,eventdata,fcn{2:end}); - elseif ischar(fcn) - evalin('base',fcn); - end - end - - % Keyboard functions --------------------------------------------------------------------------------------------- - - % actions when key is pressed while jtable has the focus - function keyfunction(obj,jtable,evt) - % store cell value prior to editing - if jtable.isEditing - obj.oldValue = jtable.getValueAt(jtable.getEditingRow,jtable.getEditingColumn); - end - - % define keyboard shortcuts - keyCode = evt.getKeyCode; - modifiers = evt.getModifiers; - if modifiers == 2 && keyCode == 86 % Ctrl + V - if jtable.getSelectedRow > -1, obj.paste; end - elseif keyCode == 127 % delete - if jtable.getSelectedRow > -1, obj.paste({''}); end - elseif modifiers == 2 && keyCode == 88 % Ctrl + X - obj.cut; - elseif modifiers == 2 && ismember(keyCode,37:40) % Ctrl + navigation arrows - if jtable.getSelectedRow > -1 - if keyCode == 38 - jtable.changeSelection(0,jtable.getSelectedColumn,false,false) - elseif keyCode == 40 - jtable.changeSelection(jtable.getRowCount-1,jtable.getSelectedColumn,false,false) - elseif keyCode == 37 - jtable.changeSelection(jtable.getSelectedRow,0,false,false) - else%if keyCode == 39 - jtable.changeSelection(jtable.getSelectedRow,jtable.getColumnCount-1,false,false) - end - end - elseif modifiers == 8 && ismember(keyCode,37:40) % Alt + navigation arrows - if keyCode == 38 - obj.insertRows('above','InternalUse'); - elseif keyCode == 40 - obj.insertRows('below','InternalUse'); - elseif keyCode == 37 - obj.insertColumns('left','InternalUse'); - else%if keyCode == 39 - obj.insertColumns('right','InternalUse'); - end - elseif modifiers == 2 && (strcmp(evt.getKeyChar,'-') || keyCode == 45) % Ctrl + Minus - obj.deleteRows; - elseif modifiers == 2 && keyCode == 8 % Ctrl + backspace - obj.deleteColumns; - end - - % call user's callback - obj.callKeyFcn([],evt,'KeyPressFcn'); - end - - % function that creates the 'eventdata' for the 'KeyPressFcn' and 'KeyReleaseFcn' properties and executes the callback - function callKeyFcn(obj,~,evt,keyFcn) - if ~isempty(obj.(keyFcn)) - % create 'eventdata' structure - eventdata.Character = lower(evt.getKeyChar); - eventdata.Modifier = lower(char(evt.getKeyModifiersText(evt.getModifiers))); - eventdata.Key = lower(char(evt.getKeyText(evt.getKeyCode))); - - % use the english designation for the keys - keyCode = evt.getKeyCode; - if keyCode == 37 - eventdata.Key = 'leftarrow'; - elseif keyCode == 38 - eventdata.Key = 'uparrow'; - elseif keyCode == 39 - eventdata.Key = 'rightarrow'; - elseif keyCode == 40 - eventdata.Key = 'downarrow'; - elseif keyCode == 8 - eventdata.Key = 'backspace'; - elseif keyCode == 9 - eventdata.Key = 'tab'; - elseif keyCode == 10 - eventdata.Key = 'return'; - elseif keyCode == 20 - eventdata.Key = 'capslock'; - elseif keyCode == 127 - eventdata.Key = 'delete'; - .... % among other keys - end - eventdata.EventName = keyFcn(1:end-3); - - % evalue user's callback function - obj.evalFcn(obj.(keyFcn),eventdata); - end - end - - % CellEditCallback ---------------------------------------------------------------------------------------------- - - % function that creates the 'eventdata' for the 'CellEditCallback' property and executes this callback - function callCellEditCallback(obj,rows,cols,oldData,editData,eventName) - if ~isempty(obj.CellEditCallback) - % create 'eventdata' structure - eventdata.RowIndices = double(rows); - eventdata.ColumnIndices = double(cols); - eventdata.PreviousData = oldData; - eventdata.EditData = editData; - % callbackdata.NewData = obj.Data; - eventdata.EventName = eventName; - - % evalue user's callback function - obj.evalFcn(obj.CellEditCallback,eventdata); - end - end - - % this function will only be used when a single cell is edited (see 'cut', 'paste', 'insertColumns', - % 'insertRows', 'deleteColumns' and 'deleteRows' functions for the other edition types) - function cellEdit(obj,model,eventdata) - % control callback re-entrancy - % taken from https://undocumentedmatlab.com/blog/controlling-callback-re-entrancy#comment-73083 - if ~isempty(obj.editing) - return - else - obj.editing = true; - end - - % get the cell edited (according to the model) - i = eventdata.getFirstRow; - j = eventdata.getColumn; - - if i > -1 && j > -1 - % store data (according to the view) - oldData = obj.Data; - - % get and store new data - editData = model.getValueAt(i,j); - numData = str2double(editData); % convert string to double if required - if ~isnan(numData) && ~ismember(obj.info.ColumnFormat{j+1},{'char','longchar','popup'}) - editData = numData; - model.setValueAt(editData,i,j); - end - - % call user's callback function if the value is really modified - if ~isequal(editData,obj.oldValue) - obj.isDataModified = true; - - i = obj.jtable.convertRowIndexToView(i); - %j = obj.jtable.convertColumnIndexToView(j); - oldData{i+1,j+1} = obj.oldValue; - - obj.callCellEditCallback(i+1,j+1,oldData,editData,'CellEdition'); - end - - drawnow - obj.editing = []; - end - end - - % function that stops the current edition - function stopEditing(obj) - editor = obj.jtable.getCellEditor; - if ~isempty(editor), editor.stopCellEditing; end - end - - % function that displays a warning if a sort mode is currently active - function flag = isSortModeActive(obj,functionName) - flag = (obj.SortDirection ~= 0); % obj.SortedColumn > 0 - if flag - warning(['''',functionName,''' was interrupted to avoid errors or unwanted behaviors when the sort mode is active.']); - end - end - - % ----------------------------------------------------------------------------------------------------------------------------------- - % function that is executed when the selection in the table changes - function selectionChanged(obj,src,evt,mode) %#ok - % registry the current cell that is in edit mode - obj.editingRow = obj.jtable.getEditingRow; - obj.editingCol = obj.jtable.getEditingColumn; - - if obj.jtable.getSelectedRowCount > 0 && obj.jtable.getSelectedColumnCount > 0 %~src.isSelectionEmpty - % get first and last (or lead) row/column selected - first = src.getMinSelectionIndex; - last = src.getLeadSelectionIndex; - if last == first, first = src.getMaxSelectionIndex; end - obj.([mode,'SelectionRange']) = {first,last}; - - % call user's callback - if ~isempty(obj.CellSelectionCallback) %&& ~evt.getValueIsAdjusting -% % this code was discarded because the number of selected cells (or pair of Indices) in large tables could be excessive -% ind = 1 + combvec(obj.jtable.getSelectedColumns',obj.jtable.getSelectedRows')'; -% callbackdata.Indices = ind(:,[2 1]); - - callbackdata.RowIndices = double(obj.jtable.getSelectedRows) + 1; - callbackdata.ColumnIndices = double(obj.jtable.getSelectedColumns) + 1; - - % evalue user's callback function - obj.evalFcn(obj.CellSelectionCallback,callbackdata); - end - end - end - - % function to restore the previous selection when new data is assigned in the table - function rememberSelection(obj) - if ~isempty(obj.RowsSelectionRange) && ... - max(obj.RowsSelectionRange{:}) < obj.jtable.getRowCount && ... - max(obj.ColumnsSelectionRange{:}) < obj.jtable.getColumnCount - obj.jtable.setColumnSelectionInterval(obj.ColumnsSelectionRange{:}); - obj.jtable.setRowSelectionInterval(obj.RowsSelectionRange{:}); - end - end - - % function to hightlight the row headers according to the selection in the table - function highlightRowHeaders(obj) - firstRow = obj.jtable.getSelectedRow; - if firstRow == -1 || obj.jtable.getSelectedColumnCount == 0 - obj.rowheader.clearSelection; - else - obj.rowheader.setColumnSelectionInterval(0,0); - obj.rowheader.setRowSelectionInterval(firstRow,firstRow + obj.jtable.getSelectedRowCount - 1); - end - - end - end - - %% Validation functions - % the follow functions validates the user inputs (when the table is created or property is updated) - methods (Static, Access = protected, Hidden) - function binaryValidation(x,varargin) - % validateattributes(x,{'numeric','logical'},{'vector','binary'}) - flag = (islogical(x) && isvector(x)) || ... - (isnumeric(x) && isvector(x) && all(ismember(x,[0 1]))); % 'isvector' function validates scalar values - if ~flag % assert(flag,blablabla) - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,'This must be either: ',... - '- a logical or logical array ',... - '- a numeric scalar 0 or 1 ',... - '- a 1-by-n or n-by-1 numeric array with binary values '); - end - end - - function callbackValidation(x,varargin) - flag = isempty(x) || isa(x,'function_handle') || ... - ((ischar(x) || iscell(x)) && isrow(x)); - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,'This must be either: ',... - '- a function handle (@fcnName) ',... - '- a character vector (''fcnName'') ',... - '- a cell array containing @fcnName or ''fcnName'' and extra arguments if function requires it '); - end - end - - function flag = colorValidation(x,varargin) - flag = (isnumeric(x) && all(size(x) == [1 3]) && (min(x) >= 0) && (max(x) <= 1)) || ... - (ischar(x) && isscalar(x) && ismember(lower(x),{'y','m','c','r','g','b','w','k'})) || ... - (ischar(x) && isrow(x) && ismember(lower(x),{'yellow','magenta','cyan','red','green','blue','white','black'})); - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,'This must be either: ',... - '- a short name of color (''r'', ''g'', ''b'', ''y'', ''m'', ''c'', ''w'' or ''k'') ',... - '- a long name of color (''red'', ''green'', ''blue'', ''yellow'', ''magenta'', ''cyan'', ''white'' or ''black'') ',... - '- a RGB triplet (1-by-3 row vector with values in the range [0,1]) '); - end - end - - function flag = columnalignValidation(x,varargin) - flag = ((ischar(x) && isrow(x)) || (iscellstr(x) && isvector(x))) && all(ismember(lower(x),{'left','center','right'})); - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,'This must be either: ',... - '- a char ''left'', ''center'' or ''right'' ',... - '- a 1-by-n or n-by-1 cell array of character vectors with those values '); - end - end - - function flag = columnformatValidation(x,varargin) - % validateattributes(x,{'char','cell'},{}) - flag = ischar(x) || (iscellstr(x) && isvector(x)); - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - formatInfo = ['- a character vector with a valid formatting operator (see ',... - 'documentation) ']; - error('\b\n%s',premsg,'This must be either: ',... - '- an empty char vector '''' ','- char vectors as ''bank'', ''char'', ''color'', ''logical'', ''longchar'' or ''popup'' ',... - formatInfo,'- a 1-by-n or n-by-1 cell array of character vectors with those formats '); - end - end - - function flag = colformatdataValidation(x,varargin) - flag = iscell(x) && all(cellfun(@(arg)isempty(arg) || iscellstr(arg),x)); - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,'This must be either: ',... - '- an empty cell array {}',... - '- a 1-by-n or n-by-1 cell array with empty values or cellstr arrays '); - end - end - - function flag = columnwidthValidation(x,varargin) - % validateattributes(x,{'cell','numeric'},{'vector','nonnegative'}); - flag = (isnumeric(x) && isscalar(x) && x >= 0) || ... - (iscell(x) && isvector(x) && all(cellfun(@(arg)isnumeric(arg) && arg >= 0,x))); - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,'This must be either: ',... - '- a positive number (value is in pixel units) ',... - '- a 1-by-n or n-by-1 cell array with positive numbers '); - end - end - - function flag = dataValidation(x,varargin) - % validateattributes(x,{'cell','numeric','logical'},{'2d'}); - flag = (iscell(x) || isnumeric(x) || islogical(x)) && ismatrix(x); - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,'This must be a 2D numeric, logical or cell array '); - end - end - - function flag = fontnameValidation(x,varargin) - % validateattributes(x,{'char'},{}); - flag = ischar(x) && isrow(x) && any(strcmpi(x,olduitable.listfonts)); - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,... - 'This must be a char vector with the name of a supported system font (see List system fonts) '); - end - end - - function flag = fontsizeValidation(x,varargin) - % validateattributes(x,{'numeric'},{'scalar','integer','positive'}); - flag = isnumeric(x) && isscalar(x) && x > 0; % && rem(x,1) == 0 - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,'This must be a positive number (value is in pixel units) '); - end - end - - function flag = fontstyleValidation(x,varargin) - flag = (isnumeric(x) && isscalar(x) && ismember(x,[0 1 2 3])) || ... - (ischar(x) && ismember(lower(x),{'normal','bold','italic','bold italic'})); - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,'This must be either: ',... - '- char vector ''normal'' (or 0) ',... - '- char vector ''bold'' (or 1) ',... - '- char vector ''italic'' (or 2) ',... - '- char vector ''bold italic'' (or 3) '); - end - end - - function flag = headerNamesValidation(x,varargin) - flag = isempty(x) || (ischar(x) && strcmpi(x,'numbered')) || (iscellstr(x) && isvector(x)); - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,'This must be either: ',... - '- char vector ''numbered'' ',... - '- an empty cell array {} or matrix [] ',... - '- a 1-by-n or n-by-1 cell array of character vectors '); - end - end - - function flag = jpopupValidation(x,varargin) - flag = isempty(x) || (ischar(x) && strcmpi(x,'auto')) || ... - isa(x,'javax.swing.JPopupMenu') || isa(x,'javahandle_withcallbacks.javax.swing.JPopupMenu'); - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,'This must be either: ',... - '- char vector ''auto'' ',... - '- an empty cell array {} or matrix [] ',... - '- a Java component of type javax.swing.JPopupMenu '); - end - end - - function flag = onoffValidation(x,varargin) - % any(validatestring(x,{'on','off'})) - flag = ischar(x) && ismember(x,{'on','off'}); - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,'This must be one of these values: ''on'' | ''off'' '); - end - end - - function flag = parentValidation(x,varargin) - flag = (isempty(x) && (iscell(x) || isnumeric(x))) || ... - (ismember(class(x),olduitable.validParent) && isvalid(x)); - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid or handle was deleted. ']; end - error('\b\n%s',premsg,'Parent must be one of these objects: Figure | Panel | ButtonGroup | Tab '); - end - end - - function flag = positionValidation(x,varargin) - % validateattributes(x,{'numeric'},{'size',[1,4],'nonnegative'}) - flag = isnumeric(x) && all(size(x) == [1,4]) && min(x) >= 0; - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,'This must be a 1-by-4 numeric array of the form [left bottom width height] '); - end - end - - function flag = rgbValidation(x,varargin) - % validateattributes(x,{'numeric'},{'size',[NaN,3],'<=',1,'>=',0}) - flag = isnumeric(x) && size(x,1) >= 1 && size(x,2) == 3 && (min(x(:)) >= 0) && (max(x(:)) <= 1); - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,'This must be either: ',... - '- a RGB triplet (1-by-3 numeric array with values in the range [0,1]) ',... - '- an m-by-3 matrix of RGB triplets '); - end - end - - function flag = rowheightValidation(x,varargin) - flag = (ischar(x) && strcmpi(x,'auto')) || (isnumeric(x) && isscalar(x) && x >= 0); - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,'This must be either: ',... - '- char vector ''auto'' ',... - '- a positive number (value is in pixel units) '); - end - end - - function flag = tagValidation(x,varargin) - flag = ischar(x) && (isempty(x) || isrow(x)); - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,'This must be a character vector (''tagName'') '); - end - end - - function flag = tooltipsValidation(x,varargin) - flag = (ischar(x) && isempty(x)) || (iscellstr(x) && isvector(x)); - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,'This must be either: ',... - '- an empty char '''' ',... - '- a 1-by-n or n-by-1 cell array of character vectors '); - end - end - - function flag = unitsValidation(x,varargin) - % any(validatestring(x,{'pixels','normalized','inches','centimeters','points','characters'})) - flag = ischar(x) && isrow(x) && ismember(x,{'pixels','normalized','inches','centimeters','points','characters'}); - if ~flag - premsg = ''; - if nargin == 2, premsg = ['''',varargin{:},'''',' value is invalid. ']; end - error('\b\n%s',premsg,'It must be one of these: ',... - '''pixels'' | ''normalized'' | ''inches'' | ''centimeters'' | ''points'' | ''characters'' '); - end - end - - end - - %% Utility functions - methods (Static, Access = protected, Hidden) - - % function that returns the rgb triplet form of a color since its - % short or long name (val) or the same value if it is already a rgb triplet - function val = char2rgb(val) - if ischar(val) - colors = [1 1 0;1 0 1;0 1 1;1 0 0;0 1 0;0 0 1;1 1 1;0 0 0]; - if length(val) == 1 - %val = bitget(find('krgybmcw' == val)-1,1:3); - [~,ind] = ismember(lower(val),{'y','m','c','r','g','b','w','k'}); - else - [~,ind] = ismember(lower(val),{'yellow','magenta','cyan','red','green','blue','white','black'}); - end - val = colors(ind,:); - end - %javacolor = java.awt.Color(val(1),val(2),val(3)); - end - - % function that adjusts a value (val) to fit to the num of columns in table (n) - function val = resize2columncount(n,val0,val) % [val,uniVal] = resize2columncount(n,val0,val) - if ischar(val) || (isnumeric(val) && isscalar(val)) - %uniVal = val; - val = repmat({val},1,n); % repeat single value n times - else - if length(val)n - val = val(1:n); % truncate long cell array up to a length n - end - %uniVal = olduitable.uniqueValue(val); % verify and registry if cell array has only one value - end - end - - % idem to 'resize2columncount' but for logical or 0-1 arrays (or scalar with those values) - function val = resizelogical2columns(n,val0,val) % [val,uniVal] = resizelogical2columns(n,val0,val) - if isscalar(val) - %uniVal = val; - val = repmat(val,1,n); - else - if length(val)n - val = val(1:n); - end - %uniVal = olduitable.uniqueValue(val); - end - end - - % function that convert an rgb triplet to the equivalent java color - function javacolor = rgb2java(val) - javacolor = java.awt.Color(val(1),val(2),val(3)); - end - - % function that convert a numeric row vector to a cell array of chars - function cell = num2cellstr(val) -% if verLessThan('matlab','8.1') % versions earlier than R2013a -% cell = cellstr(cellfun(@num2str,num2cell(val'),'UniformOutput',false))'; - if verLessThan('matlab','9.1') % versions earlier than R2016b - cell = strsplit(num2str(val)); - else - cell = cellstr(string(val)); - end - end - - % function that returns the unique value in the vector 'val' or the same vector if it has more than one value - function val = uniqueValue(val) - if iscell(val) - uniques = unique(cellfun(@num2str,val,'UniformOutput',false)); - if isscalar(uniques) - val = uniques{1}; - num = str2double(val); - if ~isnan(num), val = num; end - end - elseif isnumeric(val) || islogical(val) - uniques = unique(val); - if isscalar(uniques), val = uniques; end - end - end - - % function that converts the contents of the clipboard to a cell array - function data = getclipdata() - % get the contents of the clipboard and convert it to a java.lang.String object - c = java.awt.Toolkit.getDefaultToolkit.getSystemClipboard; - clip = java.lang.String(c.getData(java.awt.datatransfer.DataFlavor.stringFlavor)); - % clip = java.lang.String(clipboard('paste')); - - % convert the string to an m-by-1 java array (where m is the number of rows in the data) - rowStringData = clip.split('\n'); - - % split each row into individual elements (cells) - stringData = cell(0,0); - for i = 1:length(rowStringData) - stringData(i,:) = cell(rowStringData(i).split('\t')); - end - - % return 'stringData' to a numerical type if required - numData = str2double(stringData); - ind = isnan(numData); - data = num2cell(numData); - data(ind) = stringData(ind); - end - - % function that simulates a keyboard action - function keyRobot(modifier,keyChar) - robot = java.awt.Robot; - robot.keyPress(java.awt.event.KeyEvent.(['VK_',upper(modifier)])); - robot.keyPress(java.awt.event.KeyEvent.(['VK_',upper(keyChar)])); - robot.keyRelease(java.awt.event.KeyEvent.(['VK_',upper(keyChar)])); - robot.keyRelease(java.awt.event.KeyEvent.(['VK_',upper(modifier)])); - end - - % function that obtains the data from a table model as a cell array - function dataInModel = getDataInModel(model) - vectors = feature(44,model.getDataVector,1); - dataVectors = cellfun(@(x)feature(44,x,1),vectors,'UniformOutput',false); - dataInModel = [dataVectors{:}]'; - end - end -end diff --git a/Interface/dev/BED.m b/Interface/dev/BED.m deleted file mode 100644 index 483973f..0000000 --- a/Interface/dev/BED.m +++ /dev/null @@ -1,248 +0,0 @@ -clc, clearvars %clear - -% CSV files -% Liang,Dawson,SeongH,SeongM,SeongL -file_names = { 'datafiles/SR_EQ1_L.csv','datafiles/SR_EQ1_D.csv',... - 'datafiles/SR_EQ1_SH.csv','datafiles/SR_EQ1_SM.csv','datafiles/SR_EQ1_SL.csv'}; -number_studies = numel(file_names); -% Data from the files: -%y (SR) - survival rate in percentage -%tau - elapsed time in months -%%%points from all the files%%% -tau_list = []; -y_list = []; -for i = 1:length(file_names) - data = load(file_names{i}); - tau_list = [tau_list; data(:,1)]; - y_list = [y_list; data(:,2)]; -end - -N_values = [128, 35, 83, 51, 24]; %N - number of patients -d_values = [4.88, 1.5, 1.8, 1.8, 1.8]; %d - dose per fraction Gy/fx -D_values = [53.6, 61.5, 55, 45, 32.5]; %D - prescription dose Gy -T_day_values = [28, 42, 37, 37, 37]; %T_day - treatment time in days -T_day_mean = mean(T_day_values); -T_month_values = zeros(size(T_day_values)); %T_month - treatment time in months -for i = 1:length(T_day_values) - tm = T_day_values(i)/30; - T_month_values(i) = tm; -end - -v = [1.99, 0.0099754, 14.4153, 0.0056126, 0.71, 0.19]; -%v - vector with parameters obtained from fit2 - %v(1) - K50/K0 - %v(2) - alpha Gy^-1 - %v(3) - alpha/beta Gy - %v(4) - gamma days^-1 - %v(5) - sigmak/K0 - %v(6) - delta - -%x (BED) - Biologically effective dose (Gy) -x_values = zeros(size(N_values)); -for i = 1:length(x_values) - bed = (1+(d_values(i)/v(3)))*D_values(i) - (v(4)*T_day_values(i))/v(2); - x_values(i) = bed; -end - -disp('BED values:'); -disp(['Liang: ', num2str(x_values(1))]); -disp(['Dawson: ', num2str(x_values(2))]); -disp(['SeongH: ', num2str(x_values(3))]); -disp(['SeongM: ', num2str(x_values(4))]); -disp(['SeongL: ', num2str(x_values(5))]); - - -% Plotting -hold on -x_points = linspace(0, 90, 91); - -% tau = 1year -tau = 365; -y_plot = []; -x_plot = []; -for i = 1:length(x_points) - sr = fit(x_points(i),tau,v,T_day_mean); %-> change this! - if ~isnan(sr) - bed = x_points(i); - y_plot = [y_plot, sr]; - x_plot = [x_plot, bed]; - end -end - -% curve -plot(x_plot, y_plot, '--', 'LineWidth', 2, 'Color', '#FE0100','DisplayName', 'tau=1year') - -% points - -% Liang -x = x_values(1); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 's', 'LineWidth', 2, 'Color', '#FE0100','MarkerSize', 8, 'HandleVisibility', 'off') -% Dawson -x = x_values(2); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 's', 'LineWidth', 2, 'Color', '#FE0100','MarkerSize', 8, 'HandleVisibility', 'off') -% SeongH -x = x_values(3); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 's', 'LineWidth', 2, 'Color', '#FE0100','MarkerSize', 8, 'HandleVisibility', 'off') -% SeongM -x = x_values(4); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 's', 'LineWidth', 2, 'Color', '#FE0100','MarkerSize', 8, 'HandleVisibility', 'off') -% SeongL -x = x_values(5); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 's', 'LineWidth', 2, 'Color', '#FE0100','MarkerSize', 8, 'HandleVisibility', 'off') - - -% tau = 2years -tau = 730; -y_plot = []; -x_plot = []; -for i = 1:length(x_points) - sr = fit(x_points(i),tau,v,T_day_mean); %> change this! - if ~isnan(sr) - bed = x_points(i); - y_plot = [y_plot, sr]; - x_plot = [x_plot, bed]; - end -end - -%curve -plot(x_plot, y_plot, '--', 'LineWidth', 2, 'Color', '#0000F7','DisplayName', 'tau=2years') - -% points - -% Liang -x = x_values(1); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 'v', 'LineWidth', 2, 'Color', '#0000F7','MarkerSize', 8, 'HandleVisibility', 'off') -% Dawson -x = x_values(2); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 'v', 'LineWidth', 2, 'Color', '#0000F7','MarkerSize', 8, 'HandleVisibility', 'off') -% SeongH -x = x_values(3); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 'v', 'LineWidth', 2, 'Color', '#0000F7','MarkerSize', 8, 'HandleVisibility', 'off') -% SeongM -x = x_values(4); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 'v', 'LineWidth', 2, 'Color', '#0000F7','MarkerSize', 8, 'HandleVisibility', 'off') -% SeongL -x = x_values(5); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 'v', 'LineWidth', 2, 'Color', '#0000F7','MarkerSize', 8, 'HandleVisibility', 'off') - -% tau = 3years -tau = 1095; -y_plot = []; -x_plot = []; -for i = 1:length(x_points) - sr = fit(x_points(i),tau,v,T_day_mean); %-> change this! - if ~isnan(sr) - bed = x_points(i); - y_plot = [y_plot, sr]; - x_plot = [x_plot, bed]; - end -end - -%curve -plot(x_plot, y_plot, '--', 'LineWidth', 2, 'Color', '#FD04FC','DisplayName', 'tau=3years') - - -% points - -% Liang -x = x_values(1); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 'v', 'LineWidth', 2, 'Color', '#FD04FC','MarkerSize', 8, 'HandleVisibility', 'off') -% Dawson -x = x_values(2); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 'v', 'LineWidth', 2, 'Color', '#FD04FC','MarkerSize', 8, 'HandleVisibility', 'off') -% SeongH -x = x_values(3); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 'v', 'LineWidth', 2, 'Color', '#FD04FC','MarkerSize', 8, 'HandleVisibility', 'off') -% SeongM -x = x_values(4); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 'v', 'LineWidth', 2, 'Color', '#FD04FC','MarkerSize', 8, 'HandleVisibility', 'off') -% SeongL -x = x_values(5); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 'v', 'LineWidth', 2, 'Color', '#FD04FC','MarkerSize', 8, 'HandleVisibility', 'off') - - -% tau = 4years -tau = 1460; -y_plot = []; -x_plot = []; -for i = 1:length(x_points) - sr = fit(x_points(i),tau,v,T_day_mean); %-> change this! - if ~isnan(sr) - bed = x_points(i); - y_plot = [y_plot, sr]; - x_plot = [x_plot, bed]; - end -end - -%curve -plot(x_plot, y_plot, '--', 'LineWidth', 2, 'Color', '#000000','DisplayName', 'tau=4years') - - -% points - -% Liang -x = x_values(1); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 'o', 'LineWidth', 2, 'Color', '#000000','MarkerSize', 8, 'HandleVisibility', 'off') -% Dawson -x = x_values(2); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 'o', 'LineWidth', 2, 'Color', '#000000','MarkerSize', 8, 'HandleVisibility', 'off') -% SeongH -x = x_values(3); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 'o', 'LineWidth', 2, 'Color', '#000000','MarkerSize', 8, 'HandleVisibility', 'off') -% SeongM -x = x_values(4); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 'o', 'LineWidth', 2, 'Color', '#000000','MarkerSize', 8, 'HandleVisibility', 'off') -% SeongL -x = x_values(5); -y = fit(x,tau,v,T_day_mean); %-> change this! -plot(x, y, 'o', 'LineWidth', 2, 'Color', '#000000','MarkerSize', 8, 'HandleVisibility', 'off') - -%legend,lables and title -legend('Location', 'northeast') -legend('boxoff') -xlabel('Biologically effective dose (Gy)') -ylabel('Survival Rate (%)-SR') -title('BED') - -%saving the plot -%saveas(gcf, 'BED.pdf') - -%%%%%%%%%%%%%%%%%%%%%%% -%Functions% -function result = fit(BED,tau,v,T_day) - %v(1) - K50/K0 - %v(2) - alpha Gy^-1 - %v(3) - be ta Gy^-2 - %v(4) - gamma days^-1 - %v(5) - sigmak/K0 - %v(6) - delta - denominator = v(5); - p = v(2)*BED - ((v(4) * (tau - T_day)) ^ v(6)); - numerator = exp(-p) - v(1); - t = numerator / denominator; - if isreal(t) - result = 100 * (1/2)*(1-erf(t/sqrt(2))); - else - result = NaN; - end - end - diff --git a/Interface/dev/Data1.m b/Interface/dev/Data1.m deleted file mode 100644 index 82b82df..0000000 --- a/Interface/dev/Data1.m +++ /dev/null @@ -1,9 +0,0 @@ -6.045197740112997 83.35570469798658 -12.146892655367235 63.6241610738255 -18.0225988700565 53.55704697986577 -24.01129943502825 42.48322147651007 -30.112994350282484 36.442953020134226 -36.101694915254235 30.80536912751677 -42.09039548022599 30.604026845637577 -48.079096045197744 21.543624161073822 -54.06779661016949 21.744966442953015 \ No newline at end of file diff --git a/Interface/dev/Data2.m b/Interface/dev/Data2.m deleted file mode 100644 index 1f05b4a..0000000 --- a/Interface/dev/Data2.m +++ /dev/null @@ -1,5 +0,0 @@ -5.93220338983051 69.86577181208054 -12.033898305084747 57.18120805369127 -15.197740112994353 50.13422818791946 -36.101694915254235 25.167785234899327 -60.16949152542373 11.073825503355692 \ No newline at end of file diff --git a/Interface/dev/Data3.m b/Interface/dev/Data3.m deleted file mode 100644 index 419c700..0000000 --- a/Interface/dev/Data3.m +++ /dev/null @@ -1,9 +0,0 @@ -6.045197740112997 75.70469798657717 -12.146892655367235 53.55704697986577 -18.0225988700565 37.248322147651 -24.01129943502825 29.798657718120808 -30.112994350282484 22.550335570469798 -36.101694915254235 17.718120805369125 -42.09039548022599 14.89932885906039 -48.079096045197744 12.68456375838926 -54.06779661016949 6.845637583892611 \ No newline at end of file diff --git a/Interface/dev/Data4.m b/Interface/dev/Data4.m deleted file mode 100644 index ef519a9..0000000 --- a/Interface/dev/Data4.m +++ /dev/null @@ -1,9 +0,0 @@ -6.045197740112997 64.02684563758389 -12.033898305084747 35.23489932885906 -18.0225988700565 17.919463087248317 -24.01129943502825 10.067114093959717 -30.112994350282484 10.067114093959717 -36.101694915254235 8.053691275167765 -42.09039548022599 4.0268456375838895 -48.079096045197744 4.0268456375838895 -54.18079096045198 4.0268456375838895 \ No newline at end of file diff --git a/Interface/dev/Data5.m b/Interface/dev/Data5.m deleted file mode 100644 index fc4850a..0000000 --- a/Interface/dev/Data5.m +++ /dev/null @@ -1,5 +0,0 @@ -6.045197740112997 55.9731543624161 -12.033898305084747 24.96644295302012 -18.0225988700565 8.053691275167765 -24.01129943502825 8.255033557046971 -30. 8.053691275167765 \ No newline at end of file diff --git a/Interface/dev/Images/AddFileIcon.mat b/Interface/dev/Images/AddFileIcon.mat deleted file mode 100644 index 42cfcdd..0000000 Binary files a/Interface/dev/Images/AddFileIcon.mat and /dev/null differ diff --git a/Interface/dev/Images/AddFileIcon.png b/Interface/dev/Images/AddFileIcon.png deleted file mode 100644 index 0725429..0000000 Binary files a/Interface/dev/Images/AddFileIcon.png and /dev/null differ diff --git a/Interface/dev/Images/PNG2MAT.m b/Interface/dev/Images/PNG2MAT.m deleted file mode 100644 index 113fd4b..0000000 --- a/Interface/dev/Images/PNG2MAT.m +++ /dev/null @@ -1,11 +0,0 @@ -filenames = dir('*.png'); %# get information of all .png files in work dir -n = numel(filenames); %# number of .png files - -for i = 1:n - A = imread( filenames(i).name ); - - %# gets full path, filename radical and extension - [fpath, radical, ext] = fileparts( filenames(i).name ); - - save([radical '.mat'], 'A'); -end \ No newline at end of file diff --git a/Interface/dev/RoundStr2Double.m b/Interface/dev/RoundStr2Double.m deleted file mode 100644 index ffa021e..0000000 --- a/Interface/dev/RoundStr2Double.m +++ /dev/null @@ -1,3 +0,0 @@ -function result = RoundStr2Double(Input, Decimals) - result = round(str2double(Input),Decimals); -end \ No newline at end of file diff --git a/Interface/dev/addfile_callback.m b/Interface/dev/addfile_callback.m deleted file mode 100644 index 5c7a7b5..0000000 --- a/Interface/dev/addfile_callback.m +++ /dev/null @@ -1,34 +0,0 @@ -function pushbutton_add_Callback(~,~) - % Get data from the Data Details table - data = get(handles.uitable,'Userdata'); - % Get entries in listbox_DataSets - DataSetsList = get(handles.listbox_DataSets,'String'); - n=numel(DataSetsList); - % if there is no data yet in the list or all was deleted - if isempty(DataSetsList) - file = uigetfile; % Selects file - FileName = strsplit(file, '.'); - FileName = string(FileName{1}); % Gets file name - set(handles.listbox_DataSets,'String',FileName,... - 'Value',1) % leave this student selected - data(size(data,1)+1,:) = cell(1,7); - set(handles.uitable, ... - 'Rowname' , get(handles.listbox_DataSets,'String'),... - 'Data' , data, ... - 'Userdata' , data); - else - %check the number of the last student and add a student - %with a new number - file = uigetfile; % Selects file - FileName = strsplit(file, '.'); - FileName = string(FileName{1}); % Gets file name - DataSetsList = [DataSetsList;FileName]; - set(handles.listbox_DataSets,'String',DataSetsList,... - 'Value',n)% leave last student selected - data(size(data,1)+1,:) = cell(1,7); - set(handles.uitable,... - 'Rowname',get(handles.listbox_DataSets,'String'),... - 'Data', data, ... - 'Userdata',data); - end - end \ No newline at end of file diff --git a/Interface/dev/ciencias_ul_azul_h_s-ass.png b/Interface/dev/ciencias_ul_azul_h_s-ass.png deleted file mode 100644 index 9223147..0000000 Binary files a/Interface/dev/ciencias_ul_azul_h_s-ass.png and /dev/null differ diff --git a/Interface/dev/fit1.m b/Interface/dev/fit1.m deleted file mode 100644 index 4897bd6..0000000 --- a/Interface/dev/fit1.m +++ /dev/null @@ -1,162 +0,0 @@ -function [K, alpha, beta, gamma, a, Td, delta] = fit1(file_names, labels) - -% CSV files -%Liang,Dawson,SeongH,SeongM,SeongL - -%file_names = {'Data1.m', 'Data2.m', 'Data3.m', 'Data4.m', 'Data5.m',} - -% Data from the files: -%x (tau) - elapsed time in months -%y (SR) - survival rate in percentage - -N_values = [128, 35, 83, 51, 24]; %N - number of patients -d_values = [4.88, 1.5, 1.8, 1.8, 1.8]; %d - dose per fraction Gy/fx -D_values = [53.6, 61.5, 55, 45, 32.5]; %D - prescription dose Gy -T_day_values = [28, 42, 37, 37, 37]; %T_day - treatment time in days - -T_month_values = zeros(size(T_day_values)); %T_month - treatment time in months -for i = 1:length(T_day_values) - tm = T_day_values(i)/30; - T_month_values(i) = tm; -end - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%points from all the files%%% -%xx = []; -%yy = []; -%for i = 1:length(file_names) -% data = load(file_names{i}); -% xx = [xx; data(:,1)]; -% yy = [yy; data(:,2)]; -%end -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%v - vector with parameters to find - %v(1) - K - %v(2) - alpha Gy^-1 - %v(3) - beta Gy^-2 - %v(4) - gamma days^-1 - %v(5) - a months^-1 - %v(6) - delta - -% Initial parameter values - defined by the user -v0 = [0.042, 0.037, 0.002587, 0.00608, 1268, 0.16]; - - % Define the parameter bounds - lb = [0, 0, 0, 0, 1000, 0]; - ub = [0.05, 0.05, 0.003, 0.007, 1500, 0.30]; - - % Define the fitting function - f = @(x,v,d,D,T_day,T_month) real(100*exp(-v(1).*exp(-(v(2).*(1+(d./(v(2)./v(3)))).*D - v(4).*T_day - (v(5).*(x-T_month)).^v(6))))); - - % Chi-square function - chi2 = @(v) residuals(file_names, N_values, d_values, D_values, T_day_values, T_month_values, v, f); - - % Set up the algorithm options - %options = optimoptions('ga', 'PopulationSize', 10, 'MaxGenerations', 1000); - options = optimoptions('fmincon', ... - 'MaxIterations',1000, ... - 'TolFun',1e-9,'TolX',1e-9); - - % Run the algorithm - %v_min = ga(chi2, 6, [], [], [], [], lb, ub, [], options); - [v_min,~,~,~,~,~,hessian] = fmincon(chi2, v0, [], [], [], [], lb, ub, [], options); - - % Uncertainties - cm = inv(hessian); %cm -> covariance matrix - un = zeros(size(v_min)); %un -> vector with uncertainties - d_cm = diag(cm); %d_cm -> diagonal of the covariance matrix - for i = 1:length(un) - un(i) = sqrt(d_cm(i)); - end - - % Display the results - disp('Parameters values of that minimize the sum of squares (value ± std):'); - - K = num2str(v_min(1)); - alpha = num2str(v_min(2)); - beta = num2str(v_min(3)); - gamma = num2str(v_min(4)); - a = num2str(v_min(5)); - Td = num2str(log(2) ./ v_min(4)); - delta = num2str(v_min(6)); - disp(['K: ', K, ' ± ', num2str(un(1))]); - disp(['alpha: ', alpha, ' ± ', num2str(un(2))]); - disp(['beta: ', beta, ' ± ', num2str(un(3))]); - disp(['alpha/beta: ' num2str(v_min(2)./v_min(3))]); - disp(['gamma: ', gamma, ' ± ', num2str(un(4))]); - disp(['Td: ' Td]); - disp(['a: ', a, ' ± ', num2str(un(5))]); - disp(['delta: ', delta, ' ± ', num2str(un(6))]); - - - -% Plotting -hold on -x_points = linspace(0, 70, 71); - -for i = 1:numel(file_names) - data = load(file_names{i}); - x = data(:, 1); - y = data(:, 2); - - %original points - - my_color = rand(1,3); - all_marks = {'o','+','*','x','s','d','^','v','>','<','p','h'}; - - plot(x, y, ... - 'LineStyle','none', ... - 'Marker',all_marks{mod(i,12)},... - 'LineWidth', 2, ... - 'Color', my_color, ... - 'MarkerSize', 6, ... - 'DisplayName', labels{i}) - - fit_label = string(strcat('Fit-',labels(i))); - %fitted function - add_color = [my_color(1)/(my_color(1)+0.7), my_color(2)/(my_color(2)+0.7), my_color(3)/(my_color(3)+0.7)]; - plot(x_points, f(x_points,v_min,d_values(i),D_values(i),T_day_values(i),T_month_values(i)), ... - '--', ... - 'LineWidth', 2, ... - 'Color', add_color, ... - 'DisplayName', fit_label,... - 'HandleVisibility', 'on') - end - - -%legend,lables and title -legend('Location', 'northeast') -legend('boxoff') -xlabel('Time (months)') -ylabel('SR (%)') -title('Fit 1') - -%saving the plot -%saveas(gcf, 'fit1.pdf') - -function r = residuals(files, N_list, d_list, D_list, T_day_list, T_month_list, v, f) - s = 0; %sum for all the points of all the files - for i = 1:length(files) - data = load(files{i}); - x = data(:, 1); %x (tau) - elapsed time in months - y = data(:, 2); %y (SR) - survival rate in percentage - N = N_list(i); - d = d_list(i); - D = D_list(i); - T_day = T_day_list(i); - T_month = T_month_list(i); - sf = 0; %sum for the points of a specific file - - for j = 1:length(x) - y_fit = f(x(j),v,d,D,T_day,T_month); - sigma = y(j) .* sqrt(abs((1-y(j)))./N); - res = (y_fit - y(j)).^2 / sigma.^2; - sf = res + sf; - end - s = sf + s; - end - r = s; -end - -end %main \ No newline at end of file diff --git a/Interface/dev/fit2.m b/Interface/dev/fit2.m deleted file mode 100644 index 3545fdb..0000000 --- a/Interface/dev/fit2.m +++ /dev/null @@ -1,285 +0,0 @@ -function [K50_K0, alpha, beta, gamma, Td, sigmak_K0, delta] = fit2(file_names, labels) - -% CSV files -%Liang,Dawson,SeongH,SeongM,SeongL -number_studies = numel(file_names); -% Data from the files: -%x (tau) - elapsed time in months -%y (SR) - survival rate in percentage -N_values = [128, 35, 83, 51, 24]; %N - number of patients -d_values = [4.88, 1.5, 1.8, 1.8, 1.8]; %d - dose per fraction Gy/fx -D_values = [53.6, 61.5, 55, 45, 32.5]; %D - prescription dose Gy -T_day_values = [28, 42, 37, 37, 37]; %T_day - treatment time in days -T_month_values = zeros(size(T_day_values)); %T_month - treatment time in months -for i = 1:length(T_day_values) - tm = T_day_values(i)/30; - T_month_values(i) = tm; -end - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%points from all the files%%% -%xx = []; -%yy = []; -%for i = 1:length(file_names) -% data = load(file_names{i}); -% xx = [xx; data(:,1)]; -% yy = [yy; data(:,2)]; -%end -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%v - vector with parameters to find - %v(1) - K50/K0 - %v(2) - alpha Gy^-1 - %v(3) - beta Gy^-2 - %v(4) - gamma days^-1 - %v(5) - sigmak/K0 - %v(6) - delta - -% Initial parameter values - defined by the user HEAD -v0 = [2.03, 0.010, 0.000666, 0.00542, 0.65, 0.20]; - -% Define the parameter bounds -lb = [1.99, 0.009, 0.000647, 0.00495, 0.59, 0.19]; -ub = [2.07, 0.011, 0.000692, 0.00598, 0.71, 0.21]; - -v0 = [2.04, 0.01, 0.00067, 0.0054, 0.65, 0.20]; - -% Define the parameter bounds -lb = [1, 0, 0, 0, 0, 0]; -ub = [3, 0.015, 0.0008, 0.01, 1, .5]; - - -% Fitting function -f = @(x,v,d,D,T_day) fit(x,v,d,D,T_day,'fitting'); - - -% Chi-square function -chi2 = @(v) residuals(file_names, N_values, d_values, D_values, T_day_values, v, f); - - -%fmincon -% Set up the algorithm options -options = optimoptions('fmincon', ... - 'MaxIterations',1000, ... - 'TolFun',1e-9,'TolX',1e-9); -% Run the algorithm -[v_min,fval,exitflag,output,lambda,grad,hessian] = fmincon(chi2, v0, [], [], [], [], lb, ub, [], options); - -% Display the results -% real results -% K50/K0 = 2.03±0.04 -% alpha = 0.010±0.001 -% alpha/beta = 15.0±2.0 -% sigmak/K0 = 0.65±0.06 -% Td = 128±12 -% delta = 0.20±0.01 - -K50_K0 = num2str(v_min(1)); -alpha = num2str(v_min(2)); -beta = num2str(v_min(3)); -gamma = num2str(v_min(4)); -sigmak_K0 = num2str(v_min(5)); -Td = num2str(log(2) ./ v_min(4)); -delta = num2str(v_min(6)); - -disp('Parameters values of that minimize the sum of squares (value):'); -disp(['K50/K0: ', K50_K0]); -disp(['alpha: ', alpha]); -disp(['beta: ', beta]); -disp(['alpha/beta: ' num2str(v_min(2)./v_min(3))]); -disp(['gamma: ', gamma]); -disp(['Td: ' Td]); -disp(['sigmak/K0: ', sigmak_K0]); -disp(['delta: ', delta]); -% disp('Parameters values of that minimize the sum of squares (value ± std):'); -% disp(['K50/K0: ', num2str(v_min(1)), ' ± ', num2str(un(1))]); -% disp(['alpha: ', num2str(v_min(2)), ' ± ', num2str(un(2))]); -% disp(['beta: ', num2str(v_min(3)), ' ± ', num2str(un(3))]); -% disp(['alpha/beta: ' num2str(v_min(2)./v_min(3))]); -% disp(['gamma: ', num2str(v_min(4)), ' ± ', num2str(un(4))]); -% disp(['sigmak/K0: ', num2str(v_min(5)), ' ± ', num2str(un(5))]); -% disp(['Td: ' num2str(log(2) ./ v_min(4))]); -% disp(['delta: ', num2str(v_min(6)), ' ± ', num2str(un(6))]); - - -% Plotting -hold on -x_points = linspace(1, 70, 71); - -v_min = [2.04, 0.01, 0.00067, 0.0054, 0.65, 0.20]; - -% Liang -data = load(file_names{1}); - -y_plot = []; -x_plot = []; -x = data(:, 1); -y = data(:, 2); -%original points -plot(x, y, 'v', 'LineWidth', 2, 'Color', '#FD04FC','MarkerSize', 6, 'DisplayName', 'Liang') -%fitted function -for i = 1:length(x_points) - sr = fit(x_points(i),v_min,d_values(1),D_values(1),T_day_values(1),'plotting'); - if ~isnan(sr) - tau = x_points(i); - y_plot = [y_plot, sr]; - x_plot = [x_plot, tau]; - end -end - -plot(x_plot, y_plot, '--', 'LineWidth', 2, 'Color', '#FD04FC','HandleVisibility', 'off') -hold on; - - -% Dawson -data = load(file_names{2}); - -y_plot = []; -x_plot = []; -x = data(:, 1); -y = data(:, 2); -%original points -plot(x, y, 'o', 'LineWidth', 2, 'Color', '#0000F7','MarkerSize', 6, 'DisplayName', 'Dawson'); -%fitted function -for i = 1:length(x_points) - sr = fit(x_points(i),v_min,d_values(2),D_values(2),T_day_values(2),'plotting'); - if ~isnan(sr) - tau = x_points(i); - y_plot = [y_plot, sr]; - x_plot = [x_plot, tau]; - end -end - -plot(x_plot, y_plot, '--', 'LineWidth', 2, 'Color', '#0000F7','HandleVisibility', 'off'); -hold on; - - -% SeongH -data = load(file_names{3}); - -y_plot = []; -x_plot = []; -x = data(:, 1); -y = data(:, 2); -%original points -plot(x, y, '^', 'LineWidth', 2, 'Color', '#000000','MarkerSize', 6, 'DisplayName', 'SeongH'); -%fitted function -for i = 1:length(x_points) - sr = fit(x_points(i),v_min,d_values(3),D_values(3),T_day_values(3),'plotting'); - if ~isnan(sr) - tau = x_points(i); - y_plot = [y_plot, sr]; - x_plot = [x_plot, tau]; - end -end - -plot(x_plot, y_plot, '--', 'LineWidth', 2, 'Color', '#000000','HandleVisibility', 'off'); -hold on; - -% SeongM -data = load(file_names{4}); - -y_plot = []; -x_plot = []; -x = data(:, 1); -y = data(:, 2); -%original points -plot(x, y, 's', 'LineWidth', 2, 'Color', '#FD6C6D','MarkerSize', 6, 'DisplayName', 'SeongM'); -%fitted function -for i = 1:length(x_points) - sr = fit(x_points(i),v_min,d_values(4),D_values(4),T_day_values(4),'plotting'); - if ~isnan(sr) - tau = x_points(i); - y_plot = [y_plot, sr]; - x_plot = [x_plot, tau]; - end -end - -plot(x_plot, y_plot, '--', 'LineWidth', 2, 'Color', '#FD6C6D','HandleVisibility', 'off'); -hold on; - -% SeongL -data = load(file_names{5}); - -y_plot = []; -x_plot = []; -x = data(:, 1); -y = data(:, 2); -%original points -plot(x, y, 'o', 'LineWidth', 2, 'Color', '#46FD4B','MarkerSize', 6, 'DisplayName', 'SeongL'); -%fitted function -for i = 1:length(x_points) - sr = fit(x_points(i),v_min,d_values(5),D_values(5),T_day_values(5),'plotting'); - if ~isnan(sr) - tau = x_points(i); - y_plot = [y_plot, sr]; - x_plot = [x_plot, tau]; - end -end - -plot(x_plot, y_plot, '--', 'LineWidth', 2, 'Color', '#46FD4B','HandleVisibility', 'off'); -hold on; - -%legend,lables and title -legend('Location', 'northeast') -legend('boxoff') -xlabel('elapsed time from beginning of RT (Month)-tau') -ylabel('Survival Rate (%)-SR') -title('Fit 2') - -%saving the plot -%saveas(gcf, 'fit2.pdf') - -%%%%%%%%%%%%%%%%%%%%%%% -%Functions% - -function result = fit(tau,v,d,D,T_day,purpose) - %v(1) - K50/K0 - %v(2) - alpha Gy^-1 - %v(3) - be ta Gy^-2 - %v(4) - gamma days^-1 - %v(5) - sigmak/K0 - %v(6) - delta - denominator = v(5); - p = v(2) * (1 + d / (v(2) / v(3))) * D - v(4) * T_day - ((v(4) * (30 * tau - T_day)) ^ v(6)); - % 30->to convert months into days - numerator = exp(-p) - v(1); - t = numerator / denominator; - if strcmp(purpose, 'fitting') - %during the fitting if t assumes complex values there is no issue - result = 100 * (1/2)*(1-erf(t/sqrt(2))); - elseif strcmp(purpose, 'plotting') - if isreal(t) - result = 100 * (1/2)*(1-erf(t/sqrt(2))); - else - result = NaN; - end - end - end - - -function r = residuals(files, N_list, d_list, D_list, T_day_list, v, f) - s = 0; %sum for all the points of all the files - for i = 1:length(files) - data = load(files{i}); - x = data(:, 1); %x (tau) - elapsed time in months - y = data(:, 2); %y (SR) - survival rate in percentage - N = N_list(i); - d = d_list(i); - D = D_list(i); - T_day = T_day_list(i); - sf = 0; %sum for the points of a specific file - - for j = 1:length(x) - y_fit = f(x(j),v,d,D,T_day); - sigma = y(j) .* sqrt(abs((1-y(j)))./N); - res = (y_fit - y(j)).^2 / sigma.^2; - sf = res + sf; - end - s = sf + s; - end - r = s; -end - - -end %main \ No newline at end of file diff --git a/Interface/dev/logoFCUL.jpg b/Interface/dev/logoFCUL.jpg deleted file mode 100644 index dc3d42f..0000000 Binary files a/Interface/dev/logoFCUL.jpg and /dev/null differ diff --git a/Interface/dev/main_dev.m b/Interface/dev/main_dev.m deleted file mode 100644 index ed96389..0000000 --- a/Interface/dev/main_dev.m +++ /dev/null @@ -1,664 +0,0 @@ -function main_dev -% function main -% HELP: this function launches a GUI (Graphical User Interface) to perform -% survival rate (SR) modeling by fitting different survival models to -% clinical data inputed by the user -% -% -% INPUT -% * none -% -% OUTPUT -% * none -% -% SEE ALSO: uimenu, uitoolbar, uipushtool, uipanel, uicontrol, uigetfile, -% uibuttongroup, -% -% ------------------------------------------------------------------------- -% Authors: -% R. Pires -% A. Pardal -% R. Santos -% -% Last Update: 07/06/2023 -% -% adapted from bcf's teraPro function made in 09-01-2023 -% ------------------------------------------------------------------------- - - -%-------------------------------------------------------------------------- -% Initialize some variables for demonstration purposes -%-------------------------------------------------------------------------- -data = {}; -TestData = {true 'Data1.m' 'data1' 128 53.6 4.88 28;... - true 'Data2.m' 'data2' 35 61.5 1.5 42;... - true 'Data3.m' 'data3' 83 55 1.8 37;... - true 'Data4.m' 'data4' 51 45 1.8 37;... - true 'Data5.m' 'data5' 24 32.5 1.8 37}; -FitData = {}; -FitInput = {}; -%---------- ----------% - -%-------------------------------------------------------------------------- -% MAIN FIGURE -%-------------------------------------------------------------------------- -mainFig =figure(1); -set(mainFig ,'Name','SR Modeling',... - 'WindowState', 'maximized',... % Maximize window by default - 'KeyPressFcn',@figure_keyPressFcn,... % What happens when certain keys are pressed on the keyboard - 'MenuBar','None'); -clf, % clear the figure - - function figure_keyPressFcn(hObject,eventdata) - - switch eventdata.Key - case 'return' - pushbutton_Fit_Callback() - case 'backspace' - set(hObject,'Color','b') - case 'escape' - pushbutton_ClearAxes_Callback() - pushbutton_ClearFitAxes_Callback() - end - end -%---------- ----------% - -%-------------------------------------------------------------------------- -% CIENCIAS LOGO -%-------------------------------------------------------------------------- -[tmp,~,alfa] = imread('ciencias_ul_azul_h_s-ass.png'); - -handles.axes_logo = axes('Parent',mainFig,... - 'Units','Normalized', ... - 'Position',[0.03 0.85 0.12 0.12],... - 'Visible','off'); -tmp=image(tmp); -set(tmp, 'AlphaData', alfa); -axis equal off -%---------- ----------% - - -%-------------------------------------------------------------------------- -% MENU -%-------------------------------------------------------------------------- -handles.uimenu_new = uimenu(mainFig, ... - 'Label','New'); - -handles.uimenu_newFile = uimenu(handles.uimenu_new,... - 'Label','New File...',... - 'Callback',@uimenu_new_callback); - -handles.uimenu_saveFile = uimenu(handles.uimenu_new,... - 'Label','Save...',... - 'Separator','on',... - 'Callback',@uimenu_save_callback); - - function uimenu_new_callback(~,~) - - warndlg(['No action will happen when Pressing OK because'... - ' this Callback function is not programmed yet!'],... - '!! Warning !!') - % See Also: dialog, questdlg, errordlg - end - - function uimenu_save_callback(~,~) - % Can be any variable stored in the interface or the workspace - uisave({'data'},'ListStudents.mat') %Suggested filename - %See Also: uigetfifle, uiopen - end -%---------- ----------% - -%-------------------------------------------------------------------------- -% TOOLBAR -%-------------------------------------------------------------------------- -handles.toolbar=uitoolbar(mainFig); - -b=load('.\myloginicon.mat'); -uipushtool(handles.toolbar, ... - 'CData', b.icon,... - 'TooltipString', 'Login',... - 'Tag', 'pushtool_login',... - 'Enable', 'on',... - 'ClickedCallback', 'menu_login_Callback();') - -%------------------- -% "Add File" Button -%------------------- -uipushtool(handles.toolbar, ... - 'TooltipString', 'Add File',... - 'Tag', 'pushtool_addfile',... - 'Enable', 'on',... - 'ClickedCallback', @pushbutton_add_Callback) - -%---------------------- -% "Delete File" Button -%---------------------- -uipushtool(handles.toolbar, ... - 'TooltipString', 'Delete File',... - 'Tag', 'pushtool_delfile',... - 'Enable', 'on',... - 'ClickedCallback', @pushbutton_Callback) - -%-------------------- -% "Save Plot" Button -%-------------------- -uipushtool(handles.toolbar, ... - 'TooltipString', 'Save Plot',... - 'Tag', 'pushtool_saveplot',... - 'Enable', 'on',... - 'ClickedCallback', @pushbutton_add_Callback) -%---------- ----------% - - -%-------------------------------------------------------------------------- -% BUILD DATA SETS LIST PANEL -%-------------------------------------------------------------------------- -panel_DataList = uipanel('Tag','panel_DataList',... - 'Title', 'Data Sets',... - 'Units', 'Normalized',... - 'Position', [.16 .78 .2 .2],... - 'HighlightColor', [0 0 1],... - 'FontSize', 12,... - 'Parent', mainFig); - -uicontrol(panel_DataList,... - 'Tag', 'text',... - 'Style', 'Text', ... - 'String', ' ',... - 'FontName', 'Arial',... - 'FontSize', 13,... - 'Units', 'Normalized',... - 'Position', [.05 .95 .99 .05],... - 'Enable', 'on',... - 'Callback', @listbox_Callback); - -handles.listbox_DataSets = uicontrol(panel_DataList,... - 'Tag', 'listbox_DataSets',... - 'Style', 'listbox', ... - 'String', {'Data1', 'Data2', 'Data3', 'Data4', 'Data5'},... - 'Units', 'Normalized',... - 'Position', [.05 .30 .6 .70],... - 'Enable', 'on',... - 'Tooltipstring', 'Select a Data Set to plot',... - 'Callback', @listbox_DataSets_Callback); - - function listbox_DataSets_Callback(hObject, ~) - handles.pushbutton_delete.Enable ='on'; - % Get entries in listbox_DataSets - DataSetsList = get(handles.listbox_DataSets,'String'); - tmp = get(hObject, 'String'); - val = get(hObject, 'Value'); - % Get data stored in the Data Details table as "Userdata" - data = get(handles.uitable,'Userdata'); - % Labels for each data set - Labels = data(:,3); - % Plot the selected data set - %cla(handles.axes_plotData, 'reset') %reset plot - axes(handles.axes_plotData); %Select "plotData" axes - for i = 1:numel(DataSetsList) - if strcmp(tmp(val), DataSetsList(i)) - InputData = load(strcat('.\',string(tmp(val,:)),'.m')); - - Time = InputData(:, 1); - SR = InputData(:, 2); - - my_color = rand(1,3); - all_marks = {'o','+','*','x','s','d','^','v','>','<','p','h'}; - - plot(Time, SR, ... - 'LineStyle', 'none', ... - 'Marker', all_marks{mod(i,12)},... - 'LineWidth', 2, ... - 'Color', my_color, ... - 'MarkerSize', 6, ... - 'DisplayName', string(Labels(i))) - legend('Location', 'northeast') - legend('boxoff') - xlabel('Time (months)') - ylabel('SR (%)') - title('Clinical Data') - end - end - end - - -handles.pushbutton_add = uicontrol(panel_DataList,... - 'Tag', 'pushbutton_add',... - 'Style', 'pushbutton', ... - 'String', 'Add new',... - 'Units', 'Normalized',... - 'Position', [.68 .7 .3 .3],... - 'Enable', 'on',... - 'ForegroundColor', "#77AC30",... - 'Tooltipstring', 'Add a new data set',... - 'Callback', @pushbutton_add_Callback); - - function pushbutton_add_Callback(~,~) - - data = get(handles.uitable,'Userdata'); % Get data from the Data Details table - DataSetsList = get(handles.listbox_DataSets,'String'); % Get entries in listbox_DataSets - n=numel(DataSetsList); - - if isempty(DataSetsList) % if there is no data yet in the list or all was deleted - file = uigetfile; % Selects file - FileName = strsplit(file, '.'); - FileName = string(FileName{1}); % Gets file name - set(handles.listbox_DataSets,... - 'String', FileName,... - 'Value', 1) % leave this student selected - data(size(data,1)+1,:) = cell(1,7); - set(handles.uitable, ... - 'Rowname', get(handles.listbox_DataSets,'String'),... - 'Data', data, ... - 'Userdata', data); - else - file = uigetfile; % User selects file - FileName = strsplit(file, '.'); - FileName = string(FileName{1}); % Gets file name - DataSetsList = [DataSetsList;FileName]; - set(handles.listbox_DataSets,'String',DataSetsList,... - 'Value',n) % leave last student selected - data(size(data,1)+1,:) = cell(1,7); - set(handles.uitable,... - 'Rowname',get(handles.listbox_DataSets,'String'),... - 'Data', data, ... - 'Userdata',data); - end - end - -handles.pushbutton_delete = uicontrol(panel_DataList,... - 'Tag', 'pushbutton_delete',... - 'Style', 'pushbutton', ... - 'String', 'Delete',... - 'Units', 'Normalized',... - 'Position', [.68 .4 .3 .2],... - 'Enable', 'off',... - 'ForegroundColor', 'r',... - 'Tooltipstring', 'Deletes the selected entry from the list',... - 'Callback', @pushbutton_delete_Callback); - - function pushbutton_delete_Callback(~,~) - - % As a precaution measure, everytime data is deleted, the user - % should be questioned - qst = 'Are you sure you need to delete this information?'; - button = questdlg(qst,'WARNING DELETE','Yes','No','No'); - % No is the default button selected - if strcmp(button,'Yes') - DataList = get(handles.listbox_DataSets,'String'); - val=get(handles.listbox_DataSets,'Value'); - DataList(val) =''; - set(handles.listbox_DataSets,'String',DataList,'Value',1) - % all information related to that instance needs to be erased - %set(handles.edit_date,'String','') - set(handles.uitable,... - 'Rowname',get(handles.listbox_DataSets,'String')) - data = get(handles.uitable,'Userdata');%or get(handles.uitable,'Data'); - data(val,:)=''; - set(handles.uitable,'Data',data,'Userdata',data) - end - - end - - -handles.pushbutton_ClearAxes = uicontrol(panel_DataList,... - 'Tag', 'pushbutton_ClearAxes',... - 'Style', 'pushbutton', ... - 'String', 'Clear',... - 'Units', 'normalized',... - 'Position', [.68 .1 .3 .2],... - 'Enable', 'on',... - 'ForegroundColor', "#EDB120",... - 'Tooltipstring', 'Clear "Clinical Data" axes',... - 'Callback', @pushbutton_ClearAxes_Callback); - - function pushbutton_ClearAxes_Callback(~,~) - - cla(handles.axes_plotData, 'reset') %reset plot - axes(handles.axes_plotData); - xlabel('Time (months)') - ylabel('SR (%)') - title('Clinical Data') - hold on; - enableDefaultInteractivity(handles.axes_plotData) - - end -%---------- ----------% - -%-------------------------------------------------------------------------- -% "DATA DETAILS" PANEL -%-------------------------------------------------------------------------- -handles.panel_DataDetails = uipanel('Parent',mainFig,... - 'Tag', 'panel_DataDetails',... - 'Title', 'Data Details',... - 'Units', 'Normalized',... - 'Position', [.01 .53 .35 .25],... - 'HighlightColor', 'm',... - 'ForegroundColor', 'k',... - 'FontSize', 12); - -%----------------------------- -% "DATA DETAILS" UITABLE -%----------------------------- -handles.uitable = uitable(handles.panel_DataDetails,... - 'Tag', 'uitable',... - 'Data', TestData,... % Data displayed on the table - 'Units', 'normalized', ... - 'Position', [0.01 0.05 .98 .95],... - 'ColumnEditable', true,... - 'ColumnFormat', {'logical' 'char' 'char' '' '' '' ''},... - 'ColumnName', {'Select' 'Author' 'Label' 'Nr. Patients' 'D [Gy]' 'd [Gy/fx]' 'Td [days]'},... - 'RowName', get(handles.listbox_DataSets,'string'),... - 'Userdata', TestData,... % Data that can be accesible by the user - 'CellEditCallback', @listbox_DataSets_Callback); -%---------- ----------% - -%-------------------------------------------------------------------------- -% "PLOTS" PANEL -%-------------------------------------------------------------------------- -handles.panel_Plot = uipanel('Parent',mainFig,... - 'Tag', 'panel_Plot',... - 'Title', 'Plots',... - 'Units', 'Normalized',... - 'Position', [.39 .01 .6 .99],... - 'HighlightColor', 'k',... - 'ForegroundColor', 'k',... - 'FontSize', 12); - -%------------------------- -% AXES TO PLOT DATA -%------------------------- -handles.axes_plotData = axes('Parent',handles.panel_Plot,... - 'Units','Normalized','Position',[0.1 0.1 0.4 0.85],... - 'Visible','on'); -xlabel('Time (months)'),ylabel('SR (%)'), title('Clinical Data'), hold on -enableDefaultInteractivity(handles.axes_plotData) - -%------------------------- -% AXES TO PLOT FIT -%------------------------- -handles.axes_plotFit = axes('Parent',handles.panel_Plot,... - 'Units','Normalized','Position',[0.57 0.1 0.4 0.85],... - 'Visible','on'); -xlabel('Time (months)'),ylabel('SR (%)'), title('Fited Data'), hold on -enableDefaultInteractivity(handles.axes_plotFit) -%---------- ----------% - -%-------------------------------------------------------------------------- -% "MODEL OPTIONS" PANNEL -%-------------------------------------------------------------------------- -panel_Fit = uipanel('Parent', mainFig, ... - 'Tag', 'panel_Fit', ... - 'Title', 'Model Options', ... - 'Units', 'normalized', ... - 'Position', [.01 .23 .356 .3],... - 'HighlightColor', "#EDB120",... - 'ForegroundColor', 'k',... - 'FontSize', 12); - -%---------------------------- -% FIT1 or FIT2 RADIO BUTTONS -%---------------------------- -handles.FitSelection = uibuttongroup('Parent',panel_Fit,... - 'Title', ' ',... - 'Tag', 'buttongroup',... - 'FontSize', 10,... - 'FontWeight', 'bold',... - 'Units', 'normalized', ... - 'Position', [.05 .02 .5 .22],... - 'UserData', {},... - 'SelectionChangeFcn', @FitSelection_Callback); - -handles.radiobutton_Fit1 = uicontrol(handles.FitSelection,... - 'Tag', 'radiobutton_Fit1',... - 'Style', 'radiobutton',... - 'String', 'Fit1',...... - 'Units', 'Normalized', ... - 'Position', [.2 .3 .2 .5],... - 'TooltipString', 'Select Model 1',... - 'FontSize', 10,... - 'HorizontalAlignment', 'right'); - -handles.radiobutton_Fit2 = uicontrol(handles.FitSelection,... - 'Tag', 'radiobutton_Fit2',... - 'Style', 'radiobutton',... - 'String', 'Fit2',...... - 'Units', 'Normalized', ... - 'Position', [.8 .3 .2 .5],... - 'TooltipString', 'Select Model 2',... - 'FontSize', 10,... - 'HorizontalAlignment', 'left'); - - function FitSelection_Callback(hObject,~) - tmp = get(hObject, 'SelectedObject'); - if strcmp(tmp.String, 'Fit1') - set(handles.fit1optionsuitable, 'Visible', 'on'); - set(handles.fiteduitable1, 'Visible', 'on'); - set(handles.fit2optionsuitable, 'Visible', 'off'); - set(handles.fiteduitable2, 'Visible', 'off'); - elseif strcmp(tmp.String, 'Fit2') - set(handles.fit1optionsuitable, 'Visible', 'off'); - set(handles.fiteduitable1, 'Visible', 'off'); - set(handles.fiteduitable2, 'Visible', 'on'); - set(handles.fit2optionsuitable, 'Visible', 'on'); - end - end - - -%---------------------------- -% "MODEL OPTIONS" UITABLE -%---------------------------- -handles.fit1optionsuitable = uitable(panel_Fit,... - 'Tag', 'fit1optionsuitable',... - 'ColumnFormat', {'numeric' 'numeric' 'numeric' 'numeric' 'numeric' 'numeric'},... - 'Data', FitInput,... - 'Units', 'normalized', ... - 'Position', [0.01 .25 .99 .745],... - 'Visible', 'on',... - 'ColumnEditable', true,... - 'ColumnName', {'K' '
    &alpha
    [Gy-1]' ... - '
    &beta
    [Gy-2]' '&gamma' ... - '
    a
    [mo-1]' '&delta'},... - 'RowName', {'Initial Guess' 'Lower limit' 'Upper limit'},... - 'Userdata', FitInput,... - 'CellEditCallback', @fitoptionsuitable_Callback); - -handles.fit2optionsuitable = uitable(panel_Fit,... - 'Tag', 'fit2optionsuitable',... - 'ColumnFormat', {'numeric' 'numeric' 'numeric' 'numeric' 'numeric' 'numeric'},... - 'Data', FitInput,... - 'Units', 'normalized', ... - 'Position', [0.01 .25 .99 .745],... - 'Visible', 'off',... - 'ColumnEditable', true,... - 'ColumnName', {'K50/K0'... - '
    &alpha
    [Gy-1]' ... - '
    &beta
    [Gy-2]'... - '&gamma' ... - '
    &sigmak /K0'... - '&delta'},... - 'ColumnWidth', {50, 50, 50, 50, 50, 50},... - 'RowName', {'Initial Guess' 'Lower limit' 'Upper limit'},... - 'Userdata', FitInput,... - 'CellEditCallback', @fitoptionsuitable_Callback); - - function fitoptionsuitable_Callback(hObject,~) - tmp = get(hObject,'Data'); - % keep the data from the table somwhere - set(handles.fitoptionsuitable, ... - 'Userdata',tmp); - end - -%------------------------------------------------ -% "PERFORM FIT" BUTON -%------------------------------------------------ -handles.pushbutton_fit = uicontrol(panel_Fit,... - 'Tag', 'pushbutton_Fit',... - 'Style', 'pushbutton', ... - 'String', 'Fit',... - 'Units', 'Normalized',... - 'FontSize', 12,... - 'Position', [.6 .02 .15 .22],... - 'Enable', 'on',... - 'ForegroundColor', "#A2142F",... - 'BackgroundColor', '#77AC30',... - 'Tooltipstring', 'Perform fit',... - 'Callback', @pushbutton_Fit_Callback); - - function pushbutton_Fit_Callback(~,~) - - data = get(handles.uitable,'Userdata'); - state1 = get(handles.fit1optionsuitable, 'Visible'); - state2 = get(handles.fit2optionsuitable, 'Visible'); - DataFiles = strings(0); - DataSetsList = get(handles.listbox_DataSets,'String'); - Labels = data(:,3); - - if isempty(data) - disp('No data to show') - else - cla(handles.axes_plotFit, 'reset') %clear axes - axes(handles.axes_plotFit) - Selected = data(:,1); - for i = 1:numel(Selected) - if isequal(Selected(i),{1}) - DataFiles = [DataFiles strcat(".\",string(DataSetsList(i,:)),".m")]; - file_names = cellstr(DataFiles); - end - end - if strcmp(state1, 'on') - [K, alpha, beta, gamma, a, Td, delta] = fit1(file_names, Labels); - FitData = {round(str2double(K),5) round(str2double(alpha),5) round(str2double(beta),5)... - round(str2double(alpha)/str2double(beta),3) round(str2double(gamma),5)... - round(str2double(a),5) round(str2double(Td),0) round(str2double(delta),5)}; - set(handles.fiteduitable1,... - 'Data', FitData,... - 'Userdata', FitData) - %msgbox('Complete!') - elseif strcmp(state2, 'on') - [K50_K0, alpha, beta, gamma, Td, sigmak_k0, delta] = fit2(file_names, Labels); - FitData = {RoundStr2Double(K50_K0,5)... - RoundStr2Double(alpha,5)... - RoundStr2Double(beta,5)... - RoundStr2Double(gamma,5)... - RoundStr2Double(Td,0)... - RoundStr2Double(sigmak_k0,5)... - RoundStr2Double(delta,5)}; - set(handles.fiteduitable2,... - 'Data', FitData,... - 'Userdata', FitData) - %msgbox('Complete!') - end - end - end - -%------------------------------------------------ -% "CLEAR FIT AXES" BUTON -%------------------------------------------------ -handles.pushbutton_ClearFitAxes = uicontrol(panel_Fit,... - 'Tag', 'pushbutton_ClearFitAxes',... - 'Style', 'pushbutton', ... - 'String', 'Clear',... - 'Units', 'Normalized',... - 'Position', [.8 .02 .15 .22],... - 'Enable', 'on',... - 'ForegroundColor', "#EDB120",... - 'Tooltipstring', 'Clear "Fited Data" axes',... - 'Callback', @pushbutton_ClearFitAxes_Callback); - -function pushbutton_ClearFitAxes_Callback(~,~) - - cla(handles.axes_plotFit, 'reset') %reset plot - axes(handles.axes_plotFit); - xlabel('Time (months)') - ylabel('SR (%)') - title('Fited Data') - hold on; - enableDefaultInteractivity(handles.axes_plotFit) - -end -%---------- ----------% - -%-------------------------------------------------------------------------- -% "FITED PARAMETERS" PANEL -%-------------------------------------------------------------------------- -handles.panel_Fited = uipanel('Parent', mainFig, ... - 'Tag', 'panel_Fited', ... - 'Title', 'Fited Parameters', ... - 'Units', 'normalized', ... - 'Position', [.01 .01 .35 .2],... - 'HighlightColor', 'r',... - 'ForegroundColor', 'k',... - 'FontSize', 12); - -%---------------------------- -% "FITED PARAMETERS" UITABLES -%---------------------------- -handles.fiteduitable1 = uitable(handles.panel_Fited,... - 'Tag', 'fiteduitable1',... - 'ColumnFormat', {'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char'},... - 'Data', FitData,... - 'Units', 'Normalized', ... - 'Position', [0.01 .3 .99 .7],... - 'Visible', 'on',... - 'ColumnEditable', false,... - 'ColumnName', {'K' '
    &alpha
    [Gy-1]' ... - '
    &beta
    [Gy-2]' ... - '&alpha/&beta
    [Gy]' ... - '&gamma' ... - '
    Td
    [day]' ... - '
    a
    [mo-1]' ... - '&delta'},... - 'RowName', ' ',... - 'Userdata', FitData,... - 'CellEditCallback', @fiteduitable_Callback); - - -handles.fiteduitable2 = uitable(handles.panel_Fited,... - 'Tag', 'fiteduitable2',... - 'ColumnFormat', {'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char'},... - 'Data', FitData,... - 'Units', 'Normalized', ... - 'Position', [0.01 .3 .99 .7],... - 'Visible', 'off',... - 'ColumnEditable', false,... - 'ColumnName', {'K50/K0' ... - '
    &alpha
    [Gy-1]' ... - '
    &beta
    [Gy-2]' ... - '&alpha/&beta
    [Gy]' ... - '&gamma' ... - '
    Td
    [day]' ... - '
    &sigmak /K0' ... - '&delta'},... - 'RowName', ' ',... - 'Userdata', FitData,... - 'CellEditCallback', @fiteduitable_Callback); - -%----------------------------------- -% "FITED PARAMETERS" SAVE PLOT BUTTON -%----------------------------------- -handles.pushbutton_SavePlot = uicontrol(handles.panel_Fited,... - 'Tag', 'pushbutton_SavePlot',... - 'Style', 'pushbutton', ... - 'String', '
    Save
    Plot',... - 'Units', 'Normalized',... - 'Position', [.80 .005 .1 .25],... - 'Enable', 'on',... - 'ForegroundColor', 'r',... - 'Tooltipstring', 'Perform fit',... - 'Callback', @pushbutton_SavePlot_Callback); - - function pushbutton_SavePlot_Callback (~,~) - - FileName = inputdlg('Enter file name and extension (.png, .pdf, .jpg, .fig, .m, .jpeg, .svg):'); - - fignew = figure('Visible','off'); % Invisible figure - newAxes = copyobj(handles.axes_plotFit,fignew); % Copy the appropriate axes - set(newAxes,'Position',get(groot,'DefaultAxesPosition')); % The original position is copied too, so adjust it. - set(fignew,'CreateFcn','set(gcbf,''Visible'',''on'')'); % Make it visible upon loading - saveas(fignew,string(FileName)); - delete(fignew); - end -%----------% - -end %main \ No newline at end of file diff --git a/Interface/dev/myloginicon.mat b/Interface/dev/myloginicon.mat deleted file mode 100644 index 985fbd6..0000000 Binary files a/Interface/dev/myloginicon.mat and /dev/null differ diff --git a/Interface/dev/olduitable-master/LICENSE b/Interface/dev/olduitable-master/LICENSE deleted file mode 100644 index a8f2343..0000000 --- a/Interface/dev/olduitable-master/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Pablo Baez R. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Interface/dev/olduitable-master/README.md b/Interface/dev/olduitable-master/README.md deleted file mode 100644 index 7b3e000..0000000 --- a/Interface/dev/olduitable-master/README.md +++ /dev/null @@ -1,527 +0,0 @@ -# olduitable - -**olduitable** is a Matlab class that implements a Java-based table. It includes many of the properties of the Matlab uitable, with an interface similar to its undocumented version (v0). Besides this class incorporates new properties such as `ColumnAlign`, `ColumnColor`, `ColumnToolTip`, `GridColor`, `HeaderBackground`, `SelectionBackground`, among others, and methods to insert or delete rows and columns and paste blocks of cells as a typical spreadsheet. - -

    examples

    - -## First steps -Once downloaded, we must copy the `@olduitable` folder to any folder that is in the Matlab search path (type `userpath` in the command window to see the first folder in the path) or use `addpath` to add this folder. - -## Usage -### Creation of the table - -``` -t = olduitable; -t = olduitable('PropertyName1',value1,'PropertyName2',value2,...); -t = olduitable(parent,'PropertyName1',value1,'PropertyName2',value2,...); -``` - -As usual in Matlab, the property name can be in lowercase during this stage. - -### Modification of properties - -``` -t.PropertyName = value; % prefer this form -set('PropertyName1',value1,'PropertyName2',value2,...); -``` - -The property name can be in lowercase only for the second form. - -### Methods - -``` -t.methodName(arg1,arg2,...); -methodName(t,arg1,arg2,...); -``` - -## List of properties - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    PropertyValid inputsExamplesNotes - -
    ButtonDownFcn
    Function that executes when a mouse button is pressed in the table -
    ▸'' (default)
    ▸function handle
    ▸cell array
    ▸ char vector -
    t.ButtonDownFcn = @function1;

    t.ButtonDownFcn = @(~,e)disp(['a ',...
    e.Button,' click was made on ',e.ClickedArea]);

    t.ButtonDownFcn = {@function2,...
    extraArg1,extraArg2};

    t.ButtonDownFcn = 'disp(''a mouse button was pressed'')'; -
    The function handle receives 2 arguments by default: the Source and the EventData. The first is the olduitable object involved and the last one is a structure with the fields ClickedArea, Button, ClickCount and ClickPosition. - -
    CellEditCallback
    Function that executes when the contents of table change -
    ▸'' (default)
    ▸function handle
    ▸cell array
    ▸char vector -
    t = olduitable('ColumnEditable',true,...
    'Data',magic(5),...
    'CellEditCallback', @(~,e)disp(['the cell (',...
    num2str([e.RowIndices(1) e.ColumnIndices(1)]),...
    ') was the first one edited'])); -
    The EventData structure contains the fields: RowIndices, ColumnIndices, PreviousData, EditData and EventName. - -
    CellSelectionCallback
    Function that executes when the table selection changes -
    ▸'' (default)
    ▸function handle
    ▸cell array -
    - The EventData structure contains the fields: RowIndices and ColumnIndices. - -
    ColumnAlign
    Indicates the alignment of the columns. -
    ▸'center' (default), 'letf' or 'right'
    ▸1-by-n or n-by-1 cell array of character vectors with any of those values for each column. -
    t = olduitable('Data',magic(2),...
    'ColumnAlign',{'left','right'}); -
    If the length of the ColumnAlign array doesn't match the number of columns in the table, it will be resized truncating to the correct size or filling in with the default value.

    -This property won't have effect for the columns with 'color' or 'logical' formats. - -
    ColumnColor
    Indicates the pattern for the columns' background colors. -
    ▸[1 1 1; 0.94 0.94 0.94] (default)
    ▸m-by-3 matrix of RGB triplets -
    t = olduitable('data', magic(10),...
    'ColumnStriping','on',...
    'ColumnColor',[1 0 0; 0 1 0; 0 0 1]); -
    This property will take effect as long as the ColumnStriping property is set to 'on' and the RowStriping property is 'off'.

    -See also the setCellBg method. - -
    ColumnEditable
    Indicates the ability to edit the column cells -
    ▸logical scalar or array (false by default)
    ▸numeric scalar or array with binary values -
    t = olduitable('data',magic(2),...
    'ColumnEditable',[true false]);

    t2 = olduitable(figure,'Data',magic(2),...
    'ColumnEditable',[1 0]); -
    If the length of the ColumnEditable array doesn't match the number of columns in the table, it will be resized truncating to the correct size or filling in with the default value (or repeating the assigned unique value). - -
    ColumnFormat
    Indicates the column displays -
    ▸empty char '' (default)
    ▸char vectors as 'bank', 'char', 'color', 'logical', 'longchar' or 'popup'
    ▸char vector with a valid formatting operator (see Matlab Documentation) -
    ▸1-by-n or n-by-1 cell array of char vectors with any of those values for each column. -
    data = {'red','dog',true,pi,repmat('a',1,100);
    'blue','cat',false,25,repmat('b',1,100)};
    t = olduitable('ColumnEditable',true,...
    'ColumnFormat',{'color','popup','logical','%.2f','longchar'},...
    'Data',data);

    t2 = olduitable(figure,'ColumnEditable',true,...
    'ColumnFormat','color',...
    'Data',{java.awt.Color(0.7,0.4,0.9),'m'}); -
    If the ColumnEditable property for the columns with formats like 'color', 'logical', 'longchar' or 'popup' is false (or 0), user won't be able to interact with these columns.

    The 'color' format supports a short or long name of the basic colors and a java.awt.Color object, as in the second example. - -
    ColumnFormatData
    Indicates the list of options for the columns with a 'popup' ColumnFormat value. -
    ▸empty cell array {} (default) -
    ▸1-by-n or n-by-1 cell array with empty values or cellstr arrays. -
    t = olduitable('ColumnEditable',true,...
    'ColumnFormat',{'color','popup'},...
    'Data',{'red','dog'; 'blue','cat'});
    t.ColumnFormatData{2} = {'dog','cat',...
    'rabbit','turtle'}; -
    If the format of the column is not equal to 'popup' and the ColumnFormatData value is a cellstr a warning will appear and the popup list won't be assigned. Despite this, the value will be stored in case the user assigns the appropriate format later.

    -If the ColumnFormatData is empty for a column that has a 'popup' format (as shown in the example for the ColumnFormat property) the popup list will be created automatically considering all the different cell values for this column. - -
    ColumnName
    Indicates the names of the column headers -
    ▸'numbered'(default)
    ▸empty array
    ▸1-by-n or n-by-1 cell array of char vectors -
    t = olduitable('Data',magic(2),...
    'ColumnName',{'header 1',...
    'too long|header for a|single line'});
    -
    If an empty array is assigned ({} or []), the table won't have column headers.

    If the length of the ColumnName array doesn't match the number of columns in the table, it will be resized truncating to the correct size or filling in with empty chars (''). - -
    ColumnResizable
    Indicates the ability to resize the column widths -
    ▸logical scalar or array (true by default)
    ▸numeric scalar or array with binary values -
    t = olduitable('data',magic(2),...
    'ColumnResizable',[true false]);

    t2 = olduitable(figure,'Data',magic(2), 'ColumnResizable',[1 0]); -
    If the length of the ColumnResizable array doesn't match the number of columns in the table, it will be resized truncating to the correct size or filling in with the default value. - -
    ColumnSortable
    Indicates the ability to sort the columns -
    ▸logical scalar or array (true by default)
    ▸numeric scalar or array with binary values -
    t = olduitable('data',magic(10),...
    'ColumnSortable',[true(1,5) false(1,5)]); -
    To sort a column we must left-click the header.
    -The sort order is unsorted > ascending > descending, then the cycle starts again.

    -See also the sortColumn and unsort methods. - -
    ColumnStriping
    Indicates if columns have a shading pattern -
    ▸'on'
    ▸'off' (default) -
    t = olduitable('Data',magic(10),...
    'ColumnStriping','on'); -
    This property will take effect as long as the RowStriping property is 'off'. - -
    ColumnToolTip
    Indicates the tooltips for the column headers -
    ▸empty char '' (default)
    ▸1-by-n or n-by-1 cell array of char vectors -
    t = olduitable('Data',magic(3),...
    'ColumnToolTip',...
    {['this tooltip is very long|',...
    'to show it in a single line'],'',...
    'hi, I am the tooltip for the third column'}); -
    If the length of the ColumnToolTip array doesn't match the number of columns in the table, it will be resized truncating to the correct size or filling in with the default empty value (so, there will be no tooltips in these columns). - -
    ColumnWidth
    Indicates the width of the columns -
    ▸positive number (75 by default)
    ▸1-by-n or n-by-1 cell array with positive numbers whose values are in pixel units -
    t = olduitable('Data',magic(10),...
    'ColumnWidth',50); -
    If the length of the ColumnWidth array doesn't match the number of columns in the table, it will be resized truncating to the correct size or filling in with the default value.

    -See also the fitAllColumns2Panel and fitColumn2Data methods. - -
    Data
    Indicates the contents of the table -
    numeric, logical or cell array - - See also the getValue, setValue, paste and cut methods. - -
    Enable
    Indicates the ability to interact with the mouse and keyborad in the table -
    ▸'on' (default)
    ▸'off' -
    - The Regardless of the Enable setting, ButtonDownFcn property will remain active. - -
    FontName
    Indicates the font for the cell content. -
    any system supported font name that MATLAB can renderer - t = olduitable('data',magic(5),...
    'FontName','Courier New'); -
    - -
    FontSize
    Indicates the font size for the table -
    positive number whose value is in pixel units (12 by default) - - If a decimal number is assigned it will be rounded to the nearest integer. - -
    FontStyle
    Indicates the font style for the table -
    ▸'normal' or 0 (default)
    ▸'bold' or 1
    ▸'italic' or 2
    ▸'bold italic' or 3 -
    - - -
    ForegroundColor
    Indicates the cell text color -
    ▸short or long name of a basic color
    ▸RGB triplet ([0 0 0] by default) -
    t = olduitable('Data',magic(5),...
    'ForegroundColor','blue'); -
    See also the setCellFg method. - -
    GridColor
    Indicates the color of the grid in the table -
    ▸short or long name of a basic color
    ▸RGB triplet ([0.85 0.85 0.85] by default) -
    t = olduitable('Data',magic(5),...
    'GridColor','blue'); -
    - -
    HeaderBackground
    Indicates the background color of row and column headers -
    ▸short or long name of a basic color
    ▸RGB triplet ([0.94 0.94 0.94] by default) -
    t = olduitable('Data',magic(5),...
    'HeaderBackground',[0.57 0.79 0.97]); -
    - -
    HeaderForeground
    Indicates the foreground color of row and column headers -
    ▸short or long name of a basic color
    ▸RGB triplet ([0 0 0] by default) -
    - - -
    HeaderGridColor
    Indicates the color of the borders in the row and column headers -
    ▸short or long name of a basic color
    ▸RGB triplet ([0.75 0.75 0.75] by default) -
    t = olduitable('Data',magic(5),...
    'HeaderGridColor','black'); -
    - -
    HeaderSelectionBg
    Indicates the selection background color of row and column headers -
    ▸short or long name of a basic color
    ▸RGB triplet ([0.8 0.8 0.8] by default) -
    t = olduitable('Data',magic(5),...
    'HeaderSelectionBg','c'); -
    - -
    HeaderSelectionFg
    Indicates the selection foreground color of row and column headers -
    ▸short or long name of a basic color
    ▸RGB triplet ([0 0 0] by default) -
    - - -
    KeyPressFcn
    Function that executes when a key is pressed -
    ▸'' (default)
    ▸function handle
    ▸cell array
    ▸char vector -
    t = olduitable('Data',magic(5),...
    'KeyPressFcn',...
    @(~,e)disp(['the ''',e.Key,''' key has been pressed'])); -
    The EventData structure contains the fields: Character, Modifier, Key, and EventName. - -
    KeyReleaseFcn
    Function that executes when a key is released -
    ▸'' (default)
    ▸function handle
    ▸cell array
    ▸char vector -
    - The EventData structure contains the fields: Character, Modifier, Key, and EventName. - -
    Parent
    Indicates the parent object of the table -
    ▸Figure (gcf by default)
    ▸Panel
    ▸ButtonGroup
    ▸Tab -
    f = figure;
    f2 = figure;
    t = olduitable(f,'Data',magic(5),...
    'Parent',f2); -
    Parent assignment will have priority over the first argument - -
    Position
    Indicates the location and size of the table with respect to its parent -
    numeric array
    [left bottom width height]
    ([1 1 350 300] by default) -
    t = olduitable('Data',magic(25));
    set(t,'Units','normalized',...
    'Position',[0 0 1 1]); -
    If multiple properties are assigned in a single call, as in the example , Units property must be declared first than Position. - -
    RowColor
    Indicates the background colors of the rows -
    matrix of RGB triplets ([1 1 1; 0.94 0.94 0.94] by default) - t = olduitable('data',magic(10),...
    'RowStriping','on',...
    'RowColor',[1 0 0; 0 1 0; 0 0 1]); -
    This property will take effect as long as the RowStriping property is 'on'. If not, the first RGB triplet will be used to color all the rows.

    -See also the setCellBg method. - -
    RowHeight
    Indicates the height of the rows -
    ▸'auto' (default)
    ▸positive number whose value is in pixel units -
    t = olduitable('Data',magic(5),...
    'RowHeight',18); -
    The 'auto' value depends on the FontSize and FontName properties.

    If a decimal number is assigned it will be rounded to the nearest integer. - -
    RowName
    Indicates the names of the column headers -
    ▸'numbered' (default)
    ▸empty char ''
    ▸m-by-1 or 1-by-m cell array of char vectors -
    t = olduitable('Data',magic(2),...
    'RowName',{'Row 1';'Row 2'}); -
    If an empty array is assigned ({} or []), the table won't have row headers.

    If the length of the RowName array doesn't match the number of rows in the table, it will be resized truncating to the correct size or filling in with empty chars (''). - -
    RowStriping
    Indicates if rows have a shading pattern -
    ▸'on'
    ▸'off' (default) -
    t = olduitable('Data',magic(10),...
    'RowStriping','on'); -
    This property will have priority over ColumnStriping, so, if both properties are 'on', only the rows will have a shadding pattern. In the case that RowStriping is 'off' and ColumnStriping is 'on', the columns will appear colored. - -
    SelectionBackground
    Indicates the selection background color of cells -
    ▸short or long name of a basic color
    ▸RGB triplet ([0.93 0.95 1] by default) -
    t = olduitable('Data',magic(10),...
    'SelectionBackground',[0.65 0.81 0.95]); -
    The lead selection (last cell selected) will always have a white background color. -

    If the rows or columns have a striped pattern, this property will have no effect. - -
    SelectionForeground
    Indicates the selection foreground color of cells -
    ▸short or long name of a basic color
    ▸RGB triplet ([0 0 0] by default) -
    t = olduitable('Data',magic(10),...
    'SelectionForeground','g'); -
    The lead selection will always have a black foreground color. -

    If the rows or columns have a striped pattern, this property will have no effect. - -
    SelectionBorderColor
    Indicates the color of the external selection border -
    ▸short or long name of a basic color
    ▸RGB triplet ([0.26 0.52 0.96] by default) -
    t = olduitable('Data',magic(10),...
    'SelectionBackground',[0.65 0.81 0.95],...
    'SelectionBorderColor','k'); -
    - -
    Tag
    Assigns the table identifier -
    char vector ('' by default) - - - -
    UIContextMenu
    Indicates the context menu for table -
    ▸'auto' (default)
    ▸empty array
    ▸a javax.swing.JPopupMenu component -
    - The default UIContextMenu is similar to the context menu of the Matlab Variables Editor, so it has items such as Cut, Copy, Paste, Clear Contents and Insert and Delete Rows or Columns (the latter will only be available if the entire table is editable). - -
    Units
    Indicates the units of measure in which the Position vector is expressed -
    ▸'pixels' (default)
    ▸'normalized'
    ▸'inches'
    ▸'centimeters'
    ▸'points'
    ▸'characters' -
    - - -
    UserData
    Indicates the user data associated with the olduitable object -
    any Matlab array ([] by default) - - - -
    Visible
    Indicates the table visibility -
    ▸'on' (default)
    ▸'off' -
    - - -
    - -## Methods - -### Destructor - -To programmatically destroy the `olduitable` object named `t`, use: - -`t.delete` - -### Recoverer - -To save the property values (except for the `Parent` and for a custom `UIContextMenu`) in a structure within a *.mat file, use: - -`t.saveInfo; % it creates the t.mat file in the current directory` - -or - -`t.saveInfo('filename'); % it creates the filename.mat file in the current directory` - -### Deconstructor - -To programmatically redraw the `olduitable` whose properties were stored in the `filename.mat` file, use: - -`t2 = olduitable.loadInfo('filename'); % it's not necessary to include the .mat extension` - -### Adjust the column widths - -To adjust the column widths to the visible area of the scroll pane, use: - -`t.fitAllColumns2Panel` - -If instead, we want to adjust the panel container to the table's size, use: - -``` -previousUnits = t.Units; -t.Units = 'pixels'; -t.Position(3:4) = t.Extent; -t.Units = previousUnits; -``` - -On the other hand, to adjust the width for a column according to its content, use any of the following commands: - -``` -t.fitColumn2Data(columnIndex) -t.fitColumn2Data(columnIndex,considerHeader) -``` - -where `considerHeader` is a logical scalar (`false` by default) that indicates if the column heading name is considered in the calculation. - -This method won't have effect if the format for the column is `'longchar'` and the `considerHeader` input is `false`. If it is `true`, the resulting column width will be the one that best fits the width of the header. - -### Select a range of cells - -To programmatically select a rectangular block defined by the opposite cells `firstCell` and `lastCell`, use: - -`t.setSelection(firstCell,lastCell);` - -where `firstCell = [firstRowIndex, firstColumnIndex]` and `lastCell = [lastRowIndex, lastColumnIndex]`. - -Besides we can select a column by right-clicking the header or select multiple columns through mouse drag (with the same right button). In the same way, clicking on the upper left corner selects the entire table. - -### Sort a column -To sort a column, even if the `ColumnSortable` property for this is `false`, use: - -`t.sortColumn(column,direction);` - -where `column` is the column index and `direction` is the char vector `'ascend'` or `'descend'`. - -The current sorted column will have an arrow indicating the sort direction. Additionally, the follow read-only properties show this information. - -``` -indices = t.RowSortIndices; % indicates the order of the rows order with respect to the unsorted state -sortedColumn = t.SortedColumn; % 0 if the columns are unsorted -sortDirection = t.SortDirection; % 0 = unsorted, 1 = ascending and -1 = descending -``` - -On the other hand, if we consult the `Data` and `RowName` properties, will see reflected the current sort status. - -### Unsort the table -To programmatically unsort the table, use - -`t.unsort;` - -### Get the the content of a specific cell - -To get the cell value at `row` and `column`, use: - -`value = t.getValue(row,column);` - -### Set the content of a specific cell - -To programmatically set the cell value at `row` and `column`, use: - -`t.setValue(value,row,column)` - -The input `value` must be a scalar that is not contained in a cell array (use `{value}` will cause an error). - -### Set the background color for a single cell -To set the background color for a cell at `row` and `column`, use - -`t.setCellBg(value,row,column)` - -where `value` may be a char vector with the short or long name of a basic color (`'r'` or `'red'`for example) or a RGB triplet (`[1 0.5 0]` for example). - -To return to the previous background defined by the `RowColor` or `ColumnColor` properties, use - -`t.resetCellBg(column)` - -### Set the foreground color for a single cell -To set the foreground color for a cell at `row` and `column`, use - -`t.setCellFg(value,row,column)` - -where `value` may be a char vector with the short or long name of a basic color or a RGB triplet. - -To return to the previous foreground defined by the `ForegroundColor` property, use - -`t.resetCellFg(column)` - -**Note**: These "reset" functions will only have effect for the specfied column. - -### Paste data in the table - -To paste the contents of the clipboard (including data from Excel), use any of the following options: - -* the default context menu -* Ctrl + V -* the command `t.paste` - -### Cut data from the table - -To cut the contents of the selected cells in the table `t` use: - -* the default context menu -* Ctrl + X -* the command `t.cut` - -### Clear contents - -To clear the contents of the selected cells use: - -* the default context menu -* delete key -* the command `t.paste({''})` - -**Note**: The methods to paste, cut and clear the contents won't work if the selected columns are not editable. - -### Insert rows - -To insert rows above or below the selected cells use: - -* the default context menu -* Alt + (to insert rows above) -* Alt + (to insert rows below) -* the command `t.insertRows(direction)` where `direction` is `'above'` or `'below'`. - -### Insert columns - -To insert columns to the left or right of the selected cells use: - -* the default context menu -* Alt + (to insert columns to the left) -* Alt + (to insert columns to the right) -* the command `t.insertColumns(direction)` where `direction` is `'left'` or `'right'`. - -### Delete rows - -To delete the selected rows use: - -* the default context menu -* Ctrl + -* the command `t.deleteRows` - -### Delete columns - -To delete the selected columns use: - -* the default context menu -* Ctrl + backspace -* the command `t.deleteColumns` - -**Note**: By design the methods to insert and delete rows and columns only work if the **entire** table is editable. - -### Common keyboard shortcuts - -* Ctrl + A selects the entire table -* Ctrl + C copies the content of the selected cells to the system clipboard -* Ctrl + goes to the first row -* Ctrl + goes to the last row -* Ctrl + goes to the first column -* Ctrl + goes to the last column -* Shift + arrow expands/contracts the current selection - -## Limitations/Known Issues - -1. `olduitable` should work since Matlab R2014b, mainly due the dot notation usage, however it hasn't been tested, so maybe it could work in previous versions. Besides, should be considered the version of Java (really, the JVM) that Matlab is using. The package `asd.fgh.olduitable` used in this class was compiled in Java 7 (used for the first time in R2013b), so for earlier versions the Java classes must be recompiled and repacked. - -1. The JAR file that contains these classes is added to the dynamic path by the `javaaddpath` function. This could produce problems if another package was added before. So, the best option is to include it in the static path through a customized `javaclasspath.txt` located in the "preference folder" (type `prefdir` in the command window to know which is) or in the "startup folder". This file must contain the full name of the JAR file, like the following example: -``` - -C:\Documents\MATLAB\@olduitable\javaClasses.jar -``` -       Any change in the static Java class path will be available in the next Matlab session. - -3. The formats `'bank'` and `'char'` don't determine the alignment of the content like Matlab (left-justified for chars and right-justified for numerical data). To reproduce this behavior, we must use the `ColumnAlign` property. - -4. The use of multiple sort keys was not implemented, so only the current column sorted controls the order for the rows. Besides, if we edit the content of the cells when a sort mode is active, the new data is not re-sorted. In that case the sort sequence is reset, starting an ascending sorting if we click on the column header again. It could be easily fixed by defining `sorter.setSortsOnUpdates(true)`, but this would complicate the rearrangement of the row headers. On the other hand, the methods to insert rows are disabled while a sort mode is active. - -5. The procedures to insert and delete columns aren't very elegant and can be quite inefficient compared to `addColumn` and `moveColumn` methods, because, basically, a new data with empty columns is assigned in the table (and with it, renderers, editors, etc.), however they are the easiest way to maintain order in the columns, by matching the indices in the view with the model. In this sense, if shorcuts are used, avoid keep the left or right arrow keys pressed for a long time, it can produce a very poor performance. - -6. The drag in the headers with the Ctrl key + mouse combination was not implemented. It'll make the highlighted headers doesn't match the selection of the table (particularly for the row header, that is other javax.swing.JTable object). - -7. If we drag the scroll bars directly, specially for the horizontal bar, would see a bit of delay between the renderers of the headers and the table's body. This is probably because every time the view changes, the components of the jscrollpane are repainted. The solution for this is …..?? - -## License - -This project is licensed under the terms of the MIT License. - -## Author - -Pablo Báez R. - -## Version - -1.0 (2018-10-27) diff --git a/Interface/FitModel/fit1.m b/Interface/fit1.m similarity index 100% rename from Interface/FitModel/fit1.m rename to Interface/fit1.m diff --git a/Interface/FitModel/fit1bed.m b/Interface/fit1bed.m similarity index 100% rename from Interface/FitModel/fit1bed.m rename to Interface/fit1bed.m diff --git a/Interface/FitModel/fit2.m b/Interface/fit2.m similarity index 100% rename from Interface/FitModel/fit2.m rename to Interface/fit2.m diff --git a/Interface/FitModel/fit2bed.m b/Interface/fit2bed.m similarity index 100% rename from Interface/FitModel/fit2bed.m rename to Interface/fit2bed.m diff --git a/Interface/FitModel/logo.png b/Interface/logo.png similarity index 100% rename from Interface/FitModel/logo.png rename to Interface/logo.png diff --git a/Interface/FitModel/perform_fit1.m b/Interface/perform_fit1.m similarity index 100% rename from Interface/FitModel/perform_fit1.m rename to Interface/perform_fit1.m diff --git a/Interface/FitModel/perform_fit2.m b/Interface/perform_fit2.m similarity index 100% rename from Interface/FitModel/perform_fit2.m rename to Interface/perform_fit2.m diff --git a/Interface/FitModel/radiance.m b/Interface/radiance.m similarity index 100% rename from Interface/FitModel/radiance.m rename to Interface/radiance.m diff --git a/Interface/FitModel/sample.m b/Interface/sample.m similarity index 100% rename from Interface/FitModel/sample.m rename to Interface/sample.m diff --git a/Interface/FitModel/secondfitting.m b/Interface/secondfitting.m similarity index 100% rename from Interface/FitModel/secondfitting.m rename to Interface/secondfitting.m diff --git a/Interface/teraProMATLAB/ListStudents.mat b/Interface/teraProMATLAB/ListStudents.mat deleted file mode 100644 index 8ce62ba..0000000 Binary files a/Interface/teraProMATLAB/ListStudents.mat and /dev/null differ diff --git a/Interface/teraProMATLAB/addfile.m b/Interface/teraProMATLAB/addfile.m deleted file mode 100644 index 3162653..0000000 --- a/Interface/teraProMATLAB/addfile.m +++ /dev/null @@ -1,3 +0,0 @@ -function pushbutton_addfile_Callback(hObject, eventData) - - qst = 'Select the file to be uploaded:'; diff --git a/Interface/teraProMATLAB/ciencias_ul_azul_h_s-ass.png b/Interface/teraProMATLAB/ciencias_ul_azul_h_s-ass.png deleted file mode 100644 index 9223147..0000000 Binary files a/Interface/teraProMATLAB/ciencias_ul_azul_h_s-ass.png and /dev/null differ diff --git a/Interface/teraProMATLAB/emogi.jpg b/Interface/teraProMATLAB/emogi.jpg deleted file mode 100644 index f72c1e6..0000000 Binary files a/Interface/teraProMATLAB/emogi.jpg and /dev/null differ diff --git a/Interface/teraProMATLAB/filterByCourse.m b/Interface/teraProMATLAB/filterByCourse.m deleted file mode 100644 index d942266..0000000 --- a/Interface/teraProMATLAB/filterByCourse.m +++ /dev/null @@ -1,13 +0,0 @@ -function filterByCourse(course) - -% recover the table data stored in the Userdata of uitable_age -uitable = findobj('Tag','uitable'); -% this variable exists only inside this function -data = get(uitable,'Userdata'); - -listbox_students = findobj('Tag','listbox_students'); -list=get(listbox_students,'String'); -n=strcmp(data(:,7),course); - -set(uitable,'Data',data(n,:),... - 'Rowname',list(n)); diff --git a/Interface/teraProMATLAB/isdate.m b/Interface/teraProMATLAB/isdate.m deleted file mode 100644 index ada017a..0000000 --- a/Interface/teraProMATLAB/isdate.m +++ /dev/null @@ -1,48 +0,0 @@ -function strdate= isdate(strdate) -% function strdate = isdate(strdate) -% -% INPUT -% * strdate is a string (not cell) and returns the strdate in the format -% adopted dd-mm-yyyy -% -% OUTPUT -% * strdate as dd-mm-yyyy, empty string if no valid date -% -% ------------------------------------------------------------------------- -% made by bcf in 06-12-2010 -% ------------------------------------------------------------------------- - -n=strfind(strdate,'-'); -if isempty(n)|numel(n)~=2 - strdate=[]; - %set(gco,'String',''); % TODO: this should be removed from here??????????????????????????????????????????? - h=errordlg('Input must be a date with format dd-mm-yyyy','ERROR'); - set(h,'WindowStyle','modal') - return -end - -Day = str2double(strdate(1:n(1)-1)); -Month = str2double(strdate(n(1)+1:n(2)-1)); -Year = str2double(strdate(n(2)+1:end)); - -% do not change the order because day depends on Year and Month -if Year <1900 | Year >2100 | isempty(Year) | isnan(Year) - strdate=[]; - h=errordlg('Year is not valid!','Error');set(h,'WindowStyle','modal') - return -end -if Month <=0 | Month >12 | isempty(Month) | isnan(Month) - strdate=[];set(gco,'String','') - h=errordlg('Month is not valid!','Error');set(h,'WindowStyle','modal') - return -end -if Day <=0 | Day > eomday(Year,Month) | isempty(Day) | isnan(Day) - strdate=[];set(gco,'String','') - h=errordlg('Day is not valid!','Error');set(h,'WindowStyle','modal') - return -end - -strdate = [int2str(Month) '-' int2str(Day) '-' int2str(Year)]; -strdate = datestr(strdate,'dd-mm-yyyy'); - -end \ No newline at end of file diff --git a/Interface/teraProMATLAB/logoFCUL.jpg b/Interface/teraProMATLAB/logoFCUL.jpg deleted file mode 100644 index dc3d42f..0000000 Binary files a/Interface/teraProMATLAB/logoFCUL.jpg and /dev/null differ diff --git a/Interface/teraProMATLAB/menu_login_Callback.m b/Interface/teraProMATLAB/menu_login_Callback.m deleted file mode 100644 index ca54860..0000000 --- a/Interface/teraProMATLAB/menu_login_Callback.m +++ /dev/null @@ -1,3 +0,0 @@ -function menu_login_Callback() - -msgbox('Prepare this function to ask for username and password!') \ No newline at end of file diff --git a/Interface/teraProMATLAB/myloginicon.mat b/Interface/teraProMATLAB/myloginicon.mat deleted file mode 100644 index 985fbd6..0000000 Binary files a/Interface/teraProMATLAB/myloginicon.mat and /dev/null differ diff --git a/Interface/teraProMATLAB/mylogouticon.mat b/Interface/teraProMATLAB/mylogouticon.mat deleted file mode 100644 index 4d113a4..0000000 Binary files a/Interface/teraProMATLAB/mylogouticon.mat and /dev/null differ diff --git a/Interface/teraProMATLAB/teraPro.m b/Interface/teraProMATLAB/teraPro.m deleted file mode 100644 index 0aa537e..0000000 --- a/Interface/teraProMATLAB/teraPro.m +++ /dev/null @@ -1,465 +0,0 @@ -function teraPro -% function teraPro -% HELP: this function serves as an hypothetical example to be used -% in the lectures of Diagnóstico e Terapia com Radiações e Protões -% -% INPUT -% * none -% -% OUTPUT -% * none -% -% SEE ALSO: isdate, filterByCourse -% -% ------------------------------------------------------------------------- -% made by bcf in 09-01-2023 -% ------------------------------------------------------------------------- - - -%----------------------------------------------------- -% Initialize some variables for demonstration purposes -%----------------------------------------------------- -age = rand(30); -data = {22 51 25199 16 'Jose X' true 'Select...';... - 18 01 9501 18 'Maria XY' false 'Physics';... - 22 55 9612 '' 'Jose XYZ' true 'Mathematics'; - 26 55 9612 '' 'João Z' false 'Chemistry'}; -%--- - -%--------------------------------------------------------------- -% BUILD THE MAIN FIGURE -%--------------------------------------------------------------- -mainFig =figure(1); -set(mainFig ,'Name','Example for DTRP',... - 'Position',[1 82.3333 1280 566],... - 'KeyPressFcn',@figure_keyPressFcn,... - 'MenuBar','None'); -clf, % clear the figure - - function figure_keyPressFcn(hObject,eventdata) - - switch eventdata.Key - case 'return' - set(hObject,'Color','r') - case 'backspace' - set(hObject,'Color','b') - case 'escape' - set(hObject,'Color',[1 0.5 0]) - - end - end - - -% ADD CIENCIAS LOGO -%------------------- -[tmp,~,alfa] = imread('ciencias_ul_azul_h_s-ass.png'); -%maximize the use of temporary variables -handles.axes_logo = axes('Parent',mainFig,... - 'Units','Normalized','Position',[0.03 0.87 0.12 0.12],... - 'Visible','off'); -tmp=image(tmp); -set(tmp, 'AlphaData', alfa); -axis equal off -%--- - - - -%--------------------------------------------------------------- -% BUILD THE MENU -%--------------------------------------------------------------- -handles.uimenu_new = uimenu(mainFig,'Label','New'); -handles.uimenu_newFile = uimenu(handles.uimenu_new,... - 'Label','New File...',... - 'Callback',@uimenu_new_callback); -handles.uimenu_saveFile = uimenu(handles.uimenu_new,... - 'Label','Save...',... - 'Separator','on',... - 'Callback',@uimenu_save_callback); % See Also: UImenu properties - - - % the advantage of having the Callback function close to the creation - % of the object is that it is easy to get there with the Go To... - function uimenu_new_callback(hObject,eventdata) - - warndlg(['No action will happen when Pressing OK because'... - ' this Callback function is not programmed yet!'],... - '!! Warning !!') - - % See Also: dialog, questdlg, errordlg - end - - function uimenu_save_callback(hObject,eventdata) - - % Can be any variable stored in the interface or the workspace - uisave({'data'},'ListStudents.mat') %Suggested filename - - %See Also: uigetfifle, uiopen - end - -%--------------------------------------------------------------- -% ADD A TOOLBAR -%--------------------------------------------------------------- -handles.toolbar=uitoolbar(mainFig); -diretory = 'matlabDTRP'; -b=load('.\myloginicon.mat'); -uipushtool(handles.toolbar,'CData',b.icon,... - 'TooltipString','Login',... - 'Tag','pushtool_login',... - 'Enable','on',... - 'ClickedCallback','menu_login_Callback();') -b=load('.\mylogouticon.mat'); -uipushtool(handles.toolbar,'CData',b.icon,... - 'TooltipString','Logout',... - 'Tag','pushtool_logout',... - 'Enable','off',... - 'ClickedCallback','menu_logout_Callback();') -% CallBack Functions or any other functions -% do not need to be inside this file -%- - - -%--------------------------------------------------------------- -% BUILD A PANEL -%--------------------------------------------------------------- -panel_studentsList = uipanel('Tag','panel_studentsList',... - 'Title', 'List',... - 'Units', 'Normalized',... - 'Position', [.01 .007 .17 .84],... - 'HighlightColor', [0 0 1],... - 'FontSize', 12,... - 'Parent', mainFig); - -% is text no need to keep the handle -uicontrol(panel_studentsList,... - 'Tag','text',... - 'Style',' Text', ... - 'String','Students List at FCUL',... - 'FontName', 'Arial',... - 'FontSize',13,... - 'Units','Normalized',... - 'Position',[.05 .95 .88 .05],... - 'Enable','on',... - 'Callback',@listbox_Callback); - -handles.listbox_students = uicontrol(panel_studentsList,... - 'Tag','listbox_students',... - 'Style',' listbox', ... - 'String',{'Student1','Student2','Student344' 'Student489'},... - 'Units','Normalized',... - 'Position',[.1 .2 .75 .75],... - 'Enable','on',... - 'Callback',@listbox_students_Callback); -% String defined as cell to accomodate different size strings -% String can be a list read directly from a file or a database which then -% fills up the listbox - - function listbox_students_Callback(hObject,~) - - handles.pushbutton_delete.Enable ='on'; - - tmp = get(hObject,'String'); % cells - val= get(hObject,'Value'); - if strcmp(tmp(val),'Student1') - cla(handles.axes_plot) - plot(0:0.1:10,sin(0:0.1:10),'rs','Parent',handles.axes_plot) - elseif strcmp(tmp(val),'Student2') - handles.edit_date.String = '12-02-2023'; - else - tmp = imread('emogi.jpg'); - imagesc(rot90(tmp,2),'Parent',handles.axes_plot) - % TODO: ?????????????????? - end - - end - - -handles.pushbutton_add = uicontrol(panel_studentsList,... - 'Tag','pushbutton_add',... - 'Style',' pushbutton', ... - 'String','Add new student',... - 'Units','Normalized',... - 'Position',[.1 .12 .75 .07],... - 'Enable','on',... - 'ForegroundColor','r',... - 'Tooltipstring','This button allows to add a new student to the list',... - 'Callback',@pushbutton_add_Callback); - - function pushbutton_add_Callback(hObject,eventdata) - - - % Data may be added without question the user - qst = 'Would you like to add a new student to the list?'; - button = questdlg(qst,'Question','Yes','Cancel','Cancel'); - if strcmp(button,'Yes') - - data = get(handles.uitable,'Data'); - list = get(handles.listbox_students,'String'); - % if there is no data yet in the list or all was deleted - if isempty(list) - set(handles.listbox_students,'String',{'Student1'},... - 'Value',1) % leave this student selected - - % string needs to be cell to be consistent with the - % following code and the format adopted for the list - else - %check the number of the last student and add a student - %with a new number - n=numel(list); - nb_laststudent=str2double(list{n}(8:end)); - list = [list;'Student' int2str(nb_laststudent+1)]; - set(handles.listbox_students,'String',list,... - 'Value',n+1)% leave last student selected - - % ATTENTION: data has changed but not in the workspace - % this variable was now stored in Userdata - data(size(data,1)+1,:)=cell(1,7); - set(handles.uitable,... - 'Rowname',get(handles.listbox_students,'String'),... - 'Data', data,'Userdata',data) - end - end - - end - -handles.pushbutton_delete = uicontrol(panel_studentsList,... - 'Tag','pushbutton_delete',... - 'Style',' pushbutton', ... - 'String','Delete',... - 'Units','Normalized',... - 'Position',[.1 .02 .75 .07],... - 'Enable','off',... - 'Callback',@pushbutton_delete_Callback); - - function pushbutton_delete_Callback(hObject,~) - - % As a precaution measure, everytime data is deleted, the user - % should be questioned - qst = 'Are you sure you need to delete this information?'; - button = questdlg(qst,'WARNING DELETE','Yes','No','No'); - % No is the default button selected - if strcmp(button,'Yes') - list = get(handles.listbox_students,'String'); - val=get(handles.listbox_students,'Value'); - list(val) =''; - set(handles.listbox_students,'String',list,'Value',1) - - % all information related to that instance needs to be erased - set(handles.edit_date,'String','') - set(handles.uitable,... - 'Rowname',get(handles.listbox_students,'String')) - data = get(handles.uitable,'Userdata');%or get(handles.uitable,'Data'); - data(val,:)=''; - set(handles.uitable,'Data',data,'Userdata',data) - end - - end - -handles.buttonGroup = uibuttongroup('Parent',mainFig,... - 'Title','Student Registration',... - 'Tag','buttongroup',... - 'FontSize',12,... - 'FontWeight','bold',... - 'Units','Normalized','Position',[.19 .006 .193 .165],... - 'UserData','Test 1',... - 'SelectionChangeFcn',@buttongroup_Callback); -handles.radiobutton_yes = uicontrol(handles.buttonGroup,... - 'Tag','radiobutton_yes',... - 'Style','radiobutton',... - 'String','Yes',...... - 'Units','Normalized','Position',[.55 .47 .34 .24],... - 'TooltipString','tooltipstring',... - 'FontSize',10,... - 'HorizontalAlignment','left'); -handles.radiobutton_no = uicontrol(handles.buttonGroup,... - 'Tag','radiobutton_no',... - 'Style','radiobutton',... - 'String','No',...... - 'Units','Normalized','Position',[.15 .47 .34 .24],... - 'TooltipString','tooltipstring',... - 'FontSize',10,... - 'HorizontalAlignment','left'); - - function buttongroup_Callback(hObject,~) - - tmp = get(hObject,'SelectedObject'); - if strcmp(tmp.String,'No') - set(handles.edit_date,'String','','BackgroundColor','y') - elseif strcmp(tmp.String,'Yes') - set(handles.edit_date,'String','09-01-2023',... - 'BackgroundColor','w') - end - - end - - -uicontrol(handles.buttonGroup,'Style','text',... - 'String','Date',... - 'Units','Normalized','Position',[0.03 0.02 0.3 0.33],... - 'FontSize',10,... - 'HorizontalAlignment','left'); -handles.edit_date = uicontrol(handles.buttonGroup,'Style','edit',... - 'Tag','edit_date',... - 'Units','Normalized','Position',[0.3 0.02 0.6 0.38],... - 'TooltipString','Valid format: dd-mm-yyyy',... - 'HorizontalAlignment','left',... - 'BackgroundColor','red',... - 'UserData','',... - 'Callback',@edit_date_Callback); - - - function edit_date_Callback(hObject,eventdata) - - - oldvalue = get(hObject,'String'); - - % there should always be made a validation of the imput - thisdate = isdate(get(hObject,'String')); - if isempty(thisdate),set(hObject,'String',''),return,end - - % If the date is valid write on screen with the correct format - set(hObject,'String',thisdate) - - end - -%----------------------------- -% BUILD ONE UICONTEXTMENU -%----------------------------- -c = uicontextmenu; -m1 = uimenu(c,'Label','Red','Callback',@backgroundcolor); -m2 = uimenu(c,'Label','Blue','Callback',@backgroundcolor); -m3 = uimenu(c,'Label','White','Callback',@backgroundcolor); -set(handles.edit_date,'UIContextMenu',c) - - function backgroundcolor(source,callbackdata) - switch source.Label - case 'Red' - handles.edit_date.BackgroundColor ='r'; - case 'Blue' - handles.edit_date.BackgroundColor ='b'; - case 'White' - handles.edit_date.BackgroundColor ='w'; - end - end -%- - - -%--------------------------------------------------------------- -% BUILD A NEW PANEL -%--------------------------------------------------------------- -handles.panel_studentDetails = uipanel('Parent',mainFig,... - 'Tag', 'panel_studentDetails',... - 'Title', 'Student Details',... - 'Units', 'Normalized',... - 'Position', [.19 .2 .75 .79],... - 'HighlightColor', 'm',... - 'ForegroundColor', 'm',... - 'FontSize', 12); - -% It is convenient that the first option is an instruction -courses = {'Select Course...' 'Physics' 'Chemistry' 'Mathematics'}; -handles.popupmenu_courses = uicontrol(... - 'Parent',handles.panel_studentDetails,... - 'Style','popup',... - 'Tag','popup_courses',... - 'Units','Normalized','Position',[0.01 0.9 0.15 0.05],... - 'String',courses,... - 'TooltipString','Select Course',... - 'HorizontalAlignment','left',... - 'BackgroundColor','y',... - 'UserData','',... - 'Callback',@popupmenu_courses_Callback); - - function popupmenu_courses_Callback(hObject,~) - - % Because I'm getting the value, I need to know the relation - % between the value and the string - val = get(hObject,'Value'); - if val == 1 % it may be needed to reset all data - cla(handles.axes_plot) - - % Show the all data again - set(handles.uitable,'Data',data,... - 'Rowname',get(handles.listbox_students,'String')) - elseif val == 2 % Physics - % fill table with data - filterByCourse('Physics'); - % clear plot - cla(handles.axes_plot) - elseif val == 3 % Chemistry - plot(age(:,1),age(:,end),'kx','MarkerSize',12,... - 'Parent',handles.axes_plot) - %clear table - set(handles.uitable,'Data','','Rowname','') - elseif val == 4 % Mathematics - filterByCourse('Mathematics'); - - cla(handles.axes_plot) - for i=1:size(age,2) - plot(age(:,i),age(:,end-i+1),'x') - drawnow - end - - end - end - -handles.checkbox_verification = uicontrol(... - 'Parent',handles.panel_studentDetails,... - 'Style','checkbox',... - 'Tag','checkbox_verification',... - 'String','Student Verified',... - 'Units','Normalized','Position',[0.18 0.9 0.15 0.05],... - 'TooltipString','Select if student was verified.',... - 'UserData','',... - 'Callback',@checkbox_verification_Callback); - - function checkbox_verification_Callback(hObject,~) - - val = get(hObject,'Value'); - if val == 1 % Checkbox was selected - set(handles.uitable,'Enable','off') - else - set(handles.uitable,'Enable','on') - end - end - - -%------------------------------------------------------------------ -% BUILD UITABLE -%------------------------------------------------------------------ -handles.uitable = uitable(handles.panel_studentDetails,... - 'Tag','uitable',... - 'ColumnFormat',{'numeric' 'numeric' 'numeric' 'numeric' ... - 'char' 'logical' {'Select...' 'Physics' 'Chemistry' 'Mathematics'}},... - 'Data',data,... - 'Units','Normalized','Position',[0.01 0.01 0.5 0.85],... - 'ColumnEditable',true,... - 'ColumnName',... - {'Age' 'Code' 'Phone' 'Average' 'Name' 'Graduated' 'Degree'},... - 'RowName',get(handles.listbox_students,'string'),... - 'Userdata',data,...% Simple way store data - 'CellEditCallback',@uitable_Callback); -% Check other properties in the Inspector from Guide or Help manual - - - % if there is more than one uitable, give it an more appropriate name - function uitable_Callback(hObject,eventdata) - - tmp = get(hObject,'Data') - % keep the data from the table somwhere - set(handles.uitable,'Userdata',tmp) - - % another way to store variables in the workspace - assignin('base','data',tmp) - end - - -%------------------------------------------------------------------ -% BUILD AXES TO PLOT DATA -%------------------------------------------------------------------ -handles.axes_plot = axes('Parent',handles.panel_studentDetails,... - 'Units','Normalized','Position',[0.58 0.1 0.4 0.85],... - 'Visible','on'); -xlabel('xx'),ylabel('yy'),hold on - - -end \ No newline at end of file diff --git a/Interface/teraProMATLAB/teraProByGuide.fig b/Interface/teraProMATLAB/teraProByGuide.fig deleted file mode 100644 index 4a6b5de..0000000 Binary files a/Interface/teraProMATLAB/teraProByGuide.fig and /dev/null differ diff --git a/Interface/teraProMATLAB/teraProByGuide.m b/Interface/teraProMATLAB/teraProByGuide.m deleted file mode 100644 index bcfbe98..0000000 --- a/Interface/teraProMATLAB/teraProByGuide.m +++ /dev/null @@ -1,173 +0,0 @@ -function varargout = teraProByGuide(varargin) -%TERAPROBYGUIDE MATLAB code file for teraProByGuide.fig -% TERAPROBYGUIDE, by itself, creates a new TERAPROBYGUIDE or raises the existing -% singleton*. -% -% H = TERAPROBYGUIDE returns the handle to a new TERAPROBYGUIDE or the handle to -% the existing singleton*. -% -% TERAPROBYGUIDE('Property','Value',...) creates a new TERAPROBYGUIDE using the -% given property value pairs. Unrecognized properties are passed via -% varargin to teraProByGuide_OpeningFcn. This calling syntax produces a -% warning when there is an existing singleton*. -% -% TERAPROBYGUIDE('CALLBACK') and TERAPROBYGUIDE('CALLBACK',hObject,...) call the -% local function named CALLBACK in TERAPROBYGUIDE.M with the given input -% arguments. -% -% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one -% instance to run (singleton)". -% -% See also: GUIDE, GUIDATA, GUIHANDLES - -% Edit the above text to modify the response to help teraProByGuide - -% Last Modified by GUIDE v2.5 16-Jan-2023 08:52:47 - -% Begin initialization code - DO NOT EDIT -gui_Singleton = 1; -gui_State = struct('gui_Name', mfilename, ... - 'gui_Singleton', gui_Singleton, ... - 'gui_OpeningFcn', @teraProByGuide_OpeningFcn, ... - 'gui_OutputFcn', @teraProByGuide_OutputFcn, ... - 'gui_LayoutFcn', [], ... - 'gui_Callback', []); -if nargin && ischar(varargin{1}) - gui_State.gui_Callback = str2func(varargin{1}); -end - -if nargout - [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); -else - gui_mainfcn(gui_State, varargin{:}); -end -% End initialization code - DO NOT EDIT - - -% --- Executes just before teraProByGuide is made visible. -function teraProByGuide_OpeningFcn(hObject, eventdata, handles, varargin) -% This function has no output args, see OutputFcn. -% hObject handle to figure -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) -% varargin unrecognized PropertyName/PropertyValue pairs from the -% command line (see VARARGIN) - -% Choose default command line output for teraProByGuide -handles.output = hObject; - -% Update handles structure -guidata(hObject, handles); - -% UIWAIT makes teraProByGuide wait for user response (see UIRESUME) -% uiwait(handles.figure1); - - -% --- Outputs from this function are returned to the command line. -function varargout = teraProByGuide_OutputFcn(hObject, eventdata, handles) -% varargout cell array for returning output args (see VARARGOUT); -% hObject handle to figure -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Get default command line output from handles structure -varargout{1} = handles.output; - - - -function edit_date_Callback(hObject, eventdata, handles) -% hObject handle to edit_date (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of edit_date as text -% str2double(get(hObject,'String')) returns contents of edit_date as a double - - -% --- Executes during object creation, after setting all properties. -function edit_date_CreateFcn(hObject, eventdata, handles) -% hObject handle to edit_date (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - -% --- Executes on selection change in popupmenu_courses. -function popupmenu_courses_Callback(hObject, eventdata, handles) -% hObject handle to popupmenu_courses (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_courses contents as cell array -% contents{get(hObject,'Value')} returns selected item from popupmenu_courses - - -% --- Executes during object creation, after setting all properties. -function popupmenu_courses_CreateFcn(hObject, eventdata, handles) -% hObject handle to popupmenu_courses (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: popupmenu controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - -% --- Executes on button press in checkbox_verification. -function checkbox_verification_Callback(hObject, eventdata, handles) -% hObject handle to checkbox_verification (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hint: get(hObject,'Value') returns toggle state of checkbox_verification - - -% --- Executes on selection change in listbox_students. -function listbox_students_Callback(hObject, eventdata, handles) -% hObject handle to listbox_students (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: contents = cellstr(get(hObject,'String')) returns listbox_students contents as cell array -% contents{get(hObject,'Value')} returns selected item from listbox_students - - -% --- Executes during object creation, after setting all properties. -function listbox_students_CreateFcn(hObject, eventdata, handles) -% hObject handle to listbox_students (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: listbox controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - -% --- Executes on button press in pushbutton_add. -function pushbutton_add_Callback(hObject, eventdata, handles) -% hObject handle to pushbutton_add (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - - -% --- Executes on button press in pushbutton_delete. -function pushbutton_delete_Callback(hObject, eventdata, handles) -% hObject handle to pushbutton_delete (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - - -% -------------------------------------------------------------------- -function Untitled_1_Callback(hObject, eventdata, handles) -% hObject handle to Untitled_1 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) diff --git a/Interface/teraProOctave/ListStudents.mat b/Interface/teraProOctave/ListStudents.mat deleted file mode 100644 index 8ce62ba..0000000 Binary files a/Interface/teraProOctave/ListStudents.mat and /dev/null differ diff --git a/Interface/teraProOctave/ciencias_ul_azul_h_s-ass.png b/Interface/teraProOctave/ciencias_ul_azul_h_s-ass.png deleted file mode 100644 index 9223147..0000000 Binary files a/Interface/teraProOctave/ciencias_ul_azul_h_s-ass.png and /dev/null differ diff --git a/Interface/teraProOctave/emogi.jpg b/Interface/teraProOctave/emogi.jpg deleted file mode 100644 index f72c1e6..0000000 Binary files a/Interface/teraProOctave/emogi.jpg and /dev/null differ diff --git a/Interface/teraProOctave/filterByCourse.m b/Interface/teraProOctave/filterByCourse.m deleted file mode 100644 index 3d1f20a..0000000 --- a/Interface/teraProOctave/filterByCourse.m +++ /dev/null @@ -1,12 +0,0 @@ -function filterByCourse(course) - -% recover the table data stored in the Userdata of uitable_age -uitable = findobj('Tag','uitable'); -% this variable exists only inside this function -data = get(uitable,'Userdata'); - -listbox_students = findobj('Tag','listbox_students'); -list=get(listbox_students,'String'); -n=find(strcmp(data(:,7),course)); - -set(uitable,'Data',data(n,:),'Rowname',list(n)); diff --git a/Interface/teraProOctave/isdate.m b/Interface/teraProOctave/isdate.m deleted file mode 100644 index ada017a..0000000 --- a/Interface/teraProOctave/isdate.m +++ /dev/null @@ -1,48 +0,0 @@ -function strdate= isdate(strdate) -% function strdate = isdate(strdate) -% -% INPUT -% * strdate is a string (not cell) and returns the strdate in the format -% adopted dd-mm-yyyy -% -% OUTPUT -% * strdate as dd-mm-yyyy, empty string if no valid date -% -% ------------------------------------------------------------------------- -% made by bcf in 06-12-2010 -% ------------------------------------------------------------------------- - -n=strfind(strdate,'-'); -if isempty(n)|numel(n)~=2 - strdate=[]; - %set(gco,'String',''); % TODO: this should be removed from here??????????????????????????????????????????? - h=errordlg('Input must be a date with format dd-mm-yyyy','ERROR'); - set(h,'WindowStyle','modal') - return -end - -Day = str2double(strdate(1:n(1)-1)); -Month = str2double(strdate(n(1)+1:n(2)-1)); -Year = str2double(strdate(n(2)+1:end)); - -% do not change the order because day depends on Year and Month -if Year <1900 | Year >2100 | isempty(Year) | isnan(Year) - strdate=[]; - h=errordlg('Year is not valid!','Error');set(h,'WindowStyle','modal') - return -end -if Month <=0 | Month >12 | isempty(Month) | isnan(Month) - strdate=[];set(gco,'String','') - h=errordlg('Month is not valid!','Error');set(h,'WindowStyle','modal') - return -end -if Day <=0 | Day > eomday(Year,Month) | isempty(Day) | isnan(Day) - strdate=[];set(gco,'String','') - h=errordlg('Day is not valid!','Error');set(h,'WindowStyle','modal') - return -end - -strdate = [int2str(Month) '-' int2str(Day) '-' int2str(Year)]; -strdate = datestr(strdate,'dd-mm-yyyy'); - -end \ No newline at end of file diff --git a/Interface/teraProOctave/logoFCUL.jpg b/Interface/teraProOctave/logoFCUL.jpg deleted file mode 100644 index dc3d42f..0000000 Binary files a/Interface/teraProOctave/logoFCUL.jpg and /dev/null differ diff --git a/Interface/teraProOctave/menu_login_Callback.m b/Interface/teraProOctave/menu_login_Callback.m deleted file mode 100644 index ca54860..0000000 --- a/Interface/teraProOctave/menu_login_Callback.m +++ /dev/null @@ -1,3 +0,0 @@ -function menu_login_Callback() - -msgbox('Prepare this function to ask for username and password!') \ No newline at end of file diff --git a/Interface/teraProOctave/teraPro_Oct.m b/Interface/teraProOctave/teraPro_Oct.m deleted file mode 100644 index a855b64..0000000 --- a/Interface/teraProOctave/teraPro_Oct.m +++ /dev/null @@ -1,478 +0,0 @@ -function teraPro_Oct -% function teraPro -% HELP: this function serves as an hypothetical example to be used -% in the lectures of Diagn�stico e Terapia com Radia��es e Prot�es -% -% INPUT -% * none -% -% OUTPUT -% * none -% -% SEE ALSO: isdate, filterByCourse -% -% ------------------------------------------------------------------------- -% made by bcf in 09-01-2023 -% ------------------------------------------------------------------------- - - -%----------------------------------------------------- -% Initialize some variables for demonstration purposes -%----------------------------------------------------- -age = rand(30); -data = {22 51 25199 16 'Jose X' true 'Select...';... - 18 01 9501 18 'Maria XY' false 'Physics';... - 22 55 9612 '' 'Jose XYZ' true 'Mathematics';... - 26 55 9612 '' 'Jo�o Z' false 'Chemistry'}; -%--- - -%--------------------------------------------------------------- -% BUILD THE MAIN FIGURE -%--------------------------------------------------------------- -mainFig =figure(1000); -set(mainFig ,'Name','Example for DTRP',... - 'Position',[ 1 143 1920 751],... - 'KeyPressFcn',@figure_keyPressFcn,... - 'MenuBar','None'); -clf, % clear the figure - - function figure_keyPressFcn(hObject,eventdata) - - switch eventdata.Key - case 'return' - set(hObject,'Color','r') - - case 'backspace' - set(hObject,'Color','b') - case 'escape' - set(hObject,'Color',[1 0.5 0]) - - end - end - - -% ADD CIENCIAS LOGO -%------------------- -[tmp,~,alfa] = imread('ciencias_ul_azul_h_s-ass.png'); -%maximize the use of temporary variables -handles.axes_logo = axes('Parent',mainFig,... - 'Units','Normalized','Position',[0.03 0.87 0.12 0.12],... - 'Visible','off'); -tmp=image(tmp); -set(tmp, 'AlphaData', alfa); -axis equal off -%--- - - - -%--------------------------------------------------------------- -% BUILD THE MENU -%--------------------------------------------------------------- -handles.uimenu_new = uimenu(mainFig,'Label','New'); -handles.uimenu_newFile = uimenu(handles.uimenu_new,... - 'Label','New File...',... - 'Callback',@uimenu_new_callback); -handles.uimenu_saveFile = uimenu(handles.uimenu_new,... - 'Label','Save...',... - 'Separator','on',... - 'Callback',@uimenu_save_callback); % See Also: UImenu properties - - - % the advantage of having the Callback function close to the creation - % of the object is that it is easy to get there with the Go To... - function uimenu_new_callback(hObject,eventdata) - - uigetfile - % See Also: dialog, questdlg, errordlg - end - - function uimenu_save_callback(hObject,eventdata) - - % Can be any variable stored in the interface or the workspace - % uisave({'data'},'ListStudents.mat') %Suggested filename - %uisave is not developed for Octave - warndlg(['No action will happen when Pressing OK because'... - ' this Callback function is not programmed yet!'],... - '!! Warning !!') - - %See Also: uigetfifle, uiopen - end - -%--------------------------------------------------------------- -% ADD A TOOLBAR -%--------------------------------------------------------------- -handles.toolbar=uitoolbar(mainFig); -diretory = 'matlabDTRP'; -%b=load([ diretory '\myloginicon.mat']); -##uipushtool(handles.toolbar,'CData',b.icon,... -## 'TooltipString','Login',... -## 'Tag','pushtool_login',... -## 'Enable','on',... -## 'ClickedCallback','menu_login_Callback();') -##%b=load([diretory '\mylogouticon.mat']); -##uipushtool(handles.toolbar,'CData',b.icon,... -## 'TooltipString','Logout',... -## 'Tag','pushtool_logout',... -## 'Enable','off',... -## 'ClickedCallback','menu_logout_Callback();') -% CallBack Functions or any other functions -% do not need to be inside this file -%- - - -%--------------------------------------------------------------- -% BUILD A PANEL -%--------------------------------------------------------------- -panel_studentsList = uipanel('Tag','panel_studentsList',... - 'Title', 'List',... - 'Units', 'Normalized',... - 'Position', [.01 .007 .17 .84],... - 'HighlightColor', [0 0 1],... - 'FontSize', 12,... - 'Parent', mainFig); - -% is text no need to keep the handle -uicontrol(panel_studentsList,... - 'Style','Text',... - 'Tag','mytext',... - 'String','Students List at FCUL',... - 'FontName', 'Arial',... - 'FontSize',13,... - 'Units','Normalized',... - 'Position',[.05 .95 .88 .05],... - 'Enable','on',... - 'Callback',@listbox_Callback); - -handles.listbox_students = uicontrol(panel_studentsList,... - 'Style','listbox', ... - 'Tag','listbox_students',... - 'String',{'Student1','Student2','Student344' 'Student489'},... - 'Units','Normalized',... - 'Position',[.1 .2 .75 .75],... - 'Enable','on',... - 'Callback',@listbox_students_Callback); -% String defined as cell to accomodate different size strings -% String can be a list read directly from a file or a database which then -% fills up the listbox - - function listbox_students_Callback(hObject,~) - - %handles.pushbutton_delete.Enable ='on'; - set(handles.pushbutton_delete,'Enable','on') - - tmp = get(hObject,'String'); % cells - val= get(hObject,'Value'); - if strcmp(tmp(val),'Student1') - cla(handles.axes_plot) - plot(0:0.1:10,sin(0:0.1:10),'rs','Parent',handles.axes_plot) - elseif strcmp(tmp(val),'Student2') - set(handles.edit_date,'String','12-02-2023') - else - tmp = imread('emogi.jpg'); - imagesc(rot90(tmp,2),'Parent',handles.axes_plot) - % TODO: ?????????????????? - end - - end - - -handles.pushbutton_add = uicontrol(panel_studentsList,... - 'Style','pushbutton', ... - 'Tag','pushbutton_add',... - 'String','Add new student',... - 'Units','Normalized',... - 'Position',[.1 .12 .75 .07],... - 'Enable','on',... - 'ForegroundColor','r',... - 'Tooltipstring','This button allows to add a new student to the list',... - 'Callback',@pushbutton_add_Callback); - - function pushbutton_add_Callback(hObject,eventdata) - - - % Data may be added without question the user - qst = 'Would you like to add a new student to the list?'; - button = questdlg(qst,'Question','Yes','Cancel','Cancel'); - if strcmp(button,'Yes') - - data = get(handles.uitable,'Data'); - list = get(handles.listbox_students,'String'); - % if there is no data yet in the list or all was deleted - if isempty(list) - set(handles.listbox_students,'String',{'Student1'},... - 'Value',1) % leave this student selected - - % string needs to be cell to be consistent with the - % following code and the format adopted for the list - data = {22 51 25199 16 '' true 'Select...'}; - set(handles.uitable,'Data', data,'Userdata',data) - else - %check the number of the last student and add a student - %with a new number - n=numel(list); - nb_laststudent=str2double(list{n}(8:end)); - list = [list;['Student' int2str(nb_laststudent+1)]]; - set(handles.listbox_students,'String',list,... - 'Value',n+1)% leave last student selected - - % ATTENTION: data has changed but not in the workspace - % this variable was now stored in Userdata - data(size(data,1)+1,:)=cell(1,7); - set(handles.uitable,... - 'Rowname',get(handles.listbox_students,'String'),... - 'Data', data,'Userdata',data) - end - end - - end - -handles.pushbutton_delete = uicontrol(panel_studentsList,... - 'Style','pushbutton', ... - 'Tag','pushbutton_delete',... - 'String','Delete',... - 'Units','Normalized',... - 'Position',[.1 .02 .75 .07],... - 'Enable','off',... - 'Callback',@pushbutton_delete_Callback); - - function pushbutton_delete_Callback(hObject,~) - - % As a precaution measure, everytime data is deleted, the user - % should be questioned - qst = 'Are you sure you need to delete this information?'; - button = questdlg(qst,'WARNING DELETE','Yes','No','No'); - % No is the default button selected - if strcmp(button,'Yes') - list = get(handles.listbox_students,'String'); - val=get(handles.listbox_students,'Value'); - list(val) =''; - set(handles.listbox_students,'String',list,'Value',1) - - % all information related to that instance needs to be erased - set(handles.edit_date,'String','') - set(handles.uitable,... - 'Rowname',get(handles.listbox_students,'String')) - data = get(handles.uitable,'Userdata');%or get(handles.uitable,'Data'); - data(val,:)=''; - set(handles.uitable,'Data',data,'Userdata',data) - end - - end - -handles.buttonGroup = uibuttongroup('Parent',mainFig,... - 'Title','Student Registration',... - 'Tag','buttongroup',... - 'FontSize',12,... - 'FontWeight','bold',... - 'Units','Normalized','Position',[.19 .006 .193 .165],... - 'UserData','Test 1');%,... - % 'SelectionChangeFcn',@buttongroup_Callback); -handles.radiobutton_yes = uicontrol(handles.buttonGroup,... - 'Tag','radiobutton_yes',... - 'Style','radiobutton',... - 'String','Yes',...... - 'Units','Normalized','Position',[.55 .47 .34 .24],... - 'TooltipString','tooltipstring',... - 'FontSize',10,... - 'HorizontalAlignment','left',... - 'Callback',@buttongroup_Callback); -handles.radiobutton_no = uicontrol(handles.buttonGroup,... - 'Tag','radiobutton_no',... - 'Style','radiobutton',... - 'String','No',...... - 'Units','Normalized','Position',[.15 .47 .34 .24],... - 'TooltipString','tooltipstring',... - 'FontSize',10,... - 'HorizontalAlignment','left',... - 'Callback',@buttongroup_Callback); - - function buttongroup_Callback(hObject,~) - - tmp = get(hObject,'String'); - if strcmp(tmp,'No') - set(handles.edit_date,'String','','BackgroundColor','y') - elseif strcmp(tmp,'Yes') - set(handles.edit_date,'String','09-01-2023',... - 'BackgroundColor','w') - end - - end - - -uicontrol(handles.buttonGroup,'Style','text',... - 'String','Date',... - 'Units','Normalized','Position',[0.03 0.02 0.3 0.33],... - 'FontSize',10,... - 'HorizontalAlignment','left'); -handles.edit_date = uicontrol(handles.buttonGroup,'Style','edit',... - 'Tag','edit_date',... - 'Units','Normalized','Position',[0.3 0.02 0.6 0.38],... - 'TooltipString','Valid format: dd-mm-yyyy',... - 'HorizontalAlignment','left',... - 'BackgroundColor','red',... - 'UserData','',... - 'Callback',@edit_date_Callback); - - - function edit_date_Callback(hObject,eventdata) - - - oldvalue = get(hObject,'String'); - - % there should always be made a validation of the imput - thisdate = isdate(get(hObject,'String')); - if isempty(thisdate),set(hObject,'String',''),return,end - - % If the date is valid write on screen with the correct format - set(hObject,'String',thisdate) - - end - -%----------------------------- -% BUILD ONE UICONTEXTMENU -%----------------------------- -c = uicontextmenu; -m1 = uimenu(c,'Label','Red','Callback',@backgroundcolor); -m2 = uimenu(c,'Label','Blue','Callback',@backgroundcolor); -m3 = uimenu(c,'Label','White','Callback',@backgroundcolor); -set(handles.edit_date,'UIContextMenu',c) - - function backgroundcolor(source,callbackdata) - - tmp = get(source,'Label'); - - switch tmp - case 'Red' - set(handles.edit_date,'BackgroundColor','r'); - case 'Blue' - set(handles.edit_date,'BackgroundColor','b'); - case 'White' - set(handles.edit_date,'BackgroundColor','w'); - end - end -%- - - -%--------------------------------------------------------------- -% BUILD A NEW PANEL -%--------------------------------------------------------------- -handles.panel_studentDetails = uipanel('Parent',mainFig,... - 'Tag', 'panel_studentDetails',... - 'Title', 'Student Details',... - 'Units', 'Normalized',... - 'Position', [.19 .2 .75 .79],... - 'HighlightColor', 'm',... - 'ForegroundColor', 'm',... - 'FontSize', 12); - -% It is convenient that the first option is an instruction -courses = {'Select Course...' 'Physics' 'Chemistry' 'Mathematics'}; -handles.popupmenu_courses = uicontrol(... - 'Parent',handles.panel_studentDetails,... - 'Style','popupmenu',... - 'Tag','popup_courses',... - 'Units','Normalized','Position',[0.01 0.9 0.15 0.05],... - 'String',courses,... - 'TooltipString','Select Course',... - 'HorizontalAlignment','left',... - 'BackgroundColor','y',... - 'UserData','',... - 'Callback',@popupmenu_courses_Callback); - - function popupmenu_courses_Callback(hObject,~) - - % Because I'm getting the value, I need to know the relation - % between the value and the string - val = get(hObject,'Value'); - if val == 1 % it may be needed to reset all data - cla(handles.axes_plot) - - tmp = get(handles.uitable,'Userdata'); - % Show the all data again - set(handles.uitable,'Data',tmp,... - 'Rowname',get(handles.listbox_students,'String')) - elseif val == 2 % Physics - % fill table with data - filterByCourse('Physics'); - % clear plot - cla(handles.axes_plot) - elseif val == 3 % Chemistry - plot(age(:,1),age(:,end),'kx','MarkerSize',12,... - 'Parent',handles.axes_plot) - %clear table but do not erase the data - set(handles.uitable,'Data','','Rowname','') - elseif val == 4 % Mathematics - filterByCourse('Mathematics'); - - cla(handles.axes_plot) - for i=1:size(age,2) - plot(age(:,i),age(:,end-i+1),'x',... - 'Parent',handles.axes_plot) - drawnow - end - - end - end - -handles.checkbox_verification = uicontrol(... - 'Parent',handles.panel_studentDetails,... - 'Style','checkbox',... - 'Tag','checkbox_verification',... - 'String','Student Verified',... - 'Units','Normalized','Position',[0.18 0.9 0.15 0.05],... - 'TooltipString','Select if student was verified.',... - 'UserData','',... - 'Callback',@checkbox_verification_Callback); - - function checkbox_verification_Callback(hObject,~) - - val = get(hObject,'Value'); - if val == 1 % Checkbox was selected - set(handles.uitable,'Enable','off') - else - set(handles.uitable,'Enable','on') - end - end - - -%------------------------------------------------------------------ -% BUILD UITABLE -%------------------------------------------------------------------ -handles.uitable = uitable(handles.panel_studentDetails,... - 'Tag','uitable',... - 'ColumnFormat',{'numeric' 'numeric' 'numeric' 'numeric' ... - 'char' 'logical' {'Select...' 'Physics' 'Chemistry' 'Mathematics'}},... - 'Data',data,... - 'Units','Normalized','Position',[0.01 0.01 0.5 0.85],... - 'Columnwidth',{15 20 100 100 150 150 170},... - 'ColumnEditable',true,... - 'ColumnName',... - {'Age' 'Code' 'Phone' 'Average' 'Name' 'Graduated' 'Degree'},... - 'RowName',get(handles.listbox_students,'string'),... - 'Userdata',data,...% Simple way store data - 'CellEditCallback',@uitable_Callback); -% Check other properties in the Inspector from Guide or Help manual - - - % if there is more than one uitable, give it an more appropriate name - function uitable_Callback(hObject,eventdata) - - tmp = get(hObject,'Data'); - % keep the data from the table somwhere - set(handles.uitable,'Userdata',tmp) - - % another way to store variables in the workspace - assignin('base','data',tmp) - end - - -%------------------------------------------------------------------ -% BUILD AXES TO PLOT DATA -%------------------------------------------------------------------ -handles.axes_plot = axes('Parent',handles.panel_studentDetails,... - 'Units','Normalized','Position',[0.58 0.1 0.4 0.85],... - 'Visible','on'); -xlabel('xx'),ylabel('yy'),hold on - - -end diff --git a/Interface/FitModel/uncertainty_quocient.m b/Interface/uncertainty_quocient.m similarity index 100% rename from Interface/FitModel/uncertainty_quocient.m rename to Interface/uncertainty_quocient.m diff --git a/OLD/octaveDTRP/ListStudents.mat b/OLD/octaveDTRP/ListStudents.mat deleted file mode 100644 index 8ce62ba..0000000 Binary files a/OLD/octaveDTRP/ListStudents.mat and /dev/null differ diff --git a/OLD/octaveDTRP/ciencias_ul_azul_h_s-ass.png b/OLD/octaveDTRP/ciencias_ul_azul_h_s-ass.png deleted file mode 100644 index 9223147..0000000 Binary files a/OLD/octaveDTRP/ciencias_ul_azul_h_s-ass.png and /dev/null differ diff --git a/OLD/octaveDTRP/emogi.jpg b/OLD/octaveDTRP/emogi.jpg deleted file mode 100644 index f72c1e6..0000000 Binary files a/OLD/octaveDTRP/emogi.jpg and /dev/null differ diff --git a/OLD/octaveDTRP/filterByCourse.m b/OLD/octaveDTRP/filterByCourse.m deleted file mode 100644 index d942266..0000000 --- a/OLD/octaveDTRP/filterByCourse.m +++ /dev/null @@ -1,13 +0,0 @@ -function filterByCourse(course) - -% recover the table data stored in the Userdata of uitable_age -uitable = findobj('Tag','uitable'); -% this variable exists only inside this function -data = get(uitable,'Userdata'); - -listbox_students = findobj('Tag','listbox_students'); -list=get(listbox_students,'String'); -n=strcmp(data(:,7),course); - -set(uitable,'Data',data(n,:),... - 'Rowname',list(n)); diff --git a/OLD/octaveDTRP/isdate.m b/OLD/octaveDTRP/isdate.m deleted file mode 100644 index 9f4ab33..0000000 --- a/OLD/octaveDTRP/isdate.m +++ /dev/null @@ -1,48 +0,0 @@ -function strdate=isdate(strdate) -% function strdate = isdate(strdate) -% -% INPUT -% * strdate is a string (not cell) and returns the strdate in the format -% adopted dd-mm-yyyy -% -% OUTPUT -% * strdate as dd-mm-yyyy, empty string if no valid date -% -% ------------------------------------------------------------------------- -% made by bcf in 06-12-2010 -% ------------------------------------------------------------------------- - -n=strfind(strdate,'-'); -if isempty(n)||numel(n)~=2 - strdate=[]; - %set(gco,'String',''); % TODO: this should be removed from here??????????????????????????????????????????? - h=errordlg('Input must be a date with format dd-mm-yyyy','ERROR'); - set(h,'WindowStyle','modal') - return -end - -Day = str2double(strdate(1:n(1)-1)); -Month = str2double(strdate(n(1)+1:n(2)-1)); -Year = str2double(strdate(n(2)+1:end)); - -% do not change the order because day depends on Year and Month -if Year <1900 || Year >2100 || isempty(Year) || isnan(Year) - strdate=[]; - h=errordlg('Year is not valid!','Error');set(h,'WindowStyle','modal') - return -end -if Month <=0 || Month >12 || isempty(Month) || isnan(Month) - strdate=[];set(gco,'String','') - h=errordlg('Month is not valid!','Error');set(h,'WindowStyle','modal') - return -end -if Day <=0 || Day > eomday(Year,Month) || isempty(Day) || isnan(Day) - strdate=[];set(gco,'String','') - h=errordlg('Day is not valid!','Error');set(h,'WindowStyle','modal') - return -end - -strdate = [int2str(Month) '/' int2str(Day) '/' int2str(Year)]; -strdate = datestr(strdate, 2); - -end \ No newline at end of file diff --git a/OLD/octaveDTRP/logoFCUL.jpg b/OLD/octaveDTRP/logoFCUL.jpg deleted file mode 100644 index dc3d42f..0000000 Binary files a/OLD/octaveDTRP/logoFCUL.jpg and /dev/null differ diff --git a/OLD/octaveDTRP/menu_login_Callback.m b/OLD/octaveDTRP/menu_login_Callback.m deleted file mode 100644 index ca54860..0000000 --- a/OLD/octaveDTRP/menu_login_Callback.m +++ /dev/null @@ -1,3 +0,0 @@ -function menu_login_Callback() - -msgbox('Prepare this function to ask for username and password!') \ No newline at end of file diff --git a/OLD/octaveDTRP/myloginicon.mat b/OLD/octaveDTRP/myloginicon.mat deleted file mode 100644 index 985fbd6..0000000 Binary files a/OLD/octaveDTRP/myloginicon.mat and /dev/null differ diff --git a/OLD/octaveDTRP/mylogouticon.mat b/OLD/octaveDTRP/mylogouticon.mat deleted file mode 100644 index 4d113a4..0000000 Binary files a/OLD/octaveDTRP/mylogouticon.mat and /dev/null differ diff --git a/OLD/octaveDTRP/teraPro.m b/OLD/octaveDTRP/teraPro.m deleted file mode 100644 index 17d00d7..0000000 --- a/OLD/octaveDTRP/teraPro.m +++ /dev/null @@ -1,465 +0,0 @@ -function teraPro -% function teraPro -% HELP: this function serves as an hypothetical example to be used -% in the lectures of Diagn�stico e Terapia com Radia��es e Prot�es -% -% INPUT -% * none -% -% OUTPUT -% * none -% -% SEE ALSO: isdate, filterByCourse -% -% ------------------------------------------------------------------------- -% made by bcf in 09-01-2023 -% ------------------------------------------------------------------------- - - -%----------------------------------------------------- -% Initialize some variables for demonstration purposes -%----------------------------------------------------- -age = rand(30); -data = {22 51 25199 16 'Jose X' true 'Select...';... - 18 01 9501 18 'Maria XY' false 'Physics';... - 22 55 9612 '' 'Jose XYZ' true 'Mathematics';... - 26 55 9612 '' 'Jo�o Z' false 'Chemistry'}; -%--- - -%--------------------------------------------------------------- -% BUILD THE MAIN FIGURE -%--------------------------------------------------------------- -mainFig =figure(1); -set(mainFig ,'Name','Example for DTRP',... - 'Position',[1 82.3333 1280 566],... - 'KeyPressFcn',@figure_keyPressFcn,... - 'MenuBar','None'); -clf, % clear the figure - - function figure_keyPressFcn(hObject,eventdata) - - switch eventdata.Key - case 'return' - set(hObject,'Color','r') - - case 'backspace' - set(hObject,'Color','b') - case 'escape' - set(hObject,'Color',[1 0.5 0]) - - end - end - - -% ADD CIENCIAS LOGO -%------------------- -[tmp,~,alfa] = imread('ciencias_ul_azul_h_s-ass.png'); -%maximize the use of temporary variables -handles.axes_logo = axes('Parent',mainFig,... - 'Units','Normalized','Position',[0.03 0.87 0.12 0.12],... - 'Visible','off'); -tmp=image(tmp); -set(tmp, 'AlphaData', alfa); -axis equal off -%--- - - - -%--------------------------------------------------------------- -% BUILD THE MENU -%--------------------------------------------------------------- -handles.uimenu_new = uimenu(mainFig,'Label','New'); -handles.uimenu_newFile = uimenu(handles.uimenu_new,... - 'Label','New File...',... - 'Callback',@uimenu_new_callback); -handles.uimenu_saveFile = uimenu(handles.uimenu_new,... - 'Label','Save...',... - 'Separator','on',... - 'Callback',@uimenu_save_callback); % See Also: UImenu properties - - - % the advantage of having the Callback function close to the creation - % of the object is that it is easy to get there with the Go To... - function uimenu_new_callback(hObject,eventdata) - - warndlg(['No action will happen when Pressing OK because'... - ' this Callback function is not programmed yet!'],... - '!! Warning !!') - - % See Also: dialog, questdlg, errordlg - end - - function uimenu_save_callback(hObject,eventdata) - - % Can be any variable stored in the interface or the workspace - uisave({'data'},'ListStudents.mat') %Suggested filename - - %See Also: uigetfifle, uiopen - end - -%--------------------------------------------------------------- -% ADD A TOOLBAR -%--------------------------------------------------------------- -handles.toolbar=uitoolbar(mainFig); -diretory = 'octaveDTRP'; -%b=load([ diretory '\myloginicon.mat']); -uipushtool(handles.toolbar,... %'CData',b.icon,... - 'TooltipString','Login',... - 'Tag','pushtool_login',... - 'Enable','on',... - 'ClickedCallback','menu_login_Callback();') -%b=load([diretory '\mylogouticon.mat']); -uipushtool(handles.toolbar,... %'CData',b.icon, - 'TooltipString','Logout',... - 'Tag','pushtool_logout',... - 'Enable','off',... - 'ClickedCallback','menu_logout_Callback();') -% CallBack Functions or any other functions -% do not need to be inside this file -%- - - -%--------------------------------------------------------------- -% BUILD A PANEL -%--------------------------------------------------------------- -panel_studentsList = uipanel('Tag','panel_studentsList',... - 'Title', 'List',... - 'Units', 'Normalized',... - 'Position', [.01 .007 .17 .84],... - 'HighlightColor', [0 0 1],... - 'FontSize', 12,... - 'Parent', mainFig); - -% is text no need to keep the handle -uicontrol(panel_studentsList,... - 'Tag','text',... - 'Style','Text', ... - 'String','Students List at FCUL',... - 'FontName', 'Arial',... - 'FontSize',13,... - 'Units','Normalized',... - 'Position',[.05 .95 .88 .05],... - 'Enable','on',... - 'Callback',@listbox_Callback); - -handles.listbox_students = uicontrol(panel_studentsList,... - 'Tag','listbox_students',... - 'Style','listbox', ... - 'String',{'Student1','Student2','Student344' 'Student489'},... - 'Units','Normalized',... - 'Position',[.1 .2 .75 .75],... - 'Enable','on',... - 'Callback',@listbox_students_Callback); -% String defined as cell to accomodate different size strings -% String can be a list read directly from a file or a database which then -% fills up the listbox - - function listbox_students_Callback(hObject,~) - - handles.pushbutton_delete ='enable'; - - tmp = get(hObject,'String'); % cells - val = get(hObject,'Value'); - if strcmp(tmp(val),'Student1') - cla(handles.axes_plot) - plot(0:0.1:10,sin(0:0.1:10),'rs','Parent',handles.axes_plot) - elseif strcmp(tmp(val),'Student2') - handles.edit_date = '12-02-2023'; - else - tmp = imread('emogi.jpg'); - imagesc(rot90(tmp,2),'Parent',handles.axes_plot) - % TODO: ?????????????????? - end - - end - - -handles.pushbutton_add = uicontrol(panel_studentsList,... - 'Tag','pushbutton_add',... - 'Style','pushbutton', ... - 'String','Add new student',... - 'Units','Normalized',... - 'Position',[.1 .12 .75 .07],... - 'Enable','on',... - 'ForegroundColor','r',... - 'Tooltipstring','This button allows to add a new student to the list',... - 'Callback',@pushbutton_add_Callback); - - function pushbutton_add_Callback(hObject,eventdata) - - - % Data may be added without question the user - qst = 'Would you like to add a new student to the list?'; - button = questdlg(qst,'Question','Yes','Cancel','Cancel'); - if strcmp(button,'Yes') - - data = get(handles.uitable,'Data'); - list = get(handles.listbox_students,'String'); - % if there is no data yet in the list or all was deleted - if isempty(list) - set(handles.listbox_students,'String',{'Student1'},... - 'Value',1) % leave this student selected - - % string needs to be cell to be consistent with the - % following code and the format adopted for the list - else - %check the number of the last student and add a student - %with a new number - n=numel(list); - nb_laststudent=str2double(list{n}(8:end)); - list =[list;["Student" num2str(nb_laststudent+1)]]; - set(handles.listbox_students,'String',list,... - 'Value',n+1)% leave last student selected - - % ATTENTION: data has changed but not in the workspace - % this variable was now stored in Userdata - data(size(data,1)+1,:)=cell(1,7); - set(handles.uitable,... - 'Rowname',get(handles.listbox_students,'String'),... - 'Data', data,'Userdata',data) - end - end - - end - -handles.pushbutton_delete = uicontrol(panel_studentsList,... - 'Tag','pushbutton_delete',... - 'Style','pushbutton', ... - 'String','Delete',... - 'Units','Normalized',... - 'Position',[.1 .02 .75 .07],... - 'Enable','on',... - 'Callback',@pushbutton_delete_Callback); - - function pushbutton_delete_Callback(hObject,~) - - % As a precaution measure, everytime data is deleted, the user - % should be questioned - qst = 'Are you sure you need to delete this information?'; - button = questdlg(qst,'WARNING DELETE','Yes','No','No'); - % No is the default button selected - if strcmp(button,'Yes') - list = get(handles.listbox_students,'String'); - val=get(handles.listbox_students,'Value'); - list(val) =''; - set(handles.listbox_students,'String',list,'Value',1); - - % all information related to that instance needs to be erased - set(handles.edit_date,'String',''); - set(handles.uitable,... - 'Rowname',get(handles.listbox_students,'String')); - data = get(handles.uitable,'Userdata');%or get(handles.uitable,'Data'); - data(val,:)=''; - set(handles.uitable,'Data',data,'Userdata',data); - end - - end - -handles.buttonGroup = uibuttongroup('Parent',mainFig,... - 'Title','Student Registration',... - 'Tag','buttongroup',... - 'FontSize',12,... - 'FontWeight','bold',... - 'Units','Normalized','Position',[.19 .006 .193 .165],... - 'UserData','Test 1',... - 'SelectionChangedFcn',@buttongroup_Callback); -handles.radiobutton_yes = uicontrol(handles.buttonGroup,... - 'Tag','radiobutton_yes',... - 'Style','radiobutton',... - 'String','Yes',...... - 'Units','Normalized','Position',[.55 .47 .34 .24],... - 'TooltipString','tooltipstring',... - 'FontSize',10,... - 'HorizontalAlignment','left'); -handles.radiobutton_no = uicontrol(handles.buttonGroup,... - 'Tag','radiobutton_no',... - 'Style','radiobutton',... - 'String','No',...... - 'Units','Normalized','Position',[.15 .47 .34 .24],... - 'TooltipString','tooltipstring',... - 'FontSize',10,... - 'HorizontalAlignment','left'); - - function buttongroup_Callback(hObject,~) - - tmp = get(hObject,'SelectedObject'); - if strcmp(tmp,'No') - set(handles.edit_date,'String','','BackgroundColor','y'); - elseif strcmp(tmp,'Yes') - set(handles.edit_date,'String','09-01-2023',... - 'BackgroundColor','w'); - end - - end - - -uicontrol(handles.buttonGroup,'Style','text',... - 'String','Date',... - 'Units','Normalized','Position',[0.03 0.02 0.3 0.33],... - 'FontSize',10,... - 'HorizontalAlignment','left'); -handles.edit_date = uicontrol(handles.buttonGroup,'Style','edit',... - 'Tag','edit_date',... - 'Units','Normalized','Position',[0.3 0.02 0.6 0.38],... - 'TooltipString','Valid format: dd-mm-yyyy',... - 'HorizontalAlignment','left',... - 'BackgroundColor','red',... - 'UserData','',... - 'Callback',@edit_date_Callback); - - - function edit_date_Callback(hObject,eventdata) - - oldvalue = get(hObject,'string'); - - % there should always be made a validation of the imput - thisdate = isdate(get(hObject,'string')); - if isempty(thisdate),set(hObject,'string',''),return,end - - % If the date is valid write on screen with the correct format - set(hObject,'string',thisdate) - - end - -%----------------------------- -% BUILD ONE UICONTEXTMENU -%----------------------------- -c = uicontextmenu; -m1 = uimenu(c,'Label','Red','Callback',@backgroundcolor); -m2 = uimenu(c,'Label','Blue','Callback',@backgroundcolor); -m3 = uimenu(c,'Label','White','Callback',@backgroundcolor); -set(handles.edit_date,'UIContextMenu',c) - - function backgroundcolor(source,callbackdata) - switch source.Label - case 'Red' - handles.edit_date.BackgroundColor ='r'; - case 'Blue' - handles.edit_date.BackgroundColor ='b'; - case 'White' - handles.edit_date.BackgroundColor ='w'; - end - end -%- - - -%--------------------------------------------------------------- -% BUILD A NEW PANEL -%--------------------------------------------------------------- -handles.panel_studentDetails = uipanel('Parent',mainFig,... - 'Tag', 'panel_studentDetails',... - 'Title', 'Student Details',... - 'Units', 'Normalized',... - 'Position', [.19 .2 .75 .79],... - 'HighlightColor', 'm',... - 'ForegroundColor', 'm',... - 'FontSize', 12); - -% It is convenient that the first option is an instruction -courses = {'Select Course...' 'Physics' 'Chemistry' 'Mathematics'}; -handles.popupmenu_courses = uicontrol(... - 'Parent',handles.panel_studentDetails,... - 'Style','popupmenu',... - 'Tag','popup_courses',... - 'Units','Normalized','Position',[0.01 0.9 0.15 0.05],... - 'String',courses,... - 'TooltipString','Select Course',... - 'HorizontalAlignment','left',... - 'BackgroundColor','y',... - 'UserData','',... - 'Callback',@popupmenu_courses_Callback); - - function popupmenu_courses_Callback(hObject,~) - - % Because I'm getting the value, I need to know the relation - % between the value and the string - val = get(hObject,'Value'); - if val == 1 % it may be needed to reset all data - cla(handles.axes_plot) - - % Show the all data again - set(handles.uitable,'Data',data,... - 'Rowname',get(handles.listbox_students,'String')) - elseif val == 2 % Physics - % fill table with data - filterByCourse('Physics'); - % clear plot - cla(handles.axes_plot) - elseif val == 3 % Chemistry - plot(age(:,1),age(:,end),'kx','MarkerSize',12,... - 'Parent',handles.axes_plot) - %clear table - set(handles.uitable,'Data','','Rowname','') - elseif val == 4 % Mathematics - filterByCourse('Mathematics'); - - cla(handles.axes_plot) - for i=1:size(age,2) - plot(age(:,i),age(:,end-i+1),'x') - drawnow - end - - end - end - -handles.checkbox_verification = uicontrol(... - 'Parent',handles.panel_studentDetails,... - 'Style','checkbox',... - 'Tag','checkbox_verification',... - 'String','Student Verified',... - 'Units','Normalized','Position',[0.18 0.9 0.15 0.05],... - 'TooltipString','Select if student was verified.',... - 'UserData','',... - 'Callback',@checkbox_verification_Callback); - - function checkbox_verification_Callback(hObject,~) - - val = get(hObject,'Value'); - if val == 1 % Checkbox was selected - set(handles.uitable,'Enable','off') - else - set(handles.uitable,'Enable','on') - end - end - - -%------------------------------------------------------------------ -% BUILD UITABLE -%------------------------------------------------------------------ -handles.uitable = uitable(handles.panel_studentDetails,... - 'Tag','uitable',... - 'ColumnFormat',{'numeric' 'numeric' 'numeric' 'numeric' ... - 'char' 'logical' {'Select...' 'Physics' 'Chemistry' 'Mathematics'}},... - 'Data',data,... - 'Units','Normalized','Position',[0.01 0.01 0.5 0.85],... - 'ColumnEditable',true,... - 'ColumnName',... - {'Age' 'Code' 'Phone' 'Average' 'Name' 'Graduated' 'Degree'},... - 'RowName',get(handles.listbox_students,'string'),... - 'Userdata',data,...% Simple way store data - 'CellEditCallback',@uitable_Callback); -% Check other properties in the Inspector from Guide or Help manual - - - % if there is more than one uitable, give it an more appropriate name - function uitable_Callback(hObject,eventdata) - - tmp = get(hObject,'Data') - % keep the data from the table somwhere - set(handles.uitable,'Userdata',tmp) - - % another way to store variables in the workspace - assignin('base','data',tmp) - end - - -%------------------------------------------------------------------ -% BUILD AXES TO PLOT DATA -%------------------------------------------------------------------ -handles.axes_plot = axes('Parent',handles.panel_studentDetails,... - 'Units','Normalized','Position',[0.58 0.1 0.4 0.85],... - 'Visible','on'); -xlabel('xx'),ylabel('yy'),hold on - - -end \ No newline at end of file diff --git a/OLD/octaveDTRP/teraProByGuide.fig b/OLD/octaveDTRP/teraProByGuide.fig deleted file mode 100644 index 4a6b5de..0000000 Binary files a/OLD/octaveDTRP/teraProByGuide.fig and /dev/null differ diff --git a/OLD/octaveDTRP/teraProByGuide.m b/OLD/octaveDTRP/teraProByGuide.m deleted file mode 100644 index bcfbe98..0000000 --- a/OLD/octaveDTRP/teraProByGuide.m +++ /dev/null @@ -1,173 +0,0 @@ -function varargout = teraProByGuide(varargin) -%TERAPROBYGUIDE MATLAB code file for teraProByGuide.fig -% TERAPROBYGUIDE, by itself, creates a new TERAPROBYGUIDE or raises the existing -% singleton*. -% -% H = TERAPROBYGUIDE returns the handle to a new TERAPROBYGUIDE or the handle to -% the existing singleton*. -% -% TERAPROBYGUIDE('Property','Value',...) creates a new TERAPROBYGUIDE using the -% given property value pairs. Unrecognized properties are passed via -% varargin to teraProByGuide_OpeningFcn. This calling syntax produces a -% warning when there is an existing singleton*. -% -% TERAPROBYGUIDE('CALLBACK') and TERAPROBYGUIDE('CALLBACK',hObject,...) call the -% local function named CALLBACK in TERAPROBYGUIDE.M with the given input -% arguments. -% -% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one -% instance to run (singleton)". -% -% See also: GUIDE, GUIDATA, GUIHANDLES - -% Edit the above text to modify the response to help teraProByGuide - -% Last Modified by GUIDE v2.5 16-Jan-2023 08:52:47 - -% Begin initialization code - DO NOT EDIT -gui_Singleton = 1; -gui_State = struct('gui_Name', mfilename, ... - 'gui_Singleton', gui_Singleton, ... - 'gui_OpeningFcn', @teraProByGuide_OpeningFcn, ... - 'gui_OutputFcn', @teraProByGuide_OutputFcn, ... - 'gui_LayoutFcn', [], ... - 'gui_Callback', []); -if nargin && ischar(varargin{1}) - gui_State.gui_Callback = str2func(varargin{1}); -end - -if nargout - [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); -else - gui_mainfcn(gui_State, varargin{:}); -end -% End initialization code - DO NOT EDIT - - -% --- Executes just before teraProByGuide is made visible. -function teraProByGuide_OpeningFcn(hObject, eventdata, handles, varargin) -% This function has no output args, see OutputFcn. -% hObject handle to figure -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) -% varargin unrecognized PropertyName/PropertyValue pairs from the -% command line (see VARARGIN) - -% Choose default command line output for teraProByGuide -handles.output = hObject; - -% Update handles structure -guidata(hObject, handles); - -% UIWAIT makes teraProByGuide wait for user response (see UIRESUME) -% uiwait(handles.figure1); - - -% --- Outputs from this function are returned to the command line. -function varargout = teraProByGuide_OutputFcn(hObject, eventdata, handles) -% varargout cell array for returning output args (see VARARGOUT); -% hObject handle to figure -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Get default command line output from handles structure -varargout{1} = handles.output; - - - -function edit_date_Callback(hObject, eventdata, handles) -% hObject handle to edit_date (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: get(hObject,'String') returns contents of edit_date as text -% str2double(get(hObject,'String')) returns contents of edit_date as a double - - -% --- Executes during object creation, after setting all properties. -function edit_date_CreateFcn(hObject, eventdata, handles) -% hObject handle to edit_date (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: edit controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - -% --- Executes on selection change in popupmenu_courses. -function popupmenu_courses_Callback(hObject, eventdata, handles) -% hObject handle to popupmenu_courses (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_courses contents as cell array -% contents{get(hObject,'Value')} returns selected item from popupmenu_courses - - -% --- Executes during object creation, after setting all properties. -function popupmenu_courses_CreateFcn(hObject, eventdata, handles) -% hObject handle to popupmenu_courses (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: popupmenu controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - -% --- Executes on button press in checkbox_verification. -function checkbox_verification_Callback(hObject, eventdata, handles) -% hObject handle to checkbox_verification (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hint: get(hObject,'Value') returns toggle state of checkbox_verification - - -% --- Executes on selection change in listbox_students. -function listbox_students_Callback(hObject, eventdata, handles) -% hObject handle to listbox_students (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - -% Hints: contents = cellstr(get(hObject,'String')) returns listbox_students contents as cell array -% contents{get(hObject,'Value')} returns selected item from listbox_students - - -% --- Executes during object creation, after setting all properties. -function listbox_students_CreateFcn(hObject, eventdata, handles) -% hObject handle to listbox_students (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles empty - handles not created until after all CreateFcns called - -% Hint: listbox controls usually have a white background on Windows. -% See ISPC and COMPUTER. -if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) - set(hObject,'BackgroundColor','white'); -end - - -% --- Executes on button press in pushbutton_add. -function pushbutton_add_Callback(hObject, eventdata, handles) -% hObject handle to pushbutton_add (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - - -% --- Executes on button press in pushbutton_delete. -function pushbutton_delete_Callback(hObject, eventdata, handles) -% hObject handle to pushbutton_delete (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) - - -% -------------------------------------------------------------------- -function Untitled_1_Callback(hObject, eventdata, handles) -% hObject handle to Untitled_1 (see GCBO) -% eventdata reserved - to be defined in a future version of MATLAB -% handles structure with handles and user data (see GUIDATA) diff --git a/RADIANCE-Guide_v2.pdf b/RADIANCE-Guide_v2.pdf deleted file mode 100644 index a9f2bc1..0000000 Binary files a/RADIANCE-Guide_v2.pdf and /dev/null differ diff --git a/RADIANTE_Structure.pptx b/RADIANTE_Structure.pptx deleted file mode 100644 index 66051f3..0000000 Binary files a/RADIANTE_Structure.pptx and /dev/null differ diff --git a/References/.DS_Store b/References/.DS_Store deleted file mode 100644 index 339e020..0000000 Binary files a/References/.DS_Store and /dev/null differ diff --git a/References/MatlabCompiler.pdf b/References/MatlabCompiler.pdf deleted file mode 100644 index 582c3cc..0000000 Binary files a/References/MatlabCompiler.pdf and /dev/null differ diff --git a/References/RadiobiologicalParameters/1-s2.0-S0360301607044501-main.pdf b/References/RadiobiologicalParameters/1-s2.0-S0360301607044501-main.pdf deleted file mode 100644 index bf8a379..0000000 Binary files a/References/RadiobiologicalParameters/1-s2.0-S0360301607044501-main.pdf and /dev/null differ diff --git a/References/RadiobiologicalParameters/Ref21.pdf b/References/RadiobiologicalParameters/Ref21.pdf deleted file mode 100644 index 62a87d1..0000000 Binary files a/References/RadiobiologicalParameters/Ref21.pdf and /dev/null differ diff --git a/References/RadiobiologicalParameters/Ref22_1-s2.0-S0360301605030828.pdf b/References/RadiobiologicalParameters/Ref22_1-s2.0-S0360301605030828.pdf deleted file mode 100644 index 633155c..0000000 Binary files a/References/RadiobiologicalParameters/Ref22_1-s2.0-S0360301605030828.pdf and /dev/null differ diff --git a/References/RadiobiologicalParameters/Ref24_1-s2.0-S0748798398906503.pdf b/References/RadiobiologicalParameters/Ref24_1-s2.0-S0748798398906503.pdf deleted file mode 100644 index 460b6dd..0000000 Binary files a/References/RadiobiologicalParameters/Ref24_1-s2.0-S0748798398906503.pdf and /dev/null differ diff --git a/Tests/AddMatrix.m b/Tests/AddMatrix.m deleted file mode 100644 index a695cf6..0000000 --- a/Tests/AddMatrix.m +++ /dev/null @@ -1,34 +0,0 @@ -% Define the two matrices to be added -disp(rand(1000)); -A = rand(10000); -B = rand(10000); - -% Initialize the result matrix -C = zeros(10000); - -% Set the number of threads to use -n_threads = 1; - -% Split the rows of the matrices among the threads -rows_per_thread = floor(size(A, 1) / n_threads); -row_indices = 1:rows_per_thread:size(A, 1); - -% Perform the matrix addition using multithreading -tic %Starts clock -parfor (i = 1:size(A, 1), n_threads) - C(i, :) = A(i, :) + B(i, :); -end -toc %Stops clock - -% Check the result -if isequal(C, A+B) - disp("Matrix addition succeeded!"); - %disp("C = "); - %disp(C); -else - disp("Matrix addition failed!"); - disp("A + B = "); - disp(A+B); - disp("C = "); - disp(C); -end diff --git a/code/.DS_Store b/code/.DS_Store deleted file mode 100644 index 0061452..0000000 Binary files a/code/.DS_Store and /dev/null differ diff --git a/code/BED.m b/code/BED.m deleted file mode 100644 index be3a08f..0000000 --- a/code/BED.m +++ /dev/null @@ -1,210 +0,0 @@ -clc, clearvars %clear - -% CSV files -% Liang,Dawson,SeongH,SeongM,SeongL -file_names = { 'datafiles/SR_EQ1_L.csv','datafiles/SR_EQ1_D.csv',... - 'datafiles/SR_EQ1_SH.csv','datafiles/SR_EQ1_SM.csv','datafiles/SR_EQ1_SL.csv'}; -%Error Bars of the files points -error_bars_top = {'datafiles/error bars/errorsbars_top_1y.csv',... - 'datafiles/error bars/errorsbars_top_2y.csv',... - 'datafiles/error bars/errorsbars_top_3y.csv',... - 'datafiles/error bars/errorsbars_top_4y.csv'}; -error_bars_bot = {'datafiles/error bars/errorsbars_bot_1y.csv',... - 'datafiles/error bars/errorsbars_bot_2y.csv',... - 'datafiles/error bars/errorsbars_bot_3y.csv',... - 'datafiles/error bars/errorsbars_bot_4y.csv'}; -number_studies = numel(file_names); -number_years = 4; - -% Data from the files: -%sr (SR) - survival rate in percentage -%tau - elapsed time in months - -N_values = [128, 35, 83, 51, 24]; %N - number of patients -d_values = [4.88, 1.5, 1.8, 1.8, 1.8]; %d - dose per fraction Gy/fx -D_values = [53.6, 61.5, 55, 45, 32.5]; %D - prescription dose Gy -T_day_values = [28, 42, 37, 37, 37]; %T_day - treatment time in days - -%v - vector with parameters obtained from fit2 - %v(1) - K50/K0 - %v(2) - alpha Gy^-1 - %v(3) - beta Gy^-2 - %v(4) - gamma days^-1 - %v(5) - sigmak/K0 - %v(6) - delta -v = [1.99, 0.0099754, 0.000692, 0.0056126, 0.71, 0.19]; - - -%x (BED) - Biologically effective dose (Gy) and y (SR) - Survival Rate (%): -% we store these points for each year (1,2,3, and 4) accompanied by their -% error bars -points1y = {}; -points2y = {}; -points3y = {}; -points4y = {}; -pointsyear = {points1y,points2y,points3y,points4y}; - -bed_values = zeros(1,number_studies); -% array to store BED values - needed to plot the error bars of each point -% since they are stored in ascending order of the BED value -for n = 1:number_studies - bed_values(n) = bed(d_values(n),v(2),v(3),D_values(n),v(4),T_day_values(n)); -end -% let's reorder the studies in ascending order of the BED value -[sortedValues, sortedStudies] = sort(bed_values); - -% array with the months values for 1,2,3,and 4 years, respectively -months_values = [12,24,36,48]; - -% for each year, m: -for m = 1:length(months_values) - month = months_values(m); - % error bars for that year - errhigh = load(error_bars_top{m}); - errlow = load(error_bars_bot{m}); - - dif_index = 0; % difference between the index used to scroll - % through the error bars files and the one used to scroll through - % the bed values - - % for each study, s: - for s = 1:number_studies %s - index to scroll through the values - study = sortedStudies(s); % study - index to scroll through the studies - data = load(file_names{study}); - tau = data(:,1); % tau (months) - sr = data(:,2); % survival rate (%) - - err = s - dif_index; % err - index to scroll through the error bars - - t = 1; %index to scroll through tau - % we start by assuming there is not a tau that corresponds - % to the year in question, m - found_tau = false; - while t <= length(tau) && found_tau == false - if abs(month-tau(t))<2 - found_tau = true; %there is a tau that corresponds to the year in question - sr_val = sr(t); %respective SR (%) - bed_val = sortedValues(s); %respective BED (Gy) - pointsyear{m} = vertcat(pointsyear{m}, [bed_val,sr_val,errhigh(err),errlow(err)]); - end - t = t + 1; - end - - if found_tau == false - % if it was not found a tau that corresponds to the year in question in the file of the study - % the index we are using on the files of the error bars (err) mantains its value - dif_index = dif_index + 1; - end - end -end - - -%x (BED) - Biologically effective dose (Gy): -% array with BED values to plot the curves -T_points = linspace(1,100,100); %treatment time in days -d = 2; %dose per fraction in Gy/fx -BED_points = []; %BED in Gy -for i = 1:length(T_points) - n = calculate_n(T_points(i)); %n->number of fractions - D = d * n; %D->dose values in Gy - B = bed(d,v(2),v(3),D,v(4),T_points(i)); %B->BED in Gy - BED_points = [BED_points,B]; -end - - -% Plotting -tau_values = {365,730,1095,1460}; -colors = {'#FE0100','#0000F7','#FD04FC','#000000'}; -years_label = {'\tau = 1y', '\tau = 2y', '\tau = 3y', '\tau = 4y'}; -markers = {'s','v','v','o'}; - -hold on - -% for each year -for i = 1:number_years - points = pointsyear{i}; % points for that year - tau = tau_values{i}; - % plotting the curve: - sr_plot = []; - bed_plot = []; - for j = 1:length(BED_points) - sr = perform_fit(BED_points(j),tau,v,T_points(j)); - if ~isnan(sr) - b = BED_points(j); - sr_plot = [sr_plot, sr]; - bed_plot = [bed_plot, b]; - end - end - plot(bed_plot, sr_plot, '--', 'LineWidth', 2, 'Color', colors{i},'DisplayName', years_label{i}); - % plotting the points and their error bars: - for l = 1:length(points) - for k = 1:length(points{l}) - x_bed = points{l}(1); - y_sr = points{l}(2); - err_high = points{l}(3); - err_low = points{l}(4); - plot(x_bed, y_sr, markers{i}, 'LineWidth', 2, 'Color', colors{i},'MarkerSize', 8, 'HandleVisibility', 'off'); - errorbar(x_bed,y_sr,err_low,err_high,'Color',colors{i},'LineStyle','none','HandleVisibility', 'off'); - - end - end -end - - -%legend,lables and title -legend('Location', 'northwest') -legend('boxoff') - -xlabel('Biologically Effective Dose (Gy)', 'Interpreter', 'latex'); -ylabel('Survival Rate - $SR (\%)$', 'Interpreter', 'latex'); -title('BED','Interpreter','latex') - -%saving the plot -saveas(gcf, './results/BED.pdf') - -%%%%%%%%%%%%%%%%%%%%%%% -% Functions % - -% fitting function % -function result = perform_fit(BED,tau,v,T_day) - %v(1) - K50/K0 - %v(2) - alpha Gy^-1 - %v(3) - beta Gy^-2 - %v(4) - gamma days^-1 - %v(5) - sigmak/K0 - %v(6) - delta - denominator = v(5); - p = v(2)*BED - ((v(4) * (tau - T_day)) ^ v(6)); - numerator = exp(-p) - v(1); - t = numerator / denominator; - if isreal(t) - result = 100 * (1/2)*(1-erf(t/sqrt(2))); - else - result = NaN; - end -end - -% bed function % -function b = bed(d,alpha,beta,D,gamma,T) - alpha_beta = alpha/beta; - b = (1+(d/alpha_beta))*D - (gamma*T)/alpha; - -end - -% number of fractions in function of the time in days -function n = calculate_n(T) - if mod(T-1, 7) == 5 - % it is Saturday, so the number of doses is - % the same as the one from Friday (1 day ago) - w = fix((T-1)/7); % number of weeks - n = (T-1) - (2*w); - elseif mod(T-2, 7) == 5 - % it is Sunday, so the number of doses is - % the same as the one from Friday (2 days ago) - w = fix((T-2)/7); % number of weeks - n = (T-2) - (2*w); - else - w = fix(T/7); % number of weeks - n = T - (2*w); - end -end diff --git a/code/Build4MATLAB/CurveFit.m b/code/Build4MATLAB/CurveFit.m deleted file mode 100644 index 9cf16e7..0000000 --- a/code/Build4MATLAB/CurveFit.m +++ /dev/null @@ -1,22 +0,0 @@ -%%% Create exponential decay sample data %%% -%%% of the form y = A exp(-lambd * t) %%% -%%% with A = 40 and lambd = 0.5 %%% -rng default % Random number generator -TimeData = 0:0.1:10 % values from 0 to 10 in steps of 0.1 -yData = 40*exp(-0.5*TimeData) + randn(size(TimeData)) - -%%% Create an auxiliary function "fun", which deppends -%%% only on the variable "Variables" - the free -%%% parameters to be fitted in the model -fun = @(Variables)Sum2EvalExp(Variables, TimeData, yData); - -%%% Initial parameters guess - random in this case -Guess = rand(2,1); - -%%% The fitted parameters are obtained usign -%%% the "fminsearch" fucntion, applied to the -%%% previously deffined auxiliary function -%%% with the correspondent initial guess. -%%% Same order as they appear in the "Variables" vector -FiitedParameters = fminsearch(fun,Guess) - diff --git a/code/Build4MATLAB/LinReg.m b/code/Build4MATLAB/LinReg.m deleted file mode 100644 index 6574ae0..0000000 --- a/code/Build4MATLAB/LinReg.m +++ /dev/null @@ -1,48 +0,0 @@ - -%%% Load data from CSV file to lists %%% -TestData = dlmread('datafiles/TestDataLinReg.csv', "") - -channel = TestData(:,1); -energy = TestData(:,2); - -%%% Basic calculation of linear regression slope and intersept %%% -format long -%slope = channel\energy; % The operator "\" does the regression - -X = [ones(length(channel),1) channel]; -InterceptAndSlope = X\energy; -EnergyFit = X * InterceptAndSlope; % this is used to plot the fitting line -%%% ########################################################## %%% - -%%% Polinomial regression using function "polyfit" %%% -Fit = polyfit(channel, energy, 1) % fit parameters -energyfit = polyval(Fit, channel); % y values calculated from the fit parameters -EnergyResid = energy - energyfit; % residuals -SumResid2 = sum(EnergyResid.^2); % sum the squares of the residuals -SumTotal = (length(energy)-1) * var(energy); % total sum of squares of y -R2 = 1 - SumResid2/SumTotal; % R square -%%% ############################################## %%% - -%plotting the different points -hold on -plot(channel, energy, '*', ... % Experimental points - 'LineWidth', 2, ... - 'Color', '#FD04FC', ... - 'MarkerSize', 6, ... - 'DisplayName', 'Exp.') -plot(channel, EnergyFit, '--', ... % Fitted line - 'LineWidth', 2, ... - 'Color', '#AD54FD', ... - 'MarkerSize', 6, ... - 'DisplayName', 'Fit') -%legend,lables and title -legend('Location', 'northwest') -legend('boxoff') -xlabel('Channel') -ylabel('Energy (keV)') -title('Energy Calibration') - -%saving the plot -%saveas(gcf, 'fit.pdf') - - diff --git a/code/Build4MATLAB/Sum2Eval.m b/code/Build4MATLAB/Sum2Eval.m deleted file mode 100644 index 67d27b8..0000000 --- a/code/Build4MATLAB/Sum2Eval.m +++ /dev/null @@ -1,21 +0,0 @@ -%%% Define function "Sum2Eval" to evaluate the sum of the -%%% residuals between the input data and the calculated. -%%% -%%% "Variables" is a vector of the free parameters in the -%%% model to be fitted. -%%% "TimeData" and "yData" are the input data for the -%%% optimization. - -function Sum2Eval = sseval(Variables, tau, SR) -K = Variables(1); % -alpha = Variables(2); % Gy^-1 -beta = Variables(3); % Gy^-2 -gamma = Variables(4); % day^-1 -a = Variables(5); % mon^-1 -delta = Variables(6); % -d = 4.88; % Gy/frac -D = 53.6; % Gy -T = 28.; % days -Sum2Eval = sum((SR - exp(-K*exp(-(alpha*(1+d*beta/alpha)*D-gamma*T-(a*(tau-T).^delta))))).^2) - - diff --git a/code/Build4MATLAB/Sum2EvalExp.m b/code/Build4MATLAB/Sum2EvalExp.m deleted file mode 100644 index eccb703..0000000 --- a/code/Build4MATLAB/Sum2EvalExp.m +++ /dev/null @@ -1,13 +0,0 @@ -%%% Define function "Sum2Eval" to evaluate the sum of the -%%% residuals between the input data and the calculated. -%%% -%%% "Variables" is a vector of the free parameters in the -%%% model to be fitted (in these case, an exponential with -%%% parameters "A" and "lambda"). -%%% "TimeData" and "yData" are the input data for the -%%% optimization. - -function Sum2EvalExp = sseval(Variables, TimeData, yData) -A = Variables(1); -lambda = Variables(2); -Sum2EvalExp = sum((yData - A*exp(-lambda * TimeData)).^2); \ No newline at end of file diff --git a/code/Build4MATLAB/TestFit.m b/code/Build4MATLAB/TestFit.m deleted file mode 100644 index 63cb9ac..0000000 --- a/code/Build4MATLAB/TestFit.m +++ /dev/null @@ -1,26 +0,0 @@ -%load data from the CSV files -data = readmatrix('datafiles/TestData.csv'); - -tau = data(:,1); % Enlapsed Time -SR = data(:,2); % Survival Rate -T = data(:,3); % Treatment Time -d = data(:,4); % Dose per fraction -D = data(:,5); % Total prescribed dose -A = data(:,6); % Autor ID - -%%% Create an auxiliary function "fun", which deppends -%%% only on the variable "Variables" - the free -%%% parameters to be fitted in the model -fun = @(Variables)Sum2Eval(Variables, tau, SR); - -%%% Initial parameters guess - random in this case -%Guess = rand(6,1); -Guess = [0.04, 0.04, 0.01, 0.006, 1260., 0,16]; - -%%% The fitted parameters are obtained usign -%%% the "fminsearch" fucntion, applied to the -%%% previously deffined auxiliary function -%%% with the correspondent initial guess. -%%% Same order as they appear in the "Variables" vector -FiitedParameters = fminsearch(fun,Guess) - diff --git a/code/Build4Octave/CurveFit.m b/code/Build4Octave/CurveFit.m deleted file mode 100644 index c426784..0000000 --- a/code/Build4Octave/CurveFit.m +++ /dev/null @@ -1,23 +0,0 @@ -%%% Create exponential decay sample data %%% -%%% of the form y = A exp(-lambd * t) %%% -%%% with A = 40 and lambd = 0.5 %%% -pkg load statistics - -TimeData = 0:0.1:10; % values from 0 to 10 in steps of 0.1 -yData = 40*exp(-0.5*TimeData) + randn(size(TimeData)); - -%%% Create an auxiliary function "fun", which deppends -%%% only on the variable "Variables" - the free -%%% parameters to be fitted in the model -fun = @(Variables)Sum2EvalExp(Variables, TimeData, yData); - -%%% Initial parameters guess - random in this case -Guess = rand(2,1); - -%%% The fitted parameters are obtained usign -%%% the "fminsearch" fucntion, applied to the -%%% previously deffined auxiliary function -%%% with the correspondent initial guess. -%%% Same order as they appear in the "Variables" vector -FiitedParameters = fminsearch(fun,Guess) - diff --git a/code/Build4Octave/LinReg.m b/code/Build4Octave/LinReg.m deleted file mode 100644 index d0771a2..0000000 --- a/code/Build4Octave/LinReg.m +++ /dev/null @@ -1,48 +0,0 @@ - -%%% Load data from CSV file to lists %%% -TestData = dlmread('../datafiles/TestDataLinReg.csv', "") - -channel = TestData(:,1); -energy = TestData(:,2); - -%%% Basic calculation of linear regression slope and intersept %%% -format long -%slope = channel\energy; % The operator "\" does the regression - -X = [ones(length(channel),1) channel]; -InterceptAndSlope = X\energy; -EnergyFit = X * InterceptAndSlope; % this is used to plot the fitting line -%%% ########################################################## %%% - -%%% Polinomial regression using function "polyfit" %%% -Fit = polyfit(channel, energy, 1) % fit parameters -energyfit = polyval(Fit, channel); % y values calculated from the fit parameters -EnergyResid = energy - energyfit; % residuals -SumResid2 = sum(EnergyResid.^2); % sum the squares of the residuals -SumTotal = (length(energy)-1) * var(energy); % total sum of squares of y -R2 = 1 - SumResid2/SumTotal; % R square -%%% ############################################## %%% - -%plotting the different points -hold on -plot(channel, energy, '*', ... % Experimental points - 'LineWidth', 2, ... - 'Color', 'm', ... - 'MarkerSize', 6, ... - 'DisplayName', 'Exp.') -plot(channel, EnergyFit, '--', ... % Fitted line - 'LineWidth', 2, ... - 'Color', 'c', ... - 'MarkerSize', 6, ... - 'DisplayName', 'Fit') -%legend,lables and title -legend('Location', 'northwest') -legend('boxoff') -xlabel('Channel') -ylabel('Energy (keV)') -title('Energy Calibration') - -%saving the plot -%saveas(gcf, 'fit.pdf') - - diff --git a/code/Build4Octave/Sum2EvalExp.m b/code/Build4Octave/Sum2EvalExp.m deleted file mode 100644 index eccb703..0000000 --- a/code/Build4Octave/Sum2EvalExp.m +++ /dev/null @@ -1,13 +0,0 @@ -%%% Define function "Sum2Eval" to evaluate the sum of the -%%% residuals between the input data and the calculated. -%%% -%%% "Variables" is a vector of the free parameters in the -%%% model to be fitted (in these case, an exponential with -%%% parameters "A" and "lambda"). -%%% "TimeData" and "yData" are the input data for the -%%% optimization. - -function Sum2EvalExp = sseval(Variables, TimeData, yData) -A = Variables(1); -lambda = Variables(2); -Sum2EvalExp = sum((yData - A*exp(-lambda * TimeData)).^2); \ No newline at end of file diff --git a/code/Build4Octave/Sum2EvalTest.m b/code/Build4Octave/Sum2EvalTest.m deleted file mode 100644 index 620eff1..0000000 --- a/code/Build4Octave/Sum2EvalTest.m +++ /dev/null @@ -1,21 +0,0 @@ -%%% Define function "Sum2Eval" to evaluate the sum of the -%%% residuals between the input data and the calculated. -%%% -%%% "Variables" is a vector of the free parameters in the -%%% model to be fitted. -%%% "TimeData" and "yData" are the input data for the -%%% optimization. - -function Sum2EvalTest = sseval(Variables, tau, SR) -K = Variables(1); % -alpha = Variables(2); % Gy^-1 -beta = Variables(3); % Gy^-2 -gamma = Variables(4); % day^-1 -a = Variables(5); % mon^-1 -delta = Variables(6); % -d = 4.88; % Gy/frac -D = 53.6; % Gy -T = 28.; % days -Sum2EvalTest = sum((SR - exp(-K*exp(-(alpha*(1+d*beta/alpha)*D-gamma*T-(a*(tau-T).^delta))))).^2); - - diff --git a/code/Build4Octave/TestFit.m b/code/Build4Octave/TestFit.m deleted file mode 100644 index 1ee2bd6..0000000 --- a/code/Build4Octave/TestFit.m +++ /dev/null @@ -1,31 +0,0 @@ -%load data from the CSV files -data = dlmread('../datafiles/TestData.csv', ""); - -tau = data(:,1); % Enlapsed Time -SR = data(:,2); % Survival Rate -T = data(:,3); % Treatment Time [days] -d = data(:,4); % Dose per fraction -D = data(:,5); % Total prescribed dose -A = data(:,6); % Autor ID - -%%% Create an auxiliary function "fun", which deppends -%%% only on the variable "Variables" - the free -%%% parameters to be fitted in the model -fun = @(Variables)Sum2EvalTest(Variables, tau, SR); - -%%% Initial parameters guess - random in this case -%Guess = rand(6,1); -Guess = [0.04, 0.04, 0.01, 0.006, 1260., 0,16]; - -%%% The fitted parameters are obtained usign -%%% the "fminsearch" fucntion, applied to the -%%% previously deffined auxiliary function -%%% with the correspondent initial guess. -%%% Same order as they appear in the "Variables" vector -FiitedParameters = fminsearch(fun,Guess) - -plot(tau, SR, '*', ... % Experimental points - 'LineWidth', 2, ... - 'Color', 'm', ... - 'MarkerSize', 6, ... - 'DisplayName', 'Exp.') \ No newline at end of file diff --git a/code/Build4Octave/fit_draft.m b/code/Build4Octave/fit_draft.m deleted file mode 100644 index 3a491cb..0000000 --- a/code/Build4Octave/fit_draft.m +++ /dev/null @@ -1,51 +0,0 @@ -pkg load optim - -%load data from the CSV files -data = dlmread("../datafiles/SR_EQ1_L.csv", ""); - -x = data(:,1); -y = data(:,2); -T = 28; % treatment time in days -d = 4.88; % dose per fraction -D = 53.6; % prescription dose -N = 128; % number of patients - -v = [0.042, 0.037, 0.0026, 0.006, 1268]; -%fitting function -f = @(x,delta) real(100*exp(-v(1).*exp(-(v(2).*(1+(d./(v(2)./v(3)))).*D - v(4).*T - (v(5).*(x-T)).^delta)))); -%f = @(x,delta) (100*exp(-v(1).*exp(-(v(2).*(1+(d./(v(2)./v(3)))).*D - v(4).*T - (v(5).*(x-T)).^delta)))); - -delta0 = 0.16; -delta_min = lsqnonlin(@(delta) chi_square(delta, x, y, N), delta0); - -%plotting the different points -hold on -plot(x, y, 'v', ... -'LineWidth', 2, ... -'Color', 'b', ... -'MarkerSize', 6, ... -'DisplayName', 'Liang') -plot(x, f(x, delta_min)) - -%legend,lables and title -legend('Location', 'northeast') -legend('boxoff') -xlabel('elapsed time from beginning of RT (Month)-tau') -ylabel('Survival Rate (%)-SR') -title('Fit 1') - -% Display the results -fprintf('Value of delta that minimizes the sum of squares: %f\n', delta_min); - -function residuals = chi_square(delta, x, y, N) - v = [0.042, 0.037, 0.0026, 0.006, 1268]; - T = 28; - d = 4.88; - D = 53.6; - y_fit = real(100*exp(-v(1).*exp(-(v(2).*(1+(d./(v(2)./v(3)))).*D - v(4).*T - (v(5).*(x-T)).^delta)))); - sigma = y .* sqrt((1-y)/N); - residuals = (y_fit - y) ./ sigma; -end - - - diff --git a/code/datafiles/.DS_Store b/code/datafiles/.DS_Store deleted file mode 100644 index 881d0f7..0000000 Binary files a/code/datafiles/.DS_Store and /dev/null differ diff --git a/code/datafiles/Data1.m b/code/datafiles/Data1.m deleted file mode 100644 index b4164fc..0000000 --- a/code/datafiles/Data1.m +++ /dev/null @@ -1,9 +0,0 @@ -6.045197740112997 83.35570469798658 2.358581016 4.376112861 -12.146892655367235 63.6241610738255 3.314614436 5.460895768 -18.0225988700565 53.55704697986577 3.585810163 4.985618408 -24.01129943502825 42.48322147651007 3.43514587 4.728119436 -30.112994350282484 36.442953020134226 3.761128613 4.606218326 -36.101694915254235 30.80536912751677 3.072181893 3.397205862 -42.09039548022599 30.604026845637577 3.273524175 4.685659499 -48.079096045197744 21.543624161073822 3.15025339 3.584440488 -54.06779661016949 21.744966442953015 2.948911108 3.785782769 \ No newline at end of file diff --git a/code/datafiles/Data2.m b/code/datafiles/Data2.m deleted file mode 100644 index 21ba25d..0000000 --- a/code/datafiles/Data2.m +++ /dev/null @@ -1,5 +0,0 @@ -5.93220338983051 69.86577181208054 7.685248596 8.029037118 -12.033898305084747 57.18120805369127 7.71675113 8.609779482 -15.197740112994353 50.13422818791946 8.029037118 8.705656759 -36.101694915254235 25.167785234899327 7.077112724 4.75962197 -60.16949152542373 11.073825503355692 5.660868374 4.951376524 \ No newline at end of file diff --git a/code/datafiles/Data3.m b/code/datafiles/Data3.m deleted file mode 100644 index ec6cb05..0000000 --- a/code/datafiles/Data3.m +++ /dev/null @@ -1,9 +0,0 @@ -6.045197740112997 75.70469798657717 4.295302013 5.092453089 -12.146892655367235 53.55704697986577 5.62662649 5.189700041 -18.0225988700565 37.248322147651 5.404739077 5.003424188 -24.01129943502825 29.798657718120808 4.895219833 4.696616902 -30.112994350282484 22.550335570469798 5.000684838 3.774825366 -36.101694915254235 17.718120805369125 4.526777154 3.636488152 -42.09039548022599 14.89932885906039 4.488426243 3.266675798 -48.079096045197744 12.68456375838926 4.458293384 2.684563758 -54.06779661016949 6.845637583892611 3.358444049 2.151760033 \ No newline at end of file diff --git a/code/datafiles/Data4.m b/code/datafiles/Data4.m deleted file mode 100644 index d91ed32..0000000 --- a/code/datafiles/Data4.m +++ /dev/null @@ -1,9 +0,0 @@ -6.045197740112997 64.02684563758389 5.76907273 7.088070127 -12.033898305084747 35.23489932885906 6.1936721 6.663470757 -18.0225988700565 17.919463087248317 5.549924668 5.06232023 -24.01129943502825 10.067114093959717 4.422681824 3.740583482 -30.112994350282484 10.067114093959717 4.422681824 3.944665114 -36.101694915254235 8.053691275167765 3.987125051 3.155732091 -42.09039548022599 4.0268456375838895 2.911929873 1.986029311 -48.079096045197744 4.0268456375838895 2.911929873 1.986029311 -54.18079096045198 4.0268456375838895 2.095603342 2.190110944 \ No newline at end of file diff --git a/code/datafiles/Data5.m b/code/datafiles/Data5.m deleted file mode 100644 index f9c1ea8..0000000 --- a/code/datafiles/Data5.m +++ /dev/null @@ -1,5 +0,0 @@ -6.045197740112997 55.9731543624161 9.741131352 10.05478702 -12.033898305084747 24.96644295302012 3.604985618 8.231749075 -18.0225988700565 8.053691275167765 6.027941378 4.992466785 -24.01129943502825 8.255033557046971 5.826599096 5.3978907 -30. 8.053691275167765 6.027941378 5.400630051 \ No newline at end of file diff --git a/code/datafiles/SR_EQ1_D.csv b/code/datafiles/SR_EQ1_D.csv deleted file mode 100644 index 1682fe3..0000000 --- a/code/datafiles/SR_EQ1_D.csv +++ /dev/null @@ -1,5 +0,0 @@ -5.93220338983051, 69.86577181208054 -12.033898305084747, 57.18120805369127 -15.197740112994353, 50.13422818791946 -36.101694915254235, 25.167785234899327 -60.16949152542373, 11.073825503355692 diff --git a/code/datafiles/SR_EQ1_L.csv b/code/datafiles/SR_EQ1_L.csv deleted file mode 100644 index 6f158c1..0000000 --- a/code/datafiles/SR_EQ1_L.csv +++ /dev/null @@ -1,9 +0,0 @@ -6.045197740112997, 83.35570469798658 -12.146892655367235, 63.6241610738255 -18.0225988700565, 53.55704697986577 -24.01129943502825, 42.48322147651007 -30.112994350282484, 36.442953020134226 -36.101694915254235, 30.80536912751677 -42.09039548022599, 30.604026845637577 -48.079096045197744, 21.543624161073822 -54.06779661016949, 21.744966442953015 diff --git a/code/datafiles/SR_EQ1_SH.csv b/code/datafiles/SR_EQ1_SH.csv deleted file mode 100644 index 9fa7c6e..0000000 --- a/code/datafiles/SR_EQ1_SH.csv +++ /dev/null @@ -1,9 +0,0 @@ -6.045197740112997, 75.70469798657717 -12.146892655367235, 53.55704697986577 -18.0225988700565, 37.248322147651 -24.01129943502825, 29.798657718120808 -30.112994350282484, 22.550335570469798 -36.101694915254235, 17.718120805369125 -42.09039548022599, 14.89932885906039 -48.079096045197744, 12.68456375838926 -54.06779661016949, 6.845637583892611 diff --git a/code/datafiles/SR_EQ1_SL.csv b/code/datafiles/SR_EQ1_SL.csv deleted file mode 100644 index 5386738..0000000 --- a/code/datafiles/SR_EQ1_SL.csv +++ /dev/null @@ -1,5 +0,0 @@ -6.045197740112997, 55.9731543624161 -12.033898305084747, 24.96644295302012 -18.0225988700565, 8.053691275167765 -24.01129943502825, 8.255033557046971 -30, 8.053691275167765 diff --git a/code/datafiles/SR_EQ1_SM.csv b/code/datafiles/SR_EQ1_SM.csv deleted file mode 100644 index c705b41..0000000 --- a/code/datafiles/SR_EQ1_SM.csv +++ /dev/null @@ -1,9 +0,0 @@ -6.045197740112997, 64.02684563758389 -12.033898305084747, 35.23489932885906 -18.0225988700565, 17.919463087248317 -24.01129943502825, 10.067114093959717 -30.112994350282484, 10.067114093959717 -36.101694915254235, 8.053691275167765 -42.09039548022599, 4.0268456375838895 -48.079096045197744, 4.0268456375838895 -54.18079096045198, 4.0268456375838895 diff --git a/code/datafiles/complete file.csv b/code/datafiles/complete file.csv deleted file mode 100644 index 9c775f9..0000000 --- a/code/datafiles/complete file.csv +++ /dev/null @@ -1,66 +0,0 @@ -6.045197740112997, 83.35570469798658, 2.358581016, 4.376112861 -12.146892655367235, 63.6241610738255, 3.314614436, 5.460895768 -18.0225988700565, 53.55704697986577, 3.585810163, 4.985618408 -24.01129943502825, 42.48322147651007, 3.43514587, 4.728119436 -30.112994350282484, 36.442953020134226, 3.761128613, 4.606218326 -36.101694915254235, 30.80536912751677, 3.072181893, 3.397205862 -42.09039548022599, 30.604026845637577, 3.273524175, 4.685659499 -48.079096045197744, 21.543624161073822, 3.15025339, 3.584440488 -54.06779661016949, 21.744966442953015, 2.948911108, 3.785782769 - -128 -53.6 -4.88 -28 - -5.93220338983051, 69.86577181208054, 7.685248596, 8.029037118 -12.033898305084747, 57.18120805369127, 7.71675113, 8.609779482 -15.197740112994353, 50.13422818791946, 8.029037118, 8.705656759 -36.101694915254235, 25.167785234899327, 7.077112724, 4.75962197 -60.16949152542373, 11.073825503355692, 5.660868374, 4.951376524 - -35 -61.5 -1.5 -42 - -6.045197740112997, 75.70469798657717, 4.295302013, 5.092453089 -12.146892655367235, 53.55704697986577, 5.62662649, 5.189700041 -18.0225988700565, 37.248322147651, 5.404739077, 5.003424188 -24.01129943502825, 29.798657718120808, 4.895219833, 4.696616902 -30.112994350282484, 22.550335570469798, 5.000684838, 3.774825366 -36.101694915254235, 17.718120805369125, 4.526777154, 3.636488152 -42.09039548022599, 14.89932885906039, 4.488426243, 3.266675798 -48.079096045197744, 12.68456375838926, 4.458293384, 2.684563758 -54.06779661016949, 6.845637583892611, 3.358444049, 2.151760033 - -83 -55 -1.8 -37 - -6.045197740112997, 64.02684563758389, 5.76907273, 7.088070127 -12.033898305084747, 35.23489932885906, 6.1936721, 6.663470757 -18.0225988700565, 17.919463087248317, 5.549924668, 5.06232023 -24.01129943502825, 10.067114093959717, 4.422681824, 3.740583482 -30.112994350282484, 10.067114093959717, 4.422681824, 3.944665114 -36.101694915254235, 8.053691275167765, 3.987125051, 3.155732091 -42.09039548022599, 4.0268456375838895, 2.911929873, 1.986029311 -48.079096045197744, 4.0268456375838895, 2.911929873, 1.986029311 -54.18079096045198, 4.0268456375838895, 2.095603342, 2.190110944 - -51 -45 -1.8 -37 - -6.045197740112997, 55.9731543624161, 9.741131352, 10.05478702 -12.033898305084747, 24.96644295302012, 3.604985618, 8.231749075 -18.0225988700565, 8.053691275167765, 6.027941378, 4.992466785 -24.01129943502825, 8.255033557046971, 5.826599096, 5.3978907 -30, 8.053691275167765, 6.027941378, 5.400630051 - -24 -32.5 -1.8 -37 diff --git a/code/datafiles/error bars/.DS_Store b/code/datafiles/error bars/.DS_Store deleted file mode 100644 index c861368..0000000 Binary files a/code/datafiles/error bars/.DS_Store and /dev/null differ diff --git a/code/datafiles/error bars/errorsbars_bot_1y.csv b/code/datafiles/error bars/errorsbars_bot_1y.csv deleted file mode 100644 index 712d40e..0000000 --- a/code/datafiles/error bars/errorsbars_bot_1y.csv +++ /dev/null @@ -1,5 +0,0 @@ -8.50810962, -6.901565996, -5.015380313, -8.22287472, -4.66582774 \ No newline at end of file diff --git a/code/datafiles/error bars/errorsbars_bot_2y.csv b/code/datafiles/error bars/errorsbars_bot_2y.csv deleted file mode 100644 index 35f4774..0000000 --- a/code/datafiles/error bars/errorsbars_bot_2y.csv +++ /dev/null @@ -1,4 +0,0 @@ -5.755033557, -4.233780761, -5.006991051, -4.358221477 \ No newline at end of file diff --git a/code/datafiles/error bars/errorsbars_bot_3y.csv b/code/datafiles/error bars/errorsbars_bot_3y.csv deleted file mode 100644 index 1313c6d..0000000 --- a/code/datafiles/error bars/errorsbars_bot_3y.csv +++ /dev/null @@ -1,4 +0,0 @@ -6.053691275, -3.508120805, -7.459451902, -4.763702461 \ No newline at end of file diff --git a/code/datafiles/error bars/errorsbars_bot_4y.csv b/code/datafiles/error bars/errorsbars_bot_4y.csv deleted file mode 100644 index b27a269..0000000 --- a/code/datafiles/error bars/errorsbars_bot_4y.csv +++ /dev/null @@ -1,3 +0,0 @@ -2.568512304, -3.726230425, -4.251957494 \ No newline at end of file diff --git a/code/datafiles/error bars/errorsbars_bot_Dawson.csv b/code/datafiles/error bars/errorsbars_bot_Dawson.csv deleted file mode 100644 index 869432d..0000000 --- a/code/datafiles/error bars/errorsbars_bot_Dawson.csv +++ /dev/null @@ -1,5 +0,0 @@ -8.029037118, -8.609779482, -8.705656759, -4.75962197, -4.951376524 \ No newline at end of file diff --git a/code/datafiles/error bars/errorsbars_bot_Liang.csv b/code/datafiles/error bars/errorsbars_bot_Liang.csv deleted file mode 100644 index 774fbc9..0000000 --- a/code/datafiles/error bars/errorsbars_bot_Liang.csv +++ /dev/null @@ -1,9 +0,0 @@ -4.376112861, -5.460895768, -4.985618408, -4.728119436, -4.606218326, -3.397205862, -4.685659499, -3.584440488, -3.785782769 \ No newline at end of file diff --git a/code/datafiles/error bars/errorsbars_bot_SeongH.csv b/code/datafiles/error bars/errorsbars_bot_SeongH.csv deleted file mode 100644 index 10be38f..0000000 --- a/code/datafiles/error bars/errorsbars_bot_SeongH.csv +++ /dev/null @@ -1,9 +0,0 @@ -5.092453089, -5.189700041, -5.003424188, -4.696616902, -3.774825366, -3.636488152, -3.266675798, -2.684563758, -2.151760033 \ No newline at end of file diff --git a/code/datafiles/error bars/errorsbars_bot_SeongL.csv b/code/datafiles/error bars/errorsbars_bot_SeongL.csv deleted file mode 100644 index 2aa1e10..0000000 --- a/code/datafiles/error bars/errorsbars_bot_SeongL.csv +++ /dev/null @@ -1,5 +0,0 @@ -10.05478702, -8.231749075, -4.992466785, -5.3978907, -5.400630051 \ No newline at end of file diff --git a/code/datafiles/error bars/errorsbars_bot_SeongM.csv b/code/datafiles/error bars/errorsbars_bot_SeongM.csv deleted file mode 100644 index 2880cdf..0000000 --- a/code/datafiles/error bars/errorsbars_bot_SeongM.csv +++ /dev/null @@ -1,9 +0,0 @@ -7.088070127, -6.663470757, -5.06232023, -3.740583482, -3.944665114, -3.155732091, -1.986029311, -1.986029311, -2.190110944 \ No newline at end of file diff --git a/code/datafiles/error bars/errorsbars_top_1y.csv b/code/datafiles/error bars/errorsbars_top_1y.csv deleted file mode 100644 index 7a87e22..0000000 --- a/code/datafiles/error bars/errorsbars_top_1y.csv +++ /dev/null @@ -1,5 +0,0 @@ -8.99189038, -6.431767338, -5.81795302, -8.02712528, -3.45917226 \ No newline at end of file diff --git a/code/datafiles/error bars/errorsbars_top_2y.csv b/code/datafiles/error bars/errorsbars_top_2y.csv deleted file mode 100644 index 00e1b82..0000000 --- a/code/datafiles/error bars/errorsbars_top_2y.csv +++ /dev/null @@ -1,4 +0,0 @@ -5.078299776, -4.307885906, -5.409675615, -3.766778523 \ No newline at end of file diff --git a/code/datafiles/error bars/errorsbars_top_3y.csv b/code/datafiles/error bars/errorsbars_top_3y.csv deleted file mode 100644 index 95ec70a..0000000 --- a/code/datafiles/error bars/errorsbars_top_3y.csv +++ /dev/null @@ -1,4 +0,0 @@ -3.821308725, -4.365212528, -6.915548098, -3.361297539 \ No newline at end of file diff --git a/code/datafiles/error bars/errorsbars_top_4y.csv b/code/datafiles/error bars/errorsbars_top_4y.csv deleted file mode 100644 index 6b80f26..0000000 --- a/code/datafiles/error bars/errorsbars_top_4y.csv +++ /dev/null @@ -1,3 +0,0 @@ -2.639821029, -4.398769575, -3.039709172 \ No newline at end of file diff --git a/code/datafiles/error bars/errorsbars_top_Dawson.csv b/code/datafiles/error bars/errorsbars_top_Dawson.csv deleted file mode 100644 index 3ca451a..0000000 --- a/code/datafiles/error bars/errorsbars_top_Dawson.csv +++ /dev/null @@ -1,5 +0,0 @@ -7.685248596, -7.71675113, -8.029037118, -7.077112724, -5.660868374 \ No newline at end of file diff --git a/code/datafiles/error bars/errorsbars_top_Liang.csv b/code/datafiles/error bars/errorsbars_top_Liang.csv deleted file mode 100644 index af38b38..0000000 --- a/code/datafiles/error bars/errorsbars_top_Liang.csv +++ /dev/null @@ -1,9 +0,0 @@ -2.358581016, -3.314614436, -3.585810163, -3.43514587, -3.761128613, -3.072181893, -3.273524175, -3.15025339, -2.948911108 \ No newline at end of file diff --git a/code/datafiles/error bars/errorsbars_top_SeongH.csv b/code/datafiles/error bars/errorsbars_top_SeongH.csv deleted file mode 100644 index f3d099d..0000000 --- a/code/datafiles/error bars/errorsbars_top_SeongH.csv +++ /dev/null @@ -1,9 +0,0 @@ -4.295302013, -5.62662649, -5.404739077, -4.895219833, -5.000684838, -4.526777154, -4.488426243, -4.458293384, -3.358444049 \ No newline at end of file diff --git a/code/datafiles/error bars/errorsbars_top_SeongL.csv b/code/datafiles/error bars/errorsbars_top_SeongL.csv deleted file mode 100644 index 51ad0d3..0000000 --- a/code/datafiles/error bars/errorsbars_top_SeongL.csv +++ /dev/null @@ -1,5 +0,0 @@ -9.741131352, -3.604985618, -6.027941378, -5.826599096, -6.027941378 \ No newline at end of file diff --git a/code/datafiles/error bars/errorsbars_top_SeongM.csv b/code/datafiles/error bars/errorsbars_top_SeongM.csv deleted file mode 100644 index e3ab80a..0000000 --- a/code/datafiles/error bars/errorsbars_top_SeongM.csv +++ /dev/null @@ -1,9 +0,0 @@ -5.76907273, -6.1936721, -5.549924668, -4.422681824, -4.422681824, -3.987125051, -2.911929873, -2.911929873, -2.095603342 \ No newline at end of file diff --git a/code/datafiles/others/.DS_Store b/code/datafiles/others/.DS_Store deleted file mode 100644 index a578e1a..0000000 Binary files a/code/datafiles/others/.DS_Store and /dev/null differ diff --git a/code/datafiles/others/Bio_1Y.csv b/code/datafiles/others/Bio_1Y.csv deleted file mode 100644 index 1d8ccd1..0000000 --- a/code/datafiles/others/Bio_1Y.csv +++ /dev/null @@ -1,5 +0,0 @@ -16.44736842105263, 24.573956442831204 -30.263157894736846, 34.96642468239564 -41.71052631578948, 53.62658802177858 -45.131578947368425, 57.155626134301265 -56.05263157894738, 62.98638838475499 diff --git a/code/datafiles/others/Bio_2Y.csv b/code/datafiles/others/Bio_2Y.csv deleted file mode 100644 index 8b89045..0000000 --- a/code/datafiles/others/Bio_2Y.csv +++ /dev/null @@ -1,4 +0,0 @@ -16.44736842105263, 8.642921960072584 -30.263157894736846, 9.931941923774943 -41.71052631578948, 30.247277676951 -55.92105263157895, 42.50317604355716 diff --git a/code/datafiles/others/Bio_3Y.csv b/code/datafiles/others/Bio_3Y.csv deleted file mode 100644 index 28cb0eb..0000000 --- a/code/datafiles/others/Bio_3Y.csv +++ /dev/null @@ -1,4 +0,0 @@ -30.263157894736846, 7.656079854809434 -41.71052631578948, 17.212794918330303 -45.00000000000001, 24.258620689655174 -56.05263157894738, 29.262250453720497 diff --git a/code/datafiles/others/Bio_4Y.csv b/code/datafiles/others/Bio_4Y.csv deleted file mode 100644 index fb23980..0000000 --- a/code/datafiles/others/Bio_4Y.csv +++ /dev/null @@ -1,3 +0,0 @@ -30.394736842105267, 3.932395644283119 -41.71052631578948, 12.661070780399271 -56.05263157894738, 20.779491833030846 diff --git a/code/datafiles/others/Robustez 48.csv b/code/datafiles/others/Robustez 48.csv deleted file mode 100644 index 9b4834f..0000000 --- a/code/datafiles/others/Robustez 48.csv +++ /dev/null @@ -1,8 +0,0 @@ -5.950617283950617, 98.94977168949771 -11.97530864197531, 97.12328767123287 -18.000000000000004, 97.12328767123287 -23.925925925925924, 84.7945205479452 -30.148148148148152, 60.13698630136985 -36.074074074074076, 50.091324200913235 -42.098765432098766, 42.10045662100457 -47.92592592592593, 42.10045662100457 diff --git a/code/datafiles/others/Robustez 56.csv b/code/datafiles/others/Robustez 56.csv deleted file mode 100644 index a939217..0000000 --- a/code/datafiles/others/Robustez 56.csv +++ /dev/null @@ -1,7 +0,0 @@ -6.049382716049381, 98.4931506849315 -11.97530864197531, 96.43835616438355 -18.000000000000004, 70.63926940639269 -23.925925925925924, 49.634703196347026 -30.148148148148152, 22.69406392694063 -36.074074074074076, 19.726027397260268 -42.00000000000001, 9.680365296803643 diff --git a/code/datafiles/others/Robustez 60.csv b/code/datafiles/others/Robustez 60.csv deleted file mode 100644 index 2e24311..0000000 --- a/code/datafiles/others/Robustez 60.csv +++ /dev/null @@ -1,4 +0,0 @@ -6.049382716049381, 95.06849315068493 -11.97530864197531, 84.7945205479452 -17.901234567901234, 45.06849315068492 -23.925925925925924, 26.118721461187207 diff --git a/code/datafiles/others/Robustez2_T3.csv b/code/datafiles/others/Robustez2_T3.csv deleted file mode 100644 index 0ae5a01..0000000 --- a/code/datafiles/others/Robustez2_T3.csv +++ /dev/null @@ -1,4 +0,0 @@ -5.923913043478262, 87.6774193548387 -11.956521739130434, 73.45161290322581 -24.021739130434785, 50.41935483870968 -36.086956521739125, 44.54838709677419 diff --git a/code/datafiles/others/Robustez2_T4.csv b/code/datafiles/others/Robustez2_T4.csv deleted file mode 100644 index 0c61419..0000000 --- a/code/datafiles/others/Robustez2_T4.csv +++ /dev/null @@ -1,4 +0,0 @@ -6.005434782608695, 73.2258064516129 -11.956521739130434, 50.193548387096776 -24.021739130434785, 27.16129032258064 -36.16847826086956, 10 diff --git a/code/datafiles/others/SR_EQ2_D.csv b/code/datafiles/others/SR_EQ2_D.csv deleted file mode 100644 index 27a7978..0000000 --- a/code/datafiles/others/SR_EQ2_D.csv +++ /dev/null @@ -1,5 +0,0 @@ -6.01769911504425, 69.9009900990099 -12.101769911504427, 56.831683168316836 -15.30973451327434, 49.70297029702971 -35.88495575221239, 24.752475247524757 -59.778761061946895, 10.693069306930695 diff --git a/code/datafiles/others/SR_EQ2_L.csv b/code/datafiles/others/SR_EQ2_L.csv deleted file mode 100644 index fb83c23..0000000 --- a/code/datafiles/others/SR_EQ2_L.csv +++ /dev/null @@ -1,9 +0,0 @@ -6.128318584070799, 83.36633663366337 -12.101769911504427, 63.366336633663366 -18.075221238938052, 53.46534653465346 -24.04867256637168, 42.376237623762385 -30.022123893805308, 36.43564356435644 -35.88495575221239, 30.099009900990104 -41.969026548672566, 30.099009900990104 -47.94247787610619, 21.188118811881196 -53.80530973451328, 21.188118811881196 diff --git a/code/datafiles/others/SR_EQ2_SH.csv b/code/datafiles/others/SR_EQ2_SH.csv deleted file mode 100644 index 1738c57..0000000 --- a/code/datafiles/others/SR_EQ2_SH.csv +++ /dev/null @@ -1,9 +0,0 @@ -6.128318584070799, 75.64356435643565 -12.101769911504427, 53.46534653465346 -18.075221238938052, 37.02970297029703 -24.04867256637168, 29.306930693069305 -30.022123893805308, 22.178217821782184 -35.99557522123894, 17.227722772277232 -41.858407079646014, 14.45544554455445 -47.94247787610619, 12.277227722772281 -53.80530973451328, 6.534653465346537 diff --git a/code/datafiles/others/SR_EQ2_SL.csv b/code/datafiles/others/SR_EQ2_SL.csv deleted file mode 100644 index c9b191b..0000000 --- a/code/datafiles/others/SR_EQ2_SL.csv +++ /dev/null @@ -1,5 +0,0 @@ -6.128318584070799, 55.84158415841584 -12.101769911504427, 24.554455445544562 -18.075221238938052, 7.524752475247524 -24.04867256637168, 7.524752475247524 -30.022123893805308, 7.524752475247524 diff --git a/code/datafiles/others/SR_EQ2_SM.csv b/code/datafiles/others/SR_EQ2_SM.csv deleted file mode 100644 index c210d03..0000000 --- a/code/datafiles/others/SR_EQ2_SM.csv +++ /dev/null @@ -1,9 +0,0 @@ -6.128318584070799, 63.960396039603964 -12.101769911504427, 34.851485148514854 -18.075221238938052, 17.62376237623762 -24.04867256637168, 9.5049504950495 -30.022123893805308, 9.702970297029708 -35.99557522123894, 7.722772277227719 -41.858407079646014, 3.5643564356435604 -47.94247787610619, 3.7623762376237693 -53.915929203539825, 3.5643564356435604 diff --git a/code/datafiles/others/TestData.csv b/code/datafiles/others/TestData.csv deleted file mode 100644 index efbbadf..0000000 --- a/code/datafiles/others/TestData.csv +++ /dev/null @@ -1,9 +0,0 @@ -6.045197740112997, 83.35570469798658,28, 4.88, 53.6,0 -12.146892655367235, 63.6241610738255,28, 4.88, 53.6,0 -18.0225988700565, 53.55704697986577,28, 4.88, 53.6,0 -24.01129943502825, 42.48322147651007,28, 4.88, 53.6,0 -30.112994350282484, 36.442953020134226,28, 4.88, 53.6,0 -36.101694915254235, 30.80536912751677,28, 4.88, 53.6,0 -42.09039548022599, 30.604026845637577,28, 4.88, 53.6,0 -48.079096045197744, 21.543624161073822,28, 4.88, 53.6,0 -54.06779661016949, 21.744966442953015,28, 4.88, 53.6,0 diff --git a/code/datafiles/others/TestDataLinReg.csv b/code/datafiles/others/TestDataLinReg.csv deleted file mode 100644 index 0638be7..0000000 --- a/code/datafiles/others/TestDataLinReg.csv +++ /dev/null @@ -1,5 +0,0 @@ -627 1563.72 -694 1738.61 -747 1851.42 -774 1917.12 -792 1957.01 diff --git a/code/datafiles/others/all_data_fit1.csv b/code/datafiles/others/all_data_fit1.csv deleted file mode 100644 index 737e342..0000000 --- a/code/datafiles/others/all_data_fit1.csv +++ /dev/null @@ -1,39 +0,0 @@ -6.045197740112997, 83.35570469798658, 28, 4.88, 53.6, 0 -12.146892655367235, 63.6241610738255, 28, 4.88, 53.6, 0 -18.0225988700565, 53.55704697986577, 28, 4.88, 53.6, 0 -24.01129943502825, 42.48322147651007, 28, 4.88, 53.6, 0 -30.112994350282484, 36.442953020134226, 28, 4.88, 53.6, 0 -36.101694915254235, 30.80536912751677, 28, 4.88, 53.6, 0 -42.09039548022599, 30.604026845637577, 28, 4.88, 53.6, 0 -48.079096045197744, 21.543624161073822, 28, 4.88, 53.6, 0 -54.06779661016949, 21.744966442953015, 28, 4.88, 53.6, 0 -5.93220338983051, 69.86577181208054, 42, 1.5, 61.5, 1 -12.033898305084747, 57.18120805369127, 42, 1.5, 61.5, 1 -15.197740112994353, 50.13422818791946, 42, 1.5, 61.5, 1 -36.101694915254235, 25.167785234899327, 42, 1.5, 61.5, 1 -60.16949152542373, 11.073825503355692, 42, 1.5, 61.5, 1 -6.045197740112997, 75.70469798657717, 37, 1.8, 55, 2 -12.146892655367235, 53.55704697986577, 37, 1.8, 55, 2 -18.0225988700565, 37.248322147651, 37, 1.8, 55, 2 -24.01129943502825, 29.798657718120808, 37, 1.8, 55, 2 -30.112994350282484, 22.550335570469798, 37, 1.8, 55, 2 -36.101694915254235, 17.718120805369125, 37, 1.8, 55, 2 -42.09039548022599, 14.89932885906039, 37, 1.8, 55, 2 -48.079096045197744, 12.68456375838926, 37, 1.8, 55, 2 -54.06779661016949, 6.845637583892611, 37, 1.8, 55, 2 -6.045197740112997, 64.02684563758389, 37, 1.8, 45, 3 -12.033898305084747, 35.23489932885906, 37, 1.8, 45, 3 -18.0225988700565, 17.919463087248317, 37, 1.8, 45, 3 -24.01129943502825, 10.067114093959717, 37, 1.8, 45, 3 -30.112994350282484, 10.067114093959717, 37, 1.8, 45, 3 -36.101694915254235, 8.053691275167765, 37, 1.8, 45, 3 -42.09039548022599, 4.0268456375838895, 37, 1.8, 45, 3 -48.079096045197744, 4.0268456375838895, 37, 1.8, 45, 3 -54.18079096045198, 4.0268456375838895, 37, 1.8, 45, 3 -6.045197740112997, 55.9731543624161, 37, 1.8, 32.5, 4 -12.033898305084747, 24.96644295302012, 37, 1.8, 32.5, 4 -18.0225988700565, 8.053691275167765, 37, 1.8, 32.5, 4 -24.01129943502825, 8.255033557046971, 37, 1.8, 32.5, 4 -30, 8.053691275167765, 37, 1.8, 32.5, 4 - - diff --git a/code/fit1.m b/code/fit1.m deleted file mode 100644 index 9c768e5..0000000 --- a/code/fit1.m +++ /dev/null @@ -1,388 +0,0 @@ -clc, clearvars %clear - -% CSV files -%Liang,Dawson,SeongH,SeongM,SeongL -file_names = {'datafiles/SR_EQ1_L.csv','datafiles/SR_EQ1_D.csv',... - 'datafiles/SR_EQ1_SH.csv','datafiles/SR_EQ1_SM.csv','datafiles/SR_EQ1_SL.csv'}; -%Error Bars of the files points -error_bars_top = {'datafiles/error bars/errorsbars_top_Liang.csv',... - 'datafiles/error bars/errorsbars_top_Dawson.csv',... - 'datafiles/error bars/errorsbars_top_SeongH.csv',... - 'datafiles/error bars/errorsbars_top_SeongM.csv',... - 'datafiles/error bars/errorsbars_top_SeongL.csv'}; -error_bars_bot = {'datafiles/error bars/errorsbars_bot_Liang.csv',... - 'datafiles/error bars/errorsbars_bot_Dawson.csv',... - 'datafiles/error bars/errorsbars_bot_SeongH.csv',... - 'datafiles/error bars/errorsbars_bot_SeongM.csv',... - 'datafiles/error bars/errorsbars_bot_SeongL.csv'}; -number_studies = numel(file_names); -% Data from the files: -%x (tau) - elapsed time in months -%y (SR) - survival rate in percentage -N_values = [128, 35, 83, 51, 24]; %N - number of patients -d_values = [4.88, 1.5, 1.8, 1.8, 1.8]; %d - dose per fraction Gy/fx -D_values = [53.6, 61.5, 55, 45, 32.5]; %D - prescription dose Gy -T_day_values = [28, 42, 37, 37, 37]; %T_day - treatment time in days -T_month_values = zeros(size(T_day_values)); %T_month - treatment time in months -for i = 1:length(T_day_values) - tm = T_day_values(i)/30; - T_month_values(i) = tm; -end -n_param = 6; %n_param - number of fitting parameters -n_points = 0; %n_points - number of points from all the files -for i = 1:length(file_names) - file = load(file_names{i}); - s = size(file); - n_points = n_points + s(1); -end - -%v - vector with parameters to find - %v(1) - K - %v(2) - alpha Gy^-1 - %v(3) - beta Gy^-2 - %v(4) - gamma days^-1 - %v(5) - a months^-1 - %v(6) - delta - -% Initial parameter values - defined by the user -%v0 = [0.042, 0.037, 0.002587, 0.00608, 1268, 0.16]; -v0 = [0.042, 0.037, 0.0026, 0.0061, 1268, 0.16]; - -% Define the parameter bounds -lb = [0, 0, 0, 0, 1000, 0]; -ub = [0.05, 0.05, 0.003, 0.007, 1500, 0.30]; - -% Define the fitting function -f = @(x,v,d,D,T_day,T_month) real(100*exp(-v(1).*exp(-(v(2).*(1+(d./(v(2)./v(3)))).*D - v(4).*T_day - (v(5).*(x-T_month)).^v(6))))); - -% Perform the fit - % v_min_old: vector with parameters of the fitting function - % where we have beta instead of alpha/beta and gamma instead of Td - % v_min: vector with parameters of the fitting function - % fval: value of the chi-square - -[v_min_old,v_min,fval] = perform_fit(file_names,N_values,d_values,D_values,T_day_values,T_month_values,v0,lb,ub,f,'fitting'); - -%v_min - vector with found parameters - %v_min(1) - K - %v_min(2) - alpha Gy^-1 - %v_min(3) - alpha/beta Gy - %v_min(4) - Td days - %v_min(5) - a months^-1 - %v_min(6) - delta - - -% Root-mean-square deviation function -% rmsd = rmsd_residuals(file_names, N_values, d_values, D_values, T_day_values, T_month_values, v_min, f); - -% Goodness of the fit -% dof = no of degrees of freedom = -% = no. of clinically observed survival data points- no. of free parameters in the fitting function -dof = n_points-n_param; -% goodfit = rmsd/dof; -goodfit = fval/dof; - -% CIs (confidence intervals) calculation -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Bootstraping - -fit_replicates = []; % array to store the replicas of the fitting parameters -n = 1000; % number of replicates -> we will get 1000 new values for the fitting parameters - -% comment later -%%%%%%%%%%%%%%%%%%%%%% -histogram_study1 = []; -histogram_study2 = []; -histogram_study3 = []; -histogram_study4 = []; -histogram_study5 = []; -histograms = {histogram_study1,histogram_study2,histogram_study3,... - histogram_study4,histogram_study5}; -%%%%%%%%%%%%%%%%%%%%%% - -for i = 1:n - % cell array to store the samples for each replicate - generated_files = cell(1, number_studies); - for j = 1:number_studies - % generating a sample for each file/study - data_study=load(file_names{j}); - generated_files{j} = sample(data_study); - histograms{j} = [histograms{j}; generated_files{j}]; % comment later - end - - % perform the fit for each replica - % v_min_boot_old: vector with parameters of the fitting function - % where we have beta instead of alpha/beta and gamma instead of Td - % v_min_boot: parameters of the fitting function for that replica - % fval_boot: value of the chi-square function - - [v_min_boot_old,v_min_boot,fval_boot] = perform_fit(generated_files,N_values,d_values,D_values,T_day_values,T_month_values,v0,lb,ub,f,'bootstrapping'); - - fit_replicates = [fit_replicates; v_min_boot_old]; - -end - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% plotting the histogram for each file/study -% comment later -figure; -title('Histogram of Bootstrapped Replicas'); -for ns = 1:number_studies % for each study - points = load(file_names{ns}); % open the file - count_points = []; - for p = 1:size(points,1) % for each point in the file - c = sum(histograms{ns}(:,1) == points(p)); - % c = number of counts - count_points = horzcat(count_points,c); - end - - subplot(2,3,ns); % subplot for each file - % create histogram with counts - % Create histogram with counts - bin_edges = 1:numel(count_points); % Bin edges based on the number of counts - bar(bin_edges, count_points); - - xlabel(['Study ' num2str(ns)]); - ylabel('Frequency'); -end - -% saving the plot -saveas(gcf, './results/histograms_boot1.pdf') -% clear the figure -clf; -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -% Uncertainties given by the Bootstrapping - -% u_boot_plus = zeros(n_param); % array to store the upper uncertainty of the fitting parameters -% u_boot_minus = zeros(n_param); % array to store the lower uncertainty of the fitting parameters - -u_boot = zeros(n_param); % array to store the uncertainties of the fitting parameters -CI_u = zeros(n_param); % array to store the upper value of the confidence intervals of the fitting parameters -CI_l = zeros(n_param); % array to store the lower value of the confidence intervals of the fitting parameters - -% for i = 1:n_param -% CI = ci_boot(fit_replicates(:,i)); % confidence interval -% CI_u(i) = CI(2); -% CI_l(i) = CI(1); -% [u_plus,u_minus] = uncertainties(v_min(i),CI); -% u_boot_plus(i) = u_plus; -% u_boot_minus(i) = u_minus; -% end - -% calculating the uncertainties of the parameters -for i = 1:n_param - u_boot(i) = std(fit_replicates(:,i)); -end - -% calculating the uncertainty of Td (index 4) -% Td = ln2/gamma -% gamma = v_min_old(4) -% uncertainty(gamma) = u_boot(4) -u_Td = uncertainty_quocient(log(2),v_min_old(4),0,u_boot(4)); -% update the value of u_boot -u_boot(4) = u_Td; - -% calculating the uncertainty of alpha/beta (index 3) -% alpha/beta -% alpha = v_min_old(2) -% beta = v_min_old(3) -% uncertainty(alpha) = u_boot(2) -% uncertainty(beta) = u_boot(3) -u_beta = uncertainty_quocient(v_min_old(2),v_min_old(3),u_boot(2),u_boot(3)); -% update the value of u_boot -u_boot(3) = u_beta; - -% calculating the confidence intervals (CI) of the parameters -for np = 1:n_param - CI_l(np) = v_min(np) - u_boot(np); - CI_u(np) = v_min(np) + u_boot(np); -end - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Save the results in a file -parameters_names = {'K','alpha','alpha/beta','Td','a','delta'}; - -myfile = fopen('./results/fit1.txt', 'w'); - -fprintf(myfile, 'Goodness of the fit: %f\n', goodfit); -fprintf(myfile, '\n'); -fprintf(myfile, 'Uncertainties given by the Bootstrapping Method:\n'); -fprintf(myfile, 'Parameters values that minimize the sum of squares: value [- uncertainty + uncertainty]:\n'); -fprintf(myfile, '-----------------\n'); -formatSpec = '%s: %.6f [-%.6f + %.6f]\n CI: [%.6f,%.6f]\n'; -for i = 1:length(parameters_names) - fprintf(myfile, formatSpec, parameters_names{i}, v_min(i), u_boot(i),u_boot(i), CI_l(i),CI_u(i)); -end - -% Close the file -fclose(myfile); - - -% Plotting -colors = {'#FD04FC','#0000F7','#000000','#FD6C6D','#46FD4B'}; -studies_names = {'Liang','Dawson','SeongH','SeongM','SeongL'}; -markers = {'v','o','^','s','o'}; - -hold on -x_points = linspace(0, 70, 71); - -for i = 1:number_studies - data = load(file_names{i}); - errhigh = load(error_bars_top{i}); - errlow = load(error_bars_bot{i}); - x = data(:,1); - y = data(:,2); - %original points - plot(x, y, markers{i}, 'LineWidth', 2, 'Color', colors{i},'MarkerSize', 6, 'DisplayName', studies_names{i}) - errorbar(x,y,errlow,errhigh,'Color',colors{i},'LineStyle','none','HandleVisibility', 'off'); - %fitted function - plot(x_points, f(x_points,v_min_old,d_values(i),D_values(i),T_day_values(i),T_month_values(i)), '--', 'LineWidth', 2, 'Color', colors{i},'HandleVisibility', 'off') -end - -%legend,lables and title -legend('Location', 'northeast') -legend('boxoff') - -xlabel('Elapsed Time From Beginning of RT (Month)- $\tau$', 'Interpreter', 'latex'); -ylabel('Survival Rate - $SR (\%)$', 'Interpreter', 'latex'); -title('Fit 1','Interpreter','latex') - -%saving the plot -saveas(gcf, './results/fit1.pdf') - -%%%%%%%%%%%%%%%%%%%%%%% -%Functions% - -% Performs the fit and returns the fitting parameters and the value of the chi-square function -function [param,new_param,chi2_val] = perform_fit(files,N,d,D,T_day,T_month,initial_guess,lower_bound,upper_bound,fitting_function,purpose) - % Vector with fitting parameters -> v - % Chi-square function - chi2 = @(v) chi2_residuals(files, N, d, D, T_day, T_month, v, fitting_function,purpose); - % Set up the algorithm options - options = optimoptions('fmincon','MaxIterations',1000,'TolFun',1e-9,'TolX',1e-9); - % Run the algorithm - % param->parameters that minimize the chi-square function - % chi2_val->value of the chi-square function - [param,chi2_val] = fmincon(chi2, initial_guess, [], [], [], [], lower_bound, upper_bound, [], options); - - % new list of parameters, where two of them were changed: - % beta -> alpha/beta - % gamma -> Td - new_param = param; - alpha_beta = new_param(2)/new_param(3); - new_param(3) = alpha_beta; - Td = log(2)/new_param(4); - new_param(4) = Td; - % new param entries: - %param(1) - K - %param(2) - alpha Gy^-1 - %param(3) - alpha/beta Gy - %param(4) - Td days - %param(5) - a months^-1 - %param(6) - delta -end - -% Calculates the residuals of the points of all datafiles -% to obtain the Chi-square function -function r = chi2_residuals(files, N_list, d_list, D_list, T_day_list, T_month_list, v, f,purpose) - s = 0; %sum for all the points of all the files - for i = 1:length(files) - if strcmp(purpose, 'fitting') - data = load(files{i}); - elseif strcmp(purpose, 'bootstrapping') - data = files{i}; - end - x = data(:, 1); %x (tau) - elapsed time in months - y = data(:, 2); %y (SR) - survival rate in percentage - N = N_list(i); - d = d_list(i); - D = D_list(i); - T_day = T_day_list(i); - T_month = T_month_list(i); - sf = 0; %sum for the points of a specific file - - for j = 1:length(x) - y_fit = f(x(j),v,d,D,T_day,T_month); - sigma = y(j) .* sqrt(abs((1-y(j)))./N); - res = (y_fit - y(j)).^2 / sigma.^2; - sf = res + sf; - end - s = sf + s; - end - r = s; -end - -% Calculates the residuals of the points of all datafiles -% to obtain the Root-mean-square deviation function -% function r = rmsd_residuals(files, N_list, d_list, D_list, T_day_list, T_month_list, v, f) -% s = 0; %sum for all the points of all the files -% for i = 1:length(files) -% data = load(files{i}); -% x = data(:, 1); %x (tau) - elapsed time in months -% y = data(:, 2); %y (SR) - survival rate in percentage -% N = N_list(i); -% d = d_list(i); -% D = D_list(i); -% T_day = T_day_list(i); -% T_month = T_month_list(i); -% sf = 0; %sum for the points of a specific file -% -% for j = 1:length(x) -% y_fit = f(x(j),v,d,D,T_day,T_month); -% res = (y_fit - y(j)).^2 / N; -% sf = res + sf; -% end -% s = sf + s; -% end -% r = sqrt(s); -% end - -% Generates a sample for a given datafile (for bootstraping) -function s = sample(data_file) - x = data_file(:, 1); % x (tau) - elapsed time in months - y = data_file(:, 2); % y (SR) - survival rate in percentage - arrayLength = length(x); % filesize - arraySample = []; % array to store the new sample - % The length of the sample is equal to the length of the original file - for a = 1:arrayLength - b_value = zeros(1,2); % Each value is an array with values x,y - Index = randi(arrayLength); % Generate a random index within the range of the array - b_value(1) = x(Index); % x value of the generated point - b_value(2) = y(Index); % y value of the generated point - %arraySample=[arraySample,b_value]; - %arraySample = vertcat(arraySample, b_value); - arraySample = [arraySample; b_value]; - end - s = arraySample; -end - -% Returns the uncertainty of a quocient of two parameters a, and b -% with uncertainties un_a, and un_b, respectively -function uq = uncertainty_quocient(a,b,un_a,un_b) - uq = sqrt( (1/b^2)*(un_a)^2 + ((-a/b^2)^2)*((un_b)^2) ); -end - -% Returns the confidence interval of a fitting parameter with replicas -% obtained from Bootstrapping -% function ci = ci_boot(param_rep) - % param_rep -> replicates for the parameter in question - % Calculating the 95% confidence interval by excluding - % the most extreme 2.5% of the values in each direction - % ci = prctile(param_rep,[2.5, 97.5]); -% end - -% Gives the uncertainty lower and upper bounds -% function [u_p,u_m] = uncertainties(parameter,ci) - % parameter -> value of the fitting parameter - % ci -> confidence interval of that parameter - % u_p = ci(2) - parameter; - % u_m = parameter - ci(1); - -% end - -%%%%%%%%%%%%%%%%%%%%%%% - - - - \ No newline at end of file diff --git a/code/fit2.m b/code/fit2.m deleted file mode 100644 index 5d2ddc7..0000000 --- a/code/fit2.m +++ /dev/null @@ -1,413 +0,0 @@ -clc, clearvars %clear - -% CSV files -%Liang,Dawson,SeongH,SeongM,SeongL -file_names = { 'datafiles/SR_EQ1_L.csv','datafiles/SR_EQ1_D.csv',... - 'datafiles/SR_EQ1_SH.csv','datafiles/SR_EQ1_SM.csv','datafiles/SR_EQ1_SL.csv'}; -%Error Bars of the files points -error_bars_top = {'datafiles/error bars/errorsbars_top_Liang.csv',... - 'datafiles/error bars/errorsbars_top_Dawson.csv',... - 'datafiles/error bars/errorsbars_top_SeongH.csv',... - 'datafiles/error bars/errorsbars_top_SeongM.csv',... - 'datafiles/error bars/errorsbars_top_SeongL.csv'}; -error_bars_bot = {'datafiles/error bars/errorsbars_bot_Liang.csv',... - 'datafiles/error bars/errorsbars_bot_Dawson.csv',... - 'datafiles/error bars/errorsbars_bot_SeongH.csv',... - 'datafiles/error bars/errorsbars_bot_SeongM.csv',... - 'datafiles/error bars/errorsbars_bot_SeongL.csv'}; -number_studies = numel(file_names); -% Data from the files: -%x (tau) - elapsed time in months -%y (SR) - survival rate in percentage -N_values = [128, 35, 83, 51, 24]; %N - number of patients -d_values = [4.88, 1.5, 1.8, 1.8, 1.8]; %d - dose per fraction Gy/fx -D_values = [53.6, 61.5, 55, 45, 32.5]; %D - prescription dose Gy -T_day_values = [28, 42, 37, 37, 37]; %T_day - treatment time in days -T_month_values = zeros(size(T_day_values)); %T_month - treatment time in months -for i = 1:length(T_day_values) - tm = T_day_values(i)/30; - T_month_values(i) = tm; -end -n_param = 6; %n_param - number of fitting parameters -n_points = 0; %n_points - number of points from all the files -for i = 1:length(file_names) - file = load(file_names{i}); - s = size(file); - n_points = n_points + s(1); -end - -%v - vector with parameters to find - %v(1) - K50/K0 - %v(2) - alpha Gy^-1 - %v(3) - beta Gy^-2 - %v(4) - gamma days^-1 - %v(5) - sigmak/K0 - %v(6) - delta - -% Initial parameter values - defined by the user -v0 = [2.03, 0.010, 0.000666, 0.00542, 0.65, 0.20]; - -% Define the parameter bounds -lb = [1.99, 0.009, 0.000647, 0.00495, 0.59, 0.19]; -ub = [2.07, 0.011, 0.000692, 0.00598, 0.71, 0.21]; - -% Fitting function -f = @(x,v,d,D,T_day) fitting(x,v,d,D,T_day,'fitting'); - -% Perform the fit - % v_min_old: vector with parameters of the fitting function - % where we have beta instead of alpha/beta and gamma instead of Td - % v_min: vector with parameters of the fitting function - % fval: value of the chi-square function - -[v_min_old,v_min,fval] = perform_fit(file_names,N_values,d_values,D_values,T_day_values,v0,lb,ub,f,'fitting'); - - -% Root-mean-square deviation function -% rmsd = rmsd_residuals(file_names, N_values, d_values, D_values, T_day_values, v_min, f); -% Goodness of the fit -% dof = no of degrees of freedom = -% = no. of clinically observed survival data points- no. of free parameters in the fitting function -dof = n_points-n_param; -goodfit = fval/dof; - -% CIs (confidence intervals) calculation -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Bootstraping - -fit_replicates = []; % array to store the replicas of the fitting parameters -n = 1000; % number of replicates -> we will get 1000 new values for the fitting parameters - -% comment later -%%%%%%%%%%%%%%%%%%%%%% -histogram_study1 = []; -histogram_study2 = []; -histogram_study3 = []; -histogram_study4 = []; -histogram_study5 = []; -histograms = {histogram_study1,histogram_study2,histogram_study3,... - histogram_study4,histogram_study5}; -%%%%%%%%%%%%%%%%%%%%%% - -for i = 1:n - % cell array to store the samples for each replicate - generated_files = cell(1, number_studies); - for j = 1:number_studies - % generating a sample for each file - data_study=load(file_names{j}); - generated_files{j} = sample(data_study); - histograms{j} = vertcat(histograms{j},sample(data_study)); - end - - % perform the fit for each replica - % v_min_boot_old: vector with parameters of the fitting function - % where we have beta instead of alpha/beta and gamma instead of Td - % v_min_boot: parameters of the fitting function for that replica - % fval_boot: value of the chi-square function - - [v_min_boot_old,v_min_boot,fval_boot] = perform_fit(generated_files,N_values,d_values,D_values,T_day_values,v0,lb,ub,f,'bootstrapping'); - - fit_replicates = [fit_replicates; v_min_boot_old]; -end - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% plotting the histogram for each file/study -% comment later -figure; -title('Histogram of Bootstrapped Replicas'); -for ns = 1:number_studies % for each study - points = load(file_names{ns}); % open the file - count_points = []; - for p = 1:size(points,1) % for each point in the file - c = sum(histograms{ns}(:,1) == points(p)); - % c = number of counts - count_points = horzcat(count_points,c); - end - - subplot(2,3,ns); % subplot for each file - % create histogram with counts - % Create histogram with counts - bin_edges = 1:numel(count_points); % Bin edges based on the number of counts - bar(bin_edges, count_points); - - xlabel(['Study ' num2str(ns)]); - ylabel('Frequency'); -end - -% saving the plot -saveas(gcf, './results/histograms_boot2.pdf') -% clear the figure -clf; -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -% Uncertainties given by the Bootstrapping - -% u_boot_plus = zeros(n_param); % array to store the upper uncertainty of the fitting parameters -% u_boot_minus = zeros(n_param); % array to store the lower uncertainty of the fitting parameters - -u_boot = zeros(n_param); % array to store the uncertainties of the fitting parameters -CI_u = zeros(n_param); % array to store the upper value of the confidence intervals of the fitting parameters -CI_l = zeros(n_param); % array to store the lower value of the confidence intervals of the fitting parameters - -% for i = 1:n_param -% CI = ci_boot(fit_replicates(:,i)); % confidence interval -% CI_u(i) = CI(2); -% CI_l(i) = CI(1); -% [u_plus,u_minus] = uncertainties(v_min(i),CI); -% u_boot_plus(i) = u_plus; -% u_boot_minus(i) = u_minus; -% end - -% calculating the uncertainties of the parameters -for i = 1:n_param - u_boot(i) = std(fit_replicates(:,i)); -end - -% calculating the uncertainty of Td (index 4) -% Td = ln2/gamma -% gamma = v_min_old(4) -% uncertainty(gamma) = u_boot(4) -u_Td = uncertainty_quocient(log(2),v_min_old(4),0,u_boot(4)); -% update the value of u_boot -u_boot(4) = u_Td; - -% calculating the uncertainty of alpha/beta (index 3) -% alpha/beta -% alpha = v_min_old(2) -% beta = v_min_old(3) -% uncertainty(alpha) = u_boot(2) -% uncertainty(beta) = u_boot(3) -u_beta = uncertainty_quocient(v_min_old(2),v_min_old(3),u_boot(2),u_boot(3)); -% update the value of u_boot -u_boot(3) = u_beta; - -% calculating the confidence intervals (CI) of the parameters -for np = 1:n_param - CI_l(np) = v_min(np) - u_boot(np); - CI_u(np) = v_min(np) + u_boot(np); -end - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Save the results in a file -parameters_names = {'K50/K0','alpha','alpha/beta','Td','sigmak/K0','delta'}; - -myfile = fopen('./results/fit2.txt', 'w'); - -fprintf(myfile, 'Goodness of the fit: %f\n', goodfit); -fprintf(myfile, '\n'); -fprintf(myfile, 'Uncertainties given by the Bootstrapping Method:\n'); -fprintf(myfile, 'Parameters values that minimize the sum of squares: value [- uncertainty + uncertainty]:\n'); -fprintf(myfile, '-----------------\n'); -formatSpec = '%s: %.6f [-%.6f + %.6f]\n CI: [%.6f,%.6f]\n'; -for i = 1:length(parameters_names) - fprintf(myfile, formatSpec, parameters_names{i}, v_min(i), u_boot(i),u_boot(i), CI_l(i),CI_u(i)); -end - -% Close the file -fclose(myfile); - - -% Plotting -colors = {'#FD04FC','#0000F7','#000000','#FD6C6D','#46FD4B'}; -studies_names = {'Liang','Dawson','SeongH','SeongM','SeongL'}; -markers = {'v','o','^','s','o'}; - -hold on -x_points = linspace(1, 70, 71); - -for i = 1:number_studies - data = load(file_names{i}); - errhigh = load(error_bars_top{i}); - errlow = load(error_bars_bot{i}); - y_plot = []; - x_plot = []; - x = data(:,1); - y = data(:,2); - %original points - plot(x, y, markers{i}, 'LineWidth', 2, 'Color', colors{i},'MarkerSize', 6, 'DisplayName', studies_names{i}) - errorbar(x,y,errlow,errhigh,'Color',colors{i},'LineStyle','none','HandleVisibility', 'off'); - %fitted function - for xi = 1:length(x_points) - sr = fitting(x_points(xi),v_min_old,d_values(i),D_values(i),T_day_values(i),'plotting'); - if ~isnan(sr) - tau = x_points(xi); - y_plot = [y_plot, sr]; - x_plot = [x_plot, tau]; - end - end - plot(x_plot, y_plot, '--', 'LineWidth', 2, 'Color', colors{i},'HandleVisibility', 'off') - hold on; -end - - -%legend,lables and title -legend('Location', 'northeast') -legend('boxoff') - -xlabel('Elapsed Time From Beginning of RT (Month)- $\tau$', 'Interpreter', 'latex'); -ylabel('Survival Rate - $SR (\%)$', 'Interpreter', 'latex'); -title('Fit 2','Interpreter','latex') - -%saving the plot -saveas(gcf, './results/fit2.pdf') - -%%%%%%%%%%%%%%%%%%%%%%% -%Functions% - -% Performs the fit and returns the fitting parameters and the value of the chi-square function -function [param,new_param,chi2_val] = perform_fit(files,N,d,D,T_day,initial_guess,lower_bound,upper_bound,fitting_function,purpose) - % Vector with fitting parameters -> v - % Chi-square function - chi2 = @(v) chi2_residuals(files, N, d, D, T_day, v, fitting_function,purpose); - % Set up the algorithm options - options = optimoptions('fmincon','MaxIterations',1000,'TolFun',1e-9,'TolX',1e-9); - % Run the algorithm - % param->parameters that minimize the chi-square function - % chi2_val->value of the chi-square function - [param,chi2_val] = fmincon(chi2, initial_guess, [], [], [], [], lower_bound, upper_bound, [], options); - % new list of parameters, where two of them were changed: - % beta -> alpha/beta - % gamma -> Td - new_param = param; - alpha_beta = new_param(2)/new_param(3); - new_param(3) = alpha_beta; - Td = log(2)/new_param(4); - new_param(4) = Td; - % new param entries: - %param(1) - K50/K0 - %param(2) - alpha Gy^-1 - %param(3) - alpha/beta Gy - %param(4) - Td days - %param(5) - sigmak/K0 - %param(6) - delta -end - - -function result = fitting(tau,v,d,D,T_day,purpose) - %v(1) - K50/K0 - %v(2) - alpha Gy^-1 - %v(3) - beta Gy^-2 - %v(4) - gamma days^-1 - %v(5) - sigmak/K0 - %v(6) - delta - denominator = v(5); - p = v(2) * (1 + d / (v(2) / v(3))) * D - v(4) * T_day - ((v(4) * (30 * tau - T_day)) ^ v(6)); - % 30->to convert months into days - numerator = exp(-p) - v(1); - t = numerator / denominator; - if strcmp(purpose, 'fitting') - %during the fitting if t assumes complex values there is no issue - result = 100 * (1/2)*(1-erf(t/sqrt(2))); - elseif strcmp(purpose, 'plotting') - if isreal(t) - result = 100 * (1/2)*(1-erf(t/sqrt(2))); - else - result = NaN; - end - end - end - - -% Calculates the residuals of the points of all datafiles -% to obtain the Chi-square function -function r = chi2_residuals(files, N_list, d_list, D_list, T_day_list, v, f,purpose) - s = 0; %sum for all the points of all the files - for i = 1:length(files) - if strcmp(purpose, 'fitting') - data = load(files{i}); - elseif strcmp(purpose, 'bootstrapping') - data = files{i}; - end - x = data(:, 1); %x (tau) - elapsed time in months - y = data(:, 2); %y (SR) - survival rate in percentage - N = N_list(i); - d = d_list(i); - D = D_list(i); - T_day = T_day_list(i); - sf = 0; %sum for the points of a specific file - - for j = 1:length(x) - y_fit = f(x(j),v,d,D,T_day); - sigma = y(j) .* sqrt(abs((1-y(j)))./N); - res = (y_fit - y(j)).^2 / sigma.^2; - sf = res + sf; - end - s = sf + s; - end - r = s; -end - -% Calculates the residuals of the points of all datafiles -% to obtain the Root-mean-square deviation function -function r = rmsd_residuals(files, N_list, d_list, D_list, T_day_list, v, f) - s = 0; %sum for all the points of all the files - for i = 1:length(files) - data = load(files{i}); - x = data(:, 1); %x (tau) - elapsed time in months - y = data(:, 2); %y (SR) - survival rate in percentage - N = N_list(i); - d = d_list(i); - D = D_list(i); - T_day = T_day_list(i); - sf = 0; %sum for the points of a specific file - - for j = 1:length(x) - y_fit = f(x(j),v,d,D,T_day); - res = (y_fit - y(j)).^2 / N; - sf = res + sf; - end - s = sf + s; - end - r = sqrt(s); -end - - -% Generates a sample for a given datafile (for bootstraping) -function s = sample(data_file) - x = data_file(:, 1); % x (tau) - elapsed time in months - y = data_file(:, 2); % y (SR) - survival rate in percentage - arrayLength = length(x); % filesize - arraySample = []; % array to store the new sample - % The length of the sample is equal to the length of the original file - for a = 1:arrayLength - b_value = zeros(1,2); % Each value is an array with values x,y - Index = randi(arrayLength); % Generate a random index within the range of the array - b_value(1) = x(Index); % x value of the generated point - b_value(2) = y(Index); % y value of the generated point - %arraySample=[arraySample,b_value]; - arraySample = vertcat(arraySample, b_value); - end - s = arraySample; -end - -% Returns the uncertainty of a quocient of two parameters a, and b -% with uncertainties un_a, and un_b, respectively -function uq = uncertainty_quocient(a,b,un_a,un_b) - uq = sqrt( (1/b^2)*(un_a)^2 + ((-a/b^2)^2)*((un_b)^2) ); -end - -% Returns the confidence interval of a fitting parameter with replicas -% obtained from Bootstrapping -% function ci = ci_boot(param_rep) - % param_rep -> replicates for the parameter in question - % Calculating the 95% confidence interval by excluding - % the most extreme 2.5% of the values in each direction - % ci = prctile(param_rep,[2.5, 97.5]); -% end - -% Gives the uncertainty lower and upper bounds -% function [u_p,u_m] = uncertainties(parameter,ci) - % parameter -> value of the fitting parameter - % ci -> confidence interval of that parameter - % u_p = ci(2) - parameter; - % u_m = parameter - ci(1); - -% end - -%%%%%%%%%%%%%%%%%%%%%%% - - - - - - diff --git a/code/results/.DS_Store b/code/results/.DS_Store deleted file mode 100644 index f154145..0000000 Binary files a/code/results/.DS_Store and /dev/null differ diff --git a/code/results/BED.pdf b/code/results/BED.pdf deleted file mode 100644 index a4d9d31..0000000 Binary files a/code/results/BED.pdf and /dev/null differ diff --git a/code/results/fit1.pdf b/code/results/fit1.pdf deleted file mode 100644 index 1879d5b..0000000 Binary files a/code/results/fit1.pdf and /dev/null differ diff --git a/code/results/fit1.txt b/code/results/fit1.txt deleted file mode 100644 index 5a12baa..0000000 --- a/code/results/fit1.txt +++ /dev/null @@ -1,17 +0,0 @@ -Goodness of the fit: 0.284031 - -Uncertainties given by the Bootstrapping Method: -Parameters values that minimize the sum of squares: value [- uncertainty + uncertainty]: ------------------ -K: 0.049997 [-0.001680 + 0.001680] - CI: [0.048317,0.051677] -alpha: 0.026066 [-0.004683 + 0.004683] - CI: [0.021383,0.030748] -alpha/beta: 8.863807 [-1.670459 + 1.670459] - CI: [7.193348,10.534266] -Td: 99.045011 [-14.879211 + 14.879211] - CI: [84.165801,113.924222] -a: 1499.727119 [-40.561399 + 40.561399] - CI: [1459.165720,1540.288518] -delta: 0.149974 [-0.004266 + 0.004266] - CI: [0.145708,0.154241] diff --git a/code/results/fit2.pdf b/code/results/fit2.pdf deleted file mode 100644 index 853d3e2..0000000 Binary files a/code/results/fit2.pdf and /dev/null differ diff --git a/code/results/fit2.txt b/code/results/fit2.txt deleted file mode 100644 index 4580891..0000000 --- a/code/results/fit2.txt +++ /dev/null @@ -1,17 +0,0 @@ -Goodness of the fit: 0.307778 - -Uncertainties given by the Bootstrapping Method: -Parameters values that minimize the sum of squares: value [- uncertainty + uncertainty]: ------------------ -K50/K0: 1.990000 [-0.007091 + 0.007091] - CI: [1.982909,1.997091] -alpha: 0.009975 [-0.000714 + 0.000714] - CI: [0.009261,0.010690] -alpha/beta: 14.415315 [-1.111473 + 1.111473] - CI: [13.303841,15.526788] -Td: 123.498145 [-9.157840 + 9.157840] - CI: [114.340305,132.655984] -sigmak/K0: 0.710000 [-0.018192 + 0.018192] - CI: [0.691808,0.728192] -delta: 0.190000 [-0.001194 + 0.001194] - CI: [0.188806,0.191194] diff --git a/code/results/histograms_boot1.pdf b/code/results/histograms_boot1.pdf deleted file mode 100644 index 1e67d60..0000000 Binary files a/code/results/histograms_boot1.pdf and /dev/null differ diff --git a/code/results/histograms_boot2.pdf b/code/results/histograms_boot2.pdf deleted file mode 100644 index 48dfe1a..0000000 Binary files a/code/results/histograms_boot2.pdf and /dev/null differ