From 2eb09713a16402bff0e9620b4077d4ffa4e16b23 Mon Sep 17 00:00:00 2001 From: "vk.sriharsha" Date: Fri, 18 Sep 2020 00:51:52 -0500 Subject: [PATCH 1/7] Exception handling for playback, taskbar, and move DEA to Stat Analysis --- .../metnet/metaomgraph/MetaOmGraph.java | 237 ++--------------- .../metaomgraph/chart/MetaOmChartPanel.java | 8 + .../metaomgraph/playback/PlaybackAction.java | 121 ++++----- .../metaomgraph/ui/ColorProperties.java | 5 + .../metaomgraph/ui/MetaOmTablePanel.java | 238 +++++++++++++++++- .../ui/ReproducibilityDashboardPanel.java | 13 +- .../metnet/metaomgraph/ui/TaskbarPanel.java | 73 +++--- 7 files changed, 388 insertions(+), 307 deletions(-) diff --git a/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java b/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java index d01670e1..8862c4fa 100644 --- a/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java +++ b/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java @@ -66,9 +66,12 @@ import javax.swing.JTextPane; import javax.swing.JToggleButton; import javax.swing.KeyStroke; +import javax.swing.LookAndFeel; import javax.swing.SwingUtilities; import javax.swing.ToolTipManager; +import javax.swing.UIDefaults; import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; import javax.swing.WindowConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -637,10 +640,6 @@ public static String getVersion() { public static final String ARAPORT_THALEMINE_COMMAND = "ThaleMine"; public static final String ARAPORT_JBROWSE_COMMAND = "JBrowse"; private static JMenuItem findSamples; - private static JMenu diffExpMenu; - private static JMenuItem logChange; - private static JMenuItem loadDiffExpResults; - private static JMenuItem removeDiffExpResults; private static JMenuItem tTest; @@ -743,31 +742,31 @@ public static String getVersion() { // for splashscreen urmi static SplashScreen mySplash; - + private static Themes activeTheme; - + public enum Themes{ Light, Dark, System } - + public static boolean setTheme(Themes theme) { try { switch(theme) { case Light: - UIManager.setLookAndFeel(new FlatLightLaf()); + UIManager.setLookAndFeel(new FlatLightLaf()); break; case Dark: UIManager.setLookAndFeel(new FlatDarkLaf()); break; - + case System: UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); break; } - - + + activeTheme = theme; SwingUtilities.updateComponentTreeUI(mainWindow); } @@ -776,7 +775,7 @@ public static boolean setTheme(Themes theme) { } return true; } - + public static Themes getActiveTheme() { return activeTheme; } @@ -1343,29 +1342,6 @@ public static void init(boolean useBuffer) { toolsMenu.add(findSamples); mainMenuBar.add(toolsMenu); - diffExpMenu = new JMenu("Differential expression analysis"); - infoButtonMenu.setToolTipText("Find differentially expressed features"); - - logChange = new JMenuItem("Perform DEA"); - logChange.setActionCommand("logChange"); - logChange.addActionListener(myself); - logChange.setToolTipText("Find differentially expressed features over two groups"); - - loadDiffExpResults = new JMenuItem("Load saved DE results"); - loadDiffExpResults.setActionCommand("loadDiffExp"); - loadDiffExpResults.addActionListener(myself); - loadDiffExpResults.setToolTipText("Load saved differential expression results"); - - removeDiffExpResults = new JMenuItem("Remove saved DE results"); - removeDiffExpResults.setActionCommand("removeDiffExp"); - removeDiffExpResults.addActionListener(myself); - removeDiffExpResults.setToolTipText("Remove saved differential expression results from the project"); - - diffExpMenu.add(logChange); - diffExpMenu.add(loadDiffExpResults); - diffExpMenu.add(removeDiffExpResults); - - toolsMenu.add(diffExpMenu); ///////////// end tool menu////////////////// cascadeItem = new JMenuItem("Arrange Windows"); @@ -1537,7 +1513,7 @@ public void menuSelected(MenuEvent e) { aboutItem.addActionListener(myself); helpMenu.add(aboutItem); - historyMenu = new JMenu("History"); + historyMenu = new JMenu("Playback"); JMenuItem playbackMenu = new JMenuItem("Playback Dashboard"); playbackMenu.setMnemonic(KeyEvent.VK_A); playbackMenu.setActionCommand(PLAYBACK_COMMAND); @@ -1553,7 +1529,7 @@ public void menuSelected(MenuEvent e) { //Harsha - reproducibility log menu - ReproducibilityLogMenu = new JToggleButton("History"); + ReproducibilityLogMenu = new JToggleButton("Playback"); ReproducibilityLogMenu.setForeground(Color.BLUE); ReproducibilityLogMenu.addItemListener(new ItemListener() { @@ -2134,7 +2110,7 @@ public void finished() { // System.out.print("Loading extended info... "); if (!extInfoFile.exists()) extInfoFile = null; - + projectOpened(); try { // JOptionPane.showMessageDialog(null, "LOADING MD"); @@ -3386,176 +3362,6 @@ public void actionPerformed(ActionEvent e) { return; } - if ("logChange".equals(e.getActionCommand())) { - if (getActiveProject().getMetadataHybrid() == null) { - JOptionPane.showMessageDialog(null, "No metadata read", "No metadata", JOptionPane.ERROR_MESSAGE); - return; - } - - DifferentialExpFrame lframe = new DifferentialExpFrame(); - lframe.setSize(MetaOmGraph.getMainWindow().getWidth() / 2, MetaOmGraph.getMainWindow().getHeight() / 2); - MetaOmGraph.getDesktop().add(lframe); - lframe.setVisible(true); - - return; - } - - if ("loadDiffExp".equals(e.getActionCommand())) { - - String[] listOfDE = getActiveProject().getSavedDiffExpResNames(); - if (listOfDE == null || listOfDE.length < 1) { - JOptionPane.showMessageDialog(null, "No saved results found", "No results", - JOptionPane.INFORMATION_MESSAGE); - return; - } - // JOptionPane.showMessageDialog(null, "saved" + Arrays.toString(listOfDE)); - - // choose one from the available results - String chosenVal = (String) JOptionPane.showInputDialog(null, "Choose the DE analysis", "Please choose", - JOptionPane.PLAIN_MESSAGE, null, listOfDE, listOfDE[0]); - if (chosenVal == null) { - return; - } - - - // display chosen results - new AnimatedSwingWorker("Working...", true) { - @Override - public Object construct() { - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - try { - - DifferentialExpResults diffExpObj = getActiveProject().getDiffExpResObj(chosenVal); - logFCResultsFrame frame = null; - frame = new logFCResultsFrame(diffExpObj, getActiveProject()); - frame.setSize(MetaOmGraph.getMainWindow().getWidth() / 2, MetaOmGraph.getMainWindow().getHeight() / 2); - - - if(getDEAResultsFrame()!=null && !getDEAResultsFrame().isClosed()) { - getDEAResultsFrame().addTabToFrame(frame, diffExpObj.getID()); - getDEAResultsFrame().addTabListToFrame(frame.getGeneLists(), diffExpObj.getID()); - getDEAResultsFrame().getDesktopPane().getDesktopManager().maximizeFrame(getDEAResultsFrame()); - getDEAResultsFrame().getDesktopPane().getDesktopManager().minimizeFrame(getDEAResultsFrame()); - getDEAResultsFrame().moveToFront(); - } - else { - setDEAResultsFrame(new StatisticalResultsFrame("DEA","DEA Results")); - getDEAResultsFrame().addTabToFrame(frame, diffExpObj.getID()); - getDEAResultsFrame().addTabListToFrame(frame.getGeneLists(), diffExpObj.getID()); - getDEAResultsFrame().setTitle("DE results"); - MetaOmGraph.getDesktop().add(getDEAResultsFrame()); - frame.setVisible(true); - getDEAResultsFrame().setVisible(true); - getDEAResultsFrame().getDesktopPane().getDesktopManager().maximizeFrame(getDEAResultsFrame()); - getDEAResultsFrame().getDesktopPane().getDesktopManager().minimizeFrame(getDEAResultsFrame()); - getDEAResultsFrame().moveToFront(); - frame.setEnabled(true); - } - - - } catch (Exception e) { - - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - e.printStackTrace(pw); - String sStackTrace = sw.toString(); - - JDialog jd = new JDialog(); - JTextPane jt = new JTextPane(); - jt.setText(sStackTrace); - jt.setBounds(10, 10, 300, 100); - jd.getContentPane().add(jt); - jd.setBounds(100, 100, 500, 200); - jd.setVisible(true); - } - } - }); - return null; - } - }.start(); - //frame.setTitle("DE results"); - - - //Harsha - reproducibility log - - HashMap actionMap = new HashMap(); - HashMap dataMap = new HashMap(); - HashMap result = new HashMap(); - - try { - - actionMap.put("parent",MetaOmGraph.getCurrentProjectActionId()); - actionMap.put("section", "All"); - - dataMap.put("Chosen DEA", chosenVal); - - - result.put("result", "OK"); - - ActionProperties loadDeaAction = new ActionProperties("load-DEA",actionMap,dataMap,result,new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz").format(new Date())); - loadDeaAction.logActionProperties(); - - } - catch(Exception e1) { - - } - - - return; - } - - if ("removeDiffExp".equals(e.getActionCommand())) { - - String[] listOfDE = getActiveProject().getSavedDiffExpResNames(); - if (listOfDE == null || listOfDE.length < 1) { - JOptionPane.showMessageDialog(null, "No saved results found", "No results", - JOptionPane.INFORMATION_MESSAGE); - return; - } - - // choose one from the available results - String chosenVal = (String) JOptionPane.showInputDialog(null, "Choose the DE analysis to remove", - "Please choose", JOptionPane.PLAIN_MESSAGE, null, listOfDE, listOfDE[0]); - if (chosenVal == null) { - return; - } - - int opt = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete the selected?", "Confirm", 0, - 3); - if (opt != 0) { - return; - } - getActiveProject().removeDifferentialExpResults(chosenVal); - - - //Harsha - reproducibility log - - HashMap actionMap = new HashMap(); - HashMap dataMap = new HashMap(); - HashMap result = new HashMap(); - - try { - - actionMap.put("parent",MetaOmGraph.getCurrentProjectActionId()); - actionMap.put("section", "All"); - - dataMap.put("Removed DEA", chosenVal); - - - result.put("result", "OK"); - - ActionProperties removeDeaAction = new ActionProperties("remove-saved-DEA",actionMap,dataMap,result,new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz").format(new Date())); - removeDeaAction.logActionProperties(); - - } - catch(Exception e1) { - - } - - return; - } if (CASCADE_WINDOWS_COMMAND.equals(e.getActionCommand())) { JInternalFrame[] frames = desktop.getAllFrames(); @@ -4208,6 +4014,10 @@ public static void createReproducibilityLoggingFrame() { ReproducibilityDashboardFrame = new JInternalFrame("Playback"); + ColorUIResource oldActiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.activeTitleBackground"); + ColorUIResource oldInactiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.inactiveTitleBackground"); + Font oldFont = UIManager.getFont("InternalFrame.titleFont"); + UIManager.put("InternalFrame.activeTitleBackground", new ColorUIResource(new Color(240,128,128))); UIManager.put("InternalFrame.inactiveTitleBackground", new ColorUIResource(new Color(240,128,128))); UIManager.put("InternalFrame.titleFont", new Font("SansSerif", Font.BOLD,12)); @@ -4216,13 +4026,14 @@ public static void createReproducibilityLoggingFrame() { ReproducibilityDashboardFrame.setUI(ui); + rdp = new ReproducibilityDashboardPanel(myself); ReproducibilityDashboardFrame.add(rdp); desktop.add(ReproducibilityDashboardFrame); ReproducibilityDashboardFrame.setClosable(false); - ReproducibilityDashboardFrame.setIconifiable(true); + ReproducibilityDashboardFrame.setIconifiable(false); ReproducibilityDashboardFrame.setMaximizable(false); ReproducibilityDashboardFrame.setResizable(true); @@ -4233,7 +4044,13 @@ public static void createReproducibilityLoggingFrame() { ReproducibilityDashboardFrame.setSize(550, (int)rect.getMaxY()-200); ReproducibilityDashboardFrame.setLocation((ReproducibilityLogMenu.getX()+ReproducibilityLogMenu.getWidth())-550, 0); - ReproducibilityDashboardFrame.show(); + ReproducibilityDashboardFrame.show(); + + + UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); + UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); + UIManager.put("InternalFrame.titleFont", oldFont); + } diff --git a/src/edu/iastate/metnet/metaomgraph/chart/MetaOmChartPanel.java b/src/edu/iastate/metnet/metaomgraph/chart/MetaOmChartPanel.java index f271e56d..e63a06c8 100644 --- a/src/edu/iastate/metnet/metaomgraph/chart/MetaOmChartPanel.java +++ b/src/edu/iastate/metnet/metaomgraph/chart/MetaOmChartPanel.java @@ -1205,6 +1205,10 @@ public void createInternalFrame(boolean playback) { myParent.setFrameIcon(new ImageIcon(getClass().getResource("/resource/MetaOmicon16.png"))); myParent.getRootPane().setWindowDecorationStyle(3); + ColorUIResource oldActiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.activeTitleBackground"); + ColorUIResource oldInactiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.inactiveTitleBackground"); + Font oldFont = UIManager.getFont("InternalFrame.titleFont"); + UIManager.put("InternalFrame.activeTitleBackground", new ColorUIResource(new Color(240,128,128))); UIManager.put("InternalFrame.inactiveTitleBackground", new ColorUIResource(new Color(240,128,128))); UIManager.put("InternalFrame.titleFont", new Font("SansSerif", Font.BOLD,12)); @@ -1225,6 +1229,10 @@ public void createInternalFrame(boolean playback) { // } myParent.setName("plotwindow.php"); myParent.show(); + + UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); + UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); + UIManager.put("InternalFrame.titleFont", oldFont); // urmi // set exception listener diff --git a/src/edu/iastate/metnet/metaomgraph/playback/PlaybackAction.java b/src/edu/iastate/metnet/metaomgraph/playback/PlaybackAction.java index a253f6f0..86725832 100644 --- a/src/edu/iastate/metnet/metaomgraph/playback/PlaybackAction.java +++ b/src/edu/iastate/metnet/metaomgraph/playback/PlaybackAction.java @@ -23,7 +23,7 @@ * */ public class PlaybackAction { - + private static final String LINE_CHART_COMMAND = "line-chart"; private static final String SCATTER_PLOT_COMMAND = "scatter-plot"; private static final String BOX_PLOT_COMMAND = "box-plot"; @@ -40,8 +40,8 @@ public class PlaybackAction { private static final String SELECTED_COLUMN_PROPERTY = "Selected Column"; private static final String CORRELATION_COLUMN_PROPERTY = "Correlation Column"; private static final String PLAYABLE_PROPERTY = "Playable"; - - + + /** *

* This method is the first method called when the play button is clicked. It takes the list of actions selected (allPaths) as input, @@ -54,80 +54,85 @@ public class PlaybackAction { * */ public void playActions(int tabNo, JTree selectedTree, TreePath[] allPaths, HashMap allTabsInfo) { - - for (TreePath path : allPaths) { - DefaultMutableTreeNode node2 = (DefaultMutableTreeNode) path.getLastPathComponent(); - Object nodeObj = node2.getUserObject(); - LoggingTreeNode ltn = (LoggingTreeNode) nodeObj; - ActionProperties playedAction = allTabsInfo.get(tabNo).getActionObjects().get(ltn.getNodeNumber()); + try { + for (TreePath path : allPaths) { + DefaultMutableTreeNode node2 = (DefaultMutableTreeNode) path.getLastPathComponent(); + Object nodeObj = node2.getUserObject(); + LoggingTreeNode ltn = (LoggingTreeNode) nodeObj; + ActionProperties playedAction = allTabsInfo.get(tabNo).getActionObjects().get(ltn.getNodeNumber()); - if(playedAction.getOtherParameters().get(PLAYABLE_PROPERTY)!=null) { - String isPlayable = (String)playedAction.getOtherParameters().get(PLAYABLE_PROPERTY); - if(isPlayable.equals("true")) - { - int samplesActionId = 1; - if(playedAction.getOtherParameters().get(SAMPLE_ACTION_PROPERTY) instanceof Double) { - double temp = (double) playedAction.getOtherParameters().get(SAMPLE_ACTION_PROPERTY); - samplesActionId = (int)temp; - } - else { - samplesActionId = (int)playedAction.getOtherParameters().get(SAMPLE_ACTION_PROPERTY); - } + if(playedAction.getOtherParameters().get(PLAYABLE_PROPERTY)!=null) { - HashSet includedSamples = new HashSet(); - HashSet excludedSamples = new HashSet(); + String isPlayable = (String)playedAction.getOtherParameters().get(PLAYABLE_PROPERTY); + if(isPlayable.equals("true")) + { + int samplesActionId = 1; + if(playedAction.getOtherParameters().get(SAMPLE_ACTION_PROPERTY) instanceof Double) { + double temp = (double) playedAction.getOtherParameters().get(SAMPLE_ACTION_PROPERTY); + samplesActionId = (int)temp; + } + else { + samplesActionId = (int)playedAction.getOtherParameters().get(SAMPLE_ACTION_PROPERTY); + } - for(int i=0;i includedSamples = new HashSet(); + HashSet excludedSamples = new HashSet(); - if(allTabsInfo.get(tabNo).getActionObjects().get(i).getActionNumber() == samplesActionId) { + for(int i=0;i) { - includedSamples = new HashSet((List)sampleAction.getOtherParameters().get(INCLUDED_SAMPLES_PROPERTY)); - } - else if(sampleAction.getOtherParameters().get(INCLUDED_SAMPLES_PROPERTY) instanceof HashSet) { - includedSamples = (HashSet)sampleAction.getOtherParameters().get(INCLUDED_SAMPLES_PROPERTY); - } + ActionProperties sampleAction = allTabsInfo.get(tabNo).getActionObjects().get(i); - if(sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY) instanceof List) { - excludedSamples = new HashSet((List)sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY)); - } - else if(sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY) instanceof HashSet) { - excludedSamples = (HashSet)sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY); - } + if(sampleAction.getOtherParameters().get(INCLUDED_SAMPLES_PROPERTY) instanceof List) { + includedSamples = new HashSet((List)sampleAction.getOtherParameters().get(INCLUDED_SAMPLES_PROPERTY)); + } + else if(sampleAction.getOtherParameters().get(INCLUDED_SAMPLES_PROPERTY) instanceof HashSet) { + includedSamples = (HashSet)sampleAction.getOtherParameters().get(INCLUDED_SAMPLES_PROPERTY); + } + if(sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY) instanceof List) { + excludedSamples = new HashSet((List)sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY)); + } + else if(sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY) instanceof HashSet) { + excludedSamples = (HashSet)sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY); + } + + } } - } - if (ltn.getCommandName().equalsIgnoreCase(LINE_CHART_COMMAND)) { - playChart(playedAction, LINE_CHART_COMMAND, includedSamples, excludedSamples); - } else if (ltn.getCommandName().equalsIgnoreCase(SCATTER_PLOT_COMMAND)) { - playChart(playedAction, SCATTER_PLOT_COMMAND, includedSamples, excludedSamples); - } else if (ltn.getCommandName().equalsIgnoreCase(BOX_PLOT_COMMAND)) { - playChart(playedAction, BOX_PLOT_COMMAND, includedSamples, excludedSamples); - } else if (ltn.getCommandName().equalsIgnoreCase(HISTOGRAM_COMMAND)) { - playChart(playedAction, HISTOGRAM_COMMAND, includedSamples, excludedSamples); - } else if (ltn.getCommandName().equalsIgnoreCase(LINE_CHART_DEFAULT_GROUPING_COMMAND)) { - playChart(playedAction, LINE_CHART_DEFAULT_GROUPING_COMMAND, includedSamples, excludedSamples); - } else if (ltn.getCommandName().equalsIgnoreCase(LINE_CHART_CHOOSE_GROUPING_COMMAND)) { - playChart(playedAction, LINE_CHART_CHOOSE_GROUPING_COMMAND, includedSamples, excludedSamples); - } else if (ltn.getCommandName().equalsIgnoreCase(BAR_CHART_COMMAND)) { - playChart(playedAction, BAR_CHART_COMMAND, includedSamples, excludedSamples); - } else if (ltn.getCommandName().equalsIgnoreCase(CORRELATION_HISTOGRAM_COMMAND)) { - playChart(playedAction, CORRELATION_HISTOGRAM_COMMAND, includedSamples, excludedSamples); - } + if (ltn.getCommandName().equalsIgnoreCase(LINE_CHART_COMMAND)) { + playChart(playedAction, LINE_CHART_COMMAND, includedSamples, excludedSamples); + } else if (ltn.getCommandName().equalsIgnoreCase(SCATTER_PLOT_COMMAND)) { + playChart(playedAction, SCATTER_PLOT_COMMAND, includedSamples, excludedSamples); + } else if (ltn.getCommandName().equalsIgnoreCase(BOX_PLOT_COMMAND)) { + playChart(playedAction, BOX_PLOT_COMMAND, includedSamples, excludedSamples); + } else if (ltn.getCommandName().equalsIgnoreCase(HISTOGRAM_COMMAND)) { + playChart(playedAction, HISTOGRAM_COMMAND, includedSamples, excludedSamples); + } else if (ltn.getCommandName().equalsIgnoreCase(LINE_CHART_DEFAULT_GROUPING_COMMAND)) { + playChart(playedAction, LINE_CHART_DEFAULT_GROUPING_COMMAND, includedSamples, excludedSamples); + } else if (ltn.getCommandName().equalsIgnoreCase(LINE_CHART_CHOOSE_GROUPING_COMMAND)) { + playChart(playedAction, LINE_CHART_CHOOSE_GROUPING_COMMAND, includedSamples, excludedSamples); + } else if (ltn.getCommandName().equalsIgnoreCase(BAR_CHART_COMMAND)) { + playChart(playedAction, BAR_CHART_COMMAND, includedSamples, excludedSamples); + } else if (ltn.getCommandName().equalsIgnoreCase(CORRELATION_HISTOGRAM_COMMAND)) { + playChart(playedAction, CORRELATION_HISTOGRAM_COMMAND, includedSamples, excludedSamples); + } + } } } } + catch(Exception e) { + + } } - + /** * This method plays the chart-type action by calling the respective chart's MetaOmTablePanel function that generates and displays the chart * based on the selected features and samples. @@ -140,7 +145,7 @@ public void playChart(ActionProperties chartAction, String chartName, HashSet genes = null; try { - + if(chartAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY) != null) { genes = (Map)chartAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY); diff --git a/src/edu/iastate/metnet/metaomgraph/ui/ColorProperties.java b/src/edu/iastate/metnet/metaomgraph/ui/ColorProperties.java index 988a4f38..b14b0052 100644 --- a/src/edu/iastate/metnet/metaomgraph/ui/ColorProperties.java +++ b/src/edu/iastate/metnet/metaomgraph/ui/ColorProperties.java @@ -39,6 +39,7 @@ public class ColorProperties extends TaskbarInternalFrame { private ColorChooseButton plotBckButton; private boolean themeEdited; private JComboBox comboBox; + private TaskbarInternalFrame currentFrame; private String _defaulttheme="light"; @@ -72,6 +73,8 @@ public ColorProperties() { setMaximizable(true); setIconifiable(true); setClosable(true); + + currentFrame = this; // setSize(600, 600); // JPanel panel = new JPanel(); @@ -81,6 +84,7 @@ public ColorProperties() { btnCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { + MetaOmGraph.getTaskBar().removeFromTaskbar(currentFrame); dispose(); } }); @@ -112,6 +116,7 @@ public void actionPerformed(ActionEvent arg0) { saveTheme(); } + MetaOmGraph.getTaskBar().removeFromTaskbar(currentFrame); dispose(); } }); diff --git a/src/edu/iastate/metnet/metaomgraph/ui/MetaOmTablePanel.java b/src/edu/iastate/metnet/metaomgraph/ui/MetaOmTablePanel.java index b627eea5..61941d2c 100644 --- a/src/edu/iastate/metnet/metaomgraph/ui/MetaOmTablePanel.java +++ b/src/edu/iastate/metnet/metaomgraph/ui/MetaOmTablePanel.java @@ -149,6 +149,13 @@ public class MetaOmTablePanel extends JPanel implements ActionListener, ListSele private JMenu removeCorrelationMenu; private JMenu selectedRowsMenu; private MenuButton infoButton; + + //Harsha + private static JMenu diffExpMenu; + private static JMenuItem logChange; + private static JMenuItem loadDiffExpResults; + private static JMenuItem removeDiffExpResults; + // urmi private JButton metabutton; private JMenuItem viewCorrStats; @@ -349,6 +356,8 @@ public void focusGained(FocusEvent e) { JMenu poolcorrMenu = new JMenu("Meta-analysis"); JMenu diffcorrMenu = new JMenu("Differntial Correlation"); JMenu informationMenu = new JMenu("Mutual Information"); + diffExpMenu = new JMenu("Differential Expression Analysis"); + JMenu distMenu = new JMenu("Distance"); ////////////////////////// @@ -495,6 +504,29 @@ public void focusGained(FocusEvent e) { distMenu.add(manhattanItem); distMenu.add(weightedEuclideanItem); distMenu.add(weightedManhattanItem); + + //Harsha + logChange = new JMenuItem("Perform DEA"); + logChange.setActionCommand("logChange"); + logChange.addActionListener(this); + logChange.setToolTipText("Find differentially expressed features over two groups"); + + loadDiffExpResults = new JMenuItem("Load saved DE results"); + loadDiffExpResults.setActionCommand("loadDiffExp"); + loadDiffExpResults.addActionListener(this); + loadDiffExpResults.setToolTipText("Load saved differential expression results"); + + removeDiffExpResults = new JMenuItem("Remove saved DE results"); + removeDiffExpResults.setActionCommand("removeDiffExp"); + removeDiffExpResults.addActionListener(this); + removeDiffExpResults.setToolTipText("Remove saved differential expression results from the project"); + + diffExpMenu.add(logChange); + diffExpMenu.add(loadDiffExpResults); + diffExpMenu.add(removeDiffExpResults); + + analyzePopupMenu.add(diffExpMenu); + analyzePopupMenu.add(distMenu); analyzePopupMenu.addSeparator(); @@ -1386,6 +1418,10 @@ public void run() { int nBins = myProject.getIncludedDataColumnCount() / 10; HistogramChart f = new HistogramChart(selected, nBins, myProject, 1, null, true); + ColorUIResource oldActiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.activeTitleBackground"); + ColorUIResource oldInactiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.inactiveTitleBackground"); + Font oldFont = UIManager.getFont("InternalFrame.titleFont"); + UIManager.put("InternalFrame.activeTitleBackground", new ColorUIResource(new Color(240,128,128))); UIManager.put("InternalFrame.inactiveTitleBackground", new ColorUIResource(new Color(240,128,128))); UIManager.put("InternalFrame.titleFont", new Font("SansSerif", Font.BOLD,12)); @@ -1403,6 +1439,11 @@ public void run() { f.setVisible(true); f.toFront(); + + UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); + UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); + UIManager.put("InternalFrame.titleFont", oldFont); + mcol.setIncluded(currentProjectIncludedSamples); mcol.setExcluded(currentProjectExcludedSamples); MetaOmGraph.getActiveTable().updateMetadataTree(); @@ -1574,6 +1615,9 @@ public void run() { MetaOmGraph.getActiveTable().updateMetadataTree(); + ColorUIResource oldActiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.activeTitleBackground"); + ColorUIResource oldInactiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.inactiveTitleBackground"); + Font oldFont = UIManager.getFont("InternalFrame.titleFont"); BoxPlot f = new BoxPlot(plotData, 0, myProject,true); @@ -1594,6 +1638,10 @@ public void run() { f.toFront(); + UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); + UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); + UIManager.put("InternalFrame.titleFont", oldFont); + mcol.setIncluded(currentProjectIncludedSamples); mcol.setExcluded(currentProjectExcludedSamples); //MetaOmAnalyzer.updateExcluded(currentProjectExcludedSamples); @@ -1737,8 +1785,9 @@ public void run() { mcol.setExcluded(excludedSamples); MetaOmGraph.getActiveTable().updateMetadataTree(); - - + ColorUIResource oldActiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.activeTitleBackground"); + ColorUIResource oldInactiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.inactiveTitleBackground"); + Font oldFont = UIManager.getFont("InternalFrame.titleFont"); ScatterPlotChart f = new ScatterPlotChart(selected, 0, myProject,true); @@ -1760,6 +1809,10 @@ public void run() { f.toFront(); + UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); + UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); + UIManager.put("InternalFrame.titleFont", oldFont); + mcol.setIncluded(currentProjectIncludedSamples); mcol.setExcluded(currentProjectExcludedSamples); MetaOmGraph.getActiveTable().updateMetadataTree(); @@ -4259,6 +4312,170 @@ public void finished() { //multiSelectAction.logActionProperties(); return; } + + //Harsha - Diff exp + + if ("logChange".equals(e.getActionCommand())) { + if (MetaOmGraph.getActiveProject().getMetadataHybrid() == null) { + JOptionPane.showMessageDialog(null, "No metadata read", "No metadata", JOptionPane.ERROR_MESSAGE); + return; + } + + DifferentialExpFrame lframe = new DifferentialExpFrame(); + lframe.setSize(MetaOmGraph.getMainWindow().getWidth() / 2, MetaOmGraph.getMainWindow().getHeight() / 2); + MetaOmGraph.getDesktop().add(lframe); + lframe.setVisible(true); + + return; + } + + if ("loadDiffExp".equals(e.getActionCommand())) { + + String[] listOfDE = MetaOmGraph.getActiveProject().getSavedDiffExpResNames(); + if (listOfDE == null || listOfDE.length < 1) { + JOptionPane.showMessageDialog(null, "No saved results found", "No results", + JOptionPane.INFORMATION_MESSAGE); + return; + } + // JOptionPane.showMessageDialog(null, "saved" + Arrays.toString(listOfDE)); + + // choose one from the available results + String chosenVal = (String) JOptionPane.showInputDialog(null, "Choose the DE analysis", "Please choose", + JOptionPane.PLAIN_MESSAGE, null, listOfDE, listOfDE[0]); + if (chosenVal == null) { + return; + } + + + // display chosen results + new AnimatedSwingWorker("Working...", true) { + @Override + public Object construct() { + EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + try { + + DifferentialExpResults diffExpObj = MetaOmGraph.getActiveProject().getDiffExpResObj(chosenVal); + logFCResultsFrame frame = null; + frame = new logFCResultsFrame(diffExpObj, MetaOmGraph.getActiveProject()); + frame.setSize(MetaOmGraph.getMainWindow().getWidth() / 2, MetaOmGraph.getMainWindow().getHeight() / 2); + + + if(MetaOmGraph.getDEAResultsFrame()!=null && !MetaOmGraph.getDEAResultsFrame().isClosed()) { + MetaOmGraph.getDEAResultsFrame().addTabToFrame(frame, diffExpObj.getID()); + MetaOmGraph.getDEAResultsFrame().addTabListToFrame(frame.getGeneLists(), diffExpObj.getID()); + MetaOmGraph.getDEAResultsFrame().getDesktopPane().getDesktopManager().maximizeFrame(MetaOmGraph.getDEAResultsFrame()); + MetaOmGraph.getDEAResultsFrame().getDesktopPane().getDesktopManager().minimizeFrame(MetaOmGraph.getDEAResultsFrame()); + MetaOmGraph.getDEAResultsFrame().moveToFront(); + } + else { + MetaOmGraph.setDEAResultsFrame(new StatisticalResultsFrame("DEA","DEA Results")); + MetaOmGraph.getDEAResultsFrame().addTabToFrame(frame, diffExpObj.getID()); + MetaOmGraph.getDEAResultsFrame().addTabListToFrame(frame.getGeneLists(), diffExpObj.getID()); + MetaOmGraph.getDEAResultsFrame().setTitle("DE results"); + MetaOmGraph.getDesktop().add(MetaOmGraph.getDEAResultsFrame()); + frame.setVisible(true); + MetaOmGraph.getDEAResultsFrame().setVisible(true); + MetaOmGraph.getDEAResultsFrame().getDesktopPane().getDesktopManager().maximizeFrame(MetaOmGraph.getDEAResultsFrame()); + MetaOmGraph.getDEAResultsFrame().getDesktopPane().getDesktopManager().minimizeFrame(MetaOmGraph.getDEAResultsFrame()); + MetaOmGraph.getDEAResultsFrame().moveToFront(); + frame.setEnabled(true); + } + + + } catch (Exception e) { + + + } + } + }); + return null; + } + }.start(); + //frame.setTitle("DE results"); + + + //Harsha - reproducibility log + + HashMap actionMap = new HashMap(); + HashMap dataMap = new HashMap(); + HashMap result = new HashMap(); + + try { + + actionMap.put("parent",MetaOmGraph.getCurrentProjectActionId()); + actionMap.put("section", "All"); + + dataMap.put("Chosen DEA", chosenVal); + + + result.put("result", "OK"); + + ActionProperties loadDeaAction = new ActionProperties("load-DEA",actionMap,dataMap,result,new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz").format(new Date())); + loadDeaAction.logActionProperties(); + + } + catch(Exception e1) { + + } + + + return; + } + + if ("removeDiffExp".equals(e.getActionCommand())) { + + String[] listOfDE = MetaOmGraph.getActiveProject().getSavedDiffExpResNames(); + if (listOfDE == null || listOfDE.length < 1) { + JOptionPane.showMessageDialog(null, "No saved results found", "No results", + JOptionPane.INFORMATION_MESSAGE); + return; + } + + // choose one from the available results + String chosenVal = (String) JOptionPane.showInputDialog(null, "Choose the DE analysis to remove", + "Please choose", JOptionPane.PLAIN_MESSAGE, null, listOfDE, listOfDE[0]); + if (chosenVal == null) { + return; + } + + int opt = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete the selected?", "Confirm", 0, + 3); + if (opt != 0) { + return; + } + MetaOmGraph.getActiveProject().removeDifferentialExpResults(chosenVal); + + + //Harsha - reproducibility log + + HashMap actionMap = new HashMap(); + HashMap dataMap = new HashMap(); + HashMap result = new HashMap(); + + try { + + actionMap.put("parent",MetaOmGraph.getCurrentProjectActionId()); + actionMap.put("section", "All"); + + dataMap.put("Removed DEA", chosenVal); + + + result.put("result", "OK"); + + ActionProperties removeDeaAction = new ActionProperties("remove-saved-DEA",actionMap,dataMap,result,new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz").format(new Date())); + removeDeaAction.logActionProperties(); + + } + catch(Exception e1) { + + } + + return; + } + + if ("save correlation".equals(e.getActionCommand())) { keepLastCorrelation(true); return; @@ -5760,6 +5977,11 @@ public void run() { nBins = 100; } double[] data = corrVals.stream().mapToDouble(d -> d).toArray(); + + ColorUIResource oldActiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.activeTitleBackground"); + ColorUIResource oldInactiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.inactiveTitleBackground"); + Font oldFont = UIManager.getFont("InternalFrame.titleFont"); + HistogramChart f = new HistogramChart(null, nBins, null, 2, data, false); UIManager.put("InternalFrame.activeTitleBackground", new ColorUIResource(new Color(240,128,128))); @@ -5779,6 +6001,10 @@ public void run() { f.setVisible(true); f.toFront(); + UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); + UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); + UIManager.put("InternalFrame.titleFont", oldFont); + } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error occured while reading data!!!", "Error", JOptionPane.ERROR_MESSAGE); @@ -5870,6 +6096,10 @@ public void plotBarChart(String colValue, boolean playback) { // gert data for the selected columns List chartData = getFeatureMetaData(colValue); + ColorUIResource oldActiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.activeTitleBackground"); + ColorUIResource oldInactiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.inactiveTitleBackground"); + Font oldFont = UIManager.getFont("InternalFrame.titleFont"); + BarChart f2 = new BarChart(myProject, colValue, chartData, 1); UIManager.put("InternalFrame.activeTitleBackground", new ColorUIResource(new Color(240,128,128))); @@ -5889,6 +6119,10 @@ public void plotBarChart(String colValue, boolean playback) { f2.setSize(1000, 700); f2.setVisible(true); f2.toFront(); + + UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); + UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); + UIManager.put("InternalFrame.titleFont", oldFont); } diff --git a/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java b/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java index 8e208471..62d4df59 100644 --- a/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java +++ b/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java @@ -47,6 +47,8 @@ import javax.swing.JTextArea; import javax.swing.JTextPane; import javax.swing.JTree; +import javax.swing.SwingConstants; +import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; @@ -285,11 +287,11 @@ public Component prepareRenderer(TableCellRenderer renderer, int row, int column rdbtnOn.setSelected(true); loggingChoicePanel.add(rdbtnOn); - rdbtnOff = new JRadioButton("off"); + rdbtnOff = new JRadioButton("pause"); loggingChoicePanel.add(rdbtnOff); rdbtnPermanentlySwitchedOff = new JRadioButton("permanently switched off"); - loggingChoicePanel.add(rdbtnPermanentlySwitchedOff); +// loggingChoicePanel.add(rdbtnPermanentlySwitchedOff); if (MetaOmGraph.getPermanentLogging() == false) { rdbtnOn.setSelected(false); @@ -850,6 +852,7 @@ public void setValueAt(Object aValue, int row, int column) { } }); + table.getColumnModel().getColumn(1).setCellRenderer(new MultilineTableRenderer()); table.getColumnModel().getColumn(1).setCellEditor(new MultilineTableCellEditor()); @@ -1221,9 +1224,11 @@ public void markActionsAsFavorite(int tabNo, JTree selectedTree, DefaultTreeMode } - } catch (IOException e) { + } + catch (Exception e) { - } finally { + } + finally { try { if(tabNo!=0 && out!=null) { out.close(); diff --git a/src/edu/iastate/metnet/metaomgraph/ui/TaskbarPanel.java b/src/edu/iastate/metnet/metaomgraph/ui/TaskbarPanel.java index c749250b..b7aa9974 100644 --- a/src/edu/iastate/metnet/metaomgraph/ui/TaskbarPanel.java +++ b/src/edu/iastate/metnet/metaomgraph/ui/TaskbarPanel.java @@ -78,24 +78,24 @@ public class TaskbarPanel extends JPanel{ private LinkedHashMap> taskbarData; private JMenuBar menuBar; - + /** * Constructor to initialize the masterdata (taskbarData) and the JPanel */ public TaskbarPanel() { - + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice defaultScreen = ge.getDefaultScreenDevice(); Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds(); setSize((int)rect.getMaxX(), 30); setLocation(0, (int)rect.getMaxY()-30); setLayout(new FlowLayout(FlowLayout.LEFT)); - + taskbarData = new LinkedHashMap>(); menuBar = new JMenuBar(); add(menuBar); } - + /** * This method adds a tab to the taskbar * @@ -110,7 +110,7 @@ public TaskbarPanel() { * */ public void addToTaskbar(TaskbarInternalFrame currentFrame) { - + if(taskbarData.get(currentFrame.getModel().getFrameType()) != null) { ArrayList listOfFrames = (ArrayList)taskbarData.get(currentFrame.getModel().getFrameType()); listOfFrames.add(currentFrame); @@ -120,13 +120,13 @@ public void addToTaskbar(TaskbarInternalFrame currentFrame) { listOfFrames.add(currentFrame); taskbarData.put(currentFrame.getModel().getFrameType(), listOfFrames); } - + reloadTaskbar(); - + } - - - + + + /** * This method removes the given frame from the taskbar. * @@ -140,11 +140,11 @@ public void addToTaskbar(TaskbarInternalFrame currentFrame) { * At the end, the taskbar is reloaded to reflect the removal. */ public void removeFromTaskbar(TaskbarInternalFrame currentFrame) { - + if(taskbarData.get(currentFrame.getModel().getFrameType()) != null) { ArrayList listOfFrames = (ArrayList)taskbarData.get(currentFrame.getModel().getFrameType()); listOfFrames.remove(currentFrame); - + if(listOfFrames.size()==0) { taskbarData.remove(currentFrame.getModel().getFrameType()); } @@ -152,23 +152,23 @@ public void removeFromTaskbar(TaskbarInternalFrame currentFrame) { else { taskbarData.remove(currentFrame.getModel().getFrameType()); } - + reloadTaskbar(); - + } - + /** * Clears the tab data from the taskbarData master data, and removes all the * JMenu objects from the menubar. */ public void removeAllTabsFromTaskbar() { - + taskbarData.clear(); menuBar.removeAll(); } - - + + /** * This method first removes all the JMenus from the menuBar object. * @@ -181,22 +181,22 @@ public void removeAllTabsFromTaskbar() { * */ public void reloadTaskbar() { - + menuBar.removeAll(); - + if(taskbarData != null) { - + for(Map.Entry> entryset : taskbarData.entrySet()) { JMenu menu = new JMenu(entryset.getKey()); List typeFrames = entryset.getValue(); - + if(typeFrames != null) { for(TaskbarInternalFrame frame : typeFrames) { JMenuItem menuItem = new JMenuItem(frame.getModel().getFrameName()); JPanel tabItemPanel = new JPanel(); tabItemPanel.setLayout(new BorderLayout()); JLabel tabItemLabel = new JLabel(frame.getModel().getFrameName()); - + tabItemPanel.add(tabItemLabel); UIManager.put("MenuItem.selectionForeground", Color.BLUE); @@ -204,25 +204,32 @@ public void reloadTaskbar() { menu.add(new JSeparator()); menu.add(menuItem); menu.setMargin(new Insets(2, 8, 2, 8)); - + menuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { + public void actionPerformed(java.awt.event.ActionEvent evt) { - frame.getDesktopPane().getDesktopManager().maximizeFrame(frame); - frame.getDesktopPane().getDesktopManager().minimizeFrame(frame); - frame.moveToFront(); - } + try { + if(frame != null) { + frame.getDesktopPane().getDesktopManager().maximizeFrame(frame); + frame.getDesktopPane().getDesktopManager().minimizeFrame(frame); + frame.moveToFront(); + } + } + catch(Exception e) { + + } + } }); } } - + JSeparator menuSeparator = new JSeparator(); menuBar.add(menuSeparator); menuBar.add(menu); - + } } - + } - + } \ No newline at end of file From fd9e79dd2917124f3b69a270d2862952c4825c90 Mon Sep 17 00:00:00 2001 From: "vk.sriharsha" Date: Sun, 27 Sep 2020 13:29:19 -0500 Subject: [PATCH 2/7] Added Mac playback button --- .../metnet/metaomgraph/MetaOmGraph.java | 64 ++- .../metaomgraph/chart/MetaOmChartPanel.java | 8 - .../ui/FeatureMetadataRemoveCols.java | 381 ++++++++++++++++++ .../metaomgraph/ui/MetaOmTablePanel.java | 4 +- 4 files changed, 442 insertions(+), 15 deletions(-) create mode 100644 src/edu/iastate/metnet/metaomgraph/ui/FeatureMetadataRemoveCols.java diff --git a/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java b/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java index 8862c4fa..784419a4 100644 --- a/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java +++ b/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java @@ -7,6 +7,8 @@ import java.awt.Event; import java.awt.EventQueue; import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.HeadlessException; @@ -21,6 +23,7 @@ import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.awt.geom.Rectangle2D; import java.beans.PropertyVetoException; import java.io.File; import java.io.FileInputStream; @@ -49,6 +52,7 @@ import javax.swing.AbstractAction; import javax.swing.Box; import javax.swing.ImageIcon; +import javax.swing.JButton; import javax.swing.JCheckBoxMenuItem; import javax.swing.JComponent; import javax.swing.JDesktopPane; @@ -1513,7 +1517,7 @@ public void menuSelected(MenuEvent e) { aboutItem.addActionListener(myself); helpMenu.add(aboutItem); - historyMenu = new JMenu("Playback"); + //historyMenu = new JMenu("Playback"); JMenuItem playbackMenu = new JMenuItem("Playback Dashboard"); playbackMenu.setMnemonic(KeyEvent.VK_A); playbackMenu.setActionCommand(PLAYBACK_COMMAND); @@ -1522,8 +1526,8 @@ public void menuSelected(MenuEvent e) { mainMenuBar.add(helpMenu); if(Utils.isMac()) { - historyMenu.add(playbackMenu); - mainMenuBar.add(historyMenu); +// historyMenu.add(playbackMenu); +// mainMenuBar.add(historyMenu); } @@ -1555,7 +1559,57 @@ else if ((ReproducibilityDashboardFrame != null) && (!ReproducibilityDashboardFr mainMenuBar.add(Box.createHorizontalGlue()); mainMenuBar.add(ReproducibilityLogMenu); + + + if (Utils.isMac()) { + JPanel playbackForMac = new JPanel() + { + @Override + protected void paintComponent(Graphics g) { + // Draw a rectangle using Rectangle2D class +// Graphics2D g2 = (Graphics2D) g; +// +// g2.setColor(new Color(255,255,240)); +// g2.setBackground(new Color(255,255,240)); +// +// // Draw the blue rectangle +// g2.fill(new Rectangle2D.Double(1250, 10, 100, 30)); +// g2.setColor(Color.BLUE); +// +// g2.drawString("Playback",1255,18); + } + }; + + JButton plbbutton = new JButton("Playback"); + playbackForMac.setLayout(null); + plbbutton.setBounds(1220, 0, 100, 30); + playbackForMac.add(plbbutton); + playbackForMac.setSize(2000,2000); + playbackForMac.setVisible(true); + playbackForMac.setBackground(Color.BLACK); + + plbbutton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if ((ReproducibilityDashboardFrame != null) && (ReproducibilityDashboardFrame.isVisible())) { + //frame.toFront(); + ReproducibilityDashboardFrame.setVisible(false); + return; + } + else if ((ReproducibilityDashboardFrame != null) && (!ReproducibilityDashboardFrame.isVisible()) && (!ReproducibilityDashboardFrame.isClosed())) { + ReproducibilityDashboardFrame.setVisible(true); + return; + } + + createReproducibilityLoggingFrame(); + } + }); + desktop.add(playbackForMac); + + } // Menu bar created setMenuIcons(); @@ -4047,8 +4101,8 @@ public static void createReproducibilityLoggingFrame() { ReproducibilityDashboardFrame.show(); - UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); - UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); + UIManager.put("InternalFrame.activeTitleBackground", new ColorUIResource(new Color(0,197,205))); + UIManager.put("InternalFrame.inactiveTitleBackground", new ColorUIResource(new Color(0,197,205))); UIManager.put("InternalFrame.titleFont", oldFont); diff --git a/src/edu/iastate/metnet/metaomgraph/chart/MetaOmChartPanel.java b/src/edu/iastate/metnet/metaomgraph/chart/MetaOmChartPanel.java index e63a06c8..f271e56d 100644 --- a/src/edu/iastate/metnet/metaomgraph/chart/MetaOmChartPanel.java +++ b/src/edu/iastate/metnet/metaomgraph/chart/MetaOmChartPanel.java @@ -1205,10 +1205,6 @@ public void createInternalFrame(boolean playback) { myParent.setFrameIcon(new ImageIcon(getClass().getResource("/resource/MetaOmicon16.png"))); myParent.getRootPane().setWindowDecorationStyle(3); - ColorUIResource oldActiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.activeTitleBackground"); - ColorUIResource oldInactiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.inactiveTitleBackground"); - Font oldFont = UIManager.getFont("InternalFrame.titleFont"); - UIManager.put("InternalFrame.activeTitleBackground", new ColorUIResource(new Color(240,128,128))); UIManager.put("InternalFrame.inactiveTitleBackground", new ColorUIResource(new Color(240,128,128))); UIManager.put("InternalFrame.titleFont", new Font("SansSerif", Font.BOLD,12)); @@ -1229,10 +1225,6 @@ public void createInternalFrame(boolean playback) { // } myParent.setName("plotwindow.php"); myParent.show(); - - UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); - UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); - UIManager.put("InternalFrame.titleFont", oldFont); // urmi // set exception listener diff --git a/src/edu/iastate/metnet/metaomgraph/ui/FeatureMetadataRemoveCols.java b/src/edu/iastate/metnet/metaomgraph/ui/FeatureMetadataRemoveCols.java new file mode 100644 index 00000000..c4920a29 --- /dev/null +++ b/src/edu/iastate/metnet/metaomgraph/ui/FeatureMetadataRemoveCols.java @@ -0,0 +1,381 @@ +package edu.iastate.metnet.metaomgraph.ui; + +import java.awt.BorderLayout; +import java.awt.EventQueue; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; +import java.awt.Color; +import java.awt.Component; + +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.DefaultCellEditor; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import java.awt.Font; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.Vector; + +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumn; + +import org.apache.logging.log4j.Logger; + +import edu.iastate.metnet.metaomgraph.MetaOmGraph; +import edu.iastate.metnet.metaomgraph.MetadataCollection; +import edu.iastate.metnet.metaomgraph.logging.ActionProperties; + +import java.awt.Dimension; +import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; +import java.awt.event.ActionEvent; + +public class FeatureMetadataRemoveCols extends JDialog { + + private JPanel contentPane; + private JTable table; + int datacolIndex = 0; + + /** + * Launch the application. + */ + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + try { + // MetadataRemoveCols frame = new MetadataRemoveCols(new String[] + // {"a1","2b","34"},null,null); + // frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + public FeatureMetadataRemoveCols getThisframe() { + return this; + } + + /** + * Create the frame. + */ + public FeatureMetadataRemoveCols(String[] headervals, MetadataCollection obj, ReadMetadata p) { + setModal(true); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setBounds(100, 100, 450, 300); + contentPane = new JPanel(); + contentPane.setBackground(Color.DARK_GRAY); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + contentPane.setLayout(new BorderLayout(0, 0)); + setContentPane(contentPane); + + JPanel panel = new JPanel(); + panel.setBackground(Color.DARK_GRAY); + panel.setFont(new Font("Garamond", Font.BOLD, 16)); + contentPane.add(panel, BorderLayout.NORTH); + + JLabel lblRemoveColumns = new JLabel("Remove Columns"); + lblRemoveColumns.setForeground(Color.GREEN); + lblRemoveColumns.setFont(new Font("Garamond", Font.BOLD, 15)); + panel.add(lblRemoveColumns); + + JPanel panel_1 = new JPanel(); + panel_1.setBackground(Color.DARK_GRAY); + contentPane.add(panel_1, BorderLayout.SOUTH); + + JButton btnDone = new JButton("Done"); + btnDone.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (obj == null) { + JOptionPane.showMessageDialog(panel, "Error!!! Can't delete columns. No file read...", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + String[] newheaders = headervals; + boolean[] toKeep = new boolean[newheaders.length]; + java.util.List removed=new ArrayList<>(); + // get data from table + DefaultTableModel tablemodel = (DefaultTableModel) table.getModel(); + for (int i = 0; i < tablemodel.getRowCount(); i++) { + if (tablemodel.getValueAt(i, 2).toString().equals("Keep")) { + toKeep[i] = true; + } else { + removed.add(tablemodel.getValueAt(i, 1).toString()); + toKeep[i] = false; + } + + } + + obj.setHeaders(newheaders, toKeep); + + p.updateHeaders(); + p.updateRemovedCols(removed); + getThisframe().dispose(); + p.setEnabled(true); + p.toFront(); + p.updateTable(); + + } + }); + panel_1.add(btnDone); + + JScrollPane scrollPane = new JScrollPane(); + scrollPane.setBackground(Color.DARK_GRAY); + contentPane.add(scrollPane, BorderLayout.CENTER); + + table = new JTable() { + @Override + public boolean isCellEditable(int row, int column) { // dont let edit first 2 cols + if (column == 0 || column == 1) { + return false; + } + return true; + } + }; + table.setRowMargin(3); + table.setRowHeight(25); + table.setIntercellSpacing(new Dimension(2, 2)); + table.setModel( + new DefaultTableModel(new Object[][] {}, new String[] { "Column number", "Header", "Keep/Remove" })); + // set default values + DefaultTableModel tablemodel = (DefaultTableModel) table.getModel(); + for (int i = 0; i < headervals.length; i++) { + tablemodel.addRow(new String[] { String.valueOf(i + 1), headervals[i], "Keep" }); + } + + TableColumn optionColumn = table.getColumnModel().getColumn(2); + JComboBox comboBox = new JComboBox(); + comboBox.addItem("Keep"); + comboBox.addItem("Remove"); + comboBox.setSelectedIndex(0); + optionColumn.setCellEditor(new DefaultCellEditor(comboBox)); + + table.setFont(new Font("Times New Roman", Font.PLAIN, 14)); + table.setForeground(Color.RED); + table.setBackground(Color.BLACK); + scrollPane.setViewportView(table); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + + } + + public FeatureMetadataRemoveCols(String[] headervals, MetadataCollection obj, MetaOmTablePanel p, + boolean permanent) { + + if (obj == null) { + JOptionPane.showMessageDialog(p, "Error!!! Can't delete columns. No file read...", "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + setTitle("Metadata Column Filter"); + setBounds(100, 100, 450, 300); + contentPane = new JPanel(); + contentPane.setBackground(Color.DARK_GRAY); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + contentPane.setLayout(new BorderLayout(0, 0)); + setContentPane(contentPane); + JPanel panel = new JPanel(); + panel.setBackground(Color.DARK_GRAY); + panel.setFont(new Font("Garamond", Font.BOLD, 16)); + contentPane.add(panel, BorderLayout.NORTH); + JLabel lblRemoveColumns; + if (permanent) { + lblRemoveColumns = new JLabel("Remove Columns"); + } else { + lblRemoveColumns = new JLabel("Filter Columns"); + } + lblRemoveColumns.setForeground(Color.GREEN); + lblRemoveColumns.setFont(new Font("Garamond", Font.BOLD, 15)); + panel.add(lblRemoveColumns); + JPanel panel_1 = new JPanel(); + panel_1.setBackground(Color.DARK_GRAY); + contentPane.add(panel_1, BorderLayout.SOUTH); + JButton btnDone = new JButton("Done"); + panel_1.add(btnDone); + + JScrollPane scrollPane = new JScrollPane(); + scrollPane.setBackground(Color.DARK_GRAY); + contentPane.add(scrollPane, BorderLayout.CENTER); + + table = new JTable() { + @Override + public boolean isCellEditable(int row, int column) { // dont let edit first 2 cols + if (column == 0 || column == 1) { + return false; + } + return true; + } + }; + table.setRowMargin(3); + table.setRowHeight(25); + table.setIntercellSpacing(new Dimension(2, 2)); + table.setModel( + new DefaultTableModel(new Object[][] {}, new String[] { "Column number", "Header", "Keep/Remove" })); + // set default values + DefaultTableModel tablemodel = (DefaultTableModel) table.getModel(); + java.util.List curr_headers = Arrays.asList(headervals); + String[] allHeaders = obj.getHeaders(); + boolean[] toKeep = new boolean[allHeaders.length]; + for (int i = 0; i < allHeaders.length; i++) { + if (curr_headers.contains(allHeaders[i])) { + toKeep[i] = true; + } else { + toKeep[i] = false; + } + } + + for (int i = 0; i < allHeaders.length; i++) { + // skip data columns as it cant be removed + if (allHeaders[i].equals(MetaOmGraph.getActiveProject().getMetadataHybrid().getDataColName())) { + datacolIndex = i; + continue; + } + if (toKeep[i]) { + tablemodel.addRow(new String[] { String.valueOf(i + 1), allHeaders[i], "Keep" }); + } else { + tablemodel.addRow(new String[] { String.valueOf(i + 1), allHeaders[i], "Remove" }); + } + } + + TableColumn optionColumn = table.getColumnModel().getColumn(2); + JComboBox comboBox = new JComboBox(); + comboBox.addItem("Keep"); + comboBox.addItem("Remove"); + comboBox.setSelectedIndex(0); + optionColumn.setCellEditor(new DefaultCellEditor(comboBox)); + + table.setFont(new Font("Times New Roman", Font.PLAIN, 14)); + table.setForeground(Color.RED); + table.setBackground(Color.BLACK); + scrollPane.setViewportView(table); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + + // action + btnDone.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + + // get data from table + DefaultTableModel tablemodel = (DefaultTableModel) table.getModel(); + ArrayList deletedColumns = new ArrayList(); + int j = 0; + for (int i = 0; i < allHeaders.length; i++) { + if (i == datacolIndex) { + toKeep[i] = true; + continue; + } + if (tablemodel.getValueAt(j, 2).toString().equals("Keep")) { + toKeep[i] = true; + j++; + } else { + toKeep[i] = false; + deletedColumns.add(tablemodel.getValueAt(j, 1).toString()); + j++; + } + } + if (permanent) { + int result = JOptionPane.showConfirmDialog((Component) null, "This will delete selected columns. This can't be undone","alert", JOptionPane.OK_CANCEL_OPTION); + if(result==JOptionPane.CANCEL_OPTION) { + return; + } + // update headers in object + obj.setHeaders(allHeaders, toKeep); + // update data in table panel +// p.resetData(); +// p.updateTable(true); +// p.updateHeaders(); + MetaOmGraph.getActiveProject().getMetadataHybrid().setCurrentHeaders(obj.getHeaders()); + + //Harsha - reproducibility log + HashMap actionMap = new HashMap(); + actionMap.put("parent",MetaOmGraph.getCurrentProjectActionId()); + actionMap.put("section", "Sample Metadata Table"); + + HashMap dataMap = new HashMap(); + dataMap.put("Deleted Columns",deletedColumns); + + HashMap resultLog = new HashMap(); + resultLog.put("result", "OK"); + + ActionProperties deleteMetadataColumnsAction = new ActionProperties("delete-metadata-columns",actionMap,dataMap,resultLog,new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz").format(new Date())); + deleteMetadataColumnsAction.logActionProperties(); + + } else { + String[] newHeaders = removeExcluded(toKeep, allHeaders); +// p.setHeaders(newHeaders); +// p.updateTable(true); +// p.updateHeaders(); + MetaOmGraph.getActiveProject().getMetadataHybrid().setCurrentHeaders(newHeaders); + + //Harsha - reproducibility log + HashMap actionMap = new HashMap(); + actionMap.put("parent",MetaOmGraph.getCurrentProjectActionId()); + actionMap.put("section", "Sample Metadata Table"); + + HashMap dataMap = new HashMap(); + dataMap.put("Filtered Columns",deletedColumns); + + HashMap resultLog = new HashMap(); + resultLog.put("result", "OK"); + + ActionProperties filterMetadataColumnsAction = new ActionProperties("filter-metadata-columns",actionMap,dataMap,resultLog,new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz").format(new Date())); + filterMetadataColumnsAction.logActionProperties(); + } + getThisframe().dispose(); + + + //Harsha - reproducibility log + HashMap actionMap = new HashMap(); + actionMap.put("parent",MetaOmGraph.getCurrentProjectActionId()); + actionMap.put("section", "Sample Metadata Table"); + HashMap dataMap = new HashMap(); + + java.util.List remlist = new ArrayList<>(); + for (int i = 0; i < toKeep.length; i++) { + if (!toKeep[i]) { + remlist.add(headervals[i]); + } + } + + dataMap.put("removedColumns", remlist); +// dataMap.put("remainingColumns", p.getAllHeaders()); + HashMap resultLog = new HashMap(); + resultLog.put("result", "OK"); + + ActionProperties removeColumnsAction = new ActionProperties("remove-table-columns",actionMap,null,resultLog,new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz").format(new Date())); + removeColumnsAction.logActionProperties(); + } + }); + + } + + protected String[] removeExcluded(boolean[] toKeep, String[] headervals) { + java.util.List reslist = new ArrayList<>(); + for (int i = 0; i < toKeep.length; i++) { + if (toKeep[i]) { + reslist.add(headervals[i]); + } + } + return reslist.toArray(new String[0]); + } + + public void permanentlyRemoveHeaders() { + + } + + public String[] tempRemoveHeaders() { + String[] res = null; + return res; + } + +} diff --git a/src/edu/iastate/metnet/metaomgraph/ui/MetaOmTablePanel.java b/src/edu/iastate/metnet/metaomgraph/ui/MetaOmTablePanel.java index 61941d2c..dfd0b250 100644 --- a/src/edu/iastate/metnet/metaomgraph/ui/MetaOmTablePanel.java +++ b/src/edu/iastate/metnet/metaomgraph/ui/MetaOmTablePanel.java @@ -688,7 +688,7 @@ public void keyPressed(KeyEvent e) { dataToolbar.add(new Separator()); dataToolbar.add(searchPanel); dataToolbar.add(listFromFilterButton); - + // add advance filter button // s advFilterButton = new JButton("Advance filter"); @@ -696,7 +696,7 @@ public void keyPressed(KeyEvent e) { advFilterButton.addActionListener(this); advFilterButton.setToolTipText("Filter/search the table with multiple queries"); dataToolbar.add(advFilterButton); - + geneListPanel.setMinimumSize(listToolbar.getPreferredSize()); listSplitPane = new JSplitPane(1, true, geneListPanel, geneListDisplayPane); listSplitPane.setDividerSize(1); From 2fe304c4b3c60490f1d9f8ac837c8c280dfa15a7 Mon Sep 17 00:00:00 2001 From: "vk.sriharsha" Date: Sat, 10 Oct 2020 01:18:06 -0500 Subject: [PATCH 3/7] All logging and playback fixes --- pom.xml | 4 +- .../metnet/metaomgraph/MetaOmAnalyzer.java | 101 +++++- .../metnet/metaomgraph/MetaOmGraph.java | 29 +- .../metaomgraph/chart/MetaOmChartPanel.java | 7 +- .../metaomgraph/playback/PlaybackAction.java | 144 ++++++-- .../metaomgraph/ui/MetaOmTablePanel.java | 106 +++++- .../metnet/metaomgraph/ui/MetadataFilter.java | 31 +- .../ui/MetadataTableDisplayPanel.java | 99 +----- .../ui/MetadataTreeDisplayPanel.java | 35 +- .../ui/ReproducibilityDashboardPanel.java | 311 +++++++++--------- 10 files changed, 484 insertions(+), 383 deletions(-) diff --git a/pom.xml b/pom.xml index efc0cebb..be0c4b4f 100644 --- a/pom.xml +++ b/pom.xml @@ -39,11 +39,11 @@ - + diff --git a/src/edu/iastate/metnet/metaomgraph/MetaOmAnalyzer.java b/src/edu/iastate/metnet/metaomgraph/MetaOmAnalyzer.java index 27d3957f..ff0a151c 100644 --- a/src/edu/iastate/metnet/metaomgraph/MetaOmAnalyzer.java +++ b/src/edu/iastate/metnet/metaomgraph/MetaOmAnalyzer.java @@ -1,5 +1,6 @@ package edu.iastate.metnet.metaomgraph; +import edu.iastate.metnet.metaomgraph.logging.ActionProperties; import edu.iastate.metnet.metaomgraph.ui.BlockingProgressDialog; import edu.iastate.metnet.metaomgraph.ui.ClearableTextField; import edu.iastate.metnet.metaomgraph.ui.DualTablePanel; @@ -16,8 +17,11 @@ import java.io.FileWriter; import java.io.IOException; import java.text.DecimalFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Set; @@ -55,11 +59,49 @@ public MetaOmAnalyzer() { * @param excluded * list of excluded data cols */ - public static void updateExcluded(Set excluded) { + public static void updateExcluded(Set excluded, boolean loggingRequired) { if (excluded.size() == 0) { MetaOmAnalyzer.exclude = null; MetaOmAnalyzer.excludeCount = 0; MetaOmGraph.fixTitle(); + + HashMap actionMap = new HashMap(); + HashMap dataMap = new HashMap(); + HashMap result = new HashMap(); + + actionMap.put("parent", MetaOmGraph.getCurrentProjectActionId()); + + MetadataHybrid mdhObj = MetaOmGraph.getActiveProject().getMetadataHybrid(); + MetadataCollection mcol = null; + if(mdhObj != null) { + mcol = mdhObj.getMetadataCollection(); + } + if(exclude != null) { + boolean [] excludedSamplesBoolean = MetaOmAnalyzer.getExclude(); + List excludedSamplesInteger = new ArrayList(); + + for(int index=0; index < exclude.length; index++) { + if(exclude[index]) { + excludedSamplesInteger.add(index); + } + } + result.put("Excluded Samples", excludedSamplesInteger); + dataMap.put("Data Column", mcol.getDatacol()); + } + else { + result.put("Excluded Samples", new Integer[0]); + } + + result.put("result", "OK"); + + ActionProperties filterMetadataAction = new ActionProperties("filter-metadata", actionMap, dataMap, result, + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz").format(new Date())); + + if(loggingRequired) { + filterMetadataAction.logActionProperties(); + MetaOmGraph.setCurrentSamplesActionId(filterMetadataAction.getActionNumber()); + } + return; } else { @@ -74,6 +116,7 @@ public static void updateExcluded(Set excluded) { int excount = 0; String[] dataCols = MetaOmGraph.getActiveProject().getDataColumnHeaders(); for (int j = 0; j < dataCols.length; j++) { + String dc = dataCols[j]; if (excluded.contains(dataCols[j])) { exclude[j] = true; excount++; @@ -86,6 +129,46 @@ public static void updateExcluded(Set excluded) { MetaOmAnalyzer.excludeCount = excount; MetaOmGraph.fixTitle(); + + // Harsha - logging the sample filter action + + HashMap actionMap = new HashMap(); + HashMap dataMap = new HashMap(); + HashMap result = new HashMap(); + + actionMap.put("parent", MetaOmGraph.getCurrentProjectActionId()); + + MetadataHybrid mdhObj = MetaOmGraph.getActiveProject().getMetadataHybrid(); + MetadataCollection mcol = null; + if(mdhObj != null) { + mcol = mdhObj.getMetadataCollection(); + } + if(exclude != null) { + boolean [] excludedSamplesBoolean = MetaOmAnalyzer.getExclude(); + List excludedSamplesInteger = new ArrayList(); + + for(int index=0; index < exclude.length; index++) { + if(exclude[index]) { + excludedSamplesInteger.add(index); + } + } + result.put("Excluded Samples", excludedSamplesInteger); + dataMap.put("Data Column", mcol.getDatacol()); + } + else { + result.put("Excluded Samples", new Integer[0]); + } + + result.put("result", "OK"); + + ActionProperties filterMetadataAction = new ActionProperties("filter-metadata", actionMap, dataMap, result, + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz").format(new Date())); + + if(loggingRequired) { + filterMetadataAction.logActionProperties(); + MetaOmGraph.setCurrentSamplesActionId(filterMetadataAction.getActionNumber()); + } + return; } @@ -148,7 +231,7 @@ public static void doAnalysis(final MetaOmProject project, String geneList, fina final Number[] result = new Number[project.getRowCount()]; // final Number[] result; String message = project.getRowName(entries[row])[project.getDefaultColumn()] + ""; - + if (method == 1) { message = message + " - Pearson Correlation"; } else if (method == 2) { @@ -368,7 +451,7 @@ public Object construct() { if ((row == 0) && (bufferSize < 0L)) { //System.gc(); - + long freemem = Runtime.getRuntime().freeMemory(); long maxmem = Runtime.getRuntime().maxMemory(); long totmem = Runtime.getRuntime().totalMemory(); @@ -584,9 +667,9 @@ public Object construct() { long timeStarted = System.nanoTime(); String timeString = "Preparing..."; for (int row = 0; (row < entries.length) && (!progress.isCanceled()); row++) { - + double[] sourceData = project.getIncludedData(entries[row]); - + CorrelationCalc calcy = new CorrelationCalc(sourceData, MetaOmAnalyzer.exclude); @@ -628,7 +711,7 @@ public Object construct() { //JOptionPane.showMessageDialog(null, "buff size:"+dataBuffer.size()); } else { //long st = System.currentTimeMillis(); - + data = project.getIncludedData(entries[i]); //long spt = System.currentTimeMillis(); //long elapsedTime = spt - st; @@ -656,7 +739,7 @@ public Object construct() { if ((row == 0) && (i >= entries.length - bufferSize)) { dataBuffer.add(data); } - + if (nameCol >= 0) { out.write(rowNames[row][nameCol] + "\t" + rowNames[i][nameCol]); } else { @@ -770,7 +853,7 @@ public static void showExcludeDialog(MetaOmProject myProject, Frame parent) { } private static class ExcludeDialog extends JDialog - implements ActionListener, HashLoadable { + implements ActionListener, HashLoadable { private MetaOmProject myProject; private DualTablePanel dtp; @@ -857,7 +940,7 @@ public ExcludeDialog(Frame parent, String title, boolean modal, MetaOmProject my buttonPanel.add(cancelButton); dtp.getButtonPanel() - .add(Box.createRigidArea(new Dimension(0, metadataExcludeButton.getPreferredSize().height))); + .add(Box.createRigidArea(new Dimension(0, metadataExcludeButton.getPreferredSize().height))); dtp.getButtonPanel().add(metadataExcludeButton); dtp.getButtonPanel().add(metadataIncludeButton); HashtableSavePanel savePanel = new HashtableSavePanel(myProject.getSavedExcludes(), this); diff --git a/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java b/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java index 55c281ce..d99d48c6 100644 --- a/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java +++ b/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java @@ -2202,7 +2202,7 @@ public void finished() { String projectName = projFileName.substring(projFileName.lastIndexOf(File.separator)+1,projFileName.lastIndexOf('.')); String currDate = new SimpleDateFormat("yyyy-MM-dd_HHmmss").format(new Date()); - String logFilePath = projFileName.substring(0,projFileName.lastIndexOf(File.separator))+File.separator+"logs"+File.separator+projectName+"_"+currDate+".log"; + String logFilePath = projFileName.substring(0,projFileName.lastIndexOf(File.separator))+File.separator+"moglog"+File.separator+projectName+"_"+currDate+".log"; logger = updateLogger(logFilePath); @@ -2328,7 +2328,7 @@ public void run() { String projFileName = source.getAbsolutePath(); String projectName = projFileName.substring(projFileName.lastIndexOf(File.separator)+1,projFileName.lastIndexOf('.')); String currDate = new SimpleDateFormat("yyyy-MM-dd_HHmmss").format(new Date()); - String logFilePath = projFileName.substring(0,projFileName.lastIndexOf(File.separator))+File.separator+"logs"+File.separator+projectName+"_"+currDate+".log"; + String logFilePath = projFileName.substring(0,projFileName.lastIndexOf(File.separator))+File.separator+"moglog"+File.separator+projectName+"_"+currDate+".log"; if(getLoggingRequired()) { logger = updateLogger(logFilePath); @@ -3884,7 +3884,7 @@ public boolean isSqrt() { * * @return */ - public String getTransform() { + public static String getTransform() { if (log2Item.isSelected()) { return "log2"; } else if (log10Item.isSelected()) { @@ -4107,8 +4107,8 @@ public static void createReproducibilityLoggingFrame() { ReproducibilityDashboardFrame.show(); - UIManager.put("InternalFrame.activeTitleBackground", new ColorUIResource(new Color(0,197,205))); - UIManager.put("InternalFrame.inactiveTitleBackground", new ColorUIResource(new Color(0,197,205))); + UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); + UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); UIManager.put("InternalFrame.titleFont", oldFont); @@ -4187,13 +4187,24 @@ public static void logGeneralProperties() { if(mdhObj != null) { mcol = mdhObj.getMetadataCollection(); } - if(mcol != null) { - result.put("Included Samples", mcol.getIncluded()); - result.put("Excluded Samples", mcol.getExcluded()); + if(MetaOmAnalyzer.getExclude() != null) { + boolean [] excludedSamplesBoolean = MetaOmAnalyzer.getExclude(); + List excludedSamplesInteger = new ArrayList(); + + for(int index=0; index < excludedSamplesBoolean.length; index++) { + if(excludedSamplesBoolean[index]) { + excludedSamplesInteger.add(index); + } + } + result.put("Excluded Samples", excludedSamplesInteger.toArray(new Integer[excludedSamplesInteger.size()])); + dataMap.put("Data Column", mcol.getDatacol()); + } + else { + result.put("Excluded Samples", new Integer[0]); dataMap.put("Data Column", mcol.getDatacol()); } dataMap.put("Start Timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz").format(new Date())); - + result.put("result", "OK"); ActionProperties generalPropertiesAction = new ActionProperties("general-properties",actionMap,dataMap,result,new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz").format(new Date())); diff --git a/src/edu/iastate/metnet/metaomgraph/chart/MetaOmChartPanel.java b/src/edu/iastate/metnet/metaomgraph/chart/MetaOmChartPanel.java index f271e56d..499702ab 100644 --- a/src/edu/iastate/metnet/metaomgraph/chart/MetaOmChartPanel.java +++ b/src/edu/iastate/metnet/metaomgraph/chart/MetaOmChartPanel.java @@ -1203,11 +1203,10 @@ public void createInternalFrame(boolean playback) { myParent.setIconifiable(true); myParent.setMaximizable(true); myParent.setFrameIcon(new ImageIcon(getClass().getResource("/resource/MetaOmicon16.png"))); - myParent.getRootPane().setWindowDecorationStyle(3); - UIManager.put("InternalFrame.activeTitleBackground", new ColorUIResource(new Color(240,128,128))); - UIManager.put("InternalFrame.inactiveTitleBackground", new ColorUIResource(new Color(240,128,128))); - UIManager.put("InternalFrame.titleFont", new Font("SansSerif", Font.BOLD,12)); +// UIManager.put("InternalFrame.activeTitleBackground", new ColorUIResource(new Color(240,128,128))); +// UIManager.put("InternalFrame.inactiveTitleBackground", new ColorUIResource(new Color(240,128,128))); +// UIManager.put("InternalFrame.titleFont", new Font("SansSerif", Font.BOLD,12)); javax.swing.plaf.basic.BasicInternalFrameUI ui = new javax.swing.plaf.basic.BasicInternalFrameUI(myParent); diff --git a/src/edu/iastate/metnet/metaomgraph/playback/PlaybackAction.java b/src/edu/iastate/metnet/metaomgraph/playback/PlaybackAction.java index 7ce9cc8c..804fedaf 100644 --- a/src/edu/iastate/metnet/metaomgraph/playback/PlaybackAction.java +++ b/src/edu/iastate/metnet/metaomgraph/playback/PlaybackAction.java @@ -1,8 +1,10 @@ package edu.iastate.metnet.metaomgraph.playback; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -48,6 +50,7 @@ public class PlaybackAction { private static final String SELECTED_COLUMN_PROPERTY = "Selected Column"; private static final String CORRELATION_COLUMN_PROPERTY = "Correlation Column"; private static final String PLAYABLE_PROPERTY = "Playable"; + private static final String TRANSFORMATION_PROPERTY = "Data Transformation"; /** @@ -95,17 +98,55 @@ public void playActions(int tabNo, JTree selectedTree, TreePath[] allPaths, Hash ActionProperties sampleAction = allTabsInfo.get(tabNo).getActionObjects().get(i); - - if(sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY) instanceof List) { - excludedSamples = new HashSet((List)sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY)); + String [] samples = MetaOmGraph.getActiveProject().getDataColumnHeaders(); + LinkedList allSamplesList = new LinkedList(Arrays.asList(samples)); + LinkedList copyAllSamplesList = new LinkedList(Arrays.asList(samples)); + Object [] exclSamples = null; + + if(sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY) instanceof List ) { + List exclSamplesList2 = (List)sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY); + exclSamples = exclSamplesList2.toArray(); } else if(sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY) instanceof HashSet) { - excludedSamples = (HashSet)sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY); + HashSet exclSamplesList2 = (HashSet)sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY); + exclSamples = exclSamplesList2.toArray(); + } + else if(sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY) instanceof Integer[]) { + exclSamples = (Object[])sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY); + } + + + for(int eindex = 0; eindex < exclSamples.length; eindex++) { + + int excludedindex = 0; + if(exclSamples[eindex] instanceof Double) { + Double a = (Double)exclSamples[eindex]; + excludedindex = a.intValue(); + } + else if(exclSamples[eindex] instanceof Integer) { + excludedindex = (int)exclSamples[eindex]; + } + + + excludedSamples.add(copyAllSamplesList.get(excludedindex)); + try { + allSamplesList.remove(copyAllSamplesList.get(excludedindex)); + } + catch(Exception e) { + StackTraceElement[] ste = e.getStackTrace(); + } } + + for(int iindex = 0; iindex < allSamplesList.size(); iindex++) { + includedSamples.add(allSamplesList.get(iindex)); + } + + //urmi //break; } + } @@ -132,7 +173,7 @@ else if(sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY) instanc - } + } } } @@ -151,35 +192,62 @@ else if(sampleAction.getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY) instanc */ public void playChart(ActionProperties chartAction, String chartName, HashSet includedSamples, HashSet excludedSamples) { - int val2[] = null; + Map genes = null; - + String currentTransformation = MetaOmGraph.getTransform(); + int val2[] = null; try { if(chartAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY) != null) { - genes = (Map)chartAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY); - - Integer [] val = new Integer[genes.size()]; - - - int j = 0; - for (Map.Entry entry : genes.entrySet()) { - if(entry.getKey() instanceof String){ - val[j++] = Integer.parseInt((String)entry.getKey()); + + if(chartAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY) instanceof List ) { + List selFeaturesList = (List)chartAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY); + Double[] selFeaturesDouble = new Double[selFeaturesList.size()]; + + for( int fno = 0 ; fno < selFeaturesList.size(); fno++ ) { + selFeaturesDouble[fno] = (Double)selFeaturesList.get(fno); } - else if(entry.getKey() instanceof Integer) { - val[j++] = (Integer)entry.getKey(); + + val2 = new int[selFeaturesDouble.length]; + + for( int i =0; i< selFeaturesDouble.length; i++ ) { + val2[i] = selFeaturesDouble[i].intValue(); } } - - val2 = new int[val.length]; - - //urmi add in reverse order - for (int i=val.length-1;i>=0;i--) { - System.out.println(i); - System.out.println(val.length-i); - val2[val.length-1-i] = val[i]; + else if(chartAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY) instanceof HashSet) { + HashSet selFeaturesHashSet = (HashSet)chartAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY); + Double[] selFeaturesDouble = new Double[selFeaturesHashSet.size()]; + + selFeaturesDouble = selFeaturesHashSet.toArray(selFeaturesDouble); + val2 = new int[selFeaturesDouble.length]; + + for( int i =0; i< selFeaturesDouble.length; i++ ) { + val2[i] = selFeaturesDouble[i].intValue(); + } + + } + else if(chartAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY) instanceof Integer[]) { + Integer[] selFeaturesIntArray = (Integer[])chartAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY); + + val2 = new int[selFeaturesIntArray.length]; + + for( int i =0; i< selFeaturesIntArray.length; i++ ) { + val2[i] = (int)selFeaturesIntArray[i]; + } + } + else if(chartAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY) instanceof Double[]) { + Double[] selFeaturesDoubleArray = (Double[])chartAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY); + + val2 = new int[selFeaturesDoubleArray.length]; + + for( int i =0; i< selFeaturesDoubleArray.length; i++ ) { + val2[i] = selFeaturesDoubleArray[i].intValue(); + } + } + else { + val2 = (int[])chartAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY); } + } @@ -206,9 +274,12 @@ else if(entry.getKey() instanceof Integer) { //@Harsha set data transformation + + String historicalTransformation = (String) chartAction.getDataParameters().get(TRANSFORMATION_PROPERTY); + MetaOmGraph.setTransform(historicalTransformation); - - + + //Run the chart MetaOmTablePanel mp = MetaOmGraph.getActiveTablePanel(); if(chartName == LINE_CHART_COMMAND) { @@ -216,7 +287,7 @@ else if(entry.getKey() instanceof Integer) { mcol.setIncluded(includedSamples); mcol.setExcluded(excludedSamples); //update the excluded samples - MetaOmAnalyzer.updateExcluded(excludedSamples); + MetaOmAnalyzer.updateExcluded(excludedSamples, false); //make chart mp.graphSelectedRows(val2); @@ -224,7 +295,7 @@ else if(entry.getKey() instanceof Integer) { //reset samples to current mcol.setIncluded(currentProjectIncludedSamples); mcol.setExcluded(currentProjectExcludedSamples); - MetaOmAnalyzer.updateExcluded(currentProjectExcludedSamples); + MetaOmAnalyzer.updateExcluded(currentProjectExcludedSamples, false); } else if(chartName == BOX_PLOT_COMMAND) { mp.makeBoxPlot(val2,toExcludeSamples); @@ -241,21 +312,21 @@ else if(chartName == LINE_CHART_DEFAULT_GROUPING_COMMAND) { mcol.setIncluded(includedSamples); mcol.setExcluded(excludedSamples); //update the excluded samples - MetaOmAnalyzer.updateExcluded(excludedSamples); + MetaOmAnalyzer.updateExcluded(excludedSamples, false); mp.plotLineChartDefaultGrouping(val2); //reset samples to current mcol.setIncluded(currentProjectIncludedSamples); mcol.setExcluded(currentProjectExcludedSamples); - MetaOmAnalyzer.updateExcluded(currentProjectExcludedSamples); + MetaOmAnalyzer.updateExcluded(currentProjectExcludedSamples, false); } else if(chartName == LINE_CHART_CHOOSE_GROUPING_COMMAND) { //for line chart mcol.setIncluded(includedSamples); mcol.setExcluded(excludedSamples); //update the excluded samples - MetaOmAnalyzer.updateExcluded(excludedSamples); + MetaOmAnalyzer.updateExcluded(excludedSamples, false); String groupChosen = (String)chartAction.getDataParameters().get(GROUPING_ATTRIBUTE_PROPERTY); mp.plotLineChartChooseGrouping(val2, groupChosen); @@ -263,7 +334,7 @@ else if(chartName == LINE_CHART_CHOOSE_GROUPING_COMMAND) { //reset samples to current; mcol.setIncluded(currentProjectIncludedSamples); mcol.setExcluded(currentProjectExcludedSamples); - MetaOmAnalyzer.updateExcluded(currentProjectExcludedSamples); + MetaOmAnalyzer.updateExcluded(currentProjectExcludedSamples, false); } else if(chartName == BAR_CHART_COMMAND) { @@ -276,11 +347,12 @@ else if(chartName == CORRELATION_HISTOGRAM_COMMAND) { } - - + //Setting back transformation to current transformation + MetaOmGraph.setTransform(currentTransformation); } catch(Exception e) { + MetaOmGraph.setTransform(currentTransformation); JOptionPane.showMessageDialog(null, "Failed to playback!!!" + e, "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); diff --git a/src/edu/iastate/metnet/metaomgraph/ui/MetaOmTablePanel.java b/src/edu/iastate/metnet/metaomgraph/ui/MetaOmTablePanel.java index f56460c8..88a5a7f2 100644 --- a/src/edu/iastate/metnet/metaomgraph/ui/MetaOmTablePanel.java +++ b/src/edu/iastate/metnet/metaomgraph/ui/MetaOmTablePanel.java @@ -1255,7 +1255,7 @@ public void graphSelectedRows() { String selList = geneLists.getSelectedValue().toString(); dataMap.put("Selected List", selList); - dataMap.put("Selected Features", getSelectedGeneNames()); + dataMap.put("Selected Features", getSelectedRowsInList()); dataMap.put("Data Transformation", MetaOmGraph.getInstance().getTransform()); dataMap.put("XAxis", myProject.getDefaultXAxis()); dataMap.put("YAxis", myProject.getDefaultYAxis()); @@ -1286,6 +1286,10 @@ public void graphSelectedRows() { */ public void graphSelectedRows(int[] selectedRows) { + ColorUIResource oldActiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.activeTitleBackground"); + ColorUIResource oldInactiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.inactiveTitleBackground"); + Font oldFont = UIManager.getFont("InternalFrame.titleFont"); + MetadataHybrid mhyb = MetaOmGraph.getActiveProject().getMetadataHybrid(); if (mhyb != null) { MetadataCollection mcol = mhyb.getMetadataCollection(); @@ -1295,7 +1299,10 @@ public void graphSelectedRows(int[] selectedRows) { Set currentProjectExcludedSamples = mcol.getExcluded(); // MetaOmGraph.getActiveTable().updateMetadataTree(); - + UIManager.put("InternalFrame.activeTitleBackground", new ColorUIResource(new Color(240,128,128))); + UIManager.put("InternalFrame.inactiveTitleBackground", new ColorUIResource(new Color(240,128,128))); + UIManager.put("InternalFrame.titleFont", new Font("SansSerif", Font.BOLD,12)); + new MetaOmChartPanel(selectedRows, myProject.getDefaultXAxis(), myProject.getDefaultYAxis(), myProject.getDefaultTitle(), myProject.getColor1(), myProject.getColor2(), myProject) .createInternalFrame(true); @@ -1307,6 +1314,9 @@ public void graphSelectedRows(int[] selectedRows) { } } + UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); + UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); + UIManager.put("InternalFrame.titleFont", oldFont); } public void createHistogram() { @@ -1321,7 +1331,7 @@ public void createHistogram() { String selList = geneLists.getSelectedValue().toString(); dataMap.put("Selected List", selList); - dataMap.put("Selected Features", getSelectedGeneNames()); + dataMap.put("Selected Features", getSelectedRowsInList()); dataMap.put("Data Transformation", MetaOmGraph.getInstance().getTransform()); dataMap.put("XAxis", myProject.getDefaultXAxis()); dataMap.put("YAxis", myProject.getDefaultYAxis()); @@ -1388,6 +1398,10 @@ public void run() { */ public void createHistogram(int[] selected,boolean[] excludedSamples) { + ColorUIResource oldActiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.activeTitleBackground"); + ColorUIResource oldInactiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.inactiveTitleBackground"); + Font oldFont = UIManager.getFont("InternalFrame.titleFont"); + EventQueue.invokeLater(new Runnable() { @Override public void run() { @@ -1419,10 +1433,17 @@ public void run() { f.setSize(1000, 700); f.setVisible(true); f.toFront(); + + UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); + UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); + UIManager.put("InternalFrame.titleFont", oldFont); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Histogram: Error occured while reading data!!!" + e, "Error", JOptionPane.ERROR_MESSAGE); + UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); + UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); + UIManager.put("InternalFrame.titleFont", oldFont); //JOptionPane.showMessageDialog(null, e.toString()); //e.printStackTrace(); @@ -1450,7 +1471,7 @@ public void makeBoxPlot() { String selList = geneLists.getSelectedValue().toString(); dataMap.put("Selected List", selList); - dataMap.put("Selected Features", getSelectedGeneNames()); + dataMap.put("Selected Features", getSelectedRowsInList()); dataMap.put("Data Transformation", MetaOmGraph.getInstance().getTransform()); dataMap.put("XAxis", myProject.getDefaultXAxis()); dataMap.put("YAxis", myProject.getDefaultYAxis()); @@ -1546,6 +1567,11 @@ public void makeBoxPlot(int[] selected, boolean[] excludedSamples) { return; } + ColorUIResource oldActiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.activeTitleBackground"); + ColorUIResource oldInactiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.inactiveTitleBackground"); + Font oldFont = UIManager.getFont("InternalFrame.titleFont"); + + // get data for box plot as hasmap HashMap plotData = new HashMap<>(); for (int i = 0; i < selected.length; i++) { @@ -1585,10 +1611,18 @@ public void run() { f.setSize(1000, 700); f.setVisible(true); f.toFront(); + + UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); + UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); + UIManager.put("InternalFrame.titleFont", oldFont); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error occured while reading data!!!", "Error", JOptionPane.ERROR_MESSAGE); + + UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); + UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); + UIManager.put("InternalFrame.titleFont", oldFont); e.printStackTrace(); return; } @@ -1611,7 +1645,7 @@ public void graphPairs() { String selList = geneLists.getSelectedValue().toString(); dataMap.put("Selected List", selList); - dataMap.put("Selected Features", getSelectedGeneNames()); + dataMap.put("Selected Features", getSelectedRowsInList()); dataMap.put("Data Transformation", MetaOmGraph.getInstance().getTransform()); dataMap.put("XAxis", myProject.getDefaultXAxis()); dataMap.put("YAxis", myProject.getDefaultYAxis()); @@ -1698,6 +1732,10 @@ public void graphPairs(int[] selected,boolean[] excludedSamples) { return; } + ColorUIResource oldActiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.activeTitleBackground"); + ColorUIResource oldInactiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.inactiveTitleBackground"); + Font oldFont = UIManager.getFont("InternalFrame.titleFont"); + EventQueue.invokeLater(new Runnable() { @Override public void run() { @@ -1722,10 +1760,18 @@ public void run() { f.setSize(1000, 700); f.setVisible(true); f.toFront(); + + UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); + UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); + UIManager.put("InternalFrame.titleFont", oldFont); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error occured while reading data!!!", "Error", JOptionPane.ERROR_MESSAGE); + UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); + UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); + UIManager.put("InternalFrame.titleFont", oldFont); + e.printStackTrace(); return; } @@ -1833,7 +1879,7 @@ public void plotLineChartDefaultGrouping() { String selList = geneLists.getSelectedValue().toString(); dataMap.put("Selected List", selList); - dataMap.put("Selected Features", getSelectedGeneNames()); + dataMap.put("Selected Features", getSelectedRowsInList()); dataMap.put("Data Transformation", MetaOmGraph.getInstance().getTransform()); dataMap.put("XAxis", myProject.getDefaultXAxis()); dataMap.put("YAxis", myProject.getDefaultYAxis()); @@ -1930,6 +1976,11 @@ public void plotLineChartDefaultGrouping(int[] selectedRows) { JOptionPane.showMessageDialog(MetaOmGraph.getMainWindow(), "No data to calculate rep information..."); return; } + + ColorUIResource oldActiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.activeTitleBackground"); + ColorUIResource oldInactiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.inactiveTitleBackground"); + Font oldFont = UIManager.getFont("InternalFrame.titleFont"); + // plot reps int[] selected = selectedRows; // JOptionPane.showMessageDialog(null, "Selected rows:" + @@ -1954,6 +2005,10 @@ public void plotLineChartDefaultGrouping(int[] selectedRows) { return; } } + + UIManager.put("InternalFrame.activeTitleBackground", new ColorUIResource(new Color(240,128,128))); + UIManager.put("InternalFrame.inactiveTitleBackground", new ColorUIResource(new Color(240,128,128))); + UIManager.put("InternalFrame.titleFont", new Font("SansSerif", Font.BOLD,12)); // plot MetaOmChartPanel ob = new MetaOmChartPanel(selected, "Groups", myProject.getDefaultYAxis(), @@ -1962,6 +2017,10 @@ public void plotLineChartDefaultGrouping(int[] selectedRows) { ob.createInternalFrame(true); + UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); + UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); + UIManager.put("InternalFrame.titleFont", oldFont); + return; } @@ -1980,7 +2039,7 @@ public void plotLineChartChooseGrouping() { String selList = geneLists.getSelectedValue().toString(); dataMap.put("Selected List", selList); - dataMap.put("Selected Features", getSelectedGeneNames()); + dataMap.put("Selected Features", getSelectedRowsInList()); dataMap.put("Data Transformation", MetaOmGraph.getInstance().getTransform()); dataMap.put("XAxis", myProject.getDefaultXAxis()); dataMap.put("YAxis", myProject.getDefaultYAxis()); @@ -2087,6 +2146,10 @@ public void plotLineChartChooseGrouping(int[] selectedRows, String groupChosen) JOptionPane.showMessageDialog(MetaOmGraph.getMainWindow(), "No data to calculate rep information..."); return; } + + ColorUIResource oldActiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.activeTitleBackground"); + ColorUIResource oldInactiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.inactiveTitleBackground"); + Font oldFont = UIManager.getFont("InternalFrame.titleFont"); // show jdialog to show all metadata attributes String[] headers = myProject.getMetadataHybrid().getMetadataHeaders(true); @@ -2122,12 +2185,20 @@ public void plotLineChartChooseGrouping(int[] selectedRows, String groupChosen) return; } } + + UIManager.put("InternalFrame.activeTitleBackground", new ColorUIResource(new Color(240,128,128))); + UIManager.put("InternalFrame.inactiveTitleBackground", new ColorUIResource(new Color(240,128,128))); + UIManager.put("InternalFrame.titleFont", new Font("SansSerif", Font.BOLD,12)); MetaOmChartPanel ob = new MetaOmChartPanel(selected, "Groups", myProject.getDefaultYAxis(), myProject.getDefaultTitle(), myProject.getColor1(), myProject.getColor2(), myProject, myVals, myStddevs, repCounts, groupNames, sampleNames, true, repsMap); ob.createInternalFrame(true); + UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); + UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); + UIManager.put("InternalFrame.titleFont", oldFont); + return; } @@ -2803,7 +2874,7 @@ public void run() { HashMap dataMap = new HashMap(); String selList = geneLists.getSelectedValue().toString(); dataMap.put("Selected List", selList); - dataMap.put("Selected Features", getSelectedGeneNames()); + dataMap.put("Selected Features", getSelectedRowsInList()); dataMap.put("Data Transformation", MetaOmGraph.getInstance().getTransform()); HashMap result = new HashMap(); @@ -4455,9 +4526,9 @@ public void run() { HashMap dataMap = new HashMap(); String selList = geneLists.getSelectedValue().toString(); dataMap.put("selectedList", selList); - dataMap.put("selectedGenes", + dataMap.put("selectedFeatures", - getSelectedGeneNames()); + getSelectedRowsInList()); dataMap.put("transformationData", MetaOmGraph.getInstance().getTransform()); HashMap resultLog = new HashMap(); @@ -4542,9 +4613,9 @@ public void run() { HashMap dataMap = new HashMap(); String selList = geneLists.getSelectedValue().toString(); dataMap.put("selectedList", selList); - dataMap.put("selectedGenes", + dataMap.put("selectedFeatures", - getSelectedGeneNames()); + getSelectedRowsInList()); HashMap resultLog = new HashMap(); resultLog.put("result", "OK"); @@ -5836,6 +5907,10 @@ public void plotCorrHist(String col_val, boolean playback) { return; } + ColorUIResource oldActiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.activeTitleBackground"); + ColorUIResource oldInactiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.inactiveTitleBackground"); + Font oldFont = UIManager.getFont("InternalFrame.titleFont"); + List corrVals = getCorrData(col_val); // create histogram @@ -5849,10 +5924,6 @@ public void run() { } double[] data = corrVals.stream().mapToDouble(d -> d).toArray(); - ColorUIResource oldActiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.activeTitleBackground"); - ColorUIResource oldInactiveTitleBackground = (ColorUIResource) UIManager.get("InternalFrame.inactiveTitleBackground"); - Font oldFont = UIManager.getFont("InternalFrame.titleFont"); - HistogramChart f = new HistogramChart(null, nBins, null, 2, data, false); UIManager.put("InternalFrame.activeTitleBackground", new ColorUIResource(new Color(240, 128, 128))); @@ -5882,6 +5953,9 @@ public void run() { JOptionPane.showMessageDialog(null, "Error occured while reading data!!!", "Error", JOptionPane.ERROR_MESSAGE); + UIManager.put("InternalFrame.activeTitleBackground", oldActiveTitleBackground); + UIManager.put("InternalFrame.inactiveTitleBackground", oldInactiveTitleBackground); + UIManager.put("InternalFrame.titleFont", oldFont); e.printStackTrace(); return; diff --git a/src/edu/iastate/metnet/metaomgraph/ui/MetadataFilter.java b/src/edu/iastate/metnet/metaomgraph/ui/MetadataFilter.java index 1086c6e9..333eaf9e 100644 --- a/src/edu/iastate/metnet/metaomgraph/ui/MetadataFilter.java +++ b/src/edu/iastate/metnet/metaomgraph/ui/MetadataFilter.java @@ -190,7 +190,7 @@ public void actionPerformed(ActionEvent e) { updateIncludedlist(); // update exclude list // JOptionPane.showMessageDialog(null, "exlist"+excluded.toString()); - MetaOmAnalyzer.updateExcluded(metadataCollection.getExcluded()); + MetaOmAnalyzer.updateExcluded(metadataCollection.getExcluded(), true); } MetaOmGraph.getActiveTable().updateMetadataTable(); MetaOmGraph.getActiveTable().updateMetadataTree(); @@ -693,35 +693,6 @@ public void updateIncludedlist() { HashMap dataMap = new HashMap(); HashMap result = new HashMap(); - try { - - actionMap.put("parent",MetaOmGraph.getCurrentProjectActionId()); - actionMap.put("section", "Feature Metadata"); - - MetadataHybrid mhyb = MetaOmGraph.getActiveProject().getMetadataHybrid(); - if(mhyb !=null) { - MetadataCollection mcol = mhyb.getMetadataCollection(); - if(mcol!= null) { - dataMap.put("Data Column", mcol.getDatacol()); - result.put("Included Samples", mcol.getIncluded()); - result.put("Excluded Samples", mcol.getExcluded()); - } - } - else { - result.put("Included Samples", null); - result.put("Excluded Samples", null); - } - - result.put("result", "OK"); - - ActionProperties sampleFilterAction = new ActionProperties("sample-advance-filter",actionMap,dataMap,result,new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz").format(new Date())); - sampleFilterAction.logActionProperties(); - - MetaOmGraph.setCurrentSamplesActionId(sampleFilterAction.getActionNumber()); - } - catch(Exception e1) { - - } } public void removeExcludedRows() { diff --git a/src/edu/iastate/metnet/metaomgraph/ui/MetadataTableDisplayPanel.java b/src/edu/iastate/metnet/metaomgraph/ui/MetadataTableDisplayPanel.java index 7d362878..76fa8c29 100644 --- a/src/edu/iastate/metnet/metaomgraph/ui/MetadataTableDisplayPanel.java +++ b/src/edu/iastate/metnet/metaomgraph/ui/MetadataTableDisplayPanel.java @@ -542,7 +542,7 @@ public void actionPerformed(ActionEvent arg0) { // clear last searched clearLastSearchedRows(); // update exclude list - MetaOmAnalyzer.updateExcluded(obj.getExcluded()); + MetaOmAnalyzer.updateExcluded(obj.getExcluded(),true); updateTable(); MetaOmGraph.getActiveTable().updateMetadataTree(); @@ -1607,7 +1607,7 @@ public void toggleSortOrder(int column) { Set excluded = new HashSet(getExcludedRowsFromTable(rowsInList)); obj.setIncluded(rowsInList); obj.setExcluded(excluded); - MetaOmAnalyzer.updateExcluded(excluded); + MetaOmAnalyzer.updateExcluded(excluded, true); MetaOmGraph.getActiveTable().updateMetadataTree(); } @@ -1814,44 +1814,12 @@ public void filterSelectedRows(boolean invert) { obj.setExcluded(exc); obj.setIncluded(inc); // update exclude list - MetaOmAnalyzer.updateExcluded(exc); + MetaOmAnalyzer.updateExcluded(exc, true); // remove selected rows from search result removeFromtoHighlight(removedList); updateTable(); MetaOmGraph.getActiveTable().updateMetadataTree(); - HashMap actionMap = new HashMap(); - HashMap dataMap = new HashMap(); - HashMap result = new HashMap(); - - try { - - actionMap.put("parent", MetaOmGraph.getCurrentProjectActionId()); - actionMap.put("section", "Feature Metadata"); - - MetadataHybrid mhyb = MetaOmGraph.getActiveProject().getMetadataHybrid(); - if (mhyb != null) { - MetadataCollection mcol = mhyb.getMetadataCollection(); - if (mcol != null) { - dataMap.put("Data Column", mcol.getDatacol()); - result.put("Included Samples", mcol.getIncluded()); - result.put("Excluded Samples", mcol.getExcluded()); - } - } else { - result.put("Included Samples", null); - result.put("Excluded Samples", null); - } - - result.put("result", "OK"); - - ActionProperties sampleFilterAction = new ActionProperties("sample-advance-filter", actionMap, dataMap, - result, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz").format(new Date())); - sampleFilterAction.logActionProperties(); - - MetaOmGraph.setCurrentSamplesActionId(sampleFilterAction.getActionNumber()); - } catch (Exception e1) { - - } } public void filterHighlightedRows(boolean invert) { @@ -1890,7 +1858,7 @@ public void filterHighlightedRows(boolean invert) { obj.setExcluded(exc); obj.setIncluded(inc); // update exclude list - MetaOmAnalyzer.updateExcluded(exc); + MetaOmAnalyzer.updateExcluded(exc, true); // after filtering updateTable(); MetaOmGraph.getActiveTable().updateMetadataTree(); @@ -1906,34 +1874,6 @@ public void filterHighlightedRows(boolean invert) { HashMap dataMap = new HashMap(); HashMap result = new HashMap(); - try { - - actionMap.put("parent", MetaOmGraph.getCurrentProjectActionId()); - actionMap.put("section", "Feature Metadata"); - - MetadataHybrid mhyb = MetaOmGraph.getActiveProject().getMetadataHybrid(); - if (mhyb != null) { - MetadataCollection mcol = mhyb.getMetadataCollection(); - if (mcol != null) { - dataMap.put("Data Column", mcol.getDatacol()); - result.put("Included Samples", mcol.getIncluded()); - result.put("Excluded Samples", mcol.getExcluded()); - } - } else { - result.put("Included Samples", null); - result.put("Excluded Samples", null); - } - - result.put("result", "OK"); - - ActionProperties sampleFilterAction = new ActionProperties("sample-advance-filter", actionMap, dataMap, - result, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz").format(new Date())); - sampleFilterAction.logActionProperties(); - - MetaOmGraph.setCurrentSamplesActionId(sampleFilterAction.getActionNumber()); - } catch (Exception e1) { - - } } public void filterRows(List s) { @@ -1954,40 +1894,13 @@ public void filterRows(List s) { obj.setExcluded(exc); obj.setIncluded(inc); // update exclude list - MetaOmAnalyzer.updateExcluded(exc); + MetaOmAnalyzer.updateExcluded(exc, true); HashMap actionMap = new HashMap(); HashMap dataMap = new HashMap(); HashMap result = new HashMap(); - try { - - actionMap.put("parent", MetaOmGraph.getCurrentProjectActionId()); - actionMap.put("section", "Feature Metadata"); - - MetadataHybrid mhyb = MetaOmGraph.getActiveProject().getMetadataHybrid(); - if (mhyb != null) { - MetadataCollection mcol = mhyb.getMetadataCollection(); - if (mcol != null) { - dataMap.put("Data Column", mcol.getDatacol()); - result.put("Included Samples", mcol.getIncluded()); - result.put("Excluded Samples", mcol.getExcluded()); - } - } else { - result.put("Included Samples", null); - result.put("Excluded Samples", null); - } - - result.put("result", "OK"); - - ActionProperties sampleFilterAction = new ActionProperties("sample-advance-filter", actionMap, dataMap, - result, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz").format(new Date())); - sampleFilterAction.logActionProperties(); - - MetaOmGraph.setCurrentSamplesActionId(sampleFilterAction.getActionNumber()); - } catch (Exception e1) { - - } + } public void displaySimilarityTable(HashMap res) { diff --git a/src/edu/iastate/metnet/metaomgraph/ui/MetadataTreeDisplayPanel.java b/src/edu/iastate/metnet/metaomgraph/ui/MetadataTreeDisplayPanel.java index e0af745c..d0a00492 100644 --- a/src/edu/iastate/metnet/metaomgraph/ui/MetadataTreeDisplayPanel.java +++ b/src/edu/iastate/metnet/metaomgraph/ui/MetadataTreeDisplayPanel.java @@ -836,7 +836,7 @@ public Object construct() { }.start(); // update exclude list - MetaOmAnalyzer.updateExcluded(obj.getExcluded()); + //MetaOmAnalyzer.updateExcluded(obj.getExcluded()); MetaOmGraph.getActiveTable().updateMetadataTable(); } @@ -862,39 +862,6 @@ public void filterXMLRoot(List resColumns) { obj.setIncluded(inc); updateTree(); - HashMap actionMap = new HashMap(); - HashMap dataMap = new HashMap(); - HashMap result = new HashMap(); - - try { - - actionMap.put("parent", MetaOmGraph.getCurrentProjectActionId()); - actionMap.put("section", "Feature Metadata"); - - MetadataHybrid mhyb = MetaOmGraph.getActiveProject().getMetadataHybrid(); - if (mhyb != null) { - MetadataCollection mcol = mhyb.getMetadataCollection(); - if (mcol != null) { - dataMap.put("Data Column", mcol.getDatacol()); - result.put("Included Samples", mcol.getIncluded()); - result.put("Excluded Samples", mcol.getExcluded()); - } - } else { - result.put("Included Samples", null); - result.put("Excluded Samples", null); - } - - result.put("result", "OK"); - - ActionProperties sampleFilterAction = new ActionProperties("sample-advance-filter", actionMap, dataMap, - result, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz").format(new Date())); - sampleFilterAction.logActionProperties(); - - MetaOmGraph.setCurrentSamplesActionId(sampleFilterAction.getActionNumber()); - } catch (Exception e1) { - - } - } /** diff --git a/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java b/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java index ffa63092..88d399c2 100644 --- a/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java +++ b/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java @@ -25,10 +25,12 @@ import java.nio.file.Files; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -62,6 +64,8 @@ import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreePath; + +import org.apache.commons.io.FilenameUtils; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -405,7 +409,13 @@ public void actionPerformed(ActionEvent arg0) { JFileChooser jfc = new JFileChooser(); jfc.setDialogTitle("open previous session log"); - jfc.setCurrentDirectory(MetaOmGraph.getActiveProject().getSourceFile()); + + File projectSource = MetaOmGraph.getActiveProject().getSourceFile(); + String logPath = FilenameUtils.getFullPathNoEndSeparator(projectSource.getAbsolutePath())+File.separator+"moglog"; + + File projectLogsDir = new File(logPath); + + jfc.setCurrentDirectory(projectLogsDir); int retValue = jfc.showOpenDialog(MetaOmGraph.getMainWindow()); if (retValue == JFileChooser.APPROVE_OPTION) { @@ -524,13 +534,13 @@ public void addActionToLogTree(ActionProperties action, int actionNumber, JTree DefaultMutableTreeNode newNode = null; try { - if (action.getOtherParameters().get(FAVORITE_PROPERTY).equals("true")) { + if(action.getOtherParameters() != null ) { + if (action.getOtherParameters().get(FAVORITE_PROPERTY)!= null && action.getOtherParameters().get(FAVORITE_PROPERTY).equals("true")) { if (action.getDataParameters().get(SELECTED_FEATURES_PROPERTY) != null) { - LinkedTreeMap features = (LinkedTreeMap) action - .getDataParameters().get(SELECTED_FEATURES_PROPERTY); + String[] features = getSelectedFeaturesFromLog(action.getDataParameters().get(SELECTED_FEATURES_PROPERTY)); newNode = new DefaultMutableTreeNode(new LoggingTreeNode("

" + actionCommandString + " [" - + (String) features.entrySet().iterator().next().getValue() + "]" + + (String) features[0] + "]" + "  

", action.getActionCommand(), actionNumber)); } else { @@ -541,49 +551,20 @@ public void addActionToLogTree(ActionProperties action, int actionNumber, JTree } } else { if (action.getDataParameters().get(SELECTED_FEATURES_PROPERTY) != null) { - LinkedTreeMap features = (LinkedTreeMap) action - .getDataParameters().get(SELECTED_FEATURES_PROPERTY); + String[] features = getSelectedFeaturesFromLog(action.getDataParameters().get(SELECTED_FEATURES_PROPERTY)); newNode = new DefaultMutableTreeNode( new LoggingTreeNode( "

"+actionCommandString + " [" - + features.entrySet().iterator().next().getValue() + "]

", + + features[0] + "]

", action.getActionCommand(), actionNumber)); } else { newNode = new DefaultMutableTreeNode(new LoggingTreeNode("

"+actionCommandString+"

", action.getActionCommand(), actionNumber)); } } - } catch (Exception e) { - - if (action.getDataParameters().get(SELECTED_FEATURES_PROPERTY) != null) { - if (action.getDataParameters().get(SELECTED_FEATURES_PROPERTY) instanceof LinkedTreeMap) { - LinkedTreeMap features = (LinkedTreeMap) action - .getDataParameters().get(SELECTED_FEATURES_PROPERTY); - newNode = new DefaultMutableTreeNode( - new LoggingTreeNode( - "

"+actionCommandString + " [" - + features.entrySet().iterator().next().getValue() + "]

", - action.getActionCommand(), actionNumber)); - } else if(action.getDataParameters().get(SELECTED_FEATURES_PROPERTY) instanceof HashMap){ - HashMap features = (HashMap) action.getDataParameters() - .get(SELECTED_FEATURES_PROPERTY); - newNode = new DefaultMutableTreeNode( - new LoggingTreeNode( - "

"+actionCommandString + " [" - + features.entrySet().iterator().next().getValue() + "]

", - action.getActionCommand(), actionNumber)); - } - else { - newNode = new DefaultMutableTreeNode( - new LoggingTreeNode( - "

"+actionCommandString+"

" , - action.getActionCommand(), actionNumber)); - } - - } else { - newNode = new DefaultMutableTreeNode(new LoggingTreeNode("

"+actionCommandString+"

", - action.getActionCommand(), actionNumber)); } + } catch (Exception e) { + } Integer parent = (int) Double.parseDouble(action.getActionParameters().get(PARENT_PROPERTY).toString()); @@ -798,7 +779,18 @@ public void mouseClicked(MouseEvent me) { Object[] num1Obj = new Object[2]; num1Obj[0] = entry.getKey(); num1Obj[1] = ""; - if (entry.getValue() instanceof List) { + + if(num1Obj[0].equals(SELECTED_FEATURES_PROPERTY)) { + Object featureIndicesList = entry.getValue(); + String[] selectedFeatures = {}; + if(featureIndicesList != null) { + selectedFeatures = getSelectedFeaturesFromLog(featureIndicesList); + } + for(int sf = 0; sf < selectedFeatures.length; sf++ ) { + num1Obj[1] += selectedFeatures[sf]+"\n"; + } + } + else if (entry.getValue() instanceof List) { List actionList = (List) entry.getValue(); for (int i = 0; i < actionList.size(); i++) { num1Obj[1] += String.valueOf(actionList.get(i)) + "\n"; @@ -902,58 +894,68 @@ public void setValueAt(Object aValue, int row, int column) { if(actionObj[i].getActionNumber() == sampleActionNumber) { String dataCol = (String)actionObj[i].getDataParameters().get(DATA_COLUMN_PROPERTY); - - if(actionObj[i].getOtherParameters().get(INCLUDED_SAMPLES_PROPERTY) instanceof List) { - - - List inclSamplesList = (List)actionObj[i].getOtherParameters().get(INCLUDED_SAMPLES_PROPERTY); - Object[] inclSamplesArray = inclSamplesList.toArray(); - Object[][] inclSamplesDArray = new Object[inclSamplesArray.length][1]; - - for(int x=0;x excludedSamples = new ArrayList(); + String [] samples = MetaOmGraph.getActiveProject().getDataColumnHeaders(); + + LinkedList allSamplesList = new LinkedList(Arrays.asList(samples)); + LinkedList copyAllSamplesList = new LinkedList(Arrays.asList(samples)); + + Object [] exclSamples = null; + + if(actionObj[i].getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY) instanceof List ) { + List exclSamplesList2 = (List)actionObj[i].getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY); + exclSamples = exclSamplesList2.toArray(); } - else if(actionObj[i].getOtherParameters().get(INCLUDED_SAMPLES_PROPERTY) instanceof HashSet) { - - - HashSet inclSamplesSet = (HashSet)actionObj[i].getOtherParameters().get(INCLUDED_SAMPLES_PROPERTY); - Object[] inclSamplesArray = inclSamplesSet.toArray(); - Object[][] inclSamplesDArray = new Object[inclSamplesArray.length][1]; - - for(int x=0;x) { + HashSet exclSamplesList2 = (HashSet)actionObj[i].getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY); + exclSamples = exclSamplesList2.toArray(); } - - - - if(actionObj[i].getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY) instanceof List ) { - List exclSamplesList = (List)actionObj[i].getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY); - Object[] exclSamplesArray = exclSamplesList.toArray(); - Object[][] exclSamplesDArray = new Object[exclSamplesArray.length][1]; - - for(int x=0;x) { - HashSet exclSamplesSet = (HashSet)actionObj[i].getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY); - Object[] exclSamplesArray = exclSamplesSet.toArray(); - Object[][] exclSamplesDArray = new Object[exclSamplesArray.length][1]; + + includedSamplesTable.setModel(new DefaultTableModel(inclSamplesDArray, new String[] {dataCol})); - for(int x=0;x) { + + String[] features = getSelectedFeaturesFromLog(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY)); - LinkedTreeMap features = (LinkedTreeMap) likedAction - .getDataParameters().get(SELECTED_FEATURES_PROPERTY); node.setUserObject(new LoggingTreeNode("

"+actionCommandString+ " [" - + (String) features.entrySet().iterator().next().getValue() + "]

" + + (String) features[0] + "]

" , logNode.getCommandName(), logNode.getNodeNumber())); - } - else { - - HashMap features = (HashMap) likedAction - .getDataParameters().get(SELECTED_FEATURES_PROPERTY); - - node.setUserObject(new LoggingTreeNode("

"+actionCommandString+ " [" - + (String) features.entrySet().iterator().next().getValue() + "]

" - , - logNode.getCommandName(), logNode.getNodeNumber())); - - } - + } else { @@ -1119,28 +1108,14 @@ public void markActionsAsFavorite(int tabNo, JTree selectedTree, DefaultTreeMode if(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY) != null) { - if (likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY) instanceof LinkedTreeMap) { - LinkedTreeMap features = (LinkedTreeMap) likedAction - .getDataParameters().get(SELECTED_FEATURES_PROPERTY); + String[] features = getSelectedFeaturesFromLog(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY)); node.setUserObject(new LoggingTreeNode("

" + actionCommandString+ " [" - + (String) features.entrySet().iterator().next().getValue() + "]" + + (String) features[0] + "]" + "  

", logNode.getCommandName(), logNode.getNodeNumber())); - } - else { - - HashMap features = (HashMap) likedAction - .getDataParameters().get(SELECTED_FEATURES_PROPERTY); - - node.setUserObject(new LoggingTreeNode("

" + actionCommandString+ " [" - + (String) features.entrySet().iterator().next().getValue() + "]" - - + "  

", - logNode.getCommandName(), logNode.getNodeNumber())); - - } + } else { @@ -1157,28 +1132,15 @@ public void markActionsAsFavorite(int tabNo, JTree selectedTree, DefaultTreeMode if(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY) != null) { - if (likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY) instanceof LinkedTreeMap) { + String[] features = getSelectedFeaturesFromLog(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY)); - LinkedTreeMap features = (LinkedTreeMap) likedAction - .getDataParameters().get(SELECTED_FEATURES_PROPERTY); node.setUserObject(new LoggingTreeNode("

" + actionCommandString+ " [" - + (String) features.entrySet().iterator().next().getValue() + "]" + + (String) features[0] + "]" + "  

", logNode.getCommandName(), logNode.getNodeNumber())); - } - else { - - HashMap features = (HashMap) likedAction - .getDataParameters().get(SELECTED_FEATURES_PROPERTY); - - node.setUserObject(new LoggingTreeNode("

" + actionCommandString+ " [" - + (String) features.entrySet().iterator().next().getValue() + "]" - - + "  

", - logNode.getCommandName(), logNode.getNodeNumber())); - } + } else { @@ -1196,28 +1158,14 @@ public void markActionsAsFavorite(int tabNo, JTree selectedTree, DefaultTreeMode if(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY) != null) { - if (likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY) instanceof LinkedTreeMap) { - - LinkedTreeMap features = (LinkedTreeMap) likedAction - .getDataParameters().get(SELECTED_FEATURES_PROPERTY); + String[] features = getSelectedFeaturesFromLog(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY)); node.setUserObject(new LoggingTreeNode("

" + actionCommandString+ " [" - + (String) features.entrySet().iterator().next().getValue() + "]" + + (String) features[0] + "]" + "  

", logNode.getCommandName(), logNode.getNodeNumber())); - } - else { - - HashMap features = (HashMap) likedAction - .getDataParameters().get(SELECTED_FEATURES_PROPERTY); - - node.setUserObject(new LoggingTreeNode("

" + actionCommandString+ " [" - + (String) features.entrySet().iterator().next().getValue() + "]" - - + "  

", - logNode.getCommandName(), logNode.getNodeNumber())); - } + } else { @@ -1328,6 +1276,69 @@ public void setTableRowSize(JTable table, int rowNum, String rowString) { } } + + public String[] getSelectedFeaturesFromLog(Object selectedFeatures) { + + + int val2[] = null; + + if(selectedFeatures != null) { + if(selectedFeatures instanceof List ) { + List selFeaturesList = (List)selectedFeatures; + Double[] selFeaturesDouble = new Double[selFeaturesList.size()]; + + for( int fno = 0 ; fno < selFeaturesList.size(); fno++ ) { + selFeaturesDouble[fno] = (Double)selFeaturesList.get(fno); + } + + val2 = new int[selFeaturesDouble.length]; + + for( int i =0; i< selFeaturesDouble.length; i++ ) { + val2[i] = selFeaturesDouble[i].intValue(); + } + } + else if(selectedFeatures instanceof HashSet) { + HashSet selFeaturesHashSet = (HashSet)selectedFeatures; + Double[] selFeaturesDouble = new Double[selFeaturesHashSet.size()]; + + selFeaturesDouble = selFeaturesHashSet.toArray(selFeaturesDouble); + val2 = new int[selFeaturesDouble.length]; + + for( int i =0; i< selFeaturesDouble.length; i++ ) { + val2[i] = selFeaturesDouble[i].intValue(); + } + + } + else if(selectedFeatures instanceof Integer[]) { + Integer[] selFeaturesIntArray = (Integer[])selectedFeatures; + + val2 = new int[selFeaturesIntArray.length]; + + for( int i =0; i< selFeaturesIntArray.length; i++ ) { + val2[i] = (int)selFeaturesIntArray[i]; + } + } + else if(selectedFeatures instanceof Double[]) { + Double[] selFeaturesDoubleArray = (Double[])selectedFeatures; + + val2 = new int[selFeaturesDoubleArray.length]; + + for( int i =0; i< selFeaturesDoubleArray.length; i++ ) { + val2[i] = selFeaturesDoubleArray[i].intValue(); + } + } + else { + val2 = (int[])selectedFeatures; + } + + } + if(val2 != null && val2.length > 0) { + String[] selectedGeneNames = MetaOmGraph.getActiveProject().getDefaultRowNames(val2); + return selectedGeneNames; + } + + return new String[] {"null"}; + } } From d8757ae77738624fd4021e864751fee741b710ca Mon Sep 17 00:00:00 2001 From: "vk.sriharsha" Date: Fri, 16 Oct 2020 04:54:18 -0500 Subject: [PATCH 4/7] All fixes of logging and playback --- .../metnet/metaomgraph/MetaOmAnalyzer.java | 3 + .../metnet/metaomgraph/MetaOmGraph.java | 60 +-- .../metaomgraph/logging/JSONMessage.java | 5 +- .../ui/ReproducibilityDashboardPanel.java | 362 +++++++++++------- .../metnet/metaomgraph/ui/TaskbarPanel.java | 11 +- 5 files changed, 263 insertions(+), 178 deletions(-) diff --git a/src/edu/iastate/metnet/metaomgraph/MetaOmAnalyzer.java b/src/edu/iastate/metnet/metaomgraph/MetaOmAnalyzer.java index ff0a151c..40d2711e 100644 --- a/src/edu/iastate/metnet/metaomgraph/MetaOmAnalyzer.java +++ b/src/edu/iastate/metnet/metaomgraph/MetaOmAnalyzer.java @@ -86,6 +86,7 @@ public static void updateExcluded(Set excluded, boolean loggingRequired) } } result.put("Excluded Samples", excludedSamplesInteger); + dataMap.put("Data Column", mcol.getDatacol()); } else { @@ -98,6 +99,7 @@ public static void updateExcluded(Set excluded, boolean loggingRequired) new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz").format(new Date())); if(loggingRequired) { + result.put("Sample Action", filterMetadataAction.getCounter()+1); filterMetadataAction.logActionProperties(); MetaOmGraph.setCurrentSamplesActionId(filterMetadataAction.getActionNumber()); } @@ -165,6 +167,7 @@ public static void updateExcluded(Set excluded, boolean loggingRequired) new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz").format(new Date())); if(loggingRequired) { + result.put("Sample Action", filterMetadataAction.getCounter()+1); filterMetadataAction.logActionProperties(); MetaOmGraph.setCurrentSamplesActionId(filterMetadataAction.getActionNumber()); } diff --git a/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java b/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java index d99d48c6..7408cecf 100644 --- a/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java +++ b/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java @@ -177,6 +177,8 @@ public class MetaOmGraph implements ActionListener { private static TaskbarPanel taskBar; private static StatisticalResultsFrame DEAResultsFrame; private static StatisticalResultsFrame DCResultsFrame; + private static JButton plbbutton; + private static JPanel playbackForMac; public static StatisticalResultsFrame getDEAResultsFrame() { @@ -860,6 +862,9 @@ public static void init(boolean useBuffer) { myself = new MetaOmGraph(); activeProject = null; recentProjects = new Vector(); + + //setting loggingRequired parameter for reproducibility logging + MetaOmGraph.setLoggingRequired(true); File homeDir = new File(System.getProperty("user.home")); File prefsFile = new File(homeDir, "metaomgraph.prefs"); @@ -913,16 +918,8 @@ public static void init(boolean useBuffer) { setCurrentTheme("light"); } - //setting loggingRequired parameter for reproducibility logging - try { - boolean lr = (boolean)in.readObject(); - MetaOmGraph.setLoggingRequired(lr); - MetaOmGraph.setPermanentLogging(lr); - - } - catch(Exception ex2) { - MetaOmGraph.setLoggingRequired(true); - } + + in.close(); } catch (FileNotFoundException e1) { @@ -1612,29 +1609,24 @@ else if ((ReproducibilityDashboardFrame != null) && (!ReproducibilityDashboardFr if (Utils.isMac()) { - JPanel playbackForMac = new JPanel() + playbackForMac = new JPanel() { @Override protected void paintComponent(Graphics g) { - // Draw a rectangle using Rectangle2D class -// Graphics2D g2 = (Graphics2D) g; -// -// g2.setColor(new Color(255,255,240)); -// g2.setBackground(new Color(255,255,240)); -// -// // Draw the blue rectangle -// g2.fill(new Rectangle2D.Double(1250, 10, 100, 30)); -// g2.setColor(Color.BLUE); -// -// g2.drawString("Playback",1255,18); + } }; - JButton plbbutton = new JButton("Playback"); + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + GraphicsDevice defaultScreen = ge.getDefaultScreenDevice(); + Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds(); + + plbbutton = new JButton("Playback"); playbackForMac.setLayout(null); - plbbutton.setBounds(1220, 0, 100, 30); - playbackForMac.add(plbbutton); - playbackForMac.setSize(2000,2000); + //plbbutton.setBounds((int)rect.getMaxX()-100, 0, 100, 20); + playbackForMac.setLayout (new BorderLayout ()); + playbackForMac.add(plbbutton, BorderLayout.EAST); + playbackForMac.setSize((int)rect.getMaxX(), 30); playbackForMac.setVisible(true); playbackForMac.setBackground(Color.BLACK); @@ -1695,6 +1687,12 @@ public void windowClosed(WindowEvent arg0) { public void windowClosing(WindowEvent arg0) { shutdown(); } + + @Override + public void windowStateChanged(WindowEvent e) { + // TODO Auto-generated method stub + //refreshPlaybackButton(); + } }); if (activeProjectFile != null) new OpenProjectWorker(activeProjectFile).start(); @@ -2209,7 +2207,6 @@ public void finished() { setCurrentLogFilePath(logFilePath); setLoggingRequired(true); - setPermanentLogging(true); logGeneralProperties(); int newProjectId = logNewProject(source.getAbsolutePath(),extInfoFile.getAbsolutePath()); @@ -3724,6 +3721,8 @@ private static void setMenuIcons() { tipsItem.setIcon(new ImageIcon( myself.getClass().getResource("/resource/tango/16x16/status/dialog-information.png"))); ReproducibilityLogMenu.setIcon(new ImageIcon(((new ImageIcon(myself.getClass().getResource("/resource/loggingicons/loggingicon2.png")).getImage()).getScaledInstance(14, 14, java.awt.Image.SCALE_SMOOTH)))); + + plbbutton.setIcon(new ImageIcon(((new ImageIcon(myself.getClass().getResource("/resource/loggingicons/loggingicon2.png")).getImage()).getScaledInstance(14, 14, java.awt.Image.SCALE_SMOOTH)))); } catch (Exception e) { e.printStackTrace(); } @@ -4102,8 +4101,13 @@ public static void createReproducibilityLoggingFrame() { Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds(); ReproducibilityDashboardFrame.setSize(550, (int)rect.getMaxY()-200); + + if(Utils.isMac()) { + ReproducibilityDashboardFrame.setLocation((ReproducibilityLogMenu.getX()+ReproducibilityLogMenu.getWidth())-550, 30); + } + else { ReproducibilityDashboardFrame.setLocation((ReproducibilityLogMenu.getX()+ReproducibilityLogMenu.getWidth())-550, 0); - + } ReproducibilityDashboardFrame.show(); diff --git a/src/edu/iastate/metnet/metaomgraph/logging/JSONMessage.java b/src/edu/iastate/metnet/metaomgraph/logging/JSONMessage.java index 7cca5656..5811a2fb 100644 --- a/src/edu/iastate/metnet/metaomgraph/logging/JSONMessage.java +++ b/src/edu/iastate/metnet/metaomgraph/logging/JSONMessage.java @@ -19,7 +19,6 @@ public class JSONMessage implements Message { private static final long serialVersionUID = 1L; private String messageString; private static final Gson GSON = new GsonBuilder() - .setPrettyPrinting() .create(); public JSONMessage(){ @@ -41,12 +40,12 @@ private void parseMessageAsJson(Object msgObj){ } public String getFormattedMessage() { - return messageString.replace("\n", "%n"); + return messageString; } public String getFormat() { - return messageString.replace("\n", "%n"); + return messageString; } public Object[] getParameters() { diff --git a/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java b/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java index 88d399c2..ac2171e5 100644 --- a/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java +++ b/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java @@ -16,10 +16,14 @@ import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; +import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StringWriter; import java.nio.file.Files; @@ -306,13 +310,10 @@ public Component prepareRenderer(TableCellRenderer renderer, int row, int column loggingChoicePanel.add(rdbtnOff); rdbtnPermanentlySwitchedOff = new JRadioButton("permanently switched off"); -// loggingChoicePanel.add(rdbtnPermanentlySwitchedOff); + // loggingChoicePanel.add(rdbtnPermanentlySwitchedOff); - if (MetaOmGraph.getPermanentLogging() == false) { - rdbtnOn.setSelected(false); - rdbtnOff.setSelected(false); - rdbtnPermanentlySwitchedOff.setSelected(true); - } + rdbtnOn.setSelected(true); + rdbtnOn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -377,7 +378,7 @@ public void actionPerformed(ActionEvent e) { G.add(rdbtnOn); G.add(rdbtnOff); - G.add(rdbtnPermanentlySwitchedOff); + //G.add(rdbtnPermanentlySwitchedOff); separator_1 = new JSeparator(); GridBagConstraints gbc_separator_1 = new GridBagConstraints(); @@ -409,27 +410,63 @@ public void actionPerformed(ActionEvent arg0) { JFileChooser jfc = new JFileChooser(); jfc.setDialogTitle("open previous session log"); - + File projectSource = MetaOmGraph.getActiveProject().getSourceFile(); String logPath = FilenameUtils.getFullPathNoEndSeparator(projectSource.getAbsolutePath())+File.separator+"moglog"; - + File projectLogsDir = new File(logPath); - + jfc.setCurrentDirectory(projectLogsDir); int retValue = jfc.showOpenDialog(MetaOmGraph.getMainWindow()); if (retValue == JFileChooser.APPROVE_OPTION) { File file = jfc.getSelectedFile(); - JTree sessionTree = new JTree(); - JTable sessionTable = new JTable(); + int[] dimensions = getDimensionsFromFile(file); - HashMap treeStruct = new HashMap(); + if(dimensions != null) { - int tabNo = createNewTabAndPopulate(sessionTree, sessionTable, file.getName(), true, - file.getAbsolutePath()); - readLogAndPopulateTree(file, sessionTree, tabNo, treeStruct); - tabbedPane.setSelectedIndex(tabNo); + if(dimensions[0] == MetaOmGraph.getActiveProject().getDataColumnCount() && dimensions[1] == MetaOmGraph.getActiveProject().getRowCount()) { + + JTree sessionTree = new JTree(); + JTable sessionTable = new JTable(); + + HashMap treeStruct = new HashMap(); + + int tabNo = createNewTabAndPopulate(sessionTree, sessionTable, file.getName(), true, + file.getAbsolutePath()); + readLogAndPopulateTree(file, sessionTree, tabNo, treeStruct); + tabbedPane.setSelectedIndex(tabNo); + + } + else { + + int result = JOptionPane.showConfirmDialog((Component) null, "The log file which you are trying to open does not have the same number of features and samples ( Features: "+dimensions[0]+" , Samples: "+dimensions[1]+" ) as the currently opened project ( Features: "+MetaOmGraph.getActiveProject().getDataColumnCount()+" , Samples: "+MetaOmGraph.getActiveProject().getRowCount()+" ). This may cause the play feature to not work properly. Do you still want to proceed?", + "Warning", JOptionPane.OK_CANCEL_OPTION); + + if(result==0) { + + JTree sessionTree = new JTree(); + JTable sessionTable = new JTable(); + + HashMap treeStruct = new HashMap(); + + int tabNo = createNewTabAndPopulate(sessionTree, sessionTable, file.getName(), true, + file.getAbsolutePath()); + readLogAndPopulateTree(file, sessionTree, tabNo, treeStruct); + tabbedPane.setSelectedIndex(tabNo); + } + else { + + } + } + + } + else { + + JOptionPane.showMessageDialog((Component) null, "The log file seems to be malformed. Please contact the MOG Support team."); + + } } } @@ -465,7 +502,7 @@ public void actionPerformed(ActionEvent arg0) { DefaultTreeModel model = (DefaultTreeModel) selectedTree.getModel(); TreePath[] allPaths = selectedTree.getSelectionPaths(); - + markActionsAsFavorite(tabNo, selectedTree, model, allPaths); } }); @@ -523,11 +560,11 @@ public void addActionToLogTree(ActionProperties action, int actionNumber, JTree try { DefaultTreeModel dtm = (DefaultTreeModel) tree.getModel(); String actionCommandString = action.getActionCommand(); - + if(action.getOtherParameters().get("Playable") != null) { actionCommandString = ""+(String) action.getActionCommand()+""; } - + if (!action.getActionCommand().equalsIgnoreCase(GENERAL_PROPERTIES_COMMAND)) { DefaultMutableTreeNode root = (DefaultMutableTreeNode) dtm.getRoot(); @@ -535,36 +572,36 @@ public void addActionToLogTree(ActionProperties action, int actionNumber, JTree DefaultMutableTreeNode newNode = null; try { if(action.getOtherParameters() != null ) { - if (action.getOtherParameters().get(FAVORITE_PROPERTY)!= null && action.getOtherParameters().get(FAVORITE_PROPERTY).equals("true")) { - if (action.getDataParameters().get(SELECTED_FEATURES_PROPERTY) != null) { - String[] features = getSelectedFeaturesFromLog(action.getDataParameters().get(SELECTED_FEATURES_PROPERTY)); - newNode = new DefaultMutableTreeNode(new LoggingTreeNode("

" - + actionCommandString + " [" - + (String) features[0] + "]" - + "  

", - action.getActionCommand(), actionNumber)); - } else { - newNode = new DefaultMutableTreeNode(new LoggingTreeNode("

" - + actionCommandString - + "  

", - action.getActionCommand(), actionNumber)); - } - } else { - if (action.getDataParameters().get(SELECTED_FEATURES_PROPERTY) != null) { - String[] features = getSelectedFeaturesFromLog(action.getDataParameters().get(SELECTED_FEATURES_PROPERTY)); - newNode = new DefaultMutableTreeNode( - new LoggingTreeNode( - "

"+actionCommandString + " [" - + features[0] + "]

", - action.getActionCommand(), actionNumber)); + if (action.getOtherParameters().get(FAVORITE_PROPERTY)!= null && action.getOtherParameters().get(FAVORITE_PROPERTY).equals("true")) { + if (action.getDataParameters().get(SELECTED_FEATURES_PROPERTY) != null) { + String[] features = getSelectedFeaturesFromLog(action.getDataParameters().get(SELECTED_FEATURES_PROPERTY)); + newNode = new DefaultMutableTreeNode(new LoggingTreeNode("

" + + actionCommandString + " [" + + (String) features[0] + "]" + + "  

", + action.getActionCommand(), actionNumber)); + } else { + newNode = new DefaultMutableTreeNode(new LoggingTreeNode("

" + + actionCommandString + + "  

", + action.getActionCommand(), actionNumber)); + } } else { - newNode = new DefaultMutableTreeNode(new LoggingTreeNode("

"+actionCommandString+"

", - action.getActionCommand(), actionNumber)); + if (action.getDataParameters().get(SELECTED_FEATURES_PROPERTY) != null) { + String[] features = getSelectedFeaturesFromLog(action.getDataParameters().get(SELECTED_FEATURES_PROPERTY)); + newNode = new DefaultMutableTreeNode( + new LoggingTreeNode( + "

"+actionCommandString + " [" + + features[0] + "]

", + action.getActionCommand(), actionNumber)); + } else { + newNode = new DefaultMutableTreeNode(new LoggingTreeNode("

"+actionCommandString+"

", + action.getActionCommand(), actionNumber)); + } } } - } } catch (Exception e) { - + } Integer parent = (int) Double.parseDouble(action.getActionParameters().get(PARENT_PROPERTY).toString()); @@ -779,12 +816,12 @@ public void mouseClicked(MouseEvent me) { Object[] num1Obj = new Object[2]; num1Obj[0] = entry.getKey(); num1Obj[1] = ""; - + if(num1Obj[0].equals(SELECTED_FEATURES_PROPERTY)) { Object featureIndicesList = entry.getValue(); String[] selectedFeatures = {}; if(featureIndicesList != null) { - selectedFeatures = getSelectedFeaturesFromLog(featureIndicesList); + selectedFeatures = getSelectedFeaturesFromLog(featureIndicesList); } for(int sf = 0; sf < selectedFeatures.length; sf++ ) { num1Obj[1] += selectedFeatures[sf]+"\n"; @@ -894,15 +931,15 @@ public void setValueAt(Object aValue, int row, int column) { if(actionObj[i].getActionNumber() == sampleActionNumber) { String dataCol = (String)actionObj[i].getDataParameters().get(DATA_COLUMN_PROPERTY); - + List excludedSamples = new ArrayList(); String [] samples = MetaOmGraph.getActiveProject().getDataColumnHeaders(); - + LinkedList allSamplesList = new LinkedList(Arrays.asList(samples)); LinkedList copyAllSamplesList = new LinkedList(Arrays.asList(samples)); - + Object [] exclSamples = null; - + if(actionObj[i].getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY) instanceof List ) { List exclSamplesList2 = (List)actionObj[i].getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY); exclSamples = exclSamplesList2.toArray(); @@ -914,10 +951,10 @@ else if(actionObj[i].getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY) instanc else if(actionObj[i].getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY) instanceof Integer[]) { exclSamples = (Object[])actionObj[i].getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY); } - - + + for(int eindex = 0; eindex < exclSamples.length; eindex++) { - + int excludedindex = 0; if(exclSamples[eindex] instanceof Double) { Double a = (Double)exclSamples[eindex]; @@ -926,24 +963,24 @@ else if(actionObj[i].getOtherParameters().get(EXCLUDED_SAMPLES_PROPERTY) instanc else if(exclSamples[eindex] instanceof Integer) { excludedindex = (int)exclSamples[eindex]; } - - + + excludedSamples.add(copyAllSamplesList.get(excludedindex)); try { - allSamplesList.remove(copyAllSamplesList.get(excludedindex)); + allSamplesList.remove(copyAllSamplesList.get(excludedindex)); } catch(Exception e) { StackTraceElement[] ste = e.getStackTrace(); } } - + Object[] inclSamplesArray = allSamplesList.toArray(); Object[][] inclSamplesDArray = new Object[inclSamplesArray.length][1]; for(int x=0;x * This method adds a set of actions as favorites and also makes the play tree display a golden star beside the name of the action @@ -1052,12 +1089,12 @@ public void expandAllNodes(JTree tree) { * */ public void markActionsAsFavorite(int tabNo, JTree selectedTree, DefaultTreeModel model, TreePath[] allPaths) { - + PlaybackTabData currentTabData = allTabsInfo.get(tabNo); String logFileName = currentTabData.getLogFileName(); BufferedWriter out = null; - + try { if (tabNo != 0) { out = new BufferedWriter(new FileWriter(logFileName, true)); @@ -1071,13 +1108,13 @@ public void markActionsAsFavorite(int tabNo, JTree selectedTree, DefaultTreeMode LoggingTreeNode logNode = (LoggingTreeNode) nodeObj; ActionProperties likedAction = allTabsInfo.get(tabNo).getActionObjects().get(ltn.getNodeNumber()); - + String actionCommandString = likedAction.getActionCommand(); - + if(likedAction.getOtherParameters().get("Playable") != null) { actionCommandString = ""+(String) likedAction.getActionCommand()+""; } - + try { if (likedAction.getOtherParameters().get(FAVORITE_PROPERTY).equals("true")) { @@ -1085,15 +1122,15 @@ public void markActionsAsFavorite(int tabNo, JTree selectedTree, DefaultTreeMode likedAction.getOtherParameters().put(FAVORITE_PROPERTY, "false"); if(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY) != null) { - - String[] features = getSelectedFeaturesFromLog(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY)); + + String[] features = getSelectedFeaturesFromLog(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY)); - node.setUserObject(new LoggingTreeNode("

"+actionCommandString+ " [" - + (String) features[0] + "]

" - , - logNode.getCommandName(), logNode.getNodeNumber())); - + node.setUserObject(new LoggingTreeNode("

"+actionCommandString+ " [" + + (String) features[0] + "]

" + , + logNode.getCommandName(), logNode.getNodeNumber())); + } else { @@ -1108,20 +1145,20 @@ public void markActionsAsFavorite(int tabNo, JTree selectedTree, DefaultTreeMode if(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY) != null) { - String[] features = getSelectedFeaturesFromLog(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY)); + String[] features = getSelectedFeaturesFromLog(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY)); - node.setUserObject(new LoggingTreeNode("

" + actionCommandString+ " [" - + (String) features[0] + "]" + node.setUserObject(new LoggingTreeNode("

" + actionCommandString+ " [" + + (String) features[0] + "]" + "  

", logNode.getCommandName(), logNode.getNodeNumber())); - + } else { node.setUserObject(new LoggingTreeNode("

" + actionCommandString - + "  

", - logNode.getCommandName(), logNode.getNodeNumber())); + + "  

", + logNode.getCommandName(), logNode.getNodeNumber())); } @@ -1132,21 +1169,21 @@ public void markActionsAsFavorite(int tabNo, JTree selectedTree, DefaultTreeMode if(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY) != null) { - String[] features = getSelectedFeaturesFromLog(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY)); + String[] features = getSelectedFeaturesFromLog(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY)); - node.setUserObject(new LoggingTreeNode("

" + actionCommandString+ " [" - + (String) features[0] + "]" + node.setUserObject(new LoggingTreeNode("

" + actionCommandString+ " [" + + (String) features[0] + "]" + "  

", logNode.getCommandName(), logNode.getNodeNumber())); - + } else { node.setUserObject(new LoggingTreeNode("

" + actionCommandString - + "  

", - logNode.getCommandName(), logNode.getNodeNumber())); + + "  

", + logNode.getCommandName(), logNode.getNodeNumber())); } model.reload(); expandAllNodes(selectedTree); @@ -1158,20 +1195,20 @@ public void markActionsAsFavorite(int tabNo, JTree selectedTree, DefaultTreeMode if(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY) != null) { - String[] features = getSelectedFeaturesFromLog(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY)); + String[] features = getSelectedFeaturesFromLog(likedAction.getDataParameters().get(SELECTED_FEATURES_PROPERTY)); - node.setUserObject(new LoggingTreeNode("

" + actionCommandString+ " [" - + (String) features[0] + "]" + node.setUserObject(new LoggingTreeNode("

" + actionCommandString+ " [" + + (String) features[0] + "]" + "  

", logNode.getCommandName(), logNode.getNodeNumber())); - + } else { node.setUserObject(new LoggingTreeNode("

" + actionCommandString - + "  

", - logNode.getCommandName(), logNode.getNodeNumber())); + + "  

", + logNode.getCommandName(), logNode.getNodeNumber())); } model.reload(); expandAllNodes(selectedTree); @@ -1207,7 +1244,7 @@ public void autoSaveLog(int tabNo) { PlaybackTabData currentTabData = allTabsInfo.get(tabNo); String logFileName = currentTabData.getLogFileName(); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); + Gson gson = new GsonBuilder().create(); ArrayList ap = new ArrayList(); for (ActionProperties act : allTabsInfo.get(tabNo).getActionObjects()) { @@ -1220,7 +1257,7 @@ public void autoSaveLog(int tabNo) { fw = new FileWriter(logFileName, false); String outputJson = gson.toJson(apArray); - String output = outputJson.substring(1, outputJson.length() - 2); + String output = outputJson.substring(1, outputJson.length() - 1); //output = output.replaceAll("\r", ""); fw.write(output); @@ -1241,6 +1278,43 @@ public void autoSaveLog(int tabNo) { + int[] getDimensionsFromFile(File logfile) { + + int[] dim = new int[2]; + + Gson gson = new Gson(); + String jsonLog = ""; + try { + + jsonLog = new String(Files.readAllBytes(logfile.toPath())); + + String listOfActions = "[" + jsonLog + "]"; + + ActionProperties[] actionsFromGSON = gson.fromJson(listOfActions, ActionProperties[].class); + + ArrayList list1 = new ArrayList(); + Collections.addAll(list1, actionsFromGSON); + + for (int action = 1; action < 5; action++) { + + if(actionsFromGSON[action].getDataParameters().get("Dimensions")!= null && actionsFromGSON[action].getDataParameters().get("Row Count") != null) { + + dim[0] = Integer.parseInt((String)actionsFromGSON[action].getDataParameters().get("Dimensions")); + dim[1] = Integer.parseInt((String)actionsFromGSON[action].getDataParameters().get("Row Count")); + + return dim; + } + } + + } catch (Exception e) { + return null; + } + + return null; + } + + + /** * This method is used to adjust the table row size based on the string being populated to the row */ @@ -1276,67 +1350,67 @@ public void setTableRowSize(JTable table, int rowNum, String rowString) { } } - + public String[] getSelectedFeaturesFromLog(Object selectedFeatures) { - + int val2[] = null; - + if(selectedFeatures != null) { - if(selectedFeatures instanceof List ) { - List selFeaturesList = (List)selectedFeatures; - Double[] selFeaturesDouble = new Double[selFeaturesList.size()]; - - for( int fno = 0 ; fno < selFeaturesList.size(); fno++ ) { - selFeaturesDouble[fno] = (Double)selFeaturesList.get(fno); + if(selectedFeatures instanceof List ) { + List selFeaturesList = (List)selectedFeatures; + Double[] selFeaturesDouble = new Double[selFeaturesList.size()]; + + for( int fno = 0 ; fno < selFeaturesList.size(); fno++ ) { + selFeaturesDouble[fno] = (Double)selFeaturesList.get(fno); + } + + val2 = new int[selFeaturesDouble.length]; + + for( int i =0; i< selFeaturesDouble.length; i++ ) { + val2[i] = selFeaturesDouble[i].intValue(); + } } - - val2 = new int[selFeaturesDouble.length]; - - for( int i =0; i< selFeaturesDouble.length; i++ ) { - val2[i] = selFeaturesDouble[i].intValue(); + else if(selectedFeatures instanceof HashSet) { + HashSet selFeaturesHashSet = (HashSet)selectedFeatures; + Double[] selFeaturesDouble = new Double[selFeaturesHashSet.size()]; + + selFeaturesDouble = selFeaturesHashSet.toArray(selFeaturesDouble); + val2 = new int[selFeaturesDouble.length]; + + for( int i =0; i< selFeaturesDouble.length; i++ ) { + val2[i] = selFeaturesDouble[i].intValue(); + } + } - } - else if(selectedFeatures instanceof HashSet) { - HashSet selFeaturesHashSet = (HashSet)selectedFeatures; - Double[] selFeaturesDouble = new Double[selFeaturesHashSet.size()]; - - selFeaturesDouble = selFeaturesHashSet.toArray(selFeaturesDouble); - val2 = new int[selFeaturesDouble.length]; - - for( int i =0; i< selFeaturesDouble.length; i++ ) { - val2[i] = selFeaturesDouble[i].intValue(); + else if(selectedFeatures instanceof Integer[]) { + Integer[] selFeaturesIntArray = (Integer[])selectedFeatures; + + val2 = new int[selFeaturesIntArray.length]; + + for( int i =0; i< selFeaturesIntArray.length; i++ ) { + val2[i] = (int)selFeaturesIntArray[i]; + } } - - } - else if(selectedFeatures instanceof Integer[]) { - Integer[] selFeaturesIntArray = (Integer[])selectedFeatures; - - val2 = new int[selFeaturesIntArray.length]; - - for( int i =0; i< selFeaturesIntArray.length; i++ ) { - val2[i] = (int)selFeaturesIntArray[i]; + else if(selectedFeatures instanceof Double[]) { + Double[] selFeaturesDoubleArray = (Double[])selectedFeatures; + + val2 = new int[selFeaturesDoubleArray.length]; + + for( int i =0; i< selFeaturesDoubleArray.length; i++ ) { + val2[i] = selFeaturesDoubleArray[i].intValue(); + } } - } - else if(selectedFeatures instanceof Double[]) { - Double[] selFeaturesDoubleArray = (Double[])selectedFeatures; - - val2 = new int[selFeaturesDoubleArray.length]; - - for( int i =0; i< selFeaturesDoubleArray.length; i++ ) { - val2[i] = selFeaturesDoubleArray[i].intValue(); + else { + val2 = (int[])selectedFeatures; } - } - else { - val2 = (int[])selectedFeatures; - } - + } if(val2 != null && val2.length > 0) { String[] selectedGeneNames = MetaOmGraph.getActiveProject().getDefaultRowNames(val2); return selectedGeneNames; } - + return new String[] {"null"}; } diff --git a/src/edu/iastate/metnet/metaomgraph/ui/TaskbarPanel.java b/src/edu/iastate/metnet/metaomgraph/ui/TaskbarPanel.java index b7aa9974..4a7b3325 100644 --- a/src/edu/iastate/metnet/metaomgraph/ui/TaskbarPanel.java +++ b/src/edu/iastate/metnet/metaomgraph/ui/TaskbarPanel.java @@ -35,6 +35,8 @@ import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; +import org.apache.commons.lang3.StringUtils; + /** * * @author Harsha @@ -192,15 +194,18 @@ public void reloadTaskbar() { if(typeFrames != null) { for(TaskbarInternalFrame frame : typeFrames) { - JMenuItem menuItem = new JMenuItem(frame.getModel().getFrameName()); + String menuItemName = frame.getModel().getFrameName(); + menuItemName = StringUtils.abbreviate(menuItemName, 80); + + JMenuItem menuItem = new JMenuItem(menuItemName); JPanel tabItemPanel = new JPanel(); tabItemPanel.setLayout(new BorderLayout()); - JLabel tabItemLabel = new JLabel(frame.getModel().getFrameName()); + JLabel tabItemLabel = new JLabel(menuItemName); tabItemPanel.add(tabItemLabel); UIManager.put("MenuItem.selectionForeground", Color.BLUE); - menuItem.setText(frame.getModel().getFrameName());; + menuItem.setText(menuItemName);; menu.add(new JSeparator()); menu.add(menuItem); menu.setMargin(new Insets(2, 8, 2, 8)); From 5431bd6079964f3468b51ce60189a8cb54cc9e04 Mon Sep 17 00:00:00 2001 From: "vk.sriharsha" Date: Fri, 16 Oct 2020 05:18:32 -0500 Subject: [PATCH 5/7] Added comments for new methods and fixes --- .../metnet/metaomgraph/MetaOmAnalyzer.java | 4 ++- .../metnet/metaomgraph/MetaOmGraph.java | 4 +++ .../metaomgraph/playback/PlaybackAction.java | 5 +++- .../ui/ReproducibilityDashboardPanel.java | 25 ++++++++++++++++++- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/edu/iastate/metnet/metaomgraph/MetaOmAnalyzer.java b/src/edu/iastate/metnet/metaomgraph/MetaOmAnalyzer.java index 40d2711e..1c458759 100644 --- a/src/edu/iastate/metnet/metaomgraph/MetaOmAnalyzer.java +++ b/src/edu/iastate/metnet/metaomgraph/MetaOmAnalyzer.java @@ -55,9 +55,11 @@ public MetaOmAnalyzer() { } /** - * @author urmi Update the exclude list to remove excluded data cols from charts + * @author urmi Update the exclude list to remove excluded data cols from charts and log + * it in the mog log. * @param excluded * list of excluded data cols + * */ public static void updateExcluded(Set excluded, boolean loggingRequired) { if (excluded.size() == 0) { diff --git a/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java b/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java index 7408cecf..5abfea6d 100644 --- a/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java +++ b/src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java @@ -1608,6 +1608,10 @@ else if ((ReproducibilityDashboardFrame != null) && (!ReproducibilityDashboardFr mainMenuBar.add(ReproducibilityLogMenu); + + //Harsha - Add a playback button to the top right corner of the window in Mac + //Added because mac was not handling JMenu button ReproducibilityLogMenu properly + if (Utils.isMac()) { playbackForMac = new JPanel() { diff --git a/src/edu/iastate/metnet/metaomgraph/playback/PlaybackAction.java b/src/edu/iastate/metnet/metaomgraph/playback/PlaybackAction.java index 804fedaf..0e32b71f 100644 --- a/src/edu/iastate/metnet/metaomgraph/playback/PlaybackAction.java +++ b/src/edu/iastate/metnet/metaomgraph/playback/PlaybackAction.java @@ -186,9 +186,11 @@ else if(exclSamples[eindex] instanceof Integer) { /** * This method plays the chart-type action by calling the respective chart's MetaOmTablePanel function that generates and displays the chart - * based on the selected features and samples. + * based on the selected features, the transformation used, and samples. * + * Sets the transformation variable of the system to the one in the log before resetting it. * Before calling the MetaOmTablePanel functions, the selected features' ids are collected into an integer array, to be passed to them. + * */ public void playChart(ActionProperties chartAction, String chartName, HashSet includedSamples, HashSet excludedSamples) { @@ -198,6 +200,7 @@ public void playChart(ActionProperties chartAction, String chartName, HashSet ) { diff --git a/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java b/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java index ac2171e5..9b089def 100644 --- a/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java +++ b/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java @@ -419,6 +419,10 @@ public void actionPerformed(ActionEvent arg0) { jfc.setCurrentDirectory(projectLogsDir); int retValue = jfc.showOpenDialog(MetaOmGraph.getMainWindow()); + /*Check whether the file being opened has valid dimensions (features size and + Samples size), and warn the user if it doesnt have the same dimensions as the + currently opened project */ + if (retValue == JFileChooser.APPROVE_OPTION) { File file = jfc.getSelectedFile(); @@ -1277,7 +1281,14 @@ public void autoSaveLog(int tabNo) { } - + /** + * This method returns the samples size, and the features size from the given log file in + * an array. dim[0] - Samples size, dim[1] - Features size + * + * + * @param logfile - The log file from which we need to get the Sample size and feature size + * @return + */ int[] getDimensionsFromFile(File logfile) { int[] dim = new int[2]; @@ -1351,6 +1362,18 @@ public void setTableRowSize(JTable table, int rowNum, String rowString) { } + + /** + * This is a utility method to get the selected features array from an Object of + * selectedFeatures. It is important because the GSON reads the selectedFeatures + * from the log file as an Object, which is sometimes interpreted as a List, or + * a HashMap or an array depending on whether it is the current log or a historical + * log opened from the file.This method ensures that SelectedFeatures are converted + * to a string array. + * + * @param selectedFeatures + * @return + */ public String[] getSelectedFeaturesFromLog(Object selectedFeatures) { From 69c0889fa0cf4be6466e88bdc1c0318c87746626 Mon Sep 17 00:00:00 2001 From: "vk.sriharsha" Date: Fri, 16 Oct 2020 05:21:12 -0500 Subject: [PATCH 6/7] pom.xml - reverted to original --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index be0c4b4f..7348c799 100644 --- a/pom.xml +++ b/pom.xml @@ -39,11 +39,11 @@ - maven-assembly-plugin + From b5c1371b8affa4f57a931b22d8b81319568bad81 Mon Sep 17 00:00:00 2001 From: "vk.sriharsha" Date: Fri, 16 Oct 2020 18:03:42 -0500 Subject: [PATCH 7/7] Edited the text of warning message --- .../ui/ReproducibilityDashboardPanel.java | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java b/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java index 9b089def..b0aaf1ea 100644 --- a/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java +++ b/src/edu/iastate/metnet/metaomgraph/ui/ReproducibilityDashboardPanel.java @@ -445,30 +445,14 @@ public void actionPerformed(ActionEvent arg0) { } else { - int result = JOptionPane.showConfirmDialog((Component) null, "The log file which you are trying to open does not have the same number of features and samples ( Features: "+dimensions[0]+" , Samples: "+dimensions[1]+" ) as the currently opened project ( Features: "+MetaOmGraph.getActiveProject().getDataColumnCount()+" , Samples: "+MetaOmGraph.getActiveProject().getRowCount()+" ). This may cause the play feature to not work properly. Do you still want to proceed?", - "Warning", JOptionPane.OK_CANCEL_OPTION); + JOptionPane.showMessageDialog((Component) null, "The log file which you are trying to open does not have the same number of samples and features ( Samples: "+dimensions[0]+" , Features: "+dimensions[1]+" ) as the currently opened project ( Samples: "+MetaOmGraph.getActiveProject().getDataColumnCount()+" , Features: "+MetaOmGraph.getActiveProject().getRowCount()+" ). \n\nPlease open a log with matching sample and feature counts. You can find the logs of the current project at : "+logPath); - if(result==0) { - - JTree sessionTree = new JTree(); - JTable sessionTable = new JTable(); - - HashMap treeStruct = new HashMap(); - - int tabNo = createNewTabAndPopulate(sessionTree, sessionTable, file.getName(), true, - file.getAbsolutePath()); - readLogAndPopulateTree(file, sessionTree, tabNo, treeStruct); - tabbedPane.setSelectedIndex(tabNo); - } - else { - - } } } else { - JOptionPane.showMessageDialog((Component) null, "The log file seems to be malformed. Please contact the MOG Support team."); + JOptionPane.showMessageDialog((Component) null, "Invalid log file :( "); }